History

avformat: add av_format_inject_global_side_data(), and disable it by default

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

Michael Niedermayer committed 12 years ago

Commit ef818d81 parent 2adcd155 files · +32 −4Browse files

Unified · Split

5 files
  1. doc/APIchanges +3 −0
  2. ffplay.c +2 −0
  3. libavformat/avformat.h +9 −1
  4. libavformat/internal.h +2 −0
  5. libavformat/utils.c +16 −3
doc/APIchanges+3−0
@@ -15,6 +15,9 @@ libavutil: 2012-10-22 · 14 unmodified lines
15 15
16API changes, most recent first:16API changes, most recent first:
17 17
182014-04-XX - xxxxxxx - lavf xx.xx.1xx - avformat.h
19 Add av_format_inject_global_side_data()
20
182014-04-12 - xxxxxxx - lavu 52.76.100 - log.h212014-04-12 - xxxxxxx - lavu 52.76.100 - log.h
19 Add av_log_get_flags()22 Add av_log_get_flags()
20 23
ffplay.c+2−0
@@ -2752,6 +2752,8 @@ static int read_thread(void *arg) · 2751 unmodified lines
2752 if (genpts)2752 if (genpts)
2753 ic->flags |= AVFMT_FLAG_GENPTS;2753 ic->flags |= AVFMT_FLAG_GENPTS;
2754 2754
2755 av_format_inject_global_side_data(ic);
2756
2755 opts = setup_find_stream_info_opts(ic, codec_opts);2757 opts = setup_find_stream_info_opts(ic, codec_opts);
2756 orig_nb_streams = ic->nb_streams;2758 orig_nb_streams = ic->nb_streams;
2757 2759
libavformat/avformat.h+9−1
@@ -862,6 +862,8 @@ typedef struct AVStream { · 861 unmodified lines
862 * - muxing: May be set by the caller before avformat_write_header().862 * - muxing: May be set by the caller before avformat_write_header().
863 *863 *
864 * Freed by libavformat in avformat_free_context().864 * Freed by libavformat in avformat_free_context().
865 *
866 * @see av_format_inject_global_side_data()
865 */867 */
866 AVPacketSideData *side_data;868 AVPacketSideData *side_data;
867 /**869 /**
@@ -1043,7 +1045,7 @@ typedef struct AVStream { · 175 unmodified lines
1043 /**1045 /**
1044 * Internal data to inject global side data1046 * Internal data to inject global side data
1045 */1047 */
1046 int global_side_data_injected;1048 int inject_global_side_data;
1047 1049
1048} AVStream;1050} AVStream;
1049 1051
@@ -1612,6 +1614,12 @@ void av_format_set_opaque(AVFormatContext *s, void *opaque); · 562 unmodified lines
1612av_format_control_message av_format_get_control_message_cb(const AVFormatContext *s);1614av_format_control_message av_format_get_control_message_cb(const AVFormatContext *s);
1613void av_format_set_control_message_cb(AVFormatContext *s, av_format_control_message callback);1615void 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 */
1621void av_format_inject_global_side_data(AVFormatContext *s);
1622
1615/**1623/**
1616 * Returns the method used to set ctx->duration.1624 * Returns the method used to set ctx->duration.
1617 *1625 *
libavformat/internal.h+2−0
@@ -52,6 +52,8 @@ struct AVFormatInternal { · 51 unmodified lines
52 * Muxing only.52 * Muxing only.
53 */53 */
54 int nb_interleaved_streams;54 int nb_interleaved_streams;
55
56 int inject_global_side_data;
55};57};
56 58
57#ifdef __GNUC__59#ifdef __GNUC__
libavformat/utils.c+16−3
@@ -110,6 +110,16 @@ MAKE_ACCESSORS(AVFormatContext, format, int, metadata_header_padding) · 109 unmodified lines
110MAKE_ACCESSORS(AVFormatContext, format, void *, opaque)110MAKE_ACCESSORS(AVFormatContext, format, void *, opaque)
111MAKE_ACCESSORS(AVFormatContext, format, av_format_control_message, control_message_cb)111MAKE_ACCESSORS(AVFormatContext, format, av_format_control_message, control_message_cb)
112 112
113void 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
113static AVCodec *find_decoder(AVFormatContext *s, AVStream *st, enum AVCodecID codec_id)123static AVCodec *find_decoder(AVFormatContext *s, AVStream *st, enum AVCodecID codec_id)
114{124{
115 if (st->codec->codec)125 if (st->codec->codec)
@@ -1527,7 +1537,7 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) · 1411 unmodified lines
1527 st->skip_samples = 0;1537 st->skip_samples = 0;
1528 }1538 }
1529 1539
1530 if (!st->global_side_data_injected) {1540 if (st->inject_global_side_data) {
1531 for (i = 0; i < st->nb_side_data; i++) {1541 for (i = 0; i < st->nb_side_data; i++) {
1532 AVPacketSideData *src_sd = &st->side_data[i];1542 AVPacketSideData *src_sd = &st->side_data[i];
1533 uint8_t *dst_data;1543 uint8_t *dst_data;
@@ -1543,7 +1553,7 @@ static int read_frame_internal(AVFormatContext *s, AVPacket *pkt) · 9 unmodified lines
1543 1553
1544 memcpy(dst_data, src_sd->data, src_sd->size);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 if (!(s->flags & AVFMT_FLAG_KEEP_SIDE_DATA))1559 if (!(s->flags & AVFMT_FLAG_KEEP_SIDE_DATA))
@@ -1717,7 +1727,8 @@ void ff_read_frame_flush(AVFormatContext *s) · 167 unmodified lines
1717 for (j = 0; j < MAX_REORDER_DELAY + 1; j++)1727 for (j = 0; j < MAX_REORDER_DELAY + 1; j++)
1718 st->pts_buffer[j] = AV_NOPTS_VALUE;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 st->info->fps_first_dts = AV_NOPTS_VALUE;3701 st->info->fps_first_dts = AV_NOPTS_VALUE;
3691 st->info->fps_last_dts = AV_NOPTS_VALUE;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 s->streams[s->nb_streams++] = st;3706 s->streams[s->nb_streams++] = st;
3694 return st;3707 return st;
3695}3708}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t