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

Unified Diff: media/formats/mp4/mp4_stream_parser.cc

Issue 1289923003: Refactor AnnexB bitstream conversion for AVC/H.264 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@annexb-avc-fix
Patch Set: Added a few comments Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/formats/mp4/mp4_stream_parser.h ('k') | media/media.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/formats/mp4/mp4_stream_parser.cc
diff --git a/media/formats/mp4/mp4_stream_parser.cc b/media/formats/mp4/mp4_stream_parser.cc
index 00d6bce7133ee193eb533c2c248c1b4f818a669d..0c64e35f70251617dee0bc0241ec20da0b1655c6 100644
--- a/media/formats/mp4/mp4_stream_parser.cc
+++ b/media/formats/mp4/mp4_stream_parser.cc
@@ -387,29 +387,6 @@ void MP4StreamParser::OnEncryptedMediaInitData(
encrypted_media_init_data_cb_.Run(EmeInitDataType::CENC, init_data);
}
-bool MP4StreamParser::PrepareAVCBuffer(
- const AVCDecoderConfigurationRecord& avc_config,
- std::vector<uint8>* frame_buf,
- std::vector<SubsampleEntry>* subsamples) const {
- // Convert the AVC NALU length fields to Annex B headers, as expected by
- // decoding libraries. Since this may enlarge the size of the buffer, we also
- // update the clear byte count for each subsample if encryption is used to
- // account for the difference in size between the length prefix and Annex B
- // start code.
- RCHECK(AVC::ConvertFrameToAnnexB(avc_config.length_size, frame_buf,
- subsamples));
-
- if (runs_->is_keyframe()) {
- // If this is a keyframe, we (re-)inject SPS and PPS headers at the start of
- // a frame. If subsample info is present, we also update the clear byte
- // count for that first subsample.
- RCHECK(AVC::InsertParamSetsAnnexB(avc_config, frame_buf, subsamples));
- }
-
- DCHECK(AVC::IsValidAnnexB(*frame_buf, *subsamples));
- return true;
-}
-
bool MP4StreamParser::PrepareAACBuffer(
const AAC& aac_config, std::vector<uint8>* frame_buf,
std::vector<SubsampleEntry>* subsamples) const {
@@ -500,8 +477,9 @@ bool MP4StreamParser::EnqueueSample(BufferQueue* audio_buffers,
std::vector<uint8> frame_buf(buf, buf + runs_->sample_size());
if (video) {
- if (!PrepareAVCBuffer(runs_->video_description().avcc,
- &frame_buf, &subsamples)) {
+ DCHECK(runs_->video_description().frame_bitstream_converter);
+ if (!runs_->video_description().frame_bitstream_converter->ConvertFrame(
+ &frame_buf, runs_->is_keyframe(), &subsamples)) {
MEDIA_LOG(ERROR, media_log_) << "Failed to prepare AVC sample for decode";
*err = true;
return false;
« no previous file with comments | « media/formats/mp4/mp4_stream_parser.h ('k') | media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698