OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/common/gpu/media/h264_parser.h" | 5 #include "content/common/gpu/media/h264_parser.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 | 10 |
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
647 FallbackScalingList8x8(i, sps.scaling_list8x8[0], | 647 FallbackScalingList8x8(i, sps.scaling_list8x8[0], |
648 sps.scaling_list8x8[1], pps->scaling_list8x8); | 648 sps.scaling_list8x8[1], pps->scaling_list8x8); |
649 } | 649 } |
650 } | 650 } |
651 } | 651 } |
652 } | 652 } |
653 return kOk; | 653 return kOk; |
654 } | 654 } |
655 | 655 |
656 static void FillDefaultSeqScalingLists(H264SPS* sps) { | 656 static void FillDefaultSeqScalingLists(H264SPS* sps) { |
657 // Assumes ints in arrays. | 657 for (int i = 0; i < 6; ++i) |
658 memset(sps->scaling_list4x4, 16, sizeof(sps->scaling_list4x4)); | 658 for (int j = 0; j < kH264ScalingList4x4Length; ++j) |
Ami GONE FROM CHROMIUM
2012/07/26 19:32:12
This is pretty awesome; were we setting each int t
Pawel Osciak
2012/07/26 19:48:49
No, we were casting this to chars later on. But di
| |
659 memset(sps->scaling_list8x8, 16, sizeof(sps->scaling_list8x8)); | 659 sps->scaling_list4x4[i][j] = 16; |
660 | |
661 for (int i = 0; i < 6; ++i) | |
662 for (int j = 0; j < kH264ScalingList8x8Length; ++j) | |
663 sps->scaling_list8x8[i][j] = 16; | |
664 | |
660 } | 665 } |
661 | 666 |
662 H264Parser::Result H264Parser::ParseSPS(int* sps_id) { | 667 H264Parser::Result H264Parser::ParseSPS(int* sps_id) { |
663 // See 7.4.2.1. | 668 // See 7.4.2.1. |
664 int data; | 669 int data; |
665 Result res; | 670 Result res; |
666 | 671 |
667 *sps_id = -1; | 672 *sps_id = -1; |
668 | 673 |
669 scoped_ptr<H264SPS> sps(new H264SPS()); | 674 scoped_ptr<H264SPS> sps(new H264SPS()); |
670 | 675 |
671 READ_BITS_OR_RETURN(8, &sps->profile_idc); | 676 READ_BITS_OR_RETURN(8, &sps->profile_idc); |
672 READ_BITS_OR_RETURN(6, &sps->constraint_setx_flag); | 677 READ_BITS_OR_RETURN(6, &sps->constraint_setx_flag); |
673 READ_BITS_OR_RETURN(2, &data); | 678 READ_BITS_OR_RETURN(2, &data); |
674 READ_BITS_OR_RETURN(8, &sps->level_idc); | 679 READ_BITS_OR_RETURN(8, &sps->level_idc); |
675 READ_UE_OR_RETURN(&sps->seq_parameter_set_id); | 680 READ_UE_OR_RETURN(&sps->seq_parameter_set_id); |
676 TRUE_OR_RETURN(sps->seq_parameter_set_id < 32); | 681 TRUE_OR_RETURN(sps->seq_parameter_set_id < 32); |
677 | 682 |
678 if (sps->profile_idc == 100 || sps->profile_idc == 110 || | 683 if (sps->profile_idc == 100 || sps->profile_idc == 110 || |
679 sps->profile_idc == 122 || sps->profile_idc == 244 || | 684 sps->profile_idc == 122 || sps->profile_idc == 244 || |
680 sps->profile_idc == 44 || sps->profile_idc == 83 || | 685 sps->profile_idc == 44 || sps->profile_idc == 83 || |
681 sps->profile_idc == 86 || sps->profile_idc == 118 || | 686 sps->profile_idc == 86 || sps->profile_idc == 118 || |
682 sps->profile_idc == 128) { | 687 sps->profile_idc == 128) { |
683 READ_UE_OR_RETURN(&sps->chroma_format_idc); | 688 READ_UE_OR_RETURN(&sps->chroma_format_idc); |
684 TRUE_OR_RETURN(sps->chroma_format_idc < 4); | 689 TRUE_OR_RETURN(sps->chroma_format_idc < 4); |
685 | 690 |
686 if (sps->chroma_format_idc == 3) | 691 if (sps->chroma_format_idc == 3) |
687 READ_BOOL_OR_RETURN(&sps->separate_colour_plane_flag); | 692 READ_BOOL_OR_RETURN(&sps->separate_colour_plane_flag); |
688 | 693 |
689 if (sps->separate_colour_plane_flag) | |
690 sps->chroma_array_type = 0; | |
691 else | |
692 sps->chroma_array_type = sps->chroma_format_idc; | |
693 | |
694 READ_UE_OR_RETURN(&sps->bit_depth_luma_minus8); | 694 READ_UE_OR_RETURN(&sps->bit_depth_luma_minus8); |
695 TRUE_OR_RETURN(sps->bit_depth_luma_minus8 < 7); | 695 TRUE_OR_RETURN(sps->bit_depth_luma_minus8 < 7); |
696 | 696 |
697 READ_UE_OR_RETURN(&sps->bit_depth_chroma_minus8); | 697 READ_UE_OR_RETURN(&sps->bit_depth_chroma_minus8); |
698 TRUE_OR_RETURN(sps->bit_depth_chroma_minus8 < 7); | 698 TRUE_OR_RETURN(sps->bit_depth_chroma_minus8 < 7); |
699 | 699 |
700 READ_BOOL_OR_RETURN(&sps->qpprime_y_zero_transform_bypass_flag); | 700 READ_BOOL_OR_RETURN(&sps->qpprime_y_zero_transform_bypass_flag); |
701 READ_BOOL_OR_RETURN(&sps->seq_scaling_matrix_present_flag); | 701 READ_BOOL_OR_RETURN(&sps->seq_scaling_matrix_present_flag); |
702 | 702 |
703 if (sps->seq_scaling_matrix_present_flag) { | 703 if (sps->seq_scaling_matrix_present_flag) { |
704 DVLOG(4) << "Scaling matrix present"; | 704 DVLOG(4) << "Scaling matrix present"; |
705 res = ParseSPSScalingLists(sps.get()); | 705 res = ParseSPSScalingLists(sps.get()); |
706 if (res != kOk) | 706 if (res != kOk) |
707 return res; | 707 return res; |
708 } else { | 708 } else { |
709 FillDefaultSeqScalingLists(sps.get()); | 709 FillDefaultSeqScalingLists(sps.get()); |
710 } | 710 } |
711 } else { | |
712 sps->chroma_format_idc = 1; | |
713 FillDefaultSeqScalingLists(sps.get()); | |
711 } | 714 } |
712 | 715 |
716 if (sps->separate_colour_plane_flag) | |
717 sps->chroma_array_type = 0; | |
718 else | |
719 sps->chroma_array_type = sps->chroma_format_idc; | |
720 | |
713 READ_UE_OR_RETURN(&sps->log2_max_frame_num_minus4); | 721 READ_UE_OR_RETURN(&sps->log2_max_frame_num_minus4); |
714 TRUE_OR_RETURN(sps->log2_max_frame_num_minus4 < 13); | 722 TRUE_OR_RETURN(sps->log2_max_frame_num_minus4 < 13); |
715 | 723 |
716 READ_UE_OR_RETURN(&sps->pic_order_cnt_type); | 724 READ_UE_OR_RETURN(&sps->pic_order_cnt_type); |
717 TRUE_OR_RETURN(sps->pic_order_cnt_type < 3); | 725 TRUE_OR_RETURN(sps->pic_order_cnt_type < 3); |
718 | 726 |
719 if (sps->pic_order_cnt_type == 0) { | 727 if (sps->pic_order_cnt_type == 0) { |
720 READ_UE_OR_RETURN(&sps->log2_max_pic_order_cnt_lsb_minus4); | 728 READ_UE_OR_RETURN(&sps->log2_max_pic_order_cnt_lsb_minus4); |
721 TRUE_OR_RETURN(sps->log2_max_pic_order_cnt_lsb_minus4 < 13); | 729 TRUE_OR_RETURN(sps->log2_max_pic_order_cnt_lsb_minus4 < 13); |
722 } else if (sps->pic_order_cnt_type == 1) { | 730 } else if (sps->pic_order_cnt_type == 1) { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
800 TRUE_OR_RETURN(pps->weighted_bipred_idc < 3); | 808 TRUE_OR_RETURN(pps->weighted_bipred_idc < 3); |
801 | 809 |
802 READ_SE_OR_RETURN(&pps->pic_init_qp_minus26); | 810 READ_SE_OR_RETURN(&pps->pic_init_qp_minus26); |
803 IN_RANGE_OR_RETURN(pps->pic_init_qp_minus26, -26, 25); | 811 IN_RANGE_OR_RETURN(pps->pic_init_qp_minus26, -26, 25); |
804 | 812 |
805 READ_SE_OR_RETURN(&pps->pic_init_qs_minus26); | 813 READ_SE_OR_RETURN(&pps->pic_init_qs_minus26); |
806 IN_RANGE_OR_RETURN(pps->pic_init_qs_minus26, -26, 25); | 814 IN_RANGE_OR_RETURN(pps->pic_init_qs_minus26, -26, 25); |
807 | 815 |
808 READ_SE_OR_RETURN(&pps->chroma_qp_index_offset); | 816 READ_SE_OR_RETURN(&pps->chroma_qp_index_offset); |
809 IN_RANGE_OR_RETURN(pps->chroma_qp_index_offset, -12, 12); | 817 IN_RANGE_OR_RETURN(pps->chroma_qp_index_offset, -12, 12); |
818 pps->second_chroma_qp_index_offset = pps->chroma_qp_index_offset; | |
810 | 819 |
811 READ_BOOL_OR_RETURN(&pps->deblocking_filter_control_present_flag); | 820 READ_BOOL_OR_RETURN(&pps->deblocking_filter_control_present_flag); |
812 READ_BOOL_OR_RETURN(&pps->constrained_intra_pred_flag); | 821 READ_BOOL_OR_RETURN(&pps->constrained_intra_pred_flag); |
813 READ_BOOL_OR_RETURN(&pps->redundant_pic_cnt_present_flag); | 822 READ_BOOL_OR_RETURN(&pps->redundant_pic_cnt_present_flag); |
814 | 823 |
815 if (br_.HasMoreRBSPData()) { | 824 if (br_.HasMoreRBSPData()) { |
816 READ_BOOL_OR_RETURN(&pps->transform_8x8_mode_flag); | 825 READ_BOOL_OR_RETURN(&pps->transform_8x8_mode_flag); |
817 READ_BOOL_OR_RETURN(&pps->pic_scaling_matrix_present_flag); | 826 READ_BOOL_OR_RETURN(&pps->pic_scaling_matrix_present_flag); |
818 | 827 |
819 if (pps->pic_scaling_matrix_present_flag) { | 828 if (pps->pic_scaling_matrix_present_flag) { |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1202 | 1211 |
1203 default: | 1212 default: |
1204 DVLOG(4) << "Unsupported SEI message"; | 1213 DVLOG(4) << "Unsupported SEI message"; |
1205 break; | 1214 break; |
1206 } | 1215 } |
1207 | 1216 |
1208 return kOk; | 1217 return kOk; |
1209 } | 1218 } |
1210 | 1219 |
1211 } // namespace content | 1220 } // namespace content |
OLD | NEW |