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.

627 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(&h->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 < h->list_count; list++) {
  132. if (get_bits1(&h->gb)) {
  133. int index;
  134. for (index = 0; ; index++) {
  135. unsigned int reordering_of_pic_nums_idc = get_ue_golomb_31(&h->gb);
  136. if (reordering_of_pic_nums_idc < 3)
  137. get_ue_golomb(&h->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 >= h->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(&h->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(&h->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(&h->gb);
  173. if (opcode == MMCO_SHORT2LONG || opcode == MMCO_LONG2UNUSED ||
  174. opcode == MMCO_LONG || opcode == MMCO_SET_MAX_LONG)
  175. get_ue_golomb_31(&h->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. int buf_index, next_avc;
  195. unsigned int pps_id;
  196. unsigned int slice_type;
  197. int state = -1, got_reset = 0;
  198. const uint8_t *ptr;
  199. int q264 = buf_size >=4 && !memcmp("Q264", buf, 4);
  200. int field_poc[2];
  201. /* set some sane default values */
  202. s->pict_type = AV_PICTURE_TYPE_I;
  203. s->key_frame = 0;
  204. s->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN;
  205. h->avctx = avctx;
  206. ff_h264_reset_sei(h);
  207. h->sei_fpa.frame_packing_arrangement_cancel_flag = -1;
  208. if (!buf_size)
  209. return 0;
  210. buf_index = 0;
  211. next_avc = h->is_avc ? 0 : buf_size;
  212. for (;;) {
  213. int src_length, dst_length, consumed, nalsize = 0;
  214. if (buf_index >= next_avc) {
  215. nalsize = get_avc_nalsize(h, buf, buf_size, &buf_index);
  216. if (nalsize < 0)
  217. break;
  218. next_avc = buf_index + nalsize;
  219. } else {
  220. buf_index = find_start_code(buf, buf_size, buf_index, next_avc);
  221. if (buf_index >= buf_size)
  222. break;
  223. if (buf_index >= next_avc)
  224. continue;
  225. }
  226. src_length = next_avc - buf_index;
  227. state = buf[buf_index];
  228. switch (state & 0x1f) {
  229. case NAL_SLICE:
  230. case NAL_IDR_SLICE:
  231. // Do not walk the whole buffer just to decode slice header
  232. if ((state & 0x1f) == NAL_IDR_SLICE || ((state >> 5) & 0x3) == 0) {
  233. /* IDR or disposable slice
  234. * No need to decode many bytes because MMCOs shall not be present. */
  235. if (src_length > 60)
  236. src_length = 60;
  237. } else {
  238. /* To decode up to MMCOs */
  239. if (src_length > 1000)
  240. src_length = 1000;
  241. }
  242. break;
  243. }
  244. ptr = ff_h264_decode_nal(h, buf + buf_index, &dst_length,
  245. &consumed, src_length);
  246. if (!ptr || dst_length < 0)
  247. break;
  248. buf_index += consumed;
  249. init_get_bits(&h->gb, ptr, 8 * dst_length);
  250. switch (h->nal_unit_type) {
  251. case NAL_SPS:
  252. ff_h264_decode_seq_parameter_set(h);
  253. break;
  254. case NAL_PPS:
  255. ff_h264_decode_picture_parameter_set(h, h->gb.size_in_bits);
  256. break;
  257. case NAL_SEI:
  258. ff_h264_decode_sei(h);
  259. break;
  260. case NAL_IDR_SLICE:
  261. s->key_frame = 1;
  262. h->prev_frame_num = 0;
  263. h->prev_frame_num_offset = 0;
  264. h->prev_poc_msb =
  265. h->prev_poc_lsb = 0;
  266. /* fall through */
  267. case NAL_SLICE:
  268. get_ue_golomb_long(&h->gb); // skip first_mb_in_slice
  269. slice_type = get_ue_golomb_31(&h->gb);
  270. s->pict_type = golomb_to_pict_type[slice_type % 5];
  271. if (h->sei_recovery_frame_cnt >= 0) {
  272. /* key frame, since recovery_frame_cnt is set */
  273. s->key_frame = 1;
  274. }
  275. pps_id = get_ue_golomb(&h->gb);
  276. if (pps_id >= MAX_PPS_COUNT) {
  277. av_log(h->avctx, AV_LOG_ERROR,
  278. "pps_id %u out of range\n", pps_id);
  279. return -1;
  280. }
  281. if (!h->pps_buffers[pps_id]) {
  282. av_log(h->avctx, AV_LOG_ERROR,
  283. "non-existing PPS %u referenced\n", pps_id);
  284. return -1;
  285. }
  286. h->pps = *h->pps_buffers[pps_id];
  287. if (!h->sps_buffers[h->pps.sps_id]) {
  288. av_log(h->avctx, AV_LOG_ERROR,
  289. "non-existing SPS %u referenced\n", h->pps.sps_id);
  290. return -1;
  291. }
  292. h->sps = *h->sps_buffers[h->pps.sps_id];
  293. h->frame_num = get_bits(&h->gb, h->sps.log2_max_frame_num);
  294. if(h->sps.ref_frame_count <= 1 && h->pps.ref_count[0] <= 1 && s->pict_type == AV_PICTURE_TYPE_I)
  295. s->key_frame = 1;
  296. s->coded_width = 16 * h->sps.mb_width;
  297. s->coded_height = 16 * h->sps.mb_height;
  298. s->width = s->coded_width - (h->sps.crop_right + h->sps.crop_left);
  299. s->height = s->coded_height - (h->sps.crop_top + h->sps.crop_bottom);
  300. if (s->width <= 0 || s->height <= 0) {
  301. s->width = s->coded_width;
  302. s->height = s->coded_height;
  303. }
  304. switch (h->sps.bit_depth_luma) {
  305. case 9:
  306. if (CHROMA444(h)) s->format = AV_PIX_FMT_YUV444P9;
  307. else if (CHROMA422(h)) s->format = AV_PIX_FMT_YUV422P9;
  308. else s->format = AV_PIX_FMT_YUV420P9;
  309. break;
  310. case 10:
  311. if (CHROMA444(h)) s->format = AV_PIX_FMT_YUV444P10;
  312. else if (CHROMA422(h)) s->format = AV_PIX_FMT_YUV422P10;
  313. else s->format = AV_PIX_FMT_YUV420P10;
  314. break;
  315. case 8:
  316. if (CHROMA444(h)) s->format = AV_PIX_FMT_YUV444P;
  317. else if (CHROMA422(h)) s->format = AV_PIX_FMT_YUV422P;
  318. else s->format = AV_PIX_FMT_YUV420P;
  319. break;
  320. default:
  321. s->format = AV_PIX_FMT_NONE;
  322. }
  323. avctx->profile = ff_h264_get_profile(&h->sps);
  324. avctx->level = h->sps.level_idc;
  325. if (h->sps.frame_mbs_only_flag) {
  326. h->picture_structure = PICT_FRAME;
  327. } else {
  328. if (get_bits1(&h->gb)) { // field_pic_flag
  329. h->picture_structure = PICT_TOP_FIELD + get_bits1(&h->gb); // bottom_field_flag
  330. } else {
  331. h->picture_structure = PICT_FRAME;
  332. }
  333. }
  334. if (h->nal_unit_type == NAL_IDR_SLICE)
  335. get_ue_golomb(&h->gb); /* idr_pic_id */
  336. if (h->sps.poc_type == 0) {
  337. h->poc_lsb = get_bits(&h->gb, h->sps.log2_max_poc_lsb);
  338. if (h->pps.pic_order_present == 1 &&
  339. h->picture_structure == PICT_FRAME)
  340. h->delta_poc_bottom = get_se_golomb(&h->gb);
  341. }
  342. if (h->sps.poc_type == 1 &&
  343. !h->sps.delta_pic_order_always_zero_flag) {
  344. h->delta_poc[0] = get_se_golomb(&h->gb);
  345. if (h->pps.pic_order_present == 1 &&
  346. h->picture_structure == PICT_FRAME)
  347. h->delta_poc[1] = get_se_golomb(&h->gb);
  348. }
  349. /* Decode POC of this picture.
  350. * The prev_ values needed for decoding POC of the next picture are not set here. */
  351. field_poc[0] = field_poc[1] = INT_MAX;
  352. ff_init_poc(h, field_poc, &s->output_picture_number);
  353. /* Continue parsing to check if MMCO_RESET is present.
  354. * FIXME: MMCO_RESET could appear in non-first slice.
  355. * Maybe, we should parse all undisposable non-IDR slice of this
  356. * picture until encountering MMCO_RESET in a slice of it. */
  357. if (h->nal_ref_idc && h->nal_unit_type != NAL_IDR_SLICE) {
  358. got_reset = scan_mmco_reset(s);
  359. if (got_reset < 0)
  360. return got_reset;
  361. }
  362. /* Set up the prev_ values for decoding POC of the next picture. */
  363. h->prev_frame_num = got_reset ? 0 : h->frame_num;
  364. h->prev_frame_num_offset = got_reset ? 0 : h->frame_num_offset;
  365. if (h->nal_ref_idc != 0) {
  366. if (!got_reset) {
  367. h->prev_poc_msb = h->poc_msb;
  368. h->prev_poc_lsb = h->poc_lsb;
  369. } else {
  370. h->prev_poc_msb = 0;
  371. h->prev_poc_lsb =
  372. h->picture_structure == PICT_BOTTOM_FIELD ? 0 : field_poc[0];
  373. }
  374. }
  375. if (h->sps.pic_struct_present_flag) {
  376. switch (h->sei_pic_struct) {
  377. case SEI_PIC_STRUCT_TOP_FIELD:
  378. case SEI_PIC_STRUCT_BOTTOM_FIELD:
  379. s->repeat_pict = 0;
  380. break;
  381. case SEI_PIC_STRUCT_FRAME:
  382. case SEI_PIC_STRUCT_TOP_BOTTOM:
  383. case SEI_PIC_STRUCT_BOTTOM_TOP:
  384. s->repeat_pict = 1;
  385. break;
  386. case SEI_PIC_STRUCT_TOP_BOTTOM_TOP:
  387. case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM:
  388. s->repeat_pict = 2;
  389. break;
  390. case SEI_PIC_STRUCT_FRAME_DOUBLING:
  391. s->repeat_pict = 3;
  392. break;
  393. case SEI_PIC_STRUCT_FRAME_TRIPLING:
  394. s->repeat_pict = 5;
  395. break;
  396. default:
  397. s->repeat_pict = h->picture_structure == PICT_FRAME ? 1 : 0;
  398. break;
  399. }
  400. } else {
  401. s->repeat_pict = h->picture_structure == PICT_FRAME ? 1 : 0;
  402. }
  403. if (h->picture_structure == PICT_FRAME) {
  404. s->picture_structure = AV_PICTURE_STRUCTURE_FRAME;
  405. if (h->sps.pic_struct_present_flag) {
  406. switch (h->sei_pic_struct) {
  407. case SEI_PIC_STRUCT_TOP_BOTTOM:
  408. case SEI_PIC_STRUCT_TOP_BOTTOM_TOP:
  409. s->field_order = AV_FIELD_TT;
  410. break;
  411. case SEI_PIC_STRUCT_BOTTOM_TOP:
  412. case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM:
  413. s->field_order = AV_FIELD_BB;
  414. break;
  415. default:
  416. s->field_order = AV_FIELD_PROGRESSIVE;
  417. break;
  418. }
  419. } else {
  420. if (field_poc[0] < field_poc[1])
  421. s->field_order = AV_FIELD_TT;
  422. else if (field_poc[0] > field_poc[1])
  423. s->field_order = AV_FIELD_BB;
  424. else
  425. s->field_order = AV_FIELD_PROGRESSIVE;
  426. }
  427. } else {
  428. if (h->picture_structure == PICT_TOP_FIELD)
  429. s->picture_structure = AV_PICTURE_STRUCTURE_TOP_FIELD;
  430. else
  431. s->picture_structure = AV_PICTURE_STRUCTURE_BOTTOM_FIELD;
  432. s->field_order = AV_FIELD_UNKNOWN;
  433. }
  434. return 0; /* no need to evaluate the rest */
  435. }
  436. }
  437. if (q264)
  438. return 0;
  439. /* didn't find a picture! */
  440. av_log(h->avctx, AV_LOG_ERROR, "missing picture in access unit with size %d\n", buf_size);
  441. return -1;
  442. }
  443. static int h264_parse(AVCodecParserContext *s,
  444. AVCodecContext *avctx,
  445. const uint8_t **poutbuf, int *poutbuf_size,
  446. const uint8_t *buf, int buf_size)
  447. {
  448. H264ParseContext *p = s->priv_data;
  449. H264Context *h = &p->h;
  450. ParseContext *pc = &p->pc;
  451. int next;
  452. if (!p->got_first) {
  453. p->got_first = 1;
  454. if (avctx->extradata_size) {
  455. h->avctx = avctx;
  456. // must be done like in decoder, otherwise opening the parser,
  457. // letting it create extradata and then closing and opening again
  458. // will cause has_b_frames to be always set.
  459. // Note that estimate_timings_from_pts does exactly this.
  460. if (!avctx->has_b_frames)
  461. h->low_delay = 1;
  462. ff_h264_decode_extradata(h, avctx->extradata, avctx->extradata_size);
  463. }
  464. }
  465. if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) {
  466. next = buf_size;
  467. } else {
  468. next = h264_find_frame_end(p, buf, buf_size);
  469. if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
  470. *poutbuf = NULL;
  471. *poutbuf_size = 0;
  472. return buf_size;
  473. }
  474. if (next < 0 && next != END_NOT_FOUND) {
  475. av_assert1(pc->last_index + next >= 0);
  476. h264_find_frame_end(p, &pc->buffer[pc->last_index + next], -next); // update state
  477. }
  478. }
  479. parse_nal_units(s, avctx, buf, buf_size);
  480. if (avctx->framerate.num)
  481. avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, (AVRational){avctx->ticks_per_frame, 1}));
  482. if (h->sei_cpb_removal_delay >= 0) {
  483. s->dts_sync_point = h->sei_buffering_period_present;
  484. s->dts_ref_dts_delta = h->sei_cpb_removal_delay;
  485. s->pts_dts_delta = h->sei_dpb_output_delay;
  486. } else {
  487. s->dts_sync_point = INT_MIN;
  488. s->dts_ref_dts_delta = INT_MIN;
  489. s->pts_dts_delta = INT_MIN;
  490. }
  491. if (s->flags & PARSER_FLAG_ONCE) {
  492. s->flags &= PARSER_FLAG_COMPLETE_FRAMES;
  493. }
  494. *poutbuf = buf;
  495. *poutbuf_size = buf_size;
  496. return next;
  497. }
  498. static int h264_split(AVCodecContext *avctx,
  499. const uint8_t *buf, int buf_size)
  500. {
  501. uint32_t state = -1;
  502. int has_sps = 0;
  503. int has_pps = 0;
  504. const uint8_t *ptr = buf, *end = buf + buf_size;
  505. int nalu_type;
  506. while (ptr < end) {
  507. ptr = avpriv_find_start_code(ptr, end, &state);
  508. if ((state & 0xFFFFFF00) != 0x100)
  509. break;
  510. nalu_type = state & 0x1F;
  511. if (nalu_type == NAL_SPS) {
  512. has_sps = 1;
  513. } else if (nalu_type == NAL_PPS)
  514. has_pps = 1;
  515. /* else if (nalu_type == 0x01 ||
  516. * nalu_type == 0x02 ||
  517. * nalu_type == 0x05) {
  518. * }
  519. */
  520. else if ((nalu_type != NAL_SEI || has_pps) &&
  521. nalu_type != NAL_AUD && nalu_type != NAL_SPS_EXT &&
  522. nalu_type != 0x0f) {
  523. if (has_sps) {
  524. while (ptr - 4 > buf && ptr[-5] == 0)
  525. ptr--;
  526. return ptr - 4 - buf;
  527. }
  528. }
  529. }
  530. return 0;
  531. }
  532. static void h264_close(AVCodecParserContext *s)
  533. {
  534. H264ParseContext *p = s->priv_data;
  535. H264Context *h = &p->h;
  536. ParseContext *pc = &p->pc;
  537. av_freep(&pc->buffer);
  538. ff_h264_free_context(h);
  539. }
  540. static av_cold int init(AVCodecParserContext *s)
  541. {
  542. H264ParseContext *p = s->priv_data;
  543. H264Context *h = &p->h;
  544. h->slice_ctx = av_mallocz(sizeof(*h->slice_ctx));
  545. if (!h->slice_ctx)
  546. return 0;
  547. h->nb_slice_ctx = 1;
  548. h->thread_context[0] = h;
  549. h->slice_context_count = 1;
  550. ff_h264dsp_init(&h->h264dsp, 8, 1);
  551. return 0;
  552. }
  553. AVCodecParser ff_h264_parser = {
  554. .codec_ids = { AV_CODEC_ID_H264 },
  555. .priv_data_size = sizeof(H264ParseContext),
  556. .parser_init = init,
  557. .parser_parse = h264_parse,
  558. .parser_close = h264_close,
  559. .split = h264_split,
  560. };