Commit 7803664a authored by igorc@chromium.org's avatar igorc@chromium.org

Allow ffmpeg to process individual NALU rather than require frames.

The new video-decoding PPAPI accepts NALU's for H264 streams.

BUG=281689
TEST=Example in the pending CL for the new PPAPI

Review URL: https://codereview.chromium.org/301243008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275601 0039d316-1c4b-4281-b951-d872f2087c98
parent 30051ba5
......@@ -68,7 +68,8 @@ static void ReleaseVideoBufferImpl(void* opaque, uint8* data) {
FFmpegVideoDecoder::FFmpegVideoDecoder(
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner)
: task_runner_(task_runner), state_(kUninitialized) {}
: task_runner_(task_runner), state_(kUninitialized),
decode_nalus_(false) {}
int FFmpegVideoDecoder::GetVideoBuffer(struct AVCodecContext* codec_context,
AVFrame* frame,
......@@ -360,6 +361,9 @@ bool FFmpegVideoDecoder::ConfigureDecoder(bool low_delay) {
codec_context_->get_buffer2 = GetVideoBufferImpl;
codec_context_->refcounted_frames = 1;
if (decode_nalus_)
codec_context_->flags2 |= CODEC_FLAG2_CHUNKS;
AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
ReleaseFFmpegResources();
......
......@@ -31,6 +31,10 @@ class MEDIA_EXPORT FFmpegVideoDecoder : public VideoDecoder {
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner);
virtual ~FFmpegVideoDecoder();
// Allow decoding of individual NALU. Entire frames are required by default.
// Disables low-latency mode. Must be called before Initialize().
void set_decode_nalus(bool decode_nalus) { decode_nalus_ = decode_nalus; }
// VideoDecoder implementation.
virtual void Initialize(const VideoDecoderConfig& config,
bool low_delay,
......@@ -84,6 +88,8 @@ class MEDIA_EXPORT FFmpegVideoDecoder : public VideoDecoder {
VideoFramePool frame_pool_;
bool decode_nalus_;
DISALLOW_COPY_AND_ASSIGN(FFmpegVideoDecoder);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment