Message ID | 20161002210853.1228-3-timo@rothenpieler.org |
---|---|
State | Changes Requested |
Headers | show |
On Sun, Oct 2, 2016 at 11:08 PM, Timo Rothenpieler <timo@rothenpieler.org> wrote: > --- > libavcodec/cuvid.c | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) > > diff --git a/libavcodec/cuvid.c b/libavcodec/cuvid.c > index e9a1dd7..5ceb94e 100644 > --- a/libavcodec/cuvid.c > +++ b/libavcodec/cuvid.c > @@ -451,25 +451,25 @@ static int cuvid_output_frame(AVCodecContext *avctx, AVFrame *frame) > frame->width = avctx->width; > frame->height = avctx->height; > if (avctx->pkt_timebase.num && avctx->pkt_timebase.den) > - frame->pts = av_rescale_q(parsed_frame.dispinfo.timestamp, (AVRational){1, 10000000}, avctx->pkt_timebase); > + frame->pkt_pts = av_rescale_q(parsed_frame.dispinfo.timestamp, (AVRational){1, 10000000}, avctx->pkt_timebase); > else > - frame->pts = parsed_frame.dispinfo.timestamp; > + frame->pkt_pts = parsed_frame.dispinfo.timestamp; > > if (parsed_frame.second_field) { > if (ctx->prev_pts == INT64_MIN) { > - ctx->prev_pts = frame->pts; > - frame->pts += (avctx->pkt_timebase.den * avctx->framerate.den) / (avctx->pkt_timebase.num * avctx->framerate.num); > + ctx->prev_pts = frame->pkt_pts; > + frame->pkt_pts += (avctx->pkt_timebase.den * avctx->framerate.den) / (avctx->pkt_timebase.num * avctx->framerate.num); > } else { > - int pts_diff = (frame->pts - ctx->prev_pts) / 2; > - ctx->prev_pts = frame->pts; > - frame->pts += pts_diff; > + int pts_diff = (frame->pkt_pts - ctx->prev_pts) / 2; > + ctx->prev_pts = frame->pkt_pts; > + frame->pkt_pts += pts_diff; > } > } > > /* CUVIDs opaque reordering breaks the internal pkt logic. > * So set pkt_pts and clear all the other pkt_ fields. > */ > - frame->pkt_pts = frame->pts; > + av_frame_set_best_effort_timestamp(frame, frame->pkt_pts); > av_frame_set_pkt_pos(frame, -1); > av_frame_set_pkt_duration(frame, 0); > av_frame_set_pkt_size(frame, -1); > -- > 2.10.0 > Please just leave the pts stuff as-is, or we'll have to undo these changes right in the next merge again, which deprecates pkt_pts and favors using AVFrame.pts for decoding as well (less redundant fields). Setting both for the time being should not have any negative effects. Settings best effort in addition seems slightly weird, do any other decoders actually set that by themself? - Hendrik
> Please just leave the pts stuff as-is, or we'll have to undo these > changes right in the next merge again, which deprecates pkt_pts and > favors using AVFrame.pts for decoding as well (less redundant fields). > Setting both for the time being should not have any negative effects. Ok, I'll leave that one out. Only thing that needs changing with those merges would be deprecation guards around setting pkt_pts then. > Settings best effort in addition seems slightly weird, do any other > decoders actually set that by themself? No, but no other decoder implements the new decode API yet, which doesn't do so for you anymore. Merging the "lavc: set best effort timestamp if unset when using new decode API" should work just fine as well though. > - Hendrik > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >
diff --git a/libavcodec/cuvid.c b/libavcodec/cuvid.c index e9a1dd7..5ceb94e 100644 --- a/libavcodec/cuvid.c +++ b/libavcodec/cuvid.c @@ -451,25 +451,25 @@ static int cuvid_output_frame(AVCodecContext *avctx, AVFrame *frame) frame->width = avctx->width; frame->height = avctx->height; if (avctx->pkt_timebase.num && avctx->pkt_timebase.den) - frame->pts = av_rescale_q(parsed_frame.dispinfo.timestamp, (AVRational){1, 10000000}, avctx->pkt_timebase); + frame->pkt_pts = av_rescale_q(parsed_frame.dispinfo.timestamp, (AVRational){1, 10000000}, avctx->pkt_timebase); else - frame->pts = parsed_frame.dispinfo.timestamp; + frame->pkt_pts = parsed_frame.dispinfo.timestamp; if (parsed_frame.second_field) { if (ctx->prev_pts == INT64_MIN) { - ctx->prev_pts = frame->pts; - frame->pts += (avctx->pkt_timebase.den * avctx->framerate.den) / (avctx->pkt_timebase.num * avctx->framerate.num); + ctx->prev_pts = frame->pkt_pts; + frame->pkt_pts += (avctx->pkt_timebase.den * avctx->framerate.den) / (avctx->pkt_timebase.num * avctx->framerate.num); } else { - int pts_diff = (frame->pts - ctx->prev_pts) / 2; - ctx->prev_pts = frame->pts; - frame->pts += pts_diff; + int pts_diff = (frame->pkt_pts - ctx->prev_pts) / 2; + ctx->prev_pts = frame->pkt_pts; + frame->pkt_pts += pts_diff; } } /* CUVIDs opaque reordering breaks the internal pkt logic. * So set pkt_pts and clear all the other pkt_ fields. */ - frame->pkt_pts = frame->pts; + av_frame_set_best_effort_timestamp(frame, frame->pkt_pts); av_frame_set_pkt_pos(frame, -1); av_frame_set_pkt_duration(frame, 0); av_frame_set_pkt_size(frame, -1);