After this commit applications needs to call av_format_inject_global_side_data() or handle AVStream side data by some other means if they want it not to be lost. This fixes a API incompatibility with libav. libav API does not allow the data to be passed through AVPackets
Unified · Split
| @@ -15,6 +15,9 @@ libavutil: 2012-10-22 · 14 unmodified lines | ||
| 15 | 15 | |
| 16 | 16 | API changes, most recent first: |
| 17 | 17 | |
| 18 | +2014-04-XX - xxxxxxx - lavf xx.xx.1xx - avformat.h | |
| 19 | + Add av_format_inject_global_side_data() | |
| 20 | + | |
| 18 | 21 | 2014-04-12 - xxxxxxx - lavu 52.76.100 - log.h |
| 19 | 22 | Add av_log_get_flags() |
| 20 | 23 | |
| @@ -2752,6 +2752,8 @@ static int read_thread(void *arg) · 2751 unmodified lines | ||
| 2752 | 2752 | if (genpts) |
| 2753 | 2753 | ic->flags |= AVFMT_FLAG_GENPTS; |
| 2754 | 2754 | |
| 2755 | + av_format_inject_global_side_data(ic); | |
| 2756 | + | |
| 2755 | 2757 | opts = setup_find_stream_info_opts(ic, codec_opts); |
| 2756 | 2758 | orig_nb_streams = ic->nb_streams; |
| 2757 | 2759 | |
| @@ -862,6 +862,8 @@ typedef struct AVStream { · 861 unmodified lines | ||
| 862 | 862 | * - muxing: May be set by the caller before avformat_write_header(). |
| 863 | 863 | * |
| 864 | 864 | * Freed by libavformat in avformat_free_context(). |
| 865 | + * | |
| 866 | + * @see av_format_inject_global_side_data() | |
| 865 | 867 | */ |
| 866 | 868 | AVPacketSideData *side_data; |
| 867 | 869 | /** |
| @@ -1043,7 +1045,7 @@ typedef struct AVStream { · 175 unmodified lines | ||
| 1043 | 1045 | /** |
| 1044 | 1046 | * Internal data to inject global side data |
| 1045 | 1047 | */ |
| 1046 | − int global_side_data_injected; | |
| 1048 | + int inject_global_side_data; | |
| 1047 | 1049 | |
| 1048 | 1050 | } AVStream; |
| 1049 | 1051 | |
| @@ -1612,6 +1614,12 @@ void av_format_set_opaque(AVFormatContext *s, void *opaque); · 562 unmodified lines | ||
| 1612 | 1614 | av_format_control_message av_format_get_control_message_cb(const AVFormatContext *s); |
| 1613 | 1615 | void av_format_set_control_message_cb(AVFormatContext *s, av_format_control_message callback); |
| 1614 | 1616 | |
| 1617 | +/** | |
| 1618 | + * This function will cause global side data to be injected in the next packet | |
| 1619 | + * of each stream as well as after any subsequent seek. | |
| 1620 | + */ | |
| 1621 | +void av_format_inject_global_side_data(AVFormatContext *s); | |
| 1622 | + | |
| 1615 | 1623 | /** |
| 1616 | 1624 | * Returns the method used to set ctx->duration. |
| 1617 | 1625 | * |
| @@ -52,6 +52,8 @@ struct AVFormatInternal { · 51 unmodified lines | ||
| 52 | 52 | * Muxing only. |
| 53 | 53 | */ |
| 54 | 54 | int nb_interleaved_streams; |
| 55 | + | |
| 56 | + int inject_global_side_data; | |
| 55 | 57 | }; |
| 56 | 58 | |
| 57 | 59 | #ifdef __GNUC__ |
| @@ -110,6 +110,16 @@ MAKE_ACCESSORS(AVFormatContext, format, int, metadata_header_padding) · 109 unmodified lines | ||
| 110 | 110 | MAKE_ACCESSORS(AVFormatContext, format, void *, opaque) |
| 111 | 111 | MAKE_ACCESSORS(AVFormatContext, format, av_format_control_message, control_message_cb) |
| 112 | 112 | |
| 113 | +void av_format_inject_global_side_data(AVFormatContext *s) | |
| 114 | +{ | |
| 115 | + int i; | |
| 116 | + s->internal->inject_global_side_data = 1; | |
| 117 | + for (i = 0; i < s->nb_streams; i++) { | |
| 118 | + AVStream *st = s->streams[i]; | |
| 119 | + st->inject_global_side_data = 1; | |
| 120 | + } | |
| 121 | +} | |
| 122 | + | |
| 113 | 123 | static AVCodec *find_decoder(AVFormatContext *s, AVStream *st, enum AVCodecID codec_id) |
| 114 | 124 | { |
| 115 | 125 | if (st->codec->codec) |
| @@ -1527,7 +1537,7 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) · 1411 unmodified lines | ||
| 1527 | 1537 | st->skip_samples = 0; |
| 1528 | 1538 | } |
| 1529 | 1539 | |
| 1530 | − if (!st->global_side_data_injected) { | |
| 1540 | + if (st->inject_global_side_data) { | |
| 1531 | 1541 | for (i = 0; i < st->nb_side_data; i++) { |
| 1532 | 1542 | AVPacketSideData *src_sd = &st->side_data[i]; |
| 1533 | 1543 | uint8_t *dst_data; |
| @@ -1543,7 +1553,7 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) · 9 unmodified lines | ||
| 1543 | 1553 | |
| 1544 | 1554 | memcpy(dst_data, src_sd->data, src_sd->size); |
| 1545 | 1555 | } |
| 1546 | − st->global_side_data_injected = 1; | |
| 1556 | + st->inject_global_side_data = 0; | |
| 1547 | 1557 | } |
| 1548 | 1558 | |
| 1549 | 1559 | if (!(s->flags & AVFMT_FLAG_KEEP_SIDE_DATA)) |
| @@ -1717,7 +1727,8 @@ void ff_read_frame_flush(AVFormatContext *s) · 167 unmodified lines | ||
| 1717 | 1727 | for (j = 0; j < MAX_REORDER_DELAY + 1; j++) |
| 1718 | 1728 | st->pts_buffer[j] = AV_NOPTS_VALUE; |
| 1719 | 1729 | |
| 1720 | − st->global_side_data_injected = 0; | |
| 1730 | + if (s->internal->inject_global_side_data) | |
| 1731 | + st->inject_global_side_data = 1; | |
| 1721 | 1732 | } |
| 1722 | 1733 | } |
| 1723 | 1734 | |
| @@ -3690,6 +3701,8 @@ AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c) · 1966 unmodified lines | ||
| 3690 | 3701 | st->info->fps_first_dts = AV_NOPTS_VALUE; |
| 3691 | 3702 | st->info->fps_last_dts = AV_NOPTS_VALUE; |
| 3692 | 3703 | |
| 3704 | + st->inject_global_side_data = s->internal->inject_global_side_data; | |
| 3705 | + | |
| 3693 | 3706 | s->streams[s->nb_streams++] = st; |
| 3694 | 3707 | return st; |
| 3695 | 3708 | } |