1 /*
2 * H.26L/H.264/AVC/JVT/14496-10/... decoder
3 * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 /**
23 * @file
24 * H.264 / AVC / MPEG4 part10 codec.
25 * @author Michael Niedermayer <michaelni@gmx.at>
26 */
27
28 #define UNCHECKED_BITSTREAM_READER 1
29
53
55
57 {
60 }
61
64 int mb_x, int mb_y, int mb_intra, int mb_skipped)
65 {
68
74 /* FIXME: It is possible albeit uncommon that slice references
75 * differ between slices. We take the easy approach and ignore
76 * it for now. If this turns out to have any relevance in
77 * practice then correct remapping should be added. */
79 ref = 0;
82 ref = 0;
83 }
86 return;
87 }
89 2, 2, 2, ref, 1);
96 }
97
100 {
106 if (field_pic) {
107 height <<= 1;
108 y <<= 1;
109 }
110
112
114 return;
115
118 int i;
119
121 offset[1] =
122 offset[2] = (y >> vshift) * src->
linesize[1];
124 offset[i] = 0;
125
126 emms_c();
127
130 }
131 }
132
133 /**
134 * Check if the top & left blocks are available if needed and
135 * change the dc mode so it only uses the available blocks.
136 */
138 {
139 static const int8_t top[12] = {
141 };
142 static const int8_t left[12] = {
144 };
145 int i;
146
148 for (i = 0; i < 4; i++) {
150 if (status < 0) {
152 "top block unavailable for requested intra4x4 mode %d at %d %d\n",
155 } else if (status) {
157 }
158 }
159 }
160
162 static const int mask[4] = { 0x8000, 0x2000, 0x80, 0x20 };
163 for (i = 0; i < 4; i++)
166 if (status < 0) {
168 "left block unavailable for requested intra4x4 mode %d at %d %d\n",
171 } else if (status) {
173 }
174 }
175 }
176
177 return 0;
178 } // FIXME cleanup like ff_h264_check_intra_pred_mode
179
180 /**
181 * Check if the top & left blocks are available if needed and
182 * change the dc mode so it only uses the available blocks.
183 */
185 int mode,
int is_chroma)
186 {
189
192 "out of range intra chroma pred mode at %d %d\n",
195 }
196
199 if (mode < 0) {
201 "top block unavailable for requested intra mode at %d %d\n",
204 }
205 }
206
209 if (mode < 0) {
211 "left block unavailable for requested intra mode at %d %d\n",
214 }
216 // mad cow disease mode, aka MBAFF + constrained_intra_pred
220 }
221 }
222
224 }
225
228 int *dst_length,
int *consumed,
int length)
229 {
230 int i, si, di;
232
233 // src[0]&0x80; // forbidden bit
236
237 src++;
238 length--;
239
240 #define STARTCODE_TEST \
241 if (i + 2 < length && src[i + 1] == 0 && src[i + 2] <= 3) { \
242 if (src[i + 2] != 3 && src[i + 2] != 0) { \
243 /* startcode, so we must be past the end */ \
244 length = i; \
245 } \
246 break; \
247 }
248
249 #if HAVE_FAST_UNALIGNED
250 #define FIND_FIRST_ZERO \
251 if (i > 0 && !src[i]) \
252 i--; \
253 while (src[i]) \
254 i++
255
256 #if HAVE_FAST_64BIT
257 for (i = 0; i + 1 <
length; i += 9) {
259 (
AV_RN64A(src + i) - 0x0100010001000101ULL)) &
260 0x8000800080008080ULL))
261 continue;
262 FIND_FIRST_ZERO;
264 i -= 7;
265 }
266 #else
267 for (i = 0; i + 1 <
length; i += 5) {
269 (
AV_RN32A(src + i) - 0x01000101U)) &
270 0x80008080U))
271 continue;
272 FIND_FIRST_ZERO;
274 i -= 3;
275 }
276 #endif
277 #else
278 for (i = 0; i + 1 <
length; i += 2) {
279 if (src[i])
280 continue;
281 if (i > 0 && src[i - 1] == 0)
282 i--;
284 }
285 #endif
286
289
290 if (!dst)
292
293 if(i>=length-1){ //no escaped 0
295 *consumed= length+1; //+1 for the header
298 }else{
299 memcpy(dst, src, length);
300 return dst;
301 }
302 }
303
304 memcpy(dst, src, i);
305 si = di = i;
306 while (si + 2 < length) {
307 // remove escapes (very rare 1:2^22)
308 if (src[si + 2] > 3) {
309 dst[di++] = src[si++];
310 dst[di++] = src[si++];
311 } else if (src[si] == 0 && src[si + 1] == 0 && src[si + 2] != 0) {
312 if (src[si + 2] == 3) { // escape
313 dst[di++] = 0;
314 dst[di++] = 0;
315 si += 3;
316 continue;
317 } else // next start code
318 goto nsc;
319 }
320
321 dst[di++] = src[si++];
322 }
323 while (si < length)
324 dst[di++] = src[si++];
325
326 nsc:
328
329 *dst_length = di;
330 *consumed = si + 1; // +1 for the header
331 /* FIXME store exact number of bits in the getbitcontext
332 * (it is needed for decoding) */
333 return dst;
334 }
335
336 /**
337 * Identify the exact end of the bitstream
338 * @return the length of the trailing, or 0 if damaged
339 */
341 {
344
346
347 for (r = 1; r < 9; r++) {
348 if (v & 1)
350 v >>= 1;
351 }
352 return 0;
353 }
354
356 {
357 int i;
358
369
372
377
380
385
390
395 }
396 }
397
399 {
403
405 row_mb_num, 8 *
sizeof(
uint8_t), fail)
407
409 big_mb_num * 48 *
sizeof(
uint8_t), fail)
413 big_mb_num * sizeof(uint16_t), fail)
415 big_mb_num *
sizeof(
uint8_t), fail)
417 row_mb_num, 16 *
sizeof(
uint8_t), fail);
419 row_mb_num, 16 *
sizeof(
uint8_t), fail);
422
424 4 * big_mb_num *
sizeof(
uint8_t), fail);
426 big_mb_num *
sizeof(
uint8_t), fail)
427
431
433 big_mb_num * sizeof(uint32_t), fail);
435 big_mb_num * sizeof(uint32_t), fail);
439 const int b_xy = 4 * x + 4 * y * h->
b_stride;
440
443 }
444
447
448 return 0;
449
450 fail:
453 }
454
455 /**
456 * Init context
457 * Allocate buffers which are not shared amongst multiple threads.
458 */
460 {
465 int yc_size = y_size + 2 * c_size;
467
474
476 memset(er, 0, sizeof(*er));
477 } else
478 if (CONFIG_ERROR_RESILIENCE) {
479
480 /* init ER */
485
491
492 // error resilience code looks cleaner with this
494 (h->
mb_num + 1) *
sizeof(
int), fail);
495
499
502
504 mb_array_size *
sizeof(
uint8_t), fail);
505
508
510 yc_size * sizeof(int16_t), fail);
514 for (i = 0; i < yc_size; i++)
516 }
517
518 return 0;
519
520 fail:
521 return AVERROR(ENOMEM);
// ff_h264_free_tables will clean up for us
522 }
523
525 int parse_extradata);
526
528 {
531
532 if (!buf || size <= 0)
533 return -1;
534
535 if (buf[0] == 1) {
536 int i, cnt, nalsize;
537 const unsigned char *p =
buf;
538
540
541 if (size < 7) {
543 "avcC %d too short\n", size);
545 }
546 /* sps and pps in the avcC always have length coded with 2 bytes,
547 * so put a fake nal_length_size = 2 while parsing them */
549 // Decode sps from avcC
550 cnt = *(p + 5) & 0x1f; // Number of sps
551 p += 6;
552 for (i = 0; i < cnt; i++) {
554 if(nalsize > size - (p-buf))
557 if (ret < 0) {
559 "Decoding sps %d from avcC failed\n", i);
561 }
562 p += nalsize;
563 }
564 // Decode pps from avcC
565 cnt = *(p++); // Number of pps
566 for (i = 0; i < cnt; i++) {
568 if(nalsize > size - (p-buf))
571 if (ret < 0) {
573 "Decoding pps %d from avcC failed\n", i);
575 }
576 p += nalsize;
577 }
578 // Store right nal length size that will be used to parse all other nals
580 } else {
583 if (ret < 0)
585 }
587 }
588
590 {
591 int i;
592
597
608
612
614
616
622 }
623
628 }
629
633
637
640
641 return 0;
642 }
643
645 {
648
650 if (ret < 0)
652
653 /* set defaults */
656
658
660
665 } else
667 }
669 }
670
673 if (ret < 0) {
676 }
677 }
678
683 }
684
686
688
691
694 "Error resilience with slice threads is enabled. It is unsafe and unsupported and may crash. "
695 "Use it at your own risk\n");
696 }
697
698 return 0;
699 }
700
702 {
705
707 return 0;
708
709 memset(h, 0, sizeof(*h));
710
712 if (ret < 0)
714
716
717 return 0;
718 }
719
720 /**
721 * Run setup operations that must be run after slice header decoding.
722 * This includes finding the next displayed frame.
723 *
724 * @param h h264 master context
725 * @param setup_finished enough NALs have been read that we can call
726 * ff_thread_finish_setup()
727 */
729 {
732 int i, pics, out_of_order, out_idx;
733
735
737 return;
738
740 /* FIXME: if we have two PAFF fields in one packet, we can't start
741 * the next thread here. If we have one field per packet, we can.
742 * The check in decode_nal_units() is not good enough to find this
743 * yet, so we assume the worst for now. */
744 // if (setup_finished)
745 // ff_thread_finish_setup(h->avctx);
747 return;
749 return;
750 }
751
754
755 /* Signal interlacing information externally. */
756 /* Prioritize picture timing SEI information over used
757 * decoding process if it exists. */
758
762 break;
766 break;
771 else
772 // try to flag soft telecine progressive
774 break;
777 /* Signal the possibility of telecined film externally
778 * (pic_struct 5,6). From these hints, let the applications
779 * decide if they apply deinterlacing. */
781 break;
784 break;
787 break;
788 }
789
793 } else {
794 /* Derive interlacing flag from used decoding process. */
796 }
798
800 /* Derive top_field_first from field pocs. */
802 } else {
804 /* Use picture timing SEI information. Even if it is a
805 * information of a past frame, better than nothing. */
809 else
811 } else {
812 /* Most likely progressive */
814 }
815 }
816
823 if (stereo) {
825 case 0:
827 break;
828 case 1:
830 break;
831 case 2:
833 break;
834 case 3:
837 else
839 break;
840 case 4:
842 break;
843 case 5:
845 break;
846 case 6:
848 break;
849 }
850
853 }
854 }
855
862 if (rotation) {
866 }
867 }
868
871
872 // FIXME do something with unavailable reference frames
873
874 /* Sort B-frames into display order */
875
880 }
881
886 }
887
888 for (i = 0; 1; i++) {
890 if(i)
892 break;
893 } else if(i) {
895 }
896 }
900 out_of_order =
FFMAX(out_of_order, 1);
911 }
912
913 pics = 0;
915 pics++;
916
918
922
924 out_idx = 0;
928 i++)
931 out_idx = i;
932 }
937
940 // for frame threading, the owner must be the second field's thread or
941 // else the first thread can release the picture and reuse it unsafely
944 }
949 } else
951 } else {
953 }
954
957 // We have reached an recovery point and all frames after it in
958 // display order are "recovered".
960 }
962 }
963
966 }
967
969 {
970 int list, i;
971 int luma_def, chroma_def;
972
978
982 }
986 }
987
990
991 for (list = 0; list < 2; list++) {
994 for (i = 0; i < sl->
ref_count[list]; i++) {
995 int luma_weight_flag, chroma_weight_flag;
996
998 if (luma_weight_flag) {
1005 }
1006 } else {
1009 }
1010
1013 if (chroma_weight_flag) {
1014 int j;
1015 for (j = 0; j < 2; j++) {
1022 }
1023 }
1024 } else {
1025 int j;
1026 for (j = 0; j < 2; j++) {
1029 }
1030 }
1031 }
1032 }
1034 break;
1035 }
1037 return 0;
1038 }
1039
1040 /**
1041 * instantaneous decoder refresh.
1042 */
1044 {
1045 int i;
1053 }
1054
1055 /* forget old pics after a seek */
1057 {
1058 int i, j;
1059
1063
1071 }
1073
1082 }
1083
1084 /* forget old pics after a seek */
1086 {
1088 int i;
1089
1091
1093
1098
1100
1103 }
1104
1106 {
1108 int field_poc[2];
1109
1113
1116
1123 else
1125 field_poc[0] =
1130 int abs_frame_num, expected_delta_per_poc_cycle, expectedpoc;
1131 int i;
1132
1135 else
1136 abs_frame_num = 0;
1137
1139 abs_frame_num--;
1140
1141 expected_delta_per_poc_cycle = 0;
1143 // FIXME integrate during sps parse
1145
1146 if (abs_frame_num > 0) {
1149
1150 expectedpoc = poc_cycle_cnt * expected_delta_per_poc_cycle;
1151 for (i = 0; i <= frame_num_in_poc_cycle; i++)
1153 } else
1154 expectedpoc = 0;
1155
1158
1159 field_poc[0] = expectedpoc + h->
delta_poc[0];
1161
1164 } else {
1166
1168 poc--;
1169
1170 field_poc[0] = poc;
1171 field_poc[1] = poc;
1172 }
1173
1175 pic_field_poc[0] = field_poc[0];
1177 pic_field_poc[1] = field_poc[1];
1178 *pic_poc =
FFMIN(pic_field_poc[0], pic_field_poc[1]);
1179
1180 return 0;
1181 }
1182
1183 /**
1184 * Compute profile from profile_idc and constraint_set?_flags.
1185 *
1186 * @param sps SPS
1187 *
1188 * @return profile as defined by FF_PROFILE_H264_*
1189 */
1191 {
1193
1196 // constraint_set1_flag set to 1
1198 break;
1202 // constraint_set3_flag set to 1
1204 break;
1205 }
1206
1208 }
1209
1211 {
1212 int ref_count[2], list_count;
1213 int num_ref_idx_active_override_flag;
1214
1215 // set defaults, might be overridden a few lines later
1218
1220 unsigned max[2];
1222
1225 num_ref_idx_active_override_flag =
get_bits1(&sl->
gb);
1226
1227 if (num_ref_idx_active_override_flag) {
1231 } else
1232 // full range is spec-ok in this case, even for frames
1233 ref_count[1] = 1;
1234 }
1235
1236 if (ref_count[0]-1 > max[0] || ref_count[1]-1 > max[1]){
1237 av_log(h->
avctx,
AV_LOG_ERROR,
"reference overflow %u > %u or %u > %u\n", ref_count[0]-1, max[0], ref_count[1]-1, max[1]);
1241 }
1242
1244 list_count = 2;
1245 else
1246 list_count = 1;
1247 } else {
1248 list_count = 0;
1249 ref_count[0] = ref_count[1] = 0;
1250 }
1251
1258 return 1;
1259 }
1260
1261 return 0;
1262 }
1263
1265
1267 const uint8_t *ptr,
int dst_length,
1268 int i, int next_avc)
1269 {
1271 buf[i] == 0x00 && buf[i + 1] == 0x00 &&
1272 buf[i + 2] == 0x01 && buf[i + 3] == 0xE0)
1274
1276 while (dst_length > 0 && ptr[dst_length - 1] == 0)
1277 dst_length--;
1278
1279 if (!dst_length)
1280 return 0;
1281
1283 }
1284
1286 {
1287 int next_avc = h->
is_avc ? 0 : buf_size;
1288 int nal_index = 0;
1289 int buf_index = 0;
1290 int nals_needed = 0;
1291 int first_slice = 0;
1292
1293 while(1) {
1295 int nalsize = 0;
1296 int dst_length, bit_length, consumed;
1298
1299 if (buf_index >= next_avc) {
1301 if (nalsize < 0)
1302 break;
1303 next_avc = buf_index + nalsize;
1304 } else {
1306 if (buf_index >= buf_size)
1307 break;
1308 if (buf_index >= next_avc)
1309 continue;
1310 }
1311
1313 next_avc - buf_index);
1314
1315 if (!ptr || dst_length < 0)
1317
1318 buf_index += consumed;
1319
1321 buf_index, next_avc);
1322 nal_index++;
1323
1324 /* packets can sometimes contain multiple PPS/SPS,
1325 * e.g. two PAFF field pictures in one packet, or a demuxer
1326 * which splits NALs strangely if so, when frame threading we
1327 * can't start the next thread until we've read all of them */
1331 nals_needed = nal_index;
1332 break;
1338 !first_slice ||
1340 nals_needed = nal_index;
1341 if (!first_slice)
1343 }
1344 }
1345
1346 return nals_needed;
1347 }
1348
1350 int parse_extradata)
1351 {
1354 int buf_index;
1355 unsigned context_count;
1356 int next_avc;
1357 int nals_needed = 0; ///< number of NALs that need decoding before the next frame thread starts
1358 int nal_index;
1359 int idr_cleared=0;
1361
1363
1372 }
1373
1375 if (buf_size > 8 &&
AV_RB32(buf) == 1 &&
AV_RB32(buf+5) > (
unsigned)buf_size) {
1377 }
else if(buf_size > 3 &&
AV_RB32(buf) > 1 &&
AV_RB32(buf) <= (
unsigned)buf_size)
1379 }
1380
1383
1384 {
1385 buf_index = 0;
1386 context_count = 0;
1387 next_avc = h->
is_avc ? 0 : buf_size;
1388 nal_index = 0;
1389 for (;;) {
1390 int consumed;
1391 int dst_length;
1392 int bit_length;
1394 int nalsize = 0;
1395 int err;
1396
1397 if (buf_index >= next_avc) {
1399 if (nalsize < 0)
1400 break;
1401 next_avc = buf_index + nalsize;
1402 } else {
1404 if (buf_index >= buf_size)
1405 break;
1406 if (buf_index >= next_avc)
1407 continue;
1408 }
1409
1411
1413 &consumed, next_avc - buf_index);
1414 if (!ptr || dst_length < 0) {
1415 ret = -1;
1417 }
1418
1420 buf_index + consumed, next_avc);
1421
1424 "NAL %d/%d at %d/%d length %d\n",
1426
1427 if (h->
is_avc && (nalsize != consumed) && nalsize)
1429 "AVC: Consumed only %d bytes instead of %d\n",
1430 consumed, nalsize);
1431
1432 buf_index += consumed;
1433 nal_index++;
1434
1438 continue;
1439
1440 again:
1441 /* Ignore per frame NAL unit type during extradata
1442 * parsing. Decoding slices is not possible in codec init
1443 * with frame-mt */
1444 if (parse_extradata) {
1452 "Ignoring NAL %d in global header/extradata\n",
1454 // fall through to next case
1457 }
1458 }
1459
1460 err = 0;
1461
1464 if ((ptr[0] & 0xFC) == 0x98) {
1467 ret = -1;
1469 }
1472 "Invalid mix of idr and non-idr slices\n");
1473 ret = -1;
1475 }
1476 if(!idr_cleared) {
1478 av_log(h,
AV_LOG_ERROR,
"invalid mixed IDR / non IDR frames cannot be decoded in slice multithreading mode\n");
1481 }
1482 idr(h);
// FIXME ensure we don't lose some frames if there is reordering
1483 }
1484 idr_cleared = 1;
1488
1489 if ( nals_needed >= nal_index
1492
1494 break;
1495
1499
1503
1506 }
1507 }
1508
1511
1516 }
1517 // If we have an IDR, all frames after it in decoded order are
1518 // "recovered".
1523 #if 1
1525 #else
1527 #endif
1528
1532
1536 if (CONFIG_H264_VDPAU_DECODER &&
1539 }
1540
1544 &buf[buf_index - consumed],
1545 consumed);
1546 if (ret < 0)
1548 } else if (CONFIG_H264_VDPAU_DECODER &&
1551 start_code,
1552 sizeof(start_code));
1554 &buf[buf_index - consumed],
1555 consumed);
1556 } else
1557 context_count++;
1558 }
1559 break;
1564 break;
1570 break;
1574 break;
1575 if (h->
is_avc ? nalsize : 1) {
1577 "SPS decoding failure, trying again with the complete NAL\n");
1579 av_assert0(next_avc - buf_index + consumed == nalsize);
1580 if ((next_avc - buf_index + consumed - 1) >= INT_MAX/8)
1581 break;
1583 8*(next_avc - buf_index + consumed - 1));
1585 break;
1586 }
1589
1590 break;
1596 break;
1603 break;
1605 break;
1606 default:
1609 }
1610
1615 context_count = 0;
1616 }
1617
1619 if (err < 0)
1623 if (context_count > 1) {
1627 context_count = 0;
1628 }
1629 /* Slice could not be decoded in parallel mode, restart. Note
1630 * that rbsp_buffer is not transferred, but since we no longer
1631 * run in parallel mode this should not be an issue. */
1633 goto again;
1634 }
1635 }
1636 }
1637 if (context_count) {
1641 }
1642
1643 ret = 0;
1645 /* clean up */
1649 }
1650
1651 return (ret < 0) ? ret : buf_index;
1652 }
1653
1654 /**
1655 * Return the number of bytes consumed for building the current frame.
1656 */
1658 {
1659 if (pos == 0)
1660 pos = 1; // avoid infinite loops (I doubt that is needed but...)
1661 if (pos + 10 > buf_size)
1662 pos = buf_size; // oops ;)
1663
1664 return pos;
1665 }
1666
1668 {
1671 int i;
1673 if (ret < 0)
1675
1677
1681 return 0;
1682
1688 dst->
data[i] += off;
1689 }
1690 return 0;
1691 }
1692
1694 {
1695 int cnt= buf[5]&0x1f;
1697 while(cnt--){
1699 if(nalsize > buf_size - (p-buf) || p[2]!=0x67)
1700 return 0;
1701 p += nalsize;
1702 }
1703 cnt = *(p++);
1704 if(!cnt)
1705 return 0;
1706 while(cnt--){
1708 if(nalsize > buf_size - (p-buf) || p[2]!=0x68)
1709 return 0;
1710 p += nalsize;
1711 }
1712 return 1;
1713 }
1714
1717 {
1719 int buf_size = avpkt->
size;
1722 int buf_index = 0;
1724 int i, out_idx;
1726
1728
1730
1731 /* end of stream, output what is still in the buffers */
1732 if (buf_size == 0) {
1733 out:
1734
1737
1738 // FIXME factorize this with the output code below
1740 out_idx = 0;
1741 for (i = 1;
1745 i++)
1748 out_idx = i;
1749 }
1750
1753
1757 if (ret < 0)
1759 *got_frame = 1;
1760 }
1761
1762 return buf_index;
1763 }
1765 int side_size;
1769 }
1770 if(h->
is_avc && buf_size >= 9 && buf[0]==1 && buf[2]==0 && (buf[4]&0xFC)==0xFC && (buf[5]&0x1F) && buf[8]==0x67){
1773 }
1774
1776 if (buf_index < 0)
1778
1782 }
1783
1786 buf_size >= 4 && !memcmp("Q264", buf, 4))
1787 return buf_size;
1790 }
1791
1796
1798
1799 /* Wait for second field. */
1800 *got_frame = 0;
1805
1809 ) {
1810 int p;
1814 int linesizes[4];
1816
1818
1819 for (p = 0; p<4; p++) {
1823 }
1824
1827 }
1828
1830 if (ret < 0)
1832 *got_frame = 1;
1833 if (CONFIG_MPEGVIDEO) {
1840 }
1841 }
1842 }
1843
1845
1847
1849 }
1850
1852 {
1853 int i;
1854
1856
1860 }
1862
1864
1869
1872
1875 }
1876
1878 {
1880
1883
1888
1889 return 0;
1890 }
1891
1892 #define OFFSET(x) offsetof(H264Context, x)
1893 #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
1897 {
"enable_er",
"Enable error resilience on damaged frames (unsafe)",
OFFSET(enable_er),
AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1,
VD },
1899 };
1900
1906 };
1907
1923 };
1924
1934 .capabilities =
/*CODEC_CAP_DRAW_HORIZ_BAND |*/ CODEC_CAP_DR1 |
1942 };
1943
1944 #if CONFIG_H264_VDPAU_DECODER
1945 static const AVClass h264_vdpau_class = {
1950 };
1951
1952 AVCodec ff_h264_vdpau_decoder = {
1953 .
name =
"h264_vdpau",
1954 .long_name =
NULL_IF_CONFIG_SMALL(
"H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (VDPAU acceleration)"),
1966 .priv_class = &h264_vdpau_class,
1967 };
1968 #endif
struct H264Context * h264
void ff_h264_unref_picture(H264Context *h, H264Picture *pic)
#define FF_PROFILE_H264_HIGH_10
const struct AVCodec * codec
int ff_h264_check_intra_pred_mode(const H264Context *h, H264SliceContext *sl, 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...
void ff_h264_flush_change(H264Context *h)
int(* start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size)
Called at the beginning of each frame or field picture.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size, int parse_extradata)
#define CODEC_FLAG2_FAST
Allow non spec compliant speedup tricks.
int sei_recovery_frame_cnt
Views are packed per line, as if interlaced.
#define AV_NUM_DATA_POINTERS
int ff_h264_execute_decode_slices(H264Context *h, unsigned context_count)
Call decode_slice() for each context.
5: top field, bottom field, top field repeated, in that order
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
mpeg2/4 4:2:0, h264 default for 4:2:0
This structure describes decoded (raw) audio or video data.
#define FF_ALLOCZ_ARRAY_OR_GOTO(ctx, p, nelem, elsize, label)
int16_t mv_cache[2][5 *8][2]
Motion vector cache.
static const AVClass h264_class
ptrdiff_t const GLvoid * data
Views are alternated temporally.
static int get_se_golomb(GetBitContext *gb)
read signed exp golomb code.
int luma_weight[48][2][2]
int edge_emu_buffer_allocated
3: top field, bottom field, in that order
#define FF_PROFILE_H264_HIGH_444
#define H264_MAX_PICTURE_COUNT
Views are next to each other, but when upscaling apply a checkerboard pattern.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define LIBAVUTIL_VERSION_INT
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
static av_cold int init(AVCodecContext *avctx)
av_cold int ff_h264_decode_init(AVCodecContext *avctx)
const uint8_t * ff_h264_decode_nal(H264Context *h, H264SliceContext *sl, const uint8_t *src, int *dst_length, int *consumed, int length)
Decode a network abstraction layer unit.
int bitstream_restriction_flag
unsigned int ref_count[2]
num_ref_idx_l0/1_active_minus1 + 1
int repeat_pict
When decoding, this signals how much the picture must be delayed.
int bipred_scratchpad_allocated
static int get_last_needed_nal(H264Context *h, const uint8_t *buf, int buf_size)
#define DELAYED_PIC_REF
Value of Picture.reference when Picture is not a reference picture, but is held for delayed output...
AVBufferPool * mb_type_pool
void ff_h264_draw_horiz_band(const H264Context *h, H264SliceContext *sl, int y, int height)
int16_t(*[2] motion_val)[2]
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
H264Picture * delayed_pic[MAX_DELAYED_PIC_COUNT+2]
int is_avc
Used to parse AVC variant of h264.
AVBufferPool * ref_index_pool
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
Same behaviour av_fast_malloc but the buffer has additional FF_INPUT_BUFFER_PADDING_SIZE at the end w...
void ff_h264_free_tables(H264Context *h)
int ff_h264_get_profile(SPS *sps)
Compute profile from profile_idc and constraint_set?_flags.
void ff_h264_decode_init_vlc(void)
int prev_poc_msb
poc_msb of the last reference pic for POC type 0
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16
#define FF_PROFILE_H264_MAIN
4: bottom field, top field, in that order
#define FRAME_RECOVERED_IDR
We have seen an IDR, so all the following frames in coded order are correctly decodable.
int luma_weight_flag[2]
7.4.3.2 luma_weight_lX_flag
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
unsigned current_sps_id
id of the current SPS
#define CODEC_FLAG_OUTPUT_CORRUPT
Output even those frames that might be corrupted.
unsigned int ref_count[2]
num_ref_idx_l0/1_active_minus1 + 1
int avpriv_h264_has_num_reorder_frames(AVCodecContext *avctx)
int ff_set_ref_count(H264Context *h, H264SliceContext *sl)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
uint8_t * chroma_pred_mode_table
enum AVDiscard skip_frame
Skip decoding for selected frames.
BYTE int const BYTE * srcp
struct AVHWAccel * hwaccel
Hardware accelerator in use.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static int decode_init_thread_copy(AVCodecContext *avctx)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
uint32_t(*[6] dequant4_coeff)[16]
#define CODEC_FLAG2_CHUNKS
Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries...
int prev_frame_num_offset
for POC type 2
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
int offset_for_non_ref_pic
void ff_h264_reset_sei(H264Context *h)
Reset SEI values at the beginning of the frame.
Stereo 3D type: this structure describes how two videos are packed within a single video surface...
#define FF_PROFILE_H264_EXTENDED
static int h264_init_context(AVCodecContext *avctx, H264Context *h)
static av_cold int end(AVCodecContext *avctx)
Multithreading support functions.
#define CODEC_CAP_HWACCEL_VDPAU
Codec can export data for HW decoding (VDPAU).
static int find_start_code(const uint8_t *buf, int buf_size, int buf_index, int next_avc)
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
#define FF_PROFILE_UNKNOWN
#define FF_PROFILE_H264_CONSTRAINED
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
uint8_t(*[2] top_borders)[(16 *3)*2]
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
#define FF_PROFILE_H264_HIGH_444_INTRA
int frame_recovered
Initial frame has been completely recovered.
Structure to hold side data for an AVFrame.
#define PICT_BOTTOM_FIELD
static int decode_rbsp_trailing(H264Context *h, const uint8_t *src)
Identify the exact end of the bitstream.
#define AV_LOG_VERBOSE
Detailed information.
AVDictionary * metadata
metadata.
int interlaced_frame
The content of the picture is interlaced.
#define MAX_DELAYED_PIC_COUNT
static void fill_rectangle(SDL_Surface *screen, int x, int y, int w, int h, int color, int update)
#define FF_PROFILE_H264_HIGH_422_INTRA
void ff_thread_finish_setup(AVCodecContext *avctx)
If the codec defines update_thread_context(), call this when they are ready for the next thread to st...
high precision timer, useful to profile code
int recovered
picture at IDR or recovery point + recovery count
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
unsigned int rbsp_buffer_size
int last_pocs[MAX_DELAYED_PIC_COUNT]
H.264 / AVC / MPEG4 part10 codec.
void ff_h264_hl_decode_mb(const H264Context *h, H264SliceContext *sl)
H264Picture DPB[H264_MAX_PICTURE_COUNT]
int width
width and height of the video frame
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int has_b_frames
Size of the frame reordering buffer in the decoder.
int flags
Additional information about the frame packing.
static int get_ue_golomb(GetBitContext *gb)
read unsigned exp golomb code.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
static int get_consumed_bytes(int pos, int buf_size)
Return the number of bytes consumed for building the current frame.
int poc_type
pic_order_cnt_type
static const uint16_t mask[17]
#define AV_EF_EXPLODE
abort decoding on minor error detection
#define CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
int is_copy
Whether the parent AVCodecContext is a copy of the context which had init() called on it...
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define ALZHEIMER_DC_L0T_PRED8x8
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int active_thread_type
Which multithreading methods are in use by the codec.
int8_t intra4x4_pred_mode_cache[5 *8]
int ff_init_poc(H264Context *h, int pic_field_poc[2], int *pic_poc)
static void flush_dpb(AVCodecContext *avctx)
int capabilities
Codec capabilities.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static const AVOption h264_options[]
int ff_pred_weight_table(H264Context *h, H264SliceContext *sl)
void(* decode_mb)(void *opaque, int ref, int mv_dir, int mv_type, int(*mv)[2][4][2], int mb_x, int mb_y, int mb_intra, int mb_skipped)
uint8_t(*[2] mvd_table)[2]
int prev_interlaced_frame
Complement sei_pic_struct SEI_PIC_STRUCT_TOP_BOTTOM and SEI_PIC_STRUCT_BOTTOM_TOP indicate interlaced...
#define FF_BUG_AUTODETECT
autodetection
simple assert() macros that are a bit more flexible than ISO C assert().
const char * name
Name of the codec implementation.
int direct_spatial_mv_pred
void ff_init_cabac_states(void)
unsigned int top_samples_available
static av_always_inline uint32_t pack16to32(unsigned a, unsigned b)
int valid_recovery_point
Are the SEI recovery points looking valid.
Video is not stereoscopic (and metadata has to be there).
static const uint8_t offset[127][2]
uint8_t * list_counts
Array of list_count per MB specifying the slice type.
Libavcodec external API header.
void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4], const uint8_t *src_data[4], const int src_linesizes[4], enum AVPixelFormat pix_fmt, int width, int height)
Copy image in src_data to dst_data.
int offset_for_top_to_bottom_field
#define FIELD_OR_MBAFF_PICTURE(h)
int slice_type_nos
S free slice type (SI/SP are remapped to I/P)
int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl)
Decode a slice header.
static const uint8_t scan8[16 *3+3]
#define ONLY_IF_THREADS_ENABLED(x)
Define a function with only the non-default version specified.
uint8_t * error_status_table
#define CODEC_FLAG2_SHOW_ALL
Show all frames before the first keyframe.
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
#define FF_DEBUG_STARTCODE
int nal_length_size
Number of bytes used for nal length (1, 2 or 4)
useful rectangle filling function
void ff_vdpau_h264_picture_start(H264Context *h)
uint8_t nb_components
The number of components each pixel has, (1-4)
static void h264_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type, int(*mv)[2][4][2], int mb_x, int mb_y, int mb_intra, int mb_skipped)
int sei_anticlockwise_rotation
void(* draw_horiz_band)(struct AVCodecContext *s, const AVFrame *src, int offset[AV_NUM_DATA_POINTERS], int y, int type, int height)
If non NULL, 'draw_horiz_band' is called by the libavcodec decoder to draw a horizontal band...
enum AVPictureType pict_type
Picture type of the frame.
int frame_num_offset
for POC type 2
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
uint16_t * slice_table
slice_table_base + 2*mb_stride + 1
int poc_cycle_length
num_ref_frames_in_pic_order_cnt_cycle
int sei_frame_packing_present
frame_packing_arrangment SEI message
#define FF_PROFILE_H264_HIGH_10_INTRA
#define AV_FRAME_FLAG_CORRUPT
The frame data may be corrupted, e.g.
void ff_thread_report_progress(ThreadFrame *f, int n, int field)
Notify later decoding threads when part of their reference picture is ready.
PPS * pps_buffers[MAX_PPS_COUNT]
#define AV_STEREO3D_FLAG_INVERT
Inverted views, Right/Bottom represents the left view.
int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length)
Decode PPS.
Context Adaptive Binary Arithmetic Coder inline functions.
H264SliceContext * slice_ctx
static int h264_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
int ticks_per_frame
For some codecs, the time base is closer to the field rate than the frame rate.
int top_borders_allocated[2]
int chroma_log2_weight_denom
static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
void av_display_rotation_set(int32_t matrix[9], double angle)
Initialize a transformation matrix describing a pure counterclockwise rotation by the specified angle...
#define PART_NOT_AVAILABLE
int thread_count
thread count is used to decide how many independent tasks should be passed to execute() ...
static void flush(AVCodecContext *avctx)
#define SLICE_FLAG_ALLOW_FIELD
allow draw_horiz_band() with field slices (MPEG2 field pics)
uint8_t * edge_emu_buffer
int dequant_coeff_pps
reinit tables when pps changes
SPS * sps_buffers[MAX_SPS_COUNT]
static const int8_t mv[256][2]
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
short offset_for_ref_frame[256]
enum AVStereo3DType type
How views are packed within the video.
int ff_h264_slice_context_init(H264Context *h, H264SliceContext *sl)
Init context Allocate buffers which are not shared amongst multiple threads.
H264 / AVC / MPEG4 part10 codec data table
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
#define FF_THREAD_SLICE
Decode more than one part of a single frame at once.
static int get_bit_length(H264Context *h, const uint8_t *buf, const uint8_t *ptr, int dst_length, int i, int next_avc)
void ff_h264_remove_all_refs(H264Context *h)
int prev_frame_num
frame_num of the last pic for POC type 1/2
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
void ff_vdpau_add_data_chunk(uint8_t *data, const uint8_t *buf, int buf_size)
int ff_h264_decode_sei(H264Context *h)
Decode SEI.
int field_poc[2]
top/bottom POC
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
#define FF_PROFILE_H264_HIGH_444_PREDICTIVE
int max_contexts
Max number of threads / contexts.
int recovery_frame
recovery_frame is the frame_num at which the next frame should be fully constructed.
main external API structure.
void av_display_matrix_flip(int32_t matrix[9], int hflip, int vflip)
Flip the input matrix horizontally and/or vertically.
static void decode_postinit(H264Context *h, int setup_finished)
Run setup operations that must be run after slice header decoding.
int ff_h264_alloc_tables(H264Context *h)
Allocate tables.
int ff_h264_check_intra4x4_pred_mode(const H264Context *h, H264SliceContext *sl)
Check if the top & left blocks are available if needed and change the dc mode so it only uses the ava...
int frame_packing_arrangement_type
void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, uint8_t *mbskip_table, uint32_t *mbtype_table, int8_t *qscale_table, int16_t(*motion_val[2])[2], int *low_delay, int mb_width, int mb_height, int mb_stride, int quarter_sample)
Print debugging info for the given picture.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
H.264 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstre...
int constraint_set_flags
constraint_set[0-3]_flag
static unsigned int get_bits1(GetBitContext *s)
SEI_PicStructType sei_pic_struct
pic_struct in picture timing SEI message
BYTE int const BYTE int int int height
int ff_h264_update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
#define FF_THREAD_FRAME
Decode more than one frame at once.
int slice_flags
slice flags
static int get_avc_nalsize(H264Context *h, const uint8_t *buf, int buf_size, int *buf_index)
Describe the class of an AVClass context structure.
AVFrameSideData * av_frame_new_side_data(AVFrame *frame, enum AVFrameSideDataType type, int size)
Add a new side data to a frame.
uint8_t non_zero_count_cache[15 *8]
non zero coeff count cache.
static av_cold int h264_decode_end(AVCodecContext *avctx)
void av_buffer_pool_uninit(AVBufferPool **ppool)
Mark the pool as being available for freeing.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
int pixel_shift
0 for 8-bit H264, 1 for high-bit-depth H264
int mmco_reset
MMCO_RESET set this 1.
H264Picture * cur_pic_ptr
int mb_mbaff
mb_aff_frame && mb_field_decoding_flag
int frame_packing_arrangement_cancel_flag
is previous arrangement canceled, -1 if never received
#define FF_PROFILE_H264_CAVLC_444
int allocate_progress
Whether to allocate progress for frame threading.
int log2_max_poc_lsb
log2_max_pic_order_cnt_lsb_minus4
6: bottom field, top field, bottom field repeated, in that order
#define FF_PROFILE_H264_INTRA
static int is_extra(const uint8_t *buf, int buf_size)
static const uint8_t start_code[]
Views are on top of each other.
int pic_struct_present_flag
AVStereo3D * av_stereo3d_create_side_data(AVFrame *frame)
Allocate a complete AVFrameSideData and add it to the frame.
av_cold void ff_h264_free_context(H264Context *h)
Free any data that may have been allocated in the H264 context like SPS, PPS etc. ...
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Views are next to each other.
static int decode(AVCodecContext *avctx, void *data, int *got_sub, AVPacket *avpkt)
static void idr(H264Context *h)
instantaneous decoder refresh.
int ff_h264_decode_seq_parameter_set(H264Context *h, int ignore_truncation)
Decode SPS.
discard all non reference
AVBufferPool * qscale_table_pool
H264Picture * next_output_pic
AVBufferPool * motion_val_pool
#define FF_PROFILE_H264_HIGH
#define SLICE_SINGLETHREAD
#define CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
common internal api header.
#define CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
int ff_h264_decode_extradata(H264Context *h, const uint8_t *buf, int size)
#define FRAME_RECOVERED_SEI
Sufficient number of frames have been decoded since a SEI recovery point, so all the following frames...
#define FF_ALLOC_OR_GOTO(ctx, p, size, label)
uint16_t * slice_table_base
int log2_max_frame_num
log2_max_frame_num_minus4 + 4
H.264 / AVC / MPEG4 part10 motion vector predicion.
const char * ff_h264_sei_stereo_mode(H264Context *h)
Get stereo_mode string from the h264 frame_packing_arrangement.
int workaround_bugs
Work around bugs in encoders which sometimes cannot be detected automatically.
int cur_chroma_format_idc
int8_t * intra4x4_pred_mode
int sei_ct_type
Bit set of clock types for fields/frames in picture timing SEI message.
#define FF_PROFILE_H264_CONSTRAINED_BASELINE
int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup)
int prev_poc_lsb
poc_lsb of the last reference pic for POC type 0
int8_t ref_cache[2][5 *8]
int top_field_first
If the content is interlaced, is top field displayed first.
const uint16_t ff_h264_mb_sizes[4]
struct AVCodecInternal * internal
Private context used for internal data.
#define FF_PROFILE_H264_BASELINE
int luma_log2_weight_denom
int chroma_weight[48][2][2][2]
Views are packed in a checkerboard-like structure per pixel.
#define FF_COMPLIANCE_STRICT
Strictly conform to all the things in the spec no matter what consequences.
int sei_display_orientation_present
display orientation SEI message
int content_interpretation_type
int key_frame
1 -> keyframe, 0-> not
Views are packed per column.
enum AVPictureType pict_type
int current_slice
current slice number, used to initialize slice_num of each thread/context
#define FF_PROFILE_H264_HIGH_422
H264Ref ref_list[2][48]
0..15: frame refs, 16..47: mbaff field refs.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> out
H264Picture last_pic_for_ec
int au_pps_id
pps_id of current access unit
static void * av_mallocz_array(size_t nmemb, size_t size)
unsigned int left_samples_available
uint8_t(*[2] mvd_table)[2]
static int init_thread_copy(AVCodecContext *avctx)
uint8_t * av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int *size)
Get side information from packet.
int8_t * intra4x4_pred_mode
int(* decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size)
Callback for each slice.
int mb_field_decoding_flag
uint8_t(* non_zero_count)[48]
uint8_t * bipred_scratchpad
AVPixelFormat
Pixel format.
This structure stores compressed data.
int sei_recovery_frame_cnt
recovery_frame_cnt from SEI message
int strict_std_compliance
strictly follow the standard (MPEG4, ...).
#define FF_ALLOCZ_OR_GOTO(ctx, p, size, label)
Context Adaptive Binary Arithmetic Coder.
int chroma_weight_flag[2]
7.4.3.2 chroma_weight_lX_flag
static const AVProfile profiles[]
void ff_h264_init_dequant_tables(H264Context *h)