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

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

Issue 2345123002: Attach color space information to hardware decoded NV12 video frames. (Closed)
Patch Set: minor bugfix Created 4 years, 2 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') | media/gpu/android_video_decode_accelerator.cc » ('j') | 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 "media/filters/h264_parser.h" 5 #include "media/filters/h264_parser.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 coded_size->height() - crop_top <= crop_bottom) { 114 coded_size->height() - crop_top <= crop_bottom) {
115 DVLOG(1) << "Frame cropping excludes entire frame."; 115 DVLOG(1) << "Frame cropping excludes entire frame.";
116 return base::nullopt; 116 return base::nullopt;
117 } 117 }
118 118
119 return gfx::Rect(crop_left, crop_top, 119 return gfx::Rect(crop_left, crop_top,
120 coded_size->width() - crop_left - crop_right, 120 coded_size->width() - crop_left - crop_right,
121 coded_size->height() - crop_top - crop_bottom); 121 coded_size->height() - crop_top - crop_bottom);
122 } 122 }
123 123
124 // Based on T-REC-H.264 E.2.1, "VUI parameters semantics",
125 // available from http://www.itu.int/rec/T-REC-H.264.
126 gfx::ColorSpace H264SPS::GetColorSpace() const {
127 if (colour_description_present_flag) {
128 return gfx::ColorSpace(
129 colour_primaries, transfer_characteristics, matrix_coefficients,
130 video_full_range_flag ? gfx::ColorSpace::RangeID::FULL
131 : gfx::ColorSpace::RangeID::LIMITED);
132 } else {
133 return gfx::ColorSpace(gfx::ColorSpace::PrimaryID::UNSPECIFIED,
134 gfx::ColorSpace::TransferID::UNSPECIFIED,
135 gfx::ColorSpace::MatrixID::UNSPECIFIED,
136 video_full_range_flag
137 ? gfx::ColorSpace::RangeID::FULL
138 : gfx::ColorSpace::RangeID::LIMITED);
139 }
140 }
141
124 H264PPS::H264PPS() { 142 H264PPS::H264PPS() {
125 memset(this, 0, sizeof(*this)); 143 memset(this, 0, sizeof(*this));
126 } 144 }
127 145
128 H264SliceHeader::H264SliceHeader() { 146 H264SliceHeader::H264SliceHeader() {
129 memset(this, 0, sizeof(*this)); 147 memset(this, 0, sizeof(*this));
130 } 148 }
131 149
132 H264SEIMessage::H264SEIMessage() { 150 H264SEIMessage::H264SEIMessage() {
133 memset(this, 0, sizeof(*this)); 151 memset(this, 0, sizeof(*this));
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 sps->sar_height = kTableSarHeight[aspect_ratio_idc]; 824 sps->sar_height = kTableSarHeight[aspect_ratio_idc];
807 } 825 }
808 } 826 }
809 827
810 int data; 828 int data;
811 // Read and ignore overscan and video signal type info. 829 // Read and ignore overscan and video signal type info.
812 READ_BOOL_OR_RETURN(&data); // overscan_info_present_flag 830 READ_BOOL_OR_RETURN(&data); // overscan_info_present_flag
813 if (data) 831 if (data)
814 READ_BOOL_OR_RETURN(&data); // overscan_appropriate_flag 832 READ_BOOL_OR_RETURN(&data); // overscan_appropriate_flag
815 833
816 READ_BOOL_OR_RETURN(&data); // video_signal_type_present_flag 834 READ_BOOL_OR_RETURN(&sps->video_signal_type_present_flag);
817 if (data) { 835 if (sps->video_signal_type_present_flag) {
818 READ_BITS_OR_RETURN(3, &data); // video_format 836 READ_BITS_OR_RETURN(3, &sps->video_format);
819 READ_BOOL_OR_RETURN(&data); // video_full_range_flag 837 READ_BOOL_OR_RETURN(&sps->video_full_range_flag);
820 READ_BOOL_OR_RETURN(&data); // colour_description_present_flag 838 READ_BOOL_OR_RETURN(&sps->colour_description_present_flag);
821 if (data) 839 if (sps->colour_description_present_flag) {
822 READ_BITS_OR_RETURN(24, &data); // color description syntax elements 840 // color description syntax elements
841 READ_BITS_OR_RETURN(8, &sps->colour_primaries);
842 READ_BITS_OR_RETURN(8, &sps->transfer_characteristics);
843 READ_BITS_OR_RETURN(8, &sps->matrix_coefficients);
844 }
823 } 845 }
824 846
825 READ_BOOL_OR_RETURN(&data); // chroma_loc_info_present_flag 847 READ_BOOL_OR_RETURN(&data); // chroma_loc_info_present_flag
826 if (data) { 848 if (data) {
827 READ_UE_OR_RETURN(&data); // chroma_sample_loc_type_top_field 849 READ_UE_OR_RETURN(&data); // chroma_sample_loc_type_top_field
828 READ_UE_OR_RETURN(&data); // chroma_sample_loc_type_bottom_field 850 READ_UE_OR_RETURN(&data); // chroma_sample_loc_type_bottom_field
829 } 851 }
830 852
831 // Read and ignore timing info. 853 // Read and ignore timing info.
832 READ_BOOL_OR_RETURN(&data); // timing_info_present_flag 854 READ_BOOL_OR_RETURN(&data); // timing_info_present_flag
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 1475
1454 default: 1476 default:
1455 DVLOG(4) << "Unsupported SEI message"; 1477 DVLOG(4) << "Unsupported SEI message";
1456 break; 1478 break;
1457 } 1479 }
1458 1480
1459 return kOk; 1481 return kOk;
1460 } 1482 }
1461 1483
1462 } // namespace media 1484 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/h264_parser.h ('k') | media/gpu/android_video_decode_accelerator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698