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

Side by Side Diff: webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.h

Issue 1645543003: H264: Improve FFmpeg decoder performance by using I420BufferPool. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: common_video not unnecessarily depending on webrtc_h264, fixed circular dependency Created 4 years, 10 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 * 9 *
10 */ 10 */
11 11
12 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_H264_H264_DECODER_IMPL_H_ 12 #ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_H264_H264_DECODER_IMPL_H_
13 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_H264_H264_DECODER_IMPL_H_ 13 #define WEBRTC_MODULES_VIDEO_CODING_CODECS_H264_H264_DECODER_IMPL_H_
14 14
15 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" 15 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
16 16
17 extern "C" { 17 extern "C" {
18 #include "third_party/ffmpeg/libavcodec/avcodec.h" 18 #include "third_party/ffmpeg/libavcodec/avcodec.h"
19 } // extern "C" 19 } // extern "C"
20 20
21 #include "webrtc/base/scoped_ptr.h" 21 #include "webrtc/base/scoped_ptr.h"
22 #include "webrtc/common_video/include/i420_buffer_pool.h"
22 23
23 namespace webrtc { 24 namespace webrtc {
24 25
25 struct AVCodecContextDeleter { 26 struct AVCodecContextDeleter {
26 void operator()(AVCodecContext* ptr) const { avcodec_free_context(&ptr); } 27 void operator()(AVCodecContext* ptr) const { avcodec_free_context(&ptr); }
27 }; 28 };
28 struct AVFrameDeleter { 29 struct AVFrameDeleter {
29 void operator()(AVFrame* ptr) const { av_frame_free(&ptr); } 30 void operator()(AVFrame* ptr) const { av_frame_free(&ptr); }
30 }; 31 };
31 32
(...skipping 13 matching lines...) Expand all
45 DecodedImageCallback* callback) override; 46 DecodedImageCallback* callback) override;
46 47
47 // |missing_frames|, |fragmentation| and |render_time_ms| are ignored. 48 // |missing_frames|, |fragmentation| and |render_time_ms| are ignored.
48 int32_t Decode(const EncodedImage& input_image, 49 int32_t Decode(const EncodedImage& input_image,
49 bool /*missing_frames*/, 50 bool /*missing_frames*/,
50 const RTPFragmentationHeader* /*fragmentation*/, 51 const RTPFragmentationHeader* /*fragmentation*/,
51 const CodecSpecificInfo* codec_specific_info = nullptr, 52 const CodecSpecificInfo* codec_specific_info = nullptr,
52 int64_t render_time_ms = -1) override; 53 int64_t render_time_ms = -1) override;
53 54
54 private: 55 private:
56 // Called by FFmpeg when it needs a frame buffer to store decoded frames in.
57 // The |VideoFrame| returned by FFmpeg at |Decode| originate from here. Their
58 // buffers are reference counted and freed by FFmpeg using |AVFreeBuffer2|.
59 static int AVGetBuffer2(
60 AVCodecContext* context, AVFrame* av_frame, int flags);
61 // Called by FFmpeg when it is done with a video frame, see |AVGetBuffer2|.
62 static void AVFreeBuffer2(void* opaque, uint8_t* data);
63
55 bool IsInitialized() const; 64 bool IsInitialized() const;
56 65
66 I420BufferPool pool_;
57 rtc::scoped_ptr<AVCodecContext, AVCodecContextDeleter> av_context_; 67 rtc::scoped_ptr<AVCodecContext, AVCodecContextDeleter> av_context_;
58 rtc::scoped_ptr<AVFrame, AVFrameDeleter> av_frame_; 68 rtc::scoped_ptr<AVFrame, AVFrameDeleter> av_frame_;
59 69
60 DecodedImageCallback* decoded_image_callback_; 70 DecodedImageCallback* decoded_image_callback_;
61 }; 71 };
62 72
63 } // namespace webrtc 73 } // namespace webrtc
64 74
65 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_H264_H264_DECODER_IMPL_H_ 75 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_H264_H264_DECODER_IMPL_H_
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/codecs/h264/h264.gypi ('k') | webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698