Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(365)

Side by Side Diff: media/filters/ffmpeg_video_decoder.cc

Issue 301243008: Allow ffmpeg to process individual NALU rather than require frames. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ranamed setter as requested Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/filters/ffmpeg_video_decoder.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/filters/ffmpeg_video_decoder.h" 5 #include "media/filters/ffmpeg_video_decoder.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 return decoder->GetVideoBuffer(s, frame, flags); 61 return decoder->GetVideoBuffer(s, frame, flags);
62 } 62 }
63 63
64 static void ReleaseVideoBufferImpl(void* opaque, uint8* data) { 64 static void ReleaseVideoBufferImpl(void* opaque, uint8* data) {
65 scoped_refptr<VideoFrame> video_frame; 65 scoped_refptr<VideoFrame> video_frame;
66 video_frame.swap(reinterpret_cast<VideoFrame**>(&opaque)); 66 video_frame.swap(reinterpret_cast<VideoFrame**>(&opaque));
67 } 67 }
68 68
69 FFmpegVideoDecoder::FFmpegVideoDecoder( 69 FFmpegVideoDecoder::FFmpegVideoDecoder(
70 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) 70 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner)
71 : task_runner_(task_runner), state_(kUninitialized) {} 71 : task_runner_(task_runner), state_(kUninitialized),
72 decode_nalus_(false) {}
72 73
73 int FFmpegVideoDecoder::GetVideoBuffer(struct AVCodecContext* codec_context, 74 int FFmpegVideoDecoder::GetVideoBuffer(struct AVCodecContext* codec_context,
74 AVFrame* frame, 75 AVFrame* frame,
75 int flags) { 76 int flags) {
76 // Don't use |codec_context_| here! With threaded decoding, 77 // Don't use |codec_context_| here! With threaded decoding,
77 // it will contain unsynchronized width/height/pix_fmt values, 78 // it will contain unsynchronized width/height/pix_fmt values,
78 // whereas |codec_context| contains the current threads's 79 // whereas |codec_context| contains the current threads's
79 // updated width/height/pix_fmt, which can change for adaptive 80 // updated width/height/pix_fmt, which can change for adaptive
80 // content. 81 // content.
81 VideoFrame::Format format = PixelFormatToVideoFormat(codec_context->pix_fmt); 82 VideoFrame::Format format = PixelFormatToVideoFormat(codec_context->pix_fmt);
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 codec_context_.reset(avcodec_alloc_context3(NULL)); 354 codec_context_.reset(avcodec_alloc_context3(NULL));
354 VideoDecoderConfigToAVCodecContext(config_, codec_context_.get()); 355 VideoDecoderConfigToAVCodecContext(config_, codec_context_.get());
355 356
356 codec_context_->thread_count = GetThreadCount(codec_context_->codec_id); 357 codec_context_->thread_count = GetThreadCount(codec_context_->codec_id);
357 codec_context_->thread_type = low_delay ? FF_THREAD_SLICE : FF_THREAD_FRAME; 358 codec_context_->thread_type = low_delay ? FF_THREAD_SLICE : FF_THREAD_FRAME;
358 codec_context_->opaque = this; 359 codec_context_->opaque = this;
359 codec_context_->flags |= CODEC_FLAG_EMU_EDGE; 360 codec_context_->flags |= CODEC_FLAG_EMU_EDGE;
360 codec_context_->get_buffer2 = GetVideoBufferImpl; 361 codec_context_->get_buffer2 = GetVideoBufferImpl;
361 codec_context_->refcounted_frames = 1; 362 codec_context_->refcounted_frames = 1;
362 363
364 if (decode_nalus_)
365 codec_context_->flags2 |= CODEC_FLAG2_CHUNKS;
366
363 AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id); 367 AVCodec* codec = avcodec_find_decoder(codec_context_->codec_id);
364 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) { 368 if (!codec || avcodec_open2(codec_context_.get(), codec, NULL) < 0) {
365 ReleaseFFmpegResources(); 369 ReleaseFFmpegResources();
366 return false; 370 return false;
367 } 371 }
368 372
369 av_frame_.reset(av_frame_alloc()); 373 av_frame_.reset(av_frame_alloc());
370 return true; 374 return true;
371 } 375 }
372 376
373 } // namespace media 377 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_video_decoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698