OLD | NEW |
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 | 9 |
9 #include "base/logging.h" | 10 #include "base/logging.h" |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
13 #include "media/base/decrypt_config.h" | 13 #include "media/base/decrypt_config.h" |
14 | 14 |
15 namespace media { | 15 namespace media { |
16 | 16 |
17 bool H264SliceHeader::IsPSlice() const { | 17 bool H264SliceHeader::IsPSlice() const { |
18 return (slice_type % 5 == kPSlice); | 18 return (slice_type % 5 == kPSlice); |
19 } | 19 } |
20 | 20 |
21 bool H264SliceHeader::IsBSlice() const { | 21 bool H264SliceHeader::IsBSlice() const { |
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 sps->scaling_list8x8[i][j] = 16; | 776 sps->scaling_list8x8[i][j] = 16; |
777 } | 777 } |
778 | 778 |
779 H264Parser::Result H264Parser::ParseSPS(int* sps_id) { | 779 H264Parser::Result H264Parser::ParseSPS(int* sps_id) { |
780 // See 7.4.2.1. | 780 // See 7.4.2.1. |
781 int data; | 781 int data; |
782 Result res; | 782 Result res; |
783 | 783 |
784 *sps_id = -1; | 784 *sps_id = -1; |
785 | 785 |
786 scoped_ptr<H264SPS> sps(new H264SPS()); | 786 std::unique_ptr<H264SPS> sps(new H264SPS()); |
787 | 787 |
788 READ_BITS_OR_RETURN(8, &sps->profile_idc); | 788 READ_BITS_OR_RETURN(8, &sps->profile_idc); |
789 READ_BOOL_OR_RETURN(&sps->constraint_set0_flag); | 789 READ_BOOL_OR_RETURN(&sps->constraint_set0_flag); |
790 READ_BOOL_OR_RETURN(&sps->constraint_set1_flag); | 790 READ_BOOL_OR_RETURN(&sps->constraint_set1_flag); |
791 READ_BOOL_OR_RETURN(&sps->constraint_set2_flag); | 791 READ_BOOL_OR_RETURN(&sps->constraint_set2_flag); |
792 READ_BOOL_OR_RETURN(&sps->constraint_set3_flag); | 792 READ_BOOL_OR_RETURN(&sps->constraint_set3_flag); |
793 READ_BOOL_OR_RETURN(&sps->constraint_set4_flag); | 793 READ_BOOL_OR_RETURN(&sps->constraint_set4_flag); |
794 READ_BOOL_OR_RETURN(&sps->constraint_set5_flag); | 794 READ_BOOL_OR_RETURN(&sps->constraint_set5_flag); |
795 READ_BITS_OR_RETURN(2, &data); // reserved_zero_2bits | 795 READ_BITS_OR_RETURN(2, &data); // reserved_zero_2bits |
796 READ_BITS_OR_RETURN(8, &sps->level_idc); | 796 READ_BITS_OR_RETURN(8, &sps->level_idc); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
895 return kOk; | 895 return kOk; |
896 } | 896 } |
897 | 897 |
898 H264Parser::Result H264Parser::ParsePPS(int* pps_id) { | 898 H264Parser::Result H264Parser::ParsePPS(int* pps_id) { |
899 // See 7.4.2.2. | 899 // See 7.4.2.2. |
900 const H264SPS* sps; | 900 const H264SPS* sps; |
901 Result res; | 901 Result res; |
902 | 902 |
903 *pps_id = -1; | 903 *pps_id = -1; |
904 | 904 |
905 scoped_ptr<H264PPS> pps(new H264PPS()); | 905 std::unique_ptr<H264PPS> pps(new H264PPS()); |
906 | 906 |
907 READ_UE_OR_RETURN(&pps->pic_parameter_set_id); | 907 READ_UE_OR_RETURN(&pps->pic_parameter_set_id); |
908 READ_UE_OR_RETURN(&pps->seq_parameter_set_id); | 908 READ_UE_OR_RETURN(&pps->seq_parameter_set_id); |
909 TRUE_OR_RETURN(pps->seq_parameter_set_id < 32); | 909 TRUE_OR_RETURN(pps->seq_parameter_set_id < 32); |
910 | 910 |
911 if (active_SPSes_.find(pps->seq_parameter_set_id) == active_SPSes_.end()) { | 911 if (active_SPSes_.find(pps->seq_parameter_set_id) == active_SPSes_.end()) { |
912 DVLOG(1) << "Invalid stream, no SPS id: " << pps->seq_parameter_set_id; | 912 DVLOG(1) << "Invalid stream, no SPS id: " << pps->seq_parameter_set_id; |
913 return kInvalidStream; | 913 return kInvalidStream; |
914 } | 914 } |
915 | 915 |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1348 | 1348 |
1349 default: | 1349 default: |
1350 DVLOG(4) << "Unsupported SEI message"; | 1350 DVLOG(4) << "Unsupported SEI message"; |
1351 break; | 1351 break; |
1352 } | 1352 } |
1353 | 1353 |
1354 return kOk; | 1354 return kOk; |
1355 } | 1355 } |
1356 | 1356 |
1357 } // namespace media | 1357 } // namespace media |
OLD | NEW |