You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

628 lines
22KB

  1. /*
  2. * H.26L/H.264/AVC/JVT/14496-10/... parser
  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. * @file
  23. * H.264 / AVC / MPEG4 part10 parser.
  24. * @author Michael Niedermayer <michaelni@gmx.at>
  25. */
  26. #define UNCHECKED_BITSTREAM_READER 1
  27. #include "libavutil/attributes.h"
  28. #include "parser.h"
  29. #include "h264data.h"
  30. #include "golomb.h"
  31. #include "internal.h"
  32. #include "mpegutils.h"
  33. typedef struct H264ParseContext {
  34. H264Context h;
  35. ParseContext pc;
  36. int got_first;
  37. } H264ParseContext;
  38. static int h264_find_frame_end(H264ParseContext *p, const uint8_t *buf,
  39. int buf_size)
  40. {
  41. H264Context *h = &p->h;
  42. int i, j;
  43. uint32_t state;
  44. ParseContext *pc = &p->pc;
  45. int next_avc= h->is_avc ? 0 : buf_size;
  46. // mb_addr= pc->mb_addr - 1;
  47. state = pc->state;
  48. if (state > 13)
  49. state = 7;
  50. if (h->is_avc && !h->nal_length_size)
  51. av_log(h->avctx, AV_LOG_ERROR, "AVC-parser: nal length size invalid\n");
  52. for (i = 0; i < buf_size; i++) {
  53. if (i >= next_avc) {
  54. int nalsize = 0;
  55. i = next_avc;
  56. for (j = 0; j < h->nal_length_size; j++)
  57. nalsize = (nalsize << 8) | buf[i++];
  58. if (nalsize <= 0 || nalsize > buf_size - i) {
  59. av_log(h->avctx, AV_LOG_ERROR, "AVC-parser: nal size %d remaining %d\n", nalsize, buf_size - i);
  60. return buf_size;
  61. }
  62. next_avc = i + nalsize;
  63. state = 5;
  64. }
  65. if (state == 7) {
  66. i += h->h264dsp.startcode_find_candidate(buf + i, next_avc - i);
  67. if (i < next_avc)
  68. state = 2;
  69. } else if (state <= 2) {
  70. if (buf[i] == 1)
  71. state ^= 5; // 2->7, 1->4, 0->5
  72. else if (buf[i])
  73. state = 7;
  74. else
  75. state >>= 1; // 2->1, 1->0, 0->0
  76. } else if (state <= 5) {
  77. int nalu_type = buf[i] & 0x1F;
  78. if (nalu_type == NAL_SEI || nalu_type == NAL_SPS ||
  79. nalu_type == NAL_PPS || nalu_type == NAL_AUD) {
  80. if (pc->frame_start_found) {
  81. i++;
  82. goto found;
  83. }
  84. } else if (nalu_type == NAL_SLICE || nalu_type == NAL_DPA ||
  85. nalu_type == NAL_IDR_SLICE) {
  86. state += 8;
  87. continue;
  88. }
  89. state = 7;
  90. } else {
  91. h->parse_history[h->parse_history_count++]= buf[i];
  92. if (h->parse_history_count>5) {
  93. unsigned int mb, last_mb= h->parse_last_mb;
  94. GetBitContext gb;
  95. init_get_bits(&gb, h->parse_history, 8*h->parse_history_count);
  96. h->parse_history_count=0;
  97. mb= get_ue_golomb_long(&gb);
  98. h->parse_last_mb= mb;
  99. if (pc->frame_start_found) {
  100. if (mb <= last_mb)
  101. goto found;
  102. } else
  103. pc->frame_start_found = 1;
  104. state = 7;
  105. }
  106. }
  107. }
  108. pc->state = state;
  109. if (h->is_avc)
  110. return next_avc;
  111. return END_NOT_FOUND;
  112. found:
  113. pc->state = 7;
  114. pc->frame_start_found = 0;
  115. if (h->is_avc)
  116. return next_avc;
  117. return i - (state & 5) - 5 * (state > 7);
  118. }
  119. static int scan_mmco_reset(AVCodecParserContext *s)
  120. {
  121. H264ParseContext *p = s->priv_data;
  122. H264Context *h = &p->h;
  123. H264SliceContext *sl = &h->slice_ctx[0];
  124. sl->slice_type_nos = s->pict_type & 3;
  125. if (h->pps.redundant_pic_cnt_present)
  126. get_ue_golomb(&sl->gb); // redundant_pic_count
  127. if (ff_set_ref_count(h, sl) < 0)
  128. return AVERROR_INVALIDDATA;
  129. if (sl->slice_type_nos != AV_PICTURE_TYPE_I) {
  130. int list;
  131. for (list = 0; list < sl->list_count; list++) {
  132. if (get_bits1(&sl->gb)) {
  133. int index;
  134. for (index = 0; ; index++) {
  135. unsigned int reordering_of_pic_nums_idc = get_ue_golomb_31(&sl->gb);
  136. if (reordering_of_pic_nums_idc < 3)
  137. get_ue_golomb(&sl->gb);
  138. else if (reordering_of_pic_nums_idc > 3) {
  139. av_log(h->avctx, AV_LOG_ERROR,
  140. "illegal reordering_of_pic_nums_idc %d\n",
  141. reordering_of_pic_nums_idc);
  142. return AVERROR_INVALIDDATA;
  143. } else
  144. break;
  145. if (index >= sl->ref_count[list]) {
  146. av_log(h->avctx, AV_LOG_ERROR,
  147. "reference count %d overflow\n", index);
  148. return AVERROR_INVALIDDATA;
  149. }
  150. }
  151. }
  152. }
  153. }
  154. if ((h->pps.weighted_pred && sl->slice_type_nos == AV_PICTURE_TYPE_P) ||
  155. (h->pps.weighted_bipred_idc == 1 && sl->slice_type_nos == AV_PICTURE_TYPE_B))
  156. ff_pred_weight_table(h, sl);
  157. if (get_bits1(&sl->gb)) { // adaptive_ref_pic_marking_mode_flag
  158. int i;
  159. for (i = 0; i < MAX_MMCO_COUNT; i++) {
  160. MMCOOpcode opcode = get_ue_golomb_31(&sl->gb);
  161. if (opcode > (unsigned) MMCO_LONG) {
  162. av_log(h->avctx, AV_LOG_ERROR,
  163. "illegal memory management control operation %d\n",
  164. opcode);
  165. return AVERROR_INVALIDDATA;
  166. }
  167. if (opcode == MMCO_END)
  168. return 0;
  169. else if (opcode == MMCO_RESET)
  170. return 1;
  171. if (opcode == MMCO_SHORT2UNUSED || opcode == MMCO_SHORT2LONG)
  172. get_ue_golomb(&sl->gb);
  173. if (opcode == MMCO_SHORT2LONG || opcode == MMCO_LONG2UNUSED ||
  174. opcode == MMCO_LONG || opcode == MMCO_SET_MAX_LONG)
  175. get_ue_golomb_31(&sl->gb);
  176. }
  177. }
  178. return 0;
  179. }
  180. /**
  181. * Parse NAL units of found picture and decode some basic information.
  182. *
  183. * @param s parser context.
  184. * @param avctx codec context.
  185. * @param buf buffer with field/frame data.
  186. * @param buf_size size of the buffer.
  187. */
  188. static inline int parse_nal_units(AVCodecParserContext *s,
  189. AVCodecContext *avctx,
  190. const uint8_t * const buf, int buf_size)
  191. {
  192. H264ParseContext *p = s->priv_data;
  193. H264Context *h = &p->h;
  194. H264SliceContext *sl = &h->slice_ctx[0];
  195. int buf_index, next_avc;
  196. unsigned int pps_id;
  197. unsigned int slice_type;
  198. int state = -1, got_reset = 0;
  199. const uint8_t *ptr;
  200. int q264 = buf_size >=4 && !memcmp("Q264", buf, 4);
  201. int field_poc[2];
  202. /* set some sane default values */
  203. s->pict_type = AV_PICTURE_TYPE_I;
  204. s->key_frame = 0;
  205. s->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN;
  206. h->avctx = avctx;
  207. ff_h264_reset_sei(h);
  208. h->sei_fpa.frame_packing_arrangement_cancel_flag = -1;
  209. if (!buf_size)
  210. return 0;
  211. buf_index = 0;
  212. next_avc = h->is_avc ? 0 : buf_size;
  213. for (;;) {
  214. int src_length, dst_length, consumed, nalsize = 0;
  215. if (buf_index >= next_avc) {
  216. nalsize = get_avc_nalsize(h, buf, buf_size, &buf_index);
  217. if (nalsize < 0)
  218. break;
  219. next_avc = buf_index + nalsize;
  220. } else {
  221. buf_index = find_start_code(buf, buf_size, buf_index, next_avc);
  222. if (buf_index >= buf_size)
  223. break;
  224. if (buf_index >= next_avc)
  225. continue;
  226. }
  227. src_length = next_avc - buf_index;
  228. state = buf[buf_index];
  229. switch (state & 0x1f) {
  230. case NAL_SLICE:
  231. case NAL_IDR_SLICE:
  232. // Do not walk the whole buffer just to decode slice header
  233. if ((state & 0x1f) == NAL_IDR_SLICE || ((state >> 5) & 0x3) == 0) {
  234. /* IDR or disposable slice
  235. * No need to decode many bytes because MMCOs shall not be present. */
  236. if (src_length > 60)
  237. src_length = 60;
  238. } else {
  239. /* To decode up to MMCOs */
  240. if (src_length > 1000)
  241. src_length = 1000;
  242. }
  243. break;
  244. }
  245. ptr = ff_h264_decode_nal(h, sl, buf + buf_index, &dst_length,
  246. &consumed, src_length);
  247. if (!ptr || dst_length < 0)
  248. break;
  249. buf_index += consumed;
  250. init_get_bits(&h->gb, ptr, 8 * dst_length);
  251. switch (h->nal_unit_type) {
  252. case NAL_SPS:
  253. ff_h264_decode_seq_parameter_set(h, 0);
  254. break;
  255. case NAL_PPS:
  256. ff_h264_decode_picture_parameter_set(h, h->gb.size_in_bits);
  257. break;
  258. case NAL_SEI:
  259. ff_h264_decode_sei(h);
  260. break;
  261. case NAL_IDR_SLICE:
  262. s->key_frame = 1;
  263. h->prev_frame_num = 0;
  264. h->prev_frame_num_offset = 0;
  265. h->prev_poc_msb =
  266. h->prev_poc_lsb = 0;
  267. /* fall through */
  268. case NAL_SLICE:
  269. init_get_bits(&sl->gb, ptr, 8 * dst_length);
  270. get_ue_golomb_long(&sl->gb); // skip first_mb_in_slice
  271. slice_type = get_ue_golomb_31(&sl->gb);
  272. s->pict_type = golomb_to_pict_type[slice_type % 5];
  273. if (h->sei_recovery_frame_cnt >= 0) {
  274. /* key frame, since recovery_frame_cnt is set */
  275. s->key_frame = 1;
  276. }
  277. pps_id = get_ue_golomb(&sl->gb);
  278. if (pps_id >= MAX_PPS_COUNT) {
  279. av_log(h->avctx, AV_LOG_ERROR,
  280. "pps_id %u out of range\n", pps_id);
  281. return -1;
  282. }
  283. if (!h->pps_buffers[pps_id]) {
  284. av_log(h->avctx, AV_LOG_ERROR,
  285. "non-existing PPS %u referenced\n", pps_id);
  286. return -1;
  287. }
  288. h->pps = *h->pps_buffers[pps_id];
  289. if (!h->sps_buffers[h->pps.sps_id]) {
  290. av_log(h->avctx, AV_LOG_ERROR,
  291. "non-existing SPS %u referenced\n", h->pps.sps_id);
  292. return -1;
  293. }
  294. h->sps = *h->sps_buffers[h->pps.sps_id];
  295. h->frame_num = get_bits(&sl->gb, h->sps.log2_max_frame_num);
  296. if(h->sps.ref_frame_count <= 1 && h->pps.ref_count[0] <= 1 && s->pict_type == AV_PICTURE_TYPE_I)
  297. s->key_frame = 1;
  298. s->coded_width = 16 * h->sps.mb_width;
  299. s->coded_height = 16 * h->sps.mb_height;
  300. s->width = s->coded_width - (h->sps.crop_right + h->sps.crop_left);
  301. s->height = s->coded_height - (h->sps.crop_top + h->sps.crop_bottom);
  302. if (s->width <= 0 || s->height <= 0) {
  303. s->width = s->coded_width;
  304. s->height = s->coded_height;
  305. }
  306. switch (h->sps.bit_depth_luma) {
  307. case 9:
  308. if (CHROMA444(h)) s->format = AV_PIX_FMT_YUV444P9;
  309. else if (CHROMA422(h)) s->format = AV_PIX_FMT_YUV422P9;
  310. else s->format = AV_PIX_FMT_YUV420P9;
  311. break;
  312. case 10:
  313. if (CHROMA444(h)) s->format = AV_PIX_FMT_YUV444P10;
  314. else if (CHROMA422(h)) s->format = AV_PIX_FMT_YUV422P10;
  315. else s->format = AV_PIX_FMT_YUV420P10;
  316. break;
  317. case 8:
  318. if (CHROMA444(h)) s->format = AV_PIX_FMT_YUV444P;
  319. else if (CHROMA422(h)) s->format = AV_PIX_FMT_YUV422P;
  320. else s->format = AV_PIX_FMT_YUV420P;
  321. break;
  322. default:
  323. s->format = AV_PIX_FMT_NONE;
  324. }
  325. avctx->profile = ff_h264_get_profile(&h->sps);
  326. avctx->level = h->sps.level_idc;
  327. if (h->sps.frame_mbs_only_flag) {
  328. h->picture_structure = PICT_FRAME;
  329. } else {
  330. if (get_bits1(&sl->gb)) { // field_pic_flag
  331. h->picture_structure = PICT_TOP_FIELD + get_bits1(&sl->gb); // bottom_field_flag
  332. } else {
  333. h->picture_structure = PICT_FRAME;
  334. }
  335. }
  336. if (h->nal_unit_type == NAL_IDR_SLICE)
  337. get_ue_golomb(&sl->gb); /* idr_pic_id */
  338. if (h->sps.poc_type == 0) {
  339. h->poc_lsb = get_bits(&sl->gb, h->sps.log2_max_poc_lsb);
  340. if (h->pps.pic_order_present == 1 &&
  341. h->picture_structure == PICT_FRAME)
  342. h->delta_poc_bottom = get_se_golomb(&sl->gb);
  343. }
  344. if (h->sps.poc_type == 1 &&
  345. !h->sps.delta_pic_order_always_zero_flag) {
  346. h->delta_poc[0] = get_se_golomb(&sl->gb);
  347. if (h->pps.pic_order_present == 1 &&
  348. h->picture_structure == PICT_FRAME)
  349. h->delta_poc[1] = get_se_golomb(&sl->gb);
  350. }
  351. /* Decode POC of this picture.
  352. * The prev_ values needed for decoding POC of the next picture are not set here. */
  353. field_poc[0] = field_poc[1] = INT_MAX;
  354. ff_init_poc(h, field_poc, &s->output_picture_number);
  355. /* Continue parsing to check if MMCO_RESET is present.
  356. * FIXME: MMCO_RESET could appear in non-first slice.
  357. * Maybe, we should parse all undisposable non-IDR slice of this
  358. * picture until encountering MMCO_RESET in a slice of it. */
  359. if (h->nal_ref_idc && h->nal_unit_type != NAL_IDR_SLICE) {
  360. got_reset = scan_mmco_reset(s);
  361. if (got_reset < 0)
  362. return got_reset;
  363. }
  364. /* Set up the prev_ values for decoding POC of the next picture. */
  365. h->prev_frame_num = got_reset ? 0 : h->frame_num;
  366. h->prev_frame_num_offset = got_reset ? 0 : h->frame_num_offset;
  367. if (h->nal_ref_idc != 0) {
  368. if (!got_reset) {
  369. h->prev_poc_msb = h->poc_msb;
  370. h->prev_poc_lsb = h->poc_lsb;
  371. } else {
  372. h->prev_poc_msb = 0;
  373. h->prev_poc_lsb =
  374. h->picture_structure == PICT_BOTTOM_FIELD ? 0 : field_poc[0];
  375. }
  376. }
  377. if (h->sps.pic_struct_present_flag) {
  378. switch (h->sei_pic_struct) {
  379. case SEI_PIC_STRUCT_TOP_FIELD:
  380. case SEI_PIC_STRUCT_BOTTOM_FIELD:
  381. s->repeat_pict = 0;
  382. break;
  383. case SEI_PIC_STRUCT_FRAME:
  384. case SEI_PIC_STRUCT_TOP_BOTTOM:
  385. case SEI_PIC_STRUCT_BOTTOM_TOP:
  386. s->repeat_pict = 1;
  387. break;
  388. case SEI_PIC_STRUCT_TOP_BOTTOM_TOP:
  389. case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM:
  390. s->repeat_pict = 2;
  391. break;
  392. case SEI_PIC_STRUCT_FRAME_DOUBLING:
  393. s->repeat_pict = 3;
  394. break;
  395. case SEI_PIC_STRUCT_FRAME_TRIPLING:
  396. s->repeat_pict = 5;
  397. break;
  398. default:
  399. s->repeat_pict = h->picture_structure == PICT_FRAME ? 1 : 0;
  400. break;
  401. }
  402. } else {
  403. s->repeat_pict = h->picture_structure == PICT_FRAME ? 1 : 0;
  404. }
  405. if (h->picture_structure == PICT_FRAME) {
  406. s->picture_structure = AV_PICTURE_STRUCTURE_FRAME;
  407. if (h->sps.pic_struct_present_flag) {
  408. switch (h->sei_pic_struct) {
  409. case SEI_PIC_STRUCT_TOP_BOTTOM:
  410. case SEI_PIC_STRUCT_TOP_BOTTOM_TOP:
  411. s->field_order = AV_FIELD_TT;
  412. break;
  413. case SEI_PIC_STRUCT_BOTTOM_TOP:
  414. case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM:
  415. s->field_order = AV_FIELD_BB;
  416. break;
  417. default:
  418. s->field_order = AV_FIELD_PROGRESSIVE;
  419. break;
  420. }
  421. } else {
  422. if (field_poc[0] < field_poc[1])
  423. s->field_order = AV_FIELD_TT;
  424. else if (field_poc[0] > field_poc[1])
  425. s->field_order = AV_FIELD_BB;
  426. else
  427. s->field_order = AV_FIELD_PROGRESSIVE;
  428. }
  429. } else {
  430. if (h->picture_structure == PICT_TOP_FIELD)
  431. s->picture_structure = AV_PICTURE_STRUCTURE_TOP_FIELD;
  432. else
  433. s->picture_structure = AV_PICTURE_STRUCTURE_BOTTOM_FIELD;
  434. s->field_order = AV_FIELD_UNKNOWN;
  435. }
  436. return 0; /* no need to evaluate the rest */
  437. }
  438. }
  439. if (q264)
  440. return 0;
  441. /* didn't find a picture! */
  442. av_log(h->avctx, AV_LOG_ERROR, "missing picture in access unit with size %d\n", buf_size);
  443. return -1;
  444. }
  445. static int h264_parse(AVCodecParserContext *s,
  446. AVCodecContext *avctx,
  447. const uint8_t **poutbuf, int *poutbuf_size,
  448. const uint8_t *buf, int buf_size)
  449. {
  450. H264ParseContext *p = s->priv_data;
  451. H264Context *h = &p->h;
  452. ParseContext *pc = &p->pc;
  453. int next;
  454. if (!p->got_first) {
  455. p->got_first = 1;
  456. if (avctx->extradata_size) {
  457. h->avctx = avctx;
  458. // must be done like in decoder, otherwise opening the parser,
  459. // letting it create extradata and then closing and opening again
  460. // will cause has_b_frames to be always set.
  461. // Note that estimate_timings_from_pts does exactly this.
  462. if (!avctx->has_b_frames)
  463. h->low_delay = 1;
  464. ff_h264_decode_extradata(h, avctx->extradata, avctx->extradata_size);
  465. }
  466. }
  467. if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) {
  468. next = buf_size;
  469. } else {
  470. next = h264_find_frame_end(p, buf, buf_size);
  471. if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
  472. *poutbuf = NULL;
  473. *poutbuf_size = 0;
  474. return buf_size;
  475. }
  476. if (next < 0 && next != END_NOT_FOUND) {
  477. av_assert1(pc->last_index + next >= 0);
  478. h264_find_frame_end(p, &pc->buffer[pc->last_index + next], -next); // update state
  479. }
  480. }
  481. parse_nal_units(s, avctx, buf, buf_size);
  482. if (avctx->framerate.num)
  483. avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, (AVRational){avctx->ticks_per_frame, 1}));
  484. if (h->sei_cpb_removal_delay >= 0) {
  485. s->dts_sync_point = h->sei_buffering_period_present;
  486. s->dts_ref_dts_delta = h->sei_cpb_removal_delay;
  487. s->pts_dts_delta = h->sei_dpb_output_delay;
  488. } else {
  489. s->dts_sync_point = INT_MIN;
  490. s->dts_ref_dts_delta = INT_MIN;
  491. s->pts_dts_delta = INT_MIN;
  492. }
  493. if (s->flags & PARSER_FLAG_ONCE) {
  494. s->flags &= PARSER_FLAG_COMPLETE_FRAMES;
  495. }
  496. *poutbuf = buf;
  497. *poutbuf_size = buf_size;
  498. return next;
  499. }
  500. static int h264_split(AVCodecContext *avctx,
  501. const uint8_t *buf, int buf_size)
  502. {
  503. uint32_t state = -1;
  504. int has_sps = 0;
  505. int has_pps = 0;
  506. const uint8_t *ptr = buf, *end = buf + buf_size;
  507. int nalu_type;
  508. while (ptr < end) {
  509. ptr = avpriv_find_start_code(ptr, end, &state);
  510. if ((state & 0xFFFFFF00) != 0x100)
  511. break;
  512. nalu_type = state & 0x1F;
  513. if (nalu_type == NAL_SPS) {
  514. has_sps = 1;
  515. } else if (nalu_type == NAL_PPS)
  516. has_pps = 1;
  517. /* else if (nalu_type == 0x01 ||
  518. * nalu_type == 0x02 ||
  519. * nalu_type == 0x05) {
  520. * }
  521. */
  522. else if ((nalu_type != NAL_SEI || has_pps) &&
  523. nalu_type != NAL_AUD && nalu_type != NAL_SPS_EXT &&
  524. nalu_type != 0x0f) {
  525. if (has_sps) {
  526. while (ptr - 4 > buf && ptr[-5] == 0)
  527. ptr--;
  528. return ptr - 4 - buf;
  529. }
  530. }
  531. }
  532. return 0;
  533. }
  534. static void h264_close(AVCodecParserContext *s)
  535. {
  536. H264ParseContext *p = s->priv_data;
  537. H264Context *h = &p->h;
  538. ParseContext *pc = &p->pc;
  539. av_freep(&pc->buffer);
  540. ff_h264_free_context(h);
  541. }
  542. static av_cold int init(AVCodecParserContext *s)
  543. {
  544. H264ParseContext *p = s->priv_data;
  545. H264Context *h = &p->h;
  546. h->slice_ctx = av_mallocz(sizeof(*h->slice_ctx));
  547. if (!h->slice_ctx)
  548. return 0;
  549. h->nb_slice_ctx = 1;
  550. h->slice_context_count = 1;
  551. ff_h264dsp_init(&h->h264dsp, 8, 1);
  552. return 0;
  553. }
  554. AVCodecParser ff_h264_parser = {
  555. .codec_ids = { AV_CODEC_ID_H264 },
  556. .priv_data_size = sizeof(H264ParseContext),
  557. .parser_init = init,
  558. .parser_parse = h264_parse,
  559. .parser_close = h264_close,
  560. .split = h264_split,
  561. };