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

Side by Side Diff: services/media/framework_ffmpeg/ffmpeg_video_decoder.cc

Issue 1814553002: Motown: Improvements to packet definition (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Added a comment. Created 4 years, 9 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 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/logging.h" 5 #include "base/logging.h"
6 #include "services/media/framework_ffmpeg/ffmpeg_video_decoder.h" 6 #include "services/media/framework_ffmpeg/ffmpeg_video_decoder.h"
7 7
8 namespace mojo { 8 namespace mojo {
9 namespace media { 9 namespace media {
10 10
11 FfmpegVideoDecoder::FfmpegVideoDecoder(AvCodecContextPtr av_codec_context) : 11 FfmpegVideoDecoder::FfmpegVideoDecoder(AvCodecContextPtr av_codec_context) :
12 FfmpegDecoderBase(std::move(av_codec_context)) { 12 FfmpegDecoderBase(std::move(av_codec_context)) {
13 DCHECK(context()); 13 DCHECK(context());
14 } 14 }
15 15
16 FfmpegVideoDecoder::~FfmpegVideoDecoder() {} 16 FfmpegVideoDecoder::~FfmpegVideoDecoder() {}
17 17
18 int FfmpegVideoDecoder::Decode( 18 int FfmpegVideoDecoder::Decode(
19 const AVPacket& av_packet, 19 const AVPacket& av_packet,
20 const AvFramePtr& av_frame_ptr, 20 const ffmpeg::AvFramePtr& av_frame_ptr,
21 PayloadAllocator* allocator, 21 PayloadAllocator* allocator,
22 bool* frame_decoded_out) { 22 bool* frame_decoded_out) {
23 DCHECK(av_frame_ptr); 23 DCHECK(av_frame_ptr);
24 DCHECK(allocator); 24 DCHECK(allocator);
25 DCHECK(frame_decoded_out); 25 DCHECK(frame_decoded_out);
26 DCHECK(context()); 26 DCHECK(context());
27 27
28 int frame_decoded = 0; 28 int frame_decoded = 0;
29 int input_bytes_used = avcodec_decode_video2( 29 int input_bytes_used = avcodec_decode_video2(
30 context().get(), 30 context().get(),
31 av_frame_ptr.get(), 31 av_frame_ptr.get(),
32 &frame_decoded, 32 &frame_decoded,
33 &av_packet); 33 &av_packet);
34 *frame_decoded_out = frame_decoded != 0; 34 *frame_decoded_out = frame_decoded != 0;
35 return input_bytes_used; 35 return input_bytes_used;
36 } 36 }
37 37
38 38
39 PacketPtr FfmpegVideoDecoder::CreateOutputPacket( 39 PacketPtr FfmpegVideoDecoder::CreateOutputPacket(
40 const AVFrame& av_frame, 40 const AVFrame& av_frame,
41 PayloadAllocator* allocator) { 41 PayloadAllocator* allocator) {
42 DCHECK(allocator); 42 DCHECK(allocator);
43 43
44 // End of stream is indicated when we're draining and produce no packet. 44 // End of stream is indicated when we're draining and produce no packet.
45 // TODO(dalesat): This is just a copy of the audio version. 45 // TODO(dalesat): This is just a copy of the audio version.
46 return Packet::Create( 46 return Packet::Create(
47 av_frame.pts, 47 av_frame.pts,
48 av_frame.pkt_duration,
49 false, 48 false,
50 packet_size_, 49 packet_size_,
51 av_frame.data[0], 50 av_frame.data[0],
52 allocator); 51 allocator);
53 } 52 }
54 53
55 PacketPtr FfmpegVideoDecoder::CreateOutputEndOfStreamPacket() { 54 PacketPtr FfmpegVideoDecoder::CreateOutputEndOfStreamPacket() {
56 // TODO(dalesat): Presentation time for this packet. 55 // TODO(dalesat): Presentation time for this packet.
57 return Packet::CreateEndOfStream(0); 56 return Packet::CreateEndOfStream(0);
58 } 57 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 } 104 }
106 105
107 void FfmpegVideoDecoder::ReleaseBufferForAvFrame( 106 void FfmpegVideoDecoder::ReleaseBufferForAvFrame(
108 void* opaque, uint8_t* buffer) { 107 void* opaque, uint8_t* buffer) {
109 // Nothing to do. 108 // Nothing to do.
110 // TODO(dalesat): Can we get rid of this method altogether? 109 // TODO(dalesat): Can we get rid of this method altogether?
111 } 110 }
112 111
113 } // namespace media 112 } // namespace media
114 } // namespace mojo 113 } // namespace mojo
OLDNEW
« no previous file with comments | « services/media/framework_ffmpeg/ffmpeg_video_decoder.h ('k') | services/media/framework_mojo/mojo_consumer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698