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

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

Issue 145973012: Add support for aspect ratio VUI parameters in H264Parser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 6 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
« no previous file with comments | « media/filters/h264_parser.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 8
9 #include "media/filters/h264_parser.h" 9 #include "media/filters/h264_parser.h"
10 10
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 } while (0) 99 } while (0)
100 100
101 #define TRUE_OR_RETURN(a) \ 101 #define TRUE_OR_RETURN(a) \
102 do { \ 102 do { \
103 if (!(a)) { \ 103 if (!(a)) { \
104 DVLOG(1) << "Error in stream: invalid value, expected " << #a; \ 104 DVLOG(1) << "Error in stream: invalid value, expected " << #a; \
105 return kInvalidStream; \ 105 return kInvalidStream; \
106 } \ 106 } \
107 } while (0) 107 } while (0)
108 108
109 enum AspectRatioIdc {
110 kExtendedSar = 255,
111 };
112
113 // ISO 14496 part 10
114 // VUI parameters: Table E-1 "Meaning of sample aspect ratio indicator"
115 static const int kTableSarWidth[] = {
116 0, 1, 12, 10, 16, 40, 24, 20, 32, 80, 18, 15, 64, 160, 4, 3, 2
117 };
118 static const int kTableSarHeight[] = {
119 0, 1, 11, 11, 11, 33, 11, 11, 11, 33, 11, 11, 33, 99, 3, 2, 1
120 };
121 COMPILE_ASSERT(arraysize(kTableSarWidth) == arraysize(kTableSarHeight),
122 sar_tables_must_have_same_size);
123
109 H264Parser::H264Parser() { 124 H264Parser::H264Parser() {
110 Reset(); 125 Reset();
111 } 126 }
112 127
113 H264Parser::~H264Parser() { 128 H264Parser::~H264Parser() {
114 STLDeleteValues(&active_SPSes_); 129 STLDeleteValues(&active_SPSes_);
115 STLDeleteValues(&active_PPSes_); 130 STLDeleteValues(&active_PPSes_);
116 } 131 }
117 132
118 void H264Parser::Reset() { 133 void H264Parser::Reset() {
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 READ_BOOL_OR_RETURN(&sps->frame_cropping_flag); 680 READ_BOOL_OR_RETURN(&sps->frame_cropping_flag);
666 if (sps->frame_cropping_flag) { 681 if (sps->frame_cropping_flag) {
667 READ_UE_OR_RETURN(&sps->frame_crop_left_offset); 682 READ_UE_OR_RETURN(&sps->frame_crop_left_offset);
668 READ_UE_OR_RETURN(&sps->frame_crop_right_offset); 683 READ_UE_OR_RETURN(&sps->frame_crop_right_offset);
669 READ_UE_OR_RETURN(&sps->frame_crop_top_offset); 684 READ_UE_OR_RETURN(&sps->frame_crop_top_offset);
670 READ_UE_OR_RETURN(&sps->frame_crop_bottom_offset); 685 READ_UE_OR_RETURN(&sps->frame_crop_bottom_offset);
671 } 686 }
672 687
673 READ_BOOL_OR_RETURN(&sps->vui_parameters_present_flag); 688 READ_BOOL_OR_RETURN(&sps->vui_parameters_present_flag);
674 if (sps->vui_parameters_present_flag) { 689 if (sps->vui_parameters_present_flag) {
675 DVLOG(1) << "VUI parameters present in SPS, ignoring"; 690 bool aspect_ratio_info_present_flag;
691 READ_BOOL_OR_RETURN(&aspect_ratio_info_present_flag);
692 if (aspect_ratio_info_present_flag) {
693 int aspect_ratio_idc;
694 READ_BITS_OR_RETURN(8, &aspect_ratio_idc);
695 if (aspect_ratio_idc == kExtendedSar) {
696 READ_BITS_OR_RETURN(16, &sps->sar_width);
697 READ_BITS_OR_RETURN(16, &sps->sar_height);
698 } else {
699 const int max_aspect_ratio_idc = arraysize(kTableSarWidth) - 1;
700 IN_RANGE_OR_RETURN(aspect_ratio_idc, 0, max_aspect_ratio_idc);
701 sps->sar_width = kTableSarWidth[aspect_ratio_idc];
702 sps->sar_height = kTableSarHeight[aspect_ratio_idc];
703 }
704 }
676 } 705 }
677 706
678 // If an SPS with the same id already exists, replace it. 707 // If an SPS with the same id already exists, replace it.
679 *sps_id = sps->seq_parameter_set_id; 708 *sps_id = sps->seq_parameter_set_id;
680 delete active_SPSes_[*sps_id]; 709 delete active_SPSes_[*sps_id];
681 active_SPSes_[*sps_id] = sps.release(); 710 active_SPSes_[*sps_id] = sps.release();
682 711
683 return kOk; 712 return kOk;
684 } 713 }
685 714
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 1153
1125 default: 1154 default:
1126 DVLOG(4) << "Unsupported SEI message"; 1155 DVLOG(4) << "Unsupported SEI message";
1127 break; 1156 break;
1128 } 1157 }
1129 1158
1130 return kOk; 1159 return kOk;
1131 } 1160 }
1132 1161
1133 } // namespace media 1162 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/h264_parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698