deps-libff: Add flag whether a decoder is hardware accelerated

This lets the decoder make decisions based on whether it is a hardware decoder or not.  Specifically, hardware decoders are more strict as to which frames can be dropped in an h264 stream.
This commit is contained in:
John Bradley
2015-03-12 14:38:33 -05:00
parent b91a98ed44
commit 2b3d82aeac
2 changed files with 9 additions and 2 deletions

View File

@@ -43,6 +43,7 @@ struct ff_decoder {
double current_pts; // pts of the most recently dispatched frame
int64_t current_pts_time; // clock time when current_pts was set
bool hwaccel_decoder;
struct ff_clock *clock;
enum ff_av_sync_type natural_sync_clock;

View File

@@ -183,7 +183,8 @@ enum AVPixelFormat get_hwaccel_format(struct AVCodecContext *s,
}
static bool initialize_decoder(struct ff_demuxer *demuxer,
AVCodecContext *codec_context, AVStream *stream)
AVCodecContext *codec_context, AVStream *stream,
bool hwaccel_decoder)
{
switch (codec_context->codec_type) {
case AVMEDIA_TYPE_AUDIO:
@@ -192,6 +193,7 @@ static bool initialize_decoder(struct ff_demuxer *demuxer,
demuxer->options.audio_packet_queue_size,
demuxer->options.audio_frame_queue_size);
demuxer->audio_decoder->hwaccel_decoder = hwaccel_decoder;
demuxer->audio_decoder->natural_sync_clock =
AV_SYNC_AUDIO_MASTER;
demuxer->audio_decoder->clock = &demuxer->clock;
@@ -214,6 +216,7 @@ static bool initialize_decoder(struct ff_demuxer *demuxer,
demuxer->options.video_packet_queue_size,
demuxer->options.video_frame_queue_size);
demuxer->video_decoder->hwaccel_decoder = hwaccel_decoder;
demuxer->video_decoder->natural_sync_clock =
AV_SYNC_VIDEO_MASTER;
demuxer->video_decoder->clock = &demuxer->clock;
@@ -240,6 +243,7 @@ static bool find_decoder(struct ff_demuxer *demuxer, AVStream *stream)
AVDictionary *options_dict = NULL;
int ret;
bool hwaccel_decoder = false;
codec_context = stream->codec;
// enable reference counted frames since we may have a buffer size
@@ -269,6 +273,7 @@ static bool find_decoder(struct ff_demuxer *demuxer, AVStream *stream)
codec_context->codec_id);
} else {
codec = codec_vda;
hwaccel_decoder = true;
}
}
}
@@ -290,7 +295,8 @@ static bool find_decoder(struct ff_demuxer *demuxer, AVStream *stream)
}
}
return initialize_decoder(demuxer, codec_context, stream);
return initialize_decoder(demuxer, codec_context, stream,
hwaccel_decoder);
}
void ff_demuxer_flush(struct ff_demuxer *demuxer)