1 /*
2 * AVS3-P2/IEEE1857.10 video parser.
3 * Copyright (c) 2020 Zhenyu Wang <wangzhenyu@pkusz.edu.cn>
4 * Bingjie Han <hanbj@pkusz.edu.cn>
5 * Huiwen Ren <hwrenx@gmail.com>
6 *
7 * This file is part of FFmpeg.
8 *
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
27
29 {
32 int cur = 0;
33
34 if (!pic_found) {
35 for (; cur < buf_size; ++cur) {
38 cur++;
39 pic_found = 1;
40 break;
41 }
42 }
43 }
44
45 if (pic_found) {
46 if (!buf_size)
48 for (; cur < buf_size; ++cur) {
53 return cur - 3;
54 }
55 }
56 }
57
60
62 }
63
66 {
67 if (buf_size < 5) {
68 return;
69 }
70
71 if (buf[0] == 0x0 && buf[1] == 0x0 && buf[2] == 0x1) {
74 int profile, ratecode, low_delay;
75
78
81
83 // Skip bits: level(8)
84 // progressive(1)
85 // field(1)
86 // library(2)
87 // resv(1)
88 // width(14)
89 // resv(1)
90 // height(14)
91 // chroma(2)
92 // sampe_precision(3)
94
96 int sample_precision =
get_bits(&gb, 3);
97 if (sample_precision == 1) {
99 } else if (sample_precision == 2) {
101 } else {
103 }
104 }
105
106 // Skip bits: resv(1)
107 // aspect(4)
109
111
112 // Skip bits: resv(1)
113 // bitrate_low(18)
114 // resv(1)
115 // bitrate_high(12)
117
120
123
124 s->width =
s->coded_width = avctx->
width;
125 s->height =
s->coded_height = avctx->
height;
126
128 "AVS3 parse seq HDR: profile %d; coded size: %dx%d; frame rate code: %d\n",
130
136 if (buf_size > 9) {
137 int pic_code_type = buf[8] & 0x3;
138 if (pic_code_type == 1 || pic_code_type == 3) {
140 } else {
142 }
143 }
144 }
145 }
146 }
147
148
150 const uint8_t **poutbuf, int *poutbuf_size,
151 const uint8_t *buf, int buf_size)
152 {
154 int next;
155
157 next = buf_size;
158 } else {
162 *poutbuf_size = 0;
163 return buf_size;
164 }
165 }
166
168
169 *poutbuf = buf;
170 *poutbuf_size = buf_size;
171
172 return next;
173 }
174
180 };