mirror of https://git.ffmpeg.org/ffmpeg.git
support reordering pts in the decoder (this might be equivalent to mplayers -correct-pts mode)
enable it with -drp (=decoder reorders pts) Originally committed as revision 8419 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
262e2bee24
commit
5039185acc
35
ffplay.c
35
ffplay.c
|
@ -211,6 +211,7 @@ static enum AVDiscard skip_idct= AVDISCARD_DEFAULT;
|
|||
static enum AVDiscard skip_loop_filter= AVDISCARD_DEFAULT;
|
||||
static int error_resilience = FF_ER_CAREFUL;
|
||||
static int error_concealment = 3;
|
||||
static int decoder_reorder_pts= 0;
|
||||
|
||||
/* current context */
|
||||
static int is_full_screen;
|
||||
|
@ -1328,6 +1329,21 @@ static int output_picture2(VideoState *is, AVFrame *src_frame, double pts1)
|
|||
return queue_picture(is, src_frame, pts);
|
||||
}
|
||||
|
||||
static uint64_t global_video_pkt_pts= AV_NOPTS_VALUE;
|
||||
|
||||
static int my_get_buffer(struct AVCodecContext *c, AVFrame *pic){
|
||||
int ret= avcodec_default_get_buffer(c, pic);
|
||||
uint64_t *pts= av_malloc(sizeof(uint64_t));
|
||||
*pts= global_video_pkt_pts;
|
||||
pic->opaque= pts;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void my_release_buffer(struct AVCodecContext *c, AVFrame *pic){
|
||||
if(pic) av_freep(&pic->opaque);
|
||||
avcodec_default_release_buffer(c, pic);
|
||||
}
|
||||
|
||||
static int video_thread(void *arg)
|
||||
{
|
||||
VideoState *is = arg;
|
||||
|
@ -1350,13 +1366,20 @@ static int video_thread(void *arg)
|
|||
|
||||
/* NOTE: ipts is the PTS of the _first_ picture beginning in
|
||||
this packet, if any */
|
||||
pts = 0;
|
||||
if (pkt->dts != AV_NOPTS_VALUE)
|
||||
pts = av_q2d(is->video_st->time_base)*pkt->dts;
|
||||
|
||||
global_video_pkt_pts= pkt->pts;
|
||||
len1 = avcodec_decode_video(is->video_st->codec,
|
||||
frame, &got_picture,
|
||||
pkt->data, pkt->size);
|
||||
|
||||
if( (decoder_reorder_pts || pkt->dts == AV_NOPTS_VALUE)
|
||||
&& frame->opaque && *(uint64_t*)frame->opaque != AV_NOPTS_VALUE)
|
||||
pts= *(uint64_t*)frame->opaque;
|
||||
else if(pkt->dts != AV_NOPTS_VALUE)
|
||||
pts= pkt->dts;
|
||||
else
|
||||
pts= 0;
|
||||
pts *= av_q2d(is->video_st->time_base);
|
||||
|
||||
// if (len1 < 0)
|
||||
// break;
|
||||
if (got_picture) {
|
||||
|
@ -1735,6 +1758,9 @@ static int stream_component_open(VideoState *is, int stream_index)
|
|||
|
||||
packet_queue_init(&is->videoq);
|
||||
is->video_tid = SDL_CreateThread(video_thread, is);
|
||||
|
||||
enc-> get_buffer= my_get_buffer;
|
||||
enc->release_buffer= my_release_buffer;
|
||||
break;
|
||||
case CODEC_TYPE_SUBTITLE:
|
||||
is->subtitle_stream = stream_index;
|
||||
|
@ -2446,6 +2472,7 @@ const OptionDef options[] = {
|
|||
{ "vismv", HAS_ARG | OPT_EXPERT, {(void*)opt_vismv}, "visualize motion vectors", "" },
|
||||
{ "fast", OPT_BOOL | OPT_EXPERT, {(void*)&fast}, "non spec compliant optimizations", "" },
|
||||
{ "genpts", OPT_BOOL | OPT_EXPERT, {(void*)&genpts}, "generate pts", "" },
|
||||
{ "drp", OPT_BOOL |OPT_EXPERT, {(void*)&decoder_reorder_pts}, "let decoder reorder pts", ""},
|
||||
{ "lowres", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&lowres}, "", "" },
|
||||
{ "skiploop", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&skip_loop_filter}, "", "" },
|
||||
{ "skipframe", OPT_INT | HAS_ARG | OPT_EXPERT, {(void*)&skip_frame}, "", "" },
|
||||
|
|
Loading…
Reference in New Issue