FFmpeg
Loading...
Searching...
No Matches
h264_parse.c
Go to the documentation of this file.
1/*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#include "libavutil/mem.h"
20#include "bytestream.h"
21#include "get_bits.h"
22#include "golomb.h"
23#include "h264.h"
24#include "h264pred.h"
25#include "h264_parse.h"
26#include "h264_ps.h"
27#include "h2645_parse.h"
28#include "mpegutils.h"
29
31 const int *ref_count, int slice_type_nos,
33 int picture_structure, void *logctx)
34{
35 int list, i, j;
36 int luma_def, chroma_def;
37
38 pwt->use_weight = 0;
39 pwt->use_weight_chroma = 0;
40
42 if (pwt->luma_log2_weight_denom > 7U) {
43 av_log(logctx, AV_LOG_ERROR, "luma_log2_weight_denom %d is out of range\n", pwt->luma_log2_weight_denom);
45 }
46 luma_def = 1 << pwt->luma_log2_weight_denom;
47
48 if (sps->chroma_format_idc) {
50 if (pwt->chroma_log2_weight_denom > 7U) {
51 av_log(logctx, AV_LOG_ERROR, "chroma_log2_weight_denom %d is out of range\n", pwt->chroma_log2_weight_denom);
53 }
54 chroma_def = 1 << pwt->chroma_log2_weight_denom;
55 }
56
57 for (list = 0; list < 2; list++) {
58 pwt->luma_weight_flag[list] = 0;
59 pwt->chroma_weight_flag[list] = 0;
60 for (i = 0; i < ref_count[list]; i++) {
61 int luma_weight_flag, chroma_weight_flag;
62
63 luma_weight_flag = get_bits1(gb);
64 if (luma_weight_flag) {
65 pwt->luma_weight[i][list][0] = get_se_golomb(gb);
66 pwt->luma_weight[i][list][1] = get_se_golomb(gb);
67 if ((int8_t)pwt->luma_weight[i][list][0] != pwt->luma_weight[i][list][0] ||
68 (int8_t)pwt->luma_weight[i][list][1] != pwt->luma_weight[i][list][1])
69 goto out_range_weight;
70 if (pwt->luma_weight[i][list][0] != luma_def ||
71 pwt->luma_weight[i][list][1] != 0) {
72 pwt->use_weight = 1;
73 pwt->luma_weight_flag[list] = 1;
74 }
75 } else {
76 pwt->luma_weight[i][list][0] = luma_def;
77 pwt->luma_weight[i][list][1] = 0;
78 }
79
80 if (sps->chroma_format_idc) {
81 chroma_weight_flag = get_bits1(gb);
82 if (chroma_weight_flag) {
83 int j;
84 for (j = 0; j < 2; j++) {
85 pwt->chroma_weight[i][list][j][0] = get_se_golomb(gb);
86 pwt->chroma_weight[i][list][j][1] = get_se_golomb(gb);
87 if ((int8_t)pwt->chroma_weight[i][list][j][0] != pwt->chroma_weight[i][list][j][0] ||
88 (int8_t)pwt->chroma_weight[i][list][j][1] != pwt->chroma_weight[i][list][j][1]) {
89 pwt->chroma_weight[i][list][j][0] = chroma_def;
90 pwt->chroma_weight[i][list][j][1] = 0;
91 goto out_range_weight;
92 }
93 if (pwt->chroma_weight[i][list][j][0] != chroma_def ||
94 pwt->chroma_weight[i][list][j][1] != 0) {
95 pwt->use_weight_chroma = 1;
96 pwt->chroma_weight_flag[list] = 1;
97 }
98 }
99 } else {
100 int j;
101 for (j = 0; j < 2; j++) {
102 pwt->chroma_weight[i][list][j][0] = chroma_def;
103 pwt->chroma_weight[i][list][j][1] = 0;
104 }
105 }
106 }
107
108 // for MBAFF
109 if (picture_structure == PICT_FRAME) {
110 pwt->luma_weight[16 + 2 * i][list][0] = pwt->luma_weight[16 + 2 * i + 1][list][0] = pwt->luma_weight[i][list][0];
111 pwt->luma_weight[16 + 2 * i][list][1] = pwt->luma_weight[16 + 2 * i + 1][list][1] = pwt->luma_weight[i][list][1];
112 if (sps->chroma_format_idc) {
113 for (j = 0; j < 2; j++) {
114 pwt->chroma_weight[16 + 2 * i][list][j][0] = pwt->chroma_weight[16 + 2 * i + 1][list][j][0] = pwt->chroma_weight[i][list][j][0];
115 pwt->chroma_weight[16 + 2 * i][list][j][1] = pwt->chroma_weight[16 + 2 * i + 1][list][j][1] = pwt->chroma_weight[i][list][j][1];
116 }
117 }
118 }
119 }
120 if (slice_type_nos != AV_PICTURE_TYPE_B)
121 break;
122 }
123 pwt->use_weight = pwt->use_weight || pwt->use_weight_chroma;
124 return 0;
125out_range_weight:
126 avpriv_request_sample(logctx, "Out of range weight");
127 return AVERROR_INVALIDDATA;
128}
129
130/**
131 * Check if the top & left blocks are available if needed and
132 * change the dc mode so it only uses the available blocks.
133 */
134int ff_h264_check_intra4x4_pred_mode(int8_t *pred_mode_cache, void *logctx,
135 int top_samples_available, int left_samples_available)
136{
137 static const int8_t top[12] = {
138 -1, 0, LEFT_DC_PRED, -1, -1, -1, -1, -1, 0
139 };
140 static const int8_t left[12] = {
141 0, -1, TOP_DC_PRED, 0, -1, -1, -1, 0, -1, DC_128_PRED
142 };
143 int i;
144
145 if (!(top_samples_available & 0x8000)) {
146 for (i = 0; i < 4; i++) {
147 int status = top[pred_mode_cache[scan8[0] + i]];
148 if (status < 0) {
149 av_log(logctx, AV_LOG_ERROR,
150 "top block unavailable for requested intra mode %d\n",
151 status);
152 return AVERROR_INVALIDDATA;
153 } else if (status) {
154 pred_mode_cache[scan8[0] + i] = status;
155 }
156 }
157 }
158
159 if ((left_samples_available & 0x8888) != 0x8888) {
160 static const int mask[4] = { 0x8000, 0x2000, 0x80, 0x20 };
161 for (i = 0; i < 4; i++)
162 if (!(left_samples_available & mask[i])) {
163 int status = left[pred_mode_cache[scan8[0] + 8 * i]];
164 if (status < 0) {
165 av_log(logctx, AV_LOG_ERROR,
166 "left block unavailable for requested intra4x4 mode %d\n",
167 status);
168 return AVERROR_INVALIDDATA;
169 } else if (status) {
170 pred_mode_cache[scan8[0] + 8 * i] = status;
171 }
172 }
173 }
174
175 return 0;
176}
177
178/**
179 * Check if the top & left blocks are available if needed and
180 * change the dc mode so it only uses the available blocks.
181 */
182int ff_h264_check_intra_pred_mode(void *logctx, int top_samples_available,
183 int left_samples_available,
184 int mode, int is_chroma)
185{
186 static const int8_t top[4] = { LEFT_DC_PRED8x8, 1, -1, -1 };
187 static const int8_t left[5] = { TOP_DC_PRED8x8, -1, 2, -1, DC_128_PRED8x8 };
188
189 if (mode > 3U) {
190 av_log(logctx, AV_LOG_ERROR,
191 "out of range intra chroma pred mode\n");
192 return AVERROR_INVALIDDATA;
193 }
194
195 if (!(top_samples_available & 0x8000)) {
196 mode = top[mode];
197 if (mode < 0) {
198 av_log(logctx, AV_LOG_ERROR,
199 "top block unavailable for requested intra mode\n");
200 return AVERROR_INVALIDDATA;
201 }
202 }
203
204 if ((left_samples_available & 0x8080) != 0x8080) {
205 mode = left[mode];
206 if (mode < 0) {
207 av_log(logctx, AV_LOG_ERROR,
208 "left block unavailable for requested intra mode\n");
209 return AVERROR_INVALIDDATA;
210 }
211 if (is_chroma && (left_samples_available & 0x8080)) {
212 // mad cow disease mode, aka MBAFF + constrained_intra_pred
214 (!(left_samples_available & 0x8000)) +
215 2 * (mode == DC_128_PRED8x8);
216 }
217 }
218
219 return mode;
220}
221
222int ff_h264_parse_ref_count(int *plist_count, int ref_count[2],
223 GetBitContext *gb, const PPS *pps,
224 int slice_type_nos, int picture_structure, void *logctx)
225{
226 int list_count;
227 int num_ref_idx_active_override_flag;
228
229 // set defaults, might be overridden a few lines later
230 ref_count[0] = pps->ref_count[0];
231 ref_count[1] = pps->ref_count[1];
232
233 if (slice_type_nos != AV_PICTURE_TYPE_I) {
234 unsigned max[2];
235 max[0] = max[1] = picture_structure == PICT_FRAME ? 15 : 31;
236
237 num_ref_idx_active_override_flag = get_bits1(gb);
238
239 if (num_ref_idx_active_override_flag) {
240 ref_count[0] = get_ue_golomb(gb) + 1;
241 if (slice_type_nos == AV_PICTURE_TYPE_B) {
242 ref_count[1] = get_ue_golomb(gb) + 1;
243 } else
244 // full range is spec-ok in this case, even for frames
245 ref_count[1] = 1;
246 }
247
248 if (slice_type_nos == AV_PICTURE_TYPE_B)
249 list_count = 2;
250 else
251 list_count = 1;
252
253 if (ref_count[0] - 1 > max[0] || (list_count == 2 && (ref_count[1] - 1 > max[1]))) {
254 av_log(logctx, AV_LOG_ERROR, "reference overflow %u > %u or %u > %u\n",
255 ref_count[0] - 1, max[0], ref_count[1] - 1, max[1]);
256 ref_count[0] = ref_count[1] = 0;
257 *plist_count = 0;
258 goto fail;
259 } else if (ref_count[1] - 1 > max[1]) {
260 av_log(logctx, AV_LOG_DEBUG, "reference overflow %u > %u \n",
261 ref_count[1] - 1, max[1]);
262 ref_count[1] = 0;
263 }
264
265 } else {
266 list_count = 0;
267 ref_count[0] = ref_count[1] = 0;
268 }
269
270 *plist_count = list_count;
271
272 return 0;
273fail:
274 *plist_count = 0;
275 ref_count[0] = 0;
276 ref_count[1] = 0;
277 return AVERROR_INVALIDDATA;
278}
279
280int ff_h264_init_poc(int pic_field_poc[2], int *pic_poc,
281 const SPS *sps, H264POCContext *pc,
282 int picture_structure, int nal_ref_idc)
283{
284 const int max_frame_num = 1 << sps->log2_max_frame_num;
285 int64_t field_poc[2];
286
288 if (pc->frame_num < pc->prev_frame_num)
289 pc->frame_num_offset += max_frame_num;
290
291 if (sps->poc_type == 0) {
292 const int max_poc_lsb = 1 << sps->log2_max_poc_lsb;
293 if (pc->prev_poc_lsb < 0)
294 pc->prev_poc_lsb = pc->poc_lsb;
295
296 if (pc->poc_lsb < pc->prev_poc_lsb &&
297 pc->prev_poc_lsb - pc->poc_lsb >= max_poc_lsb / 2)
298 pc->poc_msb = pc->prev_poc_msb + max_poc_lsb;
299 else if (pc->poc_lsb > pc->prev_poc_lsb &&
300 pc->prev_poc_lsb - pc->poc_lsb < -max_poc_lsb / 2)
301 pc->poc_msb = pc->prev_poc_msb - max_poc_lsb;
302 else
303 pc->poc_msb = pc->prev_poc_msb;
304 field_poc[0] =
305 field_poc[1] = pc->poc_msb + pc->poc_lsb;
306 if (picture_structure == PICT_FRAME)
307 field_poc[1] += pc->delta_poc_bottom;
308 } else if (sps->poc_type == 1) {
309 int abs_frame_num;
310 int64_t expected_delta_per_poc_cycle, expectedpoc;
311 int i;
312
313 if (sps->poc_cycle_length != 0)
314 abs_frame_num = pc->frame_num_offset + pc->frame_num;
315 else
316 abs_frame_num = 0;
317
318 if (nal_ref_idc == 0 && abs_frame_num > 0)
319 abs_frame_num--;
320
321 expected_delta_per_poc_cycle = 0;
322 for (i = 0; i < sps->poc_cycle_length; i++)
323 // FIXME integrate during sps parse
324 expected_delta_per_poc_cycle += sps->offset_for_ref_frame[i];
325
326 if (abs_frame_num > 0) {
327 int poc_cycle_cnt = (abs_frame_num - 1) / sps->poc_cycle_length;
328 int frame_num_in_poc_cycle = (abs_frame_num - 1) % sps->poc_cycle_length;
329
330 expectedpoc = poc_cycle_cnt * expected_delta_per_poc_cycle;
331 for (i = 0; i <= frame_num_in_poc_cycle; i++)
332 expectedpoc = expectedpoc + sps->offset_for_ref_frame[i];
333 } else
334 expectedpoc = 0;
335
336 if (nal_ref_idc == 0)
337 expectedpoc = expectedpoc + sps->offset_for_non_ref_pic;
338
339 field_poc[0] = expectedpoc + pc->delta_poc[0];
340 field_poc[1] = field_poc[0] + sps->offset_for_top_to_bottom_field;
341
342 if (picture_structure == PICT_FRAME)
343 field_poc[1] += pc->delta_poc[1];
344 } else {
345 int poc = 2 * (pc->frame_num_offset + pc->frame_num);
346
347 if (!nal_ref_idc)
348 poc--;
349
350 field_poc[0] = poc;
351 field_poc[1] = poc;
352 }
353
354 if ( field_poc[0] != (int)field_poc[0]
355 || field_poc[1] != (int)field_poc[1])
356 return AVERROR_INVALIDDATA;
357
358 if (picture_structure != PICT_BOTTOM_FIELD)
359 pic_field_poc[0] = field_poc[0];
360 if (picture_structure != PICT_TOP_FIELD)
361 pic_field_poc[1] = field_poc[1];
362 *pic_poc = FFMIN(pic_field_poc[0], pic_field_poc[1]);
363
364 return 0;
365}
366
367static int decode_extradata_ps(const uint8_t *data, int size, H264ParamSets *ps,
368 int is_avc, void *logctx)
369{
370 H2645Packet pkt = { 0 };
372 int i, ret = 0;
373
375 if (ret < 0) {
376 ret = 0;
377 goto fail;
378 }
379
380 for (i = 0; i < pkt.nb_nals; i++) {
381 H2645NAL *nal = &pkt.nals[i];
382 switch (nal->type) {
383 case H264_NAL_SPS: {
384 GetBitContext tmp_gb = nal->gb;
385 ret = ff_h264_decode_seq_parameter_set(&tmp_gb, logctx, ps, 0);
386 if (ret >= 0)
387 break;
388 av_log(logctx, AV_LOG_DEBUG,
389 "SPS decoding failure, trying again with the complete NAL\n");
390 init_get_bits8(&tmp_gb, nal->raw_data + 1, nal->raw_size - 1);
391 ret = ff_h264_decode_seq_parameter_set(&tmp_gb, logctx, ps, 0);
392 if (ret >= 0)
393 break;
394 ret = ff_h264_decode_seq_parameter_set(&nal->gb, logctx, ps, 1);
395 if (ret < 0)
396 goto fail;
397 break;
398 }
399 case H264_NAL_PPS:
400 ret = ff_h264_decode_picture_parameter_set(&nal->gb, logctx, ps,
401 nal->size_bits);
402 if (ret < 0)
403 goto fail;
404 break;
405 default:
406 av_log(logctx, AV_LOG_VERBOSE, "Ignoring NAL type %d in extradata\n",
407 nal->type);
408 break;
409 }
410 }
411
412fail:
414 return ret;
415}
416
417/* There are (invalid) samples in the wild with mp4-style extradata, where the
418 * parameter sets are stored unescaped (i.e. as RBSP).
419 * This function catches the parameter set decoding failure and tries again
420 * after escaping it */
421static int decode_extradata_ps_mp4(const uint8_t *buf, int buf_size, H264ParamSets *ps,
422 int err_recognition, void *logctx)
423{
424 int ret;
425
426 ret = decode_extradata_ps(buf, buf_size, ps, 1, logctx);
427 if (ret < 0 && !(err_recognition & AV_EF_EXPLODE)) {
428 GetByteContext gbc;
429 PutByteContext pbc;
430 uint8_t *escaped_buf;
431 int escaped_buf_size;
432
433 av_log(logctx, AV_LOG_WARNING,
434 "SPS decoding failure, trying again after escaping the NAL\n");
435
436 if (buf_size / 2 >= (INT16_MAX - AV_INPUT_BUFFER_PADDING_SIZE) / 3)
437 return AVERROR(ERANGE);
438 escaped_buf_size = buf_size * 3 / 2 + AV_INPUT_BUFFER_PADDING_SIZE;
439 escaped_buf = av_mallocz(escaped_buf_size);
440 if (!escaped_buf)
441 return AVERROR(ENOMEM);
442
443 bytestream2_init(&gbc, buf, buf_size);
444 bytestream2_init_writer(&pbc, escaped_buf, escaped_buf_size);
445
446 while (bytestream2_get_bytes_left(&gbc)) {
447 if (bytestream2_get_bytes_left(&gbc) >= 3 &&
448 bytestream2_peek_be24(&gbc) <= 3) {
449 bytestream2_put_be24(&pbc, 3);
450 bytestream2_skip(&gbc, 2);
451 } else
452 bytestream2_put_byte(&pbc, bytestream2_get_byte(&gbc));
453 }
454
455 escaped_buf_size = bytestream2_tell_p(&pbc);
456 AV_WB16(escaped_buf, escaped_buf_size - 2);
457
458 (void)decode_extradata_ps(escaped_buf, escaped_buf_size, ps, 1, logctx);
459 // lorex.mp4 decodes ok even with extradata decoding failing
460 av_freep(&escaped_buf);
461 }
462
463 return 0;
464}
465
466int ff_h264_decode_extradata(const uint8_t *data, int size, H264ParamSets *ps,
467 int *is_avc, int *nal_length_size,
468 int err_recognition, void *logctx)
469{
470 int ret;
471
472 if (!data || size <= 0)
473 return AVERROR(EINVAL);
474
475 if (data[0] == 1) {
476 int i, cnt, nalsize;
477 const uint8_t *p = data;
478
479 *is_avc = 1;
480
481 if (size < 7) {
482 av_log(logctx, AV_LOG_ERROR, "avcC %d too short\n", size);
483 return AVERROR_INVALIDDATA;
484 }
485
486 // Decode sps from avcC
487 cnt = *(p + 5) & 0x1f; // Number of sps
488 p += 6;
489 for (i = 0; i < cnt; i++) {
490 nalsize = AV_RB16(p) + 2;
491 if (nalsize > size - (p - data))
492 return AVERROR_INVALIDDATA;
493 ret = decode_extradata_ps_mp4(p, nalsize, ps, err_recognition, logctx);
494 if (ret < 0) {
495 av_log(logctx, AV_LOG_ERROR,
496 "Decoding sps %d from avcC failed\n", i);
497 return ret;
498 }
499 p += nalsize;
500 }
501 // Decode pps from avcC
502 cnt = *(p++); // Number of pps
503 for (i = 0; i < cnt; i++) {
504 nalsize = AV_RB16(p) + 2;
505 if (nalsize > size - (p - data))
506 return AVERROR_INVALIDDATA;
507 ret = decode_extradata_ps_mp4(p, nalsize, ps, err_recognition, logctx);
508 if (ret < 0) {
509 av_log(logctx, AV_LOG_ERROR,
510 "Decoding pps %d from avcC failed\n", i);
511 return ret;
512 }
513 p += nalsize;
514 }
515 // Store right nal length size that will be used to parse all other nals
516 *nal_length_size = (data[4] & 0x03) + 1;
517 } else {
518 *is_avc = 0;
519 ret = decode_extradata_ps(data, size, ps, 0, logctx);
520 if (ret < 0)
521 return ret;
522 }
523 return size;
524}
525
526/**
527 * Compute profile from profile_idc and constraint_set?_flags.
528 *
529 * @param sps SPS
530 *
531 * @return profile as defined by AV_PROFILE_H264_*
532 */
534{
535 int profile = sps->profile_idc;
536
537 switch (sps->profile_idc) {
539 // constraint_set1_flag set to 1
540 profile |= (sps->constraint_set_flags & 1 << 1) ? AV_PROFILE_H264_CONSTRAINED : 0;
541 break;
545 // constraint_set3_flag set to 1
546 profile |= (sps->constraint_set_flags & 1 << 3) ? AV_PROFILE_H264_INTRA : 0;
547 break;
548 }
549
550 return profile;
551}
static int BS_FUNC left(const BSCTX *bc)
Return the number of the bits left in a buffer.
static av_always_inline int bytestream2_tell_p(const PutByteContext *p)
Definition bytestream.h:197
static av_always_inline void bytestream2_init_writer(PutByteContext *p, uint8_t *buf, int buf_size)
Definition bytestream.h:147
static av_always_inline int bytestream2_get_bytes_left(const GetByteContext *g)
Definition bytestream.h:158
static av_always_inline void bytestream2_init(GetByteContext *g, const uint8_t *buf, int buf_size)
Definition bytestream.h:137
static av_always_inline void bytestream2_skip(GetByteContext *g, unsigned int size)
Definition bytestream.h:168
#define flags(name, subs,...)
Definition cbs_h264.c:74
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
static int FUNC sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
static int FUNC nal(CodedBitstreamContext *ctx, RWContext *rw, LCEVCRawNAL *current, int nal_unit_type)
long long int64_t
Definition coverity.c:34
#define max(a, b)
#define AV_PROFILE_H264_CONSTRAINED
Definition defs.h:107
#define AV_PROFILE_H264_HIGH_444_PREDICTIVE
Definition defs.h:122
#define AV_EF_EXPLODE
abort decoding on minor error detection
Definition defs.h:51
#define AV_PROFILE_H264_INTRA
Definition defs.h:108
#define AV_PROFILE_H264_HIGH_10
Definition defs.h:115
#define AV_PROFILE_H264_HIGH_422
Definition defs.h:118
#define AV_PROFILE_H264_BASELINE
Definition defs.h:110
static AVPacket * pkt
uint64_t pps
Definition dovi_rpuenc.c:36
bitstream reader API header.
static unsigned int get_bits1(GetBitContext *s)
Definition get_bits.h:391
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Definition get_bits.h:544
exp golomb vlc stuff
static int get_se_golomb(GetBitContext *gb)
read signed exp golomb code.
Definition golomb.h:239
static int get_ue_golomb_31(GetBitContext *gb)
read unsigned exp golomb code, constraint to a max of 31.
Definition golomb.h:120
static int get_ue_golomb(GetBitContext *gb)
Read an unsigned Exp-Golomb code in the range 0 to 8190.
Definition golomb.h:53
#define fail
Definition test.h:479
@ AV_CODEC_ID_H264
Definition codec_id.h:77
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
Definition defs.h:40
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition error.h:61
#define AVERROR(e)
Definition error.h:45
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition log.h:231
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition log.h:216
#define AV_LOG_VERBOSE
Detailed information.
Definition log.h:226
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
@ AV_PICTURE_TYPE_I
Intra.
Definition avutil.h:278
@ AV_PICTURE_TYPE_B
Bi-dir predicted.
Definition avutil.h:280
@ H2645_FLAG_SMALL_PADDING
Definition h2645_parse.h:98
@ H2645_FLAG_IS_NALFF
Definition h2645_parse.h:97
H.264 common definitions.
@ H264_NAL_PPS
Definition h264.h:42
@ H264_NAL_SPS
Definition h264.h:41
int ff_h264_get_profile(const SPS *sps)
Compute profile from profile_idc and constraint_set?_flags.
Definition h264_parse.c:533
int ff_h264_parse_ref_count(int *plist_count, int ref_count[2], GetBitContext *gb, const PPS *pps, int slice_type_nos, int picture_structure, void *logctx)
Definition h264_parse.c:222
int ff_h264_init_poc(int pic_field_poc[2], int *pic_poc, const SPS *sps, H264POCContext *pc, int picture_structure, int nal_ref_idc)
Definition h264_parse.c:280
static int decode_extradata_ps(const uint8_t *data, int size, H264ParamSets *ps, int is_avc, void *logctx)
Definition h264_parse.c:367
static int decode_extradata_ps_mp4(const uint8_t *buf, int buf_size, H264ParamSets *ps, int err_recognition, void *logctx)
Definition h264_parse.c:421
int ff_h264_pred_weight_table(GetBitContext *gb, const SPS *sps, const int *ref_count, int slice_type_nos, H264PredWeightTable *pwt, int picture_structure, void *logctx)
Definition h264_parse.c:30
int ff_h264_check_intra4x4_pred_mode(int8_t *pred_mode_cache, void *logctx, int top_samples_available, int left_samples_available)
Check if the top & left blocks are available if needed and change the dc mode so it only uses the ava...
Definition h264_parse.c:134
int ff_h264_decode_extradata(const uint8_t *data, int size, H264ParamSets *ps, int *is_avc, int *nal_length_size, int err_recognition, void *logctx)
Definition h264_parse.c:466
int ff_h264_check_intra_pred_mode(void *logctx, int top_samples_available, int left_samples_available, int mode, int is_chroma)
Check if the top & left blocks are available if needed and change the dc mode so it only uses the ava...
Definition h264_parse.c:182
H.264 decoder/parser shared code.
static const uint8_t scan8[16 *3+3]
Definition h264_parse.h:40
int ff_h264_decode_picture_parameter_set(GetBitContext *gb, AVCodecContext *avctx, H264ParamSets *ps, int bit_length)
Decode PPS.
Definition h264_ps.c:698
int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx, H264ParamSets *ps, int ignore_truncation)
Decode SPS.
Definition h264_ps.c:284
H.264 parameter set handling.
H.264 / AVC / MPEG-4 prediction functions.
#define TOP_DC_PRED
Definition h264pred.h:50
#define TOP_DC_PRED8x8
Definition h264pred.h:75
#define ALZHEIMER_DC_L0T_PRED8x8
Definition h264pred.h:79
#define DC_128_PRED
Definition h264pred.h:51
#define LEFT_DC_PRED
Definition h264pred.h:49
#define LEFT_DC_PRED8x8
Definition h264pred.h:74
#define DC_128_PRED8x8
Definition h264pred.h:76
#define AV_WB16(p, v)
#define AV_RB16(p)
void ff_h2645_packet_uninit(H2645Packet *pkt)
Free all the allocated memory in the packet.
int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length, void *logctx, int nal_length_size, enum AVCodecID codec_id, int flags)
Split an input packet into NAL units.
static const uint16_t mask[17]
Definition lzw.c:38
#define FFMIN(a, b)
Definition macros.h:49
Memory handling functions.
#define PICT_TOP_FIELD
Definition mpegutils.h:31
#define PICT_BOTTOM_FIELD
Definition mpegutils.h:32
#define PICT_FRAME
Definition mpegutils.h:33
const char data[16]
Definition mxf.c:149
int profile
Definition mxfenc.c:2299
int frame_num_offset
for POC type 2
Definition h264_parse.h:90
int prev_frame_num_offset
for POC type 2
Definition h264_parse.h:91
int prev_frame_num
frame_num of the last pic for POC type 1/2
Definition h264_parse.h:92
int prev_poc_msb
poc_msb of the last reference pic for POC type 0
Definition h264_parse.h:88
int delta_poc[2]
Definition h264_parse.h:86
int prev_poc_lsb
poc_lsb of the last reference pic for POC type 0
Definition h264_parse.h:89
int luma_weight[48][2][2]
Definition h264_parse.h:77
int chroma_weight_flag[2]
7.4.3.2 chroma_weight_lX_flag
Definition h264_parse.h:75
int luma_weight_flag[2]
7.4.3.2 luma_weight_lX_flag
Definition h264_parse.h:74
int chroma_weight[48][2][2][2]
Definition h264_parse.h:78
Picture parameter set.
Definition h264_ps.h:110
Sequence parameter set.
Definition h264_ps.h:44
Definition swscale.c:71
#define av_mallocz(s)
#define avpriv_request_sample(...)
#define av_freep(p)
#define av_log(a,...)
int size