Showing the changes to libavcodec (1 of 1 file). Show all
Unified · Split
| @@ -16,6 +16,9 @@ · 15 unmodified lines | |||
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 17 | */ | 17 | */ |
| 18 | 18 | ||
| 19 | #include "libavutil/avassert.h" | ||
| 20 | #include "libavutil/buffer.h" | ||
| 21 | |||
| 19 | #include "avcodec.h" | 22 | #include "avcodec.h" |
| 20 | #include "apv.h" | 23 | #include "apv.h" |
| 21 | #include "cbs.h" | 24 | #include "cbs.h" |
| @@ -34,6 +37,11 @@ static const enum AVPixelFormat apv_format_table[5][5] = { · 12 unmodified lines | |||
| 34 | { AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_YUVA444P12, AV_PIX_FMT_GRAY14, AV_PIX_FMT_YUVA444P16 }, | 37 | { AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_YUVA444P12, AV_PIX_FMT_GRAY14, AV_PIX_FMT_YUVA444P16 }, |
| 35 | }; | 38 | }; |
| 36 | 39 | ||
| 40 | static void dummy_free(void *opaque, uint8_t *data) | ||
| 41 | { | ||
| 42 | av_assert0(opaque == data); | ||
| 43 | } | ||
| 44 | |||
| 37 | static int parse(AVCodecParserContext *s, | 45 | static int parse(AVCodecParserContext *s, |
| 38 | AVCodecContext *avctx, | 46 | AVCodecContext *avctx, |
| 39 | const uint8_t **poutbuf, int *poutbuf_size, | 47 | const uint8_t **poutbuf, int *poutbuf_size, |
| @@ -41,14 +49,20 @@ static int parse(AVCodecParserContext *s, · 1 unmodified line | |||
| 41 | { | 49 | { |
| 42 | APVParseContext *p = s->priv_data; | 50 | APVParseContext *p = s->priv_data; |
| 43 | CodedBitstreamFragment *au = &p->au; | 51 | CodedBitstreamFragment *au = &p->au; |
| 52 | AVBufferRef *ref = NULL; | ||
| 44 | int ret; | 53 | int ret; |
| 45 | 54 | ||
| 46 | *poutbuf = buf; | 55 | *poutbuf = buf; |
| 47 | *poutbuf_size = buf_size; | 56 | *poutbuf_size = buf_size; |
| 48 | 57 | ||
| 58 | ref = av_buffer_create((uint8_t *)buf, buf_size, dummy_free, | ||
| 59 | (void *)buf, AV_BUFFER_FLAG_READONLY); | ||
| 60 | if (!ref) | ||
| 61 | return buf_size; | ||
| 62 | |||
| 49 | p->cbc->log_ctx = avctx; | 63 | p->cbc->log_ctx = avctx; |
| 50 | 64 | ||
| 51 | ret = ff_cbs_read(p->cbc, au, NULL, buf, buf_size); | 65 | ret = ff_cbs_read(p->cbc, au, ref, buf, buf_size); |
| 52 | if (ret < 0) { | 66 | if (ret < 0) { |
| 53 | av_log(avctx, AV_LOG_ERROR, "Failed to parse access unit.\n"); | 67 | av_log(avctx, AV_LOG_ERROR, "Failed to parse access unit.\n"); |
| 54 | goto end; | 68 | goto end; |
| @@ -92,6 +106,8 @@ static int parse(AVCodecParserContext *s, · 37 unmodified lines | |||
| 92 | 106 | ||
| 93 | end: | 107 | end: |
| 94 | ff_cbs_fragment_reset(au); | 108 | ff_cbs_fragment_reset(au); |
| 109 | av_assert1(av_buffer_get_ref_count(ref) == 1); | ||
| 110 | av_buffer_unref(&ref); | ||
| 95 | p->cbc->log_ctx = NULL; | 111 | p->cbc->log_ctx = NULL; |
| 96 | 112 | ||
| 97 | return buf_size; | 113 | return buf_size; |