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

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

Issue 1534273002: Switch to standard integer types in media/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more Created 5 years 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_h265_to_annex_b_bitstream_converter.h" 5 #include "media/filters/ffmpeg_h265_to_annex_b_bitstream_converter.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "media/base/decrypt_config.h" 8 #include "media/base/decrypt_config.h"
9 #include "media/ffmpeg/ffmpeg_common.h" 9 #include "media/ffmpeg/ffmpeg_common.h"
10 #include "media/formats/mp4/avc.h" 10 #include "media/formats/mp4/avc.h"
(...skipping 26 matching lines...) Expand all
37 hevc_config_.reset(new mp4::HEVCDecoderConfigurationRecord()); 37 hevc_config_.reset(new mp4::HEVCDecoderConfigurationRecord());
38 38
39 if (!hevc_config_->Parse( 39 if (!hevc_config_->Parse(
40 stream_codec_context_->extradata, 40 stream_codec_context_->extradata,
41 stream_codec_context_->extradata_size)) { 41 stream_codec_context_->extradata_size)) {
42 DVLOG(1) << "Parsing HEVCDecoderConfiguration failed"; 42 DVLOG(1) << "Parsing HEVCDecoderConfiguration failed";
43 return false; 43 return false;
44 } 44 }
45 } 45 }
46 46
47 std::vector<uint8> input_frame; 47 std::vector<uint8_t> input_frame;
48 std::vector<SubsampleEntry> subsamples; 48 std::vector<SubsampleEntry> subsamples;
49 // TODO(servolk): Performance could be improved here, by reducing unnecessary 49 // TODO(servolk): Performance could be improved here, by reducing unnecessary
50 // data copying, but first annex b conversion code needs to be refactored to 50 // data copying, but first annex b conversion code needs to be refactored to
51 // allow that (see crbug.com/455379). 51 // allow that (see crbug.com/455379).
52 input_frame.insert(input_frame.end(), 52 input_frame.insert(input_frame.end(),
53 packet->data, packet->data + packet->size); 53 packet->data, packet->data + packet->size);
54 int nalu_size_len = hevc_config_->lengthSizeMinusOne + 1; 54 int nalu_size_len = hevc_config_->lengthSizeMinusOne + 1;
55 if (!mp4::AVC::ConvertFrameToAnnexB(nalu_size_len, &input_frame, 55 if (!mp4::AVC::ConvertFrameToAnnexB(nalu_size_len, &input_frame,
56 &subsamples)) { 56 &subsamples)) {
57 DVLOG(1) << "AnnexB conversion failed"; 57 DVLOG(1) << "AnnexB conversion failed";
58 return false; 58 return false;
59 } 59 }
60 60
61 if (packet->flags & AV_PKT_FLAG_KEY) { 61 if (packet->flags & AV_PKT_FLAG_KEY) {
62 RCHECK(mp4::HEVC::InsertParamSetsAnnexB(*hevc_config_.get(), 62 RCHECK(mp4::HEVC::InsertParamSetsAnnexB(*hevc_config_.get(),
63 &input_frame, &subsamples)); 63 &input_frame, &subsamples));
64 DVLOG(4) << "Inserted HEVC decoder params"; 64 DVLOG(4) << "Inserted HEVC decoder params";
65 } 65 }
66 66
67 uint32 output_packet_size = input_frame.size(); 67 uint32_t output_packet_size = input_frame.size();
68 68
69 if (output_packet_size == 0) 69 if (output_packet_size == 0)
70 return false; // Invalid input packet. 70 return false; // Invalid input packet.
71 71
72 // Allocate new packet for the output. 72 // Allocate new packet for the output.
73 AVPacket dest_packet; 73 AVPacket dest_packet;
74 if (av_new_packet(&dest_packet, output_packet_size) != 0) 74 if (av_new_packet(&dest_packet, output_packet_size) != 0)
75 return false; // Memory allocation failure. 75 return false; // Memory allocation failure.
76 76
77 // This is a bit tricky: since the interface does not allow us to replace 77 // This is a bit tricky: since the interface does not allow us to replace
78 // the pointer of the old packet with a new one, we will initially copy the 78 // the pointer of the old packet with a new one, we will initially copy the
79 // metadata from old packet to new bigger packet. 79 // metadata from old packet to new bigger packet.
80 av_packet_copy_props(&dest_packet, packet); 80 av_packet_copy_props(&dest_packet, packet);
81 81
82 // Proceed with the conversion of the actual in-band NAL units, leave room 82 // Proceed with the conversion of the actual in-band NAL units, leave room
83 // for configuration in the beginning. 83 // for configuration in the beginning.
84 memcpy(dest_packet.data, &input_frame[0], input_frame.size()); 84 memcpy(dest_packet.data, &input_frame[0], input_frame.size());
85 85
86 // At the end we must destroy the old packet. 86 // At the end we must destroy the old packet.
87 av_packet_unref(packet); 87 av_packet_unref(packet);
88 *packet = dest_packet; // Finally, replace the values in the input packet. 88 *packet = dest_packet; // Finally, replace the values in the input packet.
89 89
90 return true; 90 return true;
91 } 91 }
92 92
93 } // namespace media 93 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698