| 34 | |
| 35 | #if FF_API_PARSER_CODECID |
| 36 | av_cold AVCodecParserContext *av_parser_init(int codec_id) |
| 37 | #else |
| 38 | av_cold AVCodecParserContext *av_parser_init(enum AVCodecID codec_id) |
| 39 | #endif |
| 40 | { |
| 41 | AVCodecParserContext *s = NULL; |
| 42 | const AVCodecParser *parser; |
| 43 | const FFCodecParser *ffparser; |
| 44 | void *i = 0; |
| 45 | int ret; |
| 46 | |
| 47 | if (codec_id == AV_CODEC_ID_NONE) |
| 48 | return NULL; |
| 49 | |
| 50 | while ((parser = av_parser_iterate(&i))) { |
| 51 | if (parser->codec_ids[0] == codec_id || |
| 52 | parser->codec_ids[1] == codec_id || |
| 53 | parser->codec_ids[2] == codec_id || |
| 54 | parser->codec_ids[3] == codec_id || |
| 55 | parser->codec_ids[4] == codec_id || |
| 56 | parser->codec_ids[5] == codec_id || |
| 57 | parser->codec_ids[6] == codec_id) |
| 58 | goto found; |
| 59 | } |
| 60 | return NULL; |
| 61 | |
| 62 | found: |
| 63 | ffparser = ffcodecparser(parser); |
| 64 | s = av_mallocz(sizeof(AVCodecParserContext)); |
| 65 | if (!s) |
| 66 | goto err_out; |
| 67 | s->parser = parser; |
| 68 | s->priv_data = av_mallocz(ffparser->priv_data_size); |
| 69 | if (!s->priv_data) |
| 70 | goto err_out; |
| 71 | s->fetch_timestamp=1; |
| 72 | s->pict_type = AV_PICTURE_TYPE_I; |
| 73 | if (ffparser->init) { |
| 74 | ret = ffparser->init(s); |
| 75 | if (ret != 0) |
| 76 | goto err_out; |
| 77 | } |
| 78 | s->key_frame = -1; |
| 79 | s->dts_sync_point = INT_MIN; |
| 80 | s->dts_ref_dts_delta = INT_MIN; |
| 81 | s->pts_dts_delta = INT_MIN; |
| 82 | s->format = -1; |
| 83 | |
| 84 | return s; |
| 85 | |
| 86 | err_out: |
| 87 | if (s) |
| 88 | av_freep(&s->priv_data); |
| 89 | av_free(s); |
| 90 | return NULL; |
| 91 | } |
| 92 | |
| 93 | void ff_fetch_timestamp(AVCodecParserContext *s, int off, int remove, int fuzzy) |
no test coverage detected