diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-02-25 00:40:58 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-02-25 00:42:14 +0100 |
commit | 7d9b06eb179fb0d032c530d21182dce3fe0a7671 (patch) | |
tree | 7be8a4aaa2ed84b83b868f4f636c3a27dfe7b98c /libavformat | |
parent | 6e9bbaca6c6739e6524809d3e786ce1e10ad518b (diff) | |
parent | 199fb40278146c5bb162990c66ad3cd561abc780 (diff) | |
download | ffmpeg-7d9b06eb179fb0d032c530d21182dce3fe0a7671.tar.gz |
Merge commit '199fb40278146c5bb162990c66ad3cd561abc780'
* commit '199fb40278146c5bb162990c66ad3cd561abc780':
rtpdec: Use ffio_free_dyn_buf
Conflicts:
libavformat/rtpdec_latm.c
libavformat/rtpdec_svq3.c
libavformat/rtpdec_xiph.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/rtpdec_ac3.c | 19 | ||||
-rw-r--r-- | libavformat/rtpdec_asf.c | 12 | ||||
-rw-r--r-- | libavformat/rtpdec_dv.c | 13 | ||||
-rw-r--r-- | libavformat/rtpdec_h261.c | 15 | ||||
-rw-r--r-- | libavformat/rtpdec_h263_rfc2190.c | 12 | ||||
-rw-r--r-- | libavformat/rtpdec_jpeg.c | 17 | ||||
-rw-r--r-- | libavformat/rtpdec_latm.c | 12 | ||||
-rw-r--r-- | libavformat/rtpdec_mpa_robust.c | 17 | ||||
-rw-r--r-- | libavformat/rtpdec_svq3.c | 13 | ||||
-rw-r--r-- | libavformat/rtpdec_vp8.c | 19 | ||||
-rw-r--r-- | libavformat/rtpdec_xiph.c | 17 |
11 files changed, 39 insertions, 127 deletions
diff --git a/libavformat/rtpdec_ac3.c b/libavformat/rtpdec_ac3.c index b9e6e228fb..6fc9a68239 100644 --- a/libavformat/rtpdec_ac3.c +++ b/libavformat/rtpdec_ac3.c @@ -20,6 +20,7 @@ */ #include "avformat.h" +#include "avio_internal.h" #include "rtpdec_formats.h" #define RTP_AC3_PAYLOAD_HEADER_SIZE 2 @@ -31,19 +32,9 @@ struct PayloadContext { AVIOContext *fragment; }; -static void free_fragment(PayloadContext *data) -{ - if (data->fragment) { - uint8_t *p; - avio_close_dyn_buf(data->fragment, &p); - av_free(p); - data->fragment = NULL; - } -} - static void ac3_free_context(PayloadContext *data) { - free_fragment(data); + ffio_free_dyn_buf(&data->fragment); } static int ac3_handle_packet(AVFormatContext *ctx, PayloadContext *data, @@ -82,7 +73,7 @@ static int ac3_handle_packet(AVFormatContext *ctx, PayloadContext *data, case 1: case 2: /* First fragment */ - free_fragment(data); + ffio_free_dyn_buf(&data->fragment); data->last_frame = 1; data->nr_frames = nr_frames; @@ -102,7 +93,7 @@ static int ac3_handle_packet(AVFormatContext *ctx, PayloadContext *data, } if (nr_frames != data->nr_frames || data->timestamp != *timestamp) { - free_fragment(data); + ffio_free_dyn_buf(&data->fragment); av_log(ctx, AV_LOG_ERROR, "Invalid packet received\n"); return AVERROR_INVALIDDATA; } @@ -115,7 +106,7 @@ static int ac3_handle_packet(AVFormatContext *ctx, PayloadContext *data, return AVERROR(EAGAIN); if (data->last_frame != data->nr_frames) { - free_fragment(data); + ffio_free_dyn_buf(&data->fragment); av_log(ctx, AV_LOG_ERROR, "Missed %d packets\n", data->nr_frames - data->last_frame); return AVERROR_INVALIDDATA; diff --git a/libavformat/rtpdec_asf.c b/libavformat/rtpdec_asf.c index 0d6d6e7750..5b5a8da58b 100644 --- a/libavformat/rtpdec_asf.c +++ b/libavformat/rtpdec_asf.c @@ -224,10 +224,7 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf, * multiple RTP packets. */ if (asf->pktbuf && len_off != avio_tell(asf->pktbuf)) { - uint8_t *p; - avio_close_dyn_buf(asf->pktbuf, &p); - asf->pktbuf = NULL; - av_free(p); + ffio_free_dyn_buf(&asf->pktbuf); } if (!len_off && !asf->pktbuf && (res = avio_open_dyn_buf(&asf->pktbuf)) < 0) @@ -290,12 +287,7 @@ static int asfrtp_parse_packet(AVFormatContext *s, PayloadContext *asf, static void asfrtp_free_context(PayloadContext *asf) { - if (asf->pktbuf) { - uint8_t *p = NULL; - avio_close_dyn_buf(asf->pktbuf, &p); - asf->pktbuf = NULL; - av_free(p); - } + ffio_free_dyn_buf(&asf->pktbuf); av_freep(&asf->buf); av_free(asf); } diff --git a/libavformat/rtpdec_dv.c b/libavformat/rtpdec_dv.c index 3a7e14159b..43cd3cdeac 100644 --- a/libavformat/rtpdec_dv.c +++ b/libavformat/rtpdec_dv.c @@ -23,6 +23,7 @@ #include "libavcodec/bytestream.h" +#include "avio_internal.h" #include "rtpdec_formats.h" struct PayloadContext { @@ -31,17 +32,9 @@ struct PayloadContext { int bundled_audio; }; -static void dv_free_dyn_buffer(AVIOContext **dyn_buf) -{ - uint8_t *ptr_dyn_buffer; - avio_close_dyn_buf(*dyn_buf, &ptr_dyn_buffer); - av_free(ptr_dyn_buffer); - *dyn_buf = NULL; -} - static av_cold void dv_free_context(PayloadContext *data) { - dv_free_dyn_buffer(&data->buf); + ffio_free_dyn_buf(&data->buf); } static av_cold int dv_sdp_parse_fmtp_config(AVFormatContext *s, @@ -104,7 +97,7 @@ static int dv_handle_packet(AVFormatContext *ctx, PayloadContext *rtp_dv_ctx, /* drop data of previous packets in case of non-continuous (lossy) packet stream */ if (rtp_dv_ctx->buf && rtp_dv_ctx->timestamp != *timestamp) { - dv_free_dyn_buffer(&rtp_dv_ctx->buf); + ffio_free_dyn_buf(&rtp_dv_ctx->buf); } /* sanity check for size of input packet: 1 byte payload at least */ diff --git a/libavformat/rtpdec_h261.c b/libavformat/rtpdec_h261.c index 2f562bb579..787f1d0dd8 100644 --- a/libavformat/rtpdec_h261.c +++ b/libavformat/rtpdec_h261.c @@ -21,6 +21,7 @@ #include "libavcodec/get_bits.h" #include "avformat.h" +#include "avio_internal.h" #include "rtpdec_formats.h" #define RTP_H261_PAYLOAD_HEADER_SIZE 4 @@ -32,14 +33,6 @@ struct PayloadContext { uint32_t timestamp; }; -static void h261_free_dyn_buffer(AVIOContext **dyn_buf) -{ - uint8_t *ptr_dyn_buffer; - avio_close_dyn_buf(*dyn_buf, &ptr_dyn_buffer); - av_free(ptr_dyn_buffer); - *dyn_buf = NULL; -} - static av_cold void h261_free_context(PayloadContext *pl_ctx) { /* return if context is invalid */ @@ -47,9 +40,7 @@ static av_cold void h261_free_context(PayloadContext *pl_ctx) return; /* free buffer if it is valid */ - if (pl_ctx->buf) { - h261_free_dyn_buffer(&pl_ctx->buf); - } + ffio_free_dyn_buf(&pl_ctx->buf); } static int h261_handle_packet(AVFormatContext *ctx, PayloadContext *rtp_h261_ctx, @@ -62,7 +53,7 @@ static int h261_handle_packet(AVFormatContext *ctx, PayloadContext *rtp_h261_ctx /* drop data of previous packets in case of non-continuous (lossy) packet stream */ if (rtp_h261_ctx->buf && rtp_h261_ctx->timestamp != *timestamp) { - h261_free_dyn_buffer(&rtp_h261_ctx->buf); + ffio_free_dyn_buf(&rtp_h261_ctx->buf); rtp_h261_ctx->endbyte_bits = 0; } diff --git a/libavformat/rtpdec_h263_rfc2190.c b/libavformat/rtpdec_h263_rfc2190.c index ce2aacaf50..dab4d625a8 100644 --- a/libavformat/rtpdec_h263_rfc2190.c +++ b/libavformat/rtpdec_h263_rfc2190.c @@ -26,6 +26,7 @@ */ #include "avformat.h" +#include "avio_internal.h" #include "rtpdec_formats.h" #include "libavutil/attributes.h" #include "libavutil/intreadwrite.h" @@ -41,11 +42,7 @@ struct PayloadContext { static void h263_free_context(PayloadContext *data) { - if (data->buf) { - uint8_t *p; - avio_close_dyn_buf(data->buf, &p); - av_free(p); - } + ffio_free_dyn_buf(&data->buf); } static int h263_handle_packet(AVFormatContext *ctx, PayloadContext *data, @@ -63,10 +60,7 @@ static int h263_handle_packet(AVFormatContext *ctx, PayloadContext *data, if (data->buf && data->timestamp != *timestamp) { /* Dropping old buffered, unfinished data */ - uint8_t *p; - avio_close_dyn_buf(data->buf, &p); - av_free(p); - data->buf = NULL; + ffio_free_dyn_buf(&data->buf); data->endbyte_bits = 0; } diff --git a/libavformat/rtpdec_jpeg.c b/libavformat/rtpdec_jpeg.c index 7c1e7181ae..ca4debef99 100644 --- a/libavformat/rtpdec_jpeg.c +++ b/libavformat/rtpdec_jpeg.c @@ -20,6 +20,7 @@ */ #include "avformat.h" +#include "avio_internal.h" #include "rtpdec.h" #include "rtpdec_formats.h" #include "libavutil/intreadwrite.h" @@ -59,19 +60,9 @@ static const uint8_t default_quantizers[128] = { 99, 99, 99, 99, 99, 99, 99, 99 }; -static void free_frame(PayloadContext *jpeg) -{ - if (jpeg->frame) { - uint8_t *p; - avio_close_dyn_buf(jpeg->frame, &p); - av_free(p); - jpeg->frame = NULL; - } -} - static void jpeg_free_context(PayloadContext *jpeg) { - free_frame(jpeg); + ffio_free_dyn_buf(&jpeg->frame); } static int jpeg_create_huffman_table(PutByteContext *p, int table_class, @@ -332,7 +323,7 @@ static int jpeg_parse_packet(AVFormatContext *ctx, PayloadContext *jpeg, /* Skip the current frame in case of the end packet * has been lost somewhere. */ - free_frame(jpeg); + ffio_free_dyn_buf(&jpeg->frame); if ((ret = avio_open_dyn_buf(&jpeg->frame)) < 0) return ret; @@ -358,7 +349,7 @@ static int jpeg_parse_packet(AVFormatContext *ctx, PayloadContext *jpeg, if (jpeg->timestamp != *timestamp) { /* Skip the current frame if timestamp is incorrect. * A start packet has been lost somewhere. */ - free_frame(jpeg); + ffio_free_dyn_buf(&jpeg->frame); av_log(ctx, AV_LOG_ERROR, "RTP timestamps don't match.\n"); return AVERROR_INVALIDDATA; } diff --git a/libavformat/rtpdec_latm.c b/libavformat/rtpdec_latm.c index 2916f6a897..ab425bc080 100644 --- a/libavformat/rtpdec_latm.c +++ b/libavformat/rtpdec_latm.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "avio_internal.h" #include "rtpdec_formats.h" #include "internal.h" #include "libavutil/avstring.h" @@ -33,11 +34,7 @@ struct PayloadContext { static void latm_free_context(PayloadContext *data) { - if (data->dyn_buf) { - uint8_t *p; - avio_close_dyn_buf(data->dyn_buf, &p); - av_free(p); - } + ffio_free_dyn_buf(&data->dyn_buf); av_freep(&data->buf); } @@ -51,10 +48,7 @@ static int latm_parse_packet(AVFormatContext *ctx, PayloadContext *data, if (buf) { if (!data->dyn_buf || data->timestamp != *timestamp) { av_freep(&data->buf); - if (data->dyn_buf) - avio_close_dyn_buf(data->dyn_buf, &data->buf); - data->dyn_buf = NULL; - av_freep(&data->buf); + ffio_free_dyn_buf(&data->dyn_buf); data->timestamp = *timestamp; if ((ret = avio_open_dyn_buf(&data->dyn_buf)) < 0) diff --git a/libavformat/rtpdec_mpa_robust.c b/libavformat/rtpdec_mpa_robust.c index 313062d30f..2c3dc0c742 100644 --- a/libavformat/rtpdec_mpa_robust.c +++ b/libavformat/rtpdec_mpa_robust.c @@ -22,6 +22,7 @@ #include "libavutil/attributes.h" #include "libavutil/intreadwrite.h" +#include "avio_internal.h" #include "rtpdec_formats.h" struct PayloadContext { @@ -33,19 +34,9 @@ struct PayloadContext { AVIOContext *fragment; }; -static void free_fragment(PayloadContext *data) -{ - if (data->fragment) { - uint8_t *p; - avio_close_dyn_buf(data->fragment, &p); - av_free(p); - data->fragment = NULL; - } -} - static void mpa_robust_free_context(PayloadContext *data) { - free_fragment(data); + ffio_free_dyn_buf(&data->fragment); av_free(data->split_buf); } @@ -154,7 +145,7 @@ static int mpa_robust_parse_packet(AVFormatContext *ctx, PayloadContext *data, return 0; } else if (!continuation) { /* && adu_size > len */ /* First fragment */ - free_fragment(data); + ffio_free_dyn_buf(&data->fragment); data->adu_size = adu_size; data->cur_size = len; @@ -177,7 +168,7 @@ static int mpa_robust_parse_packet(AVFormatContext *ctx, PayloadContext *data, } if (adu_size = data->adu_size || data->timestamp != *timestamp) { - free_fragment(data); + ffio_free_dyn_buf(&data->fragment); av_log(ctx, AV_LOG_ERROR, "Invalid packet received\n"); return AVERROR_INVALIDDATA; } diff --git a/libavformat/rtpdec_svq3.c b/libavformat/rtpdec_svq3.c index 4d2d6ac8d1..18026a74ee 100644 --- a/libavformat/rtpdec_svq3.c +++ b/libavformat/rtpdec_svq3.c @@ -28,6 +28,7 @@ #include <string.h> #include "libavutil/intreadwrite.h" +#include "avio_internal.h" #include "internal.h" #include "rtp.h" #include "rtpdec.h" @@ -81,11 +82,7 @@ static int svq3_parse_packet (AVFormatContext *s, PayloadContext *sv, if (start_packet) { int res; - if (sv->pktbuf) { - uint8_t *tmp; - avio_close_dyn_buf(sv->pktbuf, &tmp); - av_free(tmp); - } + ffio_free_dyn_buf(&sv->pktbuf); if ((res = avio_open_dyn_buf(&sv->pktbuf)) < 0) return res; sv->timestamp = *timestamp; @@ -110,11 +107,7 @@ static int svq3_parse_packet (AVFormatContext *s, PayloadContext *sv, static void svq3_extradata_free(PayloadContext *sv) { - if (sv->pktbuf) { - uint8_t *buf; - avio_close_dyn_buf(sv->pktbuf, &buf); - av_free(buf); - } + ffio_free_dyn_buf(&sv->pktbuf); } RTPDynamicProtocolHandler ff_svq3_dynamic_handler = { diff --git a/libavformat/rtpdec_vp8.c b/libavformat/rtpdec_vp8.c index 0c93e191c9..2f4a40e852 100644 --- a/libavformat/rtpdec_vp8.c +++ b/libavformat/rtpdec_vp8.c @@ -29,6 +29,7 @@ #include "libavcodec/bytestream.h" +#include "avio_internal.h" #include "rtpdec_formats.h" struct PayloadContext { @@ -52,22 +53,12 @@ struct PayloadContext { int got_keyframe; }; -static void vp8_free_buffer(PayloadContext *vp8) -{ - uint8_t *tmp; - if (!vp8->data) - return; - avio_close_dyn_buf(vp8->data, &tmp); - av_free(tmp); - vp8->data = NULL; -} - static int vp8_broken_sequence(AVFormatContext *ctx, PayloadContext *vp8, const char *msg) { vp8->sequence_ok = 0; av_log(ctx, AV_LOG_WARNING, "%s", msg); - vp8_free_buffer(vp8); + ffio_free_dyn_buf(&vp8->data); return AVERROR(EAGAIN); } @@ -150,7 +141,7 @@ static int vp8_handle_packet(AVFormatContext *ctx, PayloadContext *vp8, int res; int non_key = buf[0] & 0x01; if (!non_key) { - vp8_free_buffer(vp8); + ffio_free_dyn_buf(&vp8->data); // Keyframe, decoding ok again vp8->sequence_ok = 1; vp8->sequence_dirty = 0; @@ -205,7 +196,7 @@ static int vp8_handle_packet(AVFormatContext *ctx, PayloadContext *vp8, old_timestamp = vp8->timestamp; } else { // Shouldn't happen - vp8_free_buffer(vp8); + ffio_free_dyn_buf(&vp8->data); } } } @@ -277,7 +268,7 @@ static av_cold int vp8_init(AVFormatContext *s, int st_index, PayloadContext *vp static void vp8_free_context(PayloadContext *vp8) { - vp8_free_buffer(vp8); + ffio_free_dyn_buf(&vp8->data); } static int vp8_need_keyframe(PayloadContext *vp8) diff --git a/libavformat/rtpdec_xiph.c b/libavformat/rtpdec_xiph.c index 535cbff549..abdbcf4a86 100644 --- a/libavformat/rtpdec_xiph.c +++ b/libavformat/rtpdec_xiph.c @@ -33,6 +33,7 @@ #include "libavutil/base64.h" #include "libavcodec/bytestream.h" +#include "avio_internal.h" #include "internal.h" #include "rtpdec.h" #include "rtpdec_formats.h" @@ -49,19 +50,9 @@ struct PayloadContext { int split_pkts; }; -static void free_fragment(PayloadContext * data) -{ - if (data->fragment) { - uint8_t* p; - avio_close_dyn_buf(data->fragment, &p); - av_free(p); - data->fragment = NULL; - } -} - static void xiph_free_context(PayloadContext * data) { - free_fragment(data); + ffio_free_dyn_buf(&data->fragment); av_freep(&data->split_buf); } @@ -168,7 +159,7 @@ static int xiph_handle_packet(AVFormatContext *ctx, PayloadContext *data, int res; // end packet has been lost somewhere, so drop buffered data - free_fragment(data); + ffio_free_dyn_buf(&data->fragment); if((res = avio_open_dyn_buf(&data->fragment)) < 0) return res; @@ -181,7 +172,7 @@ static int xiph_handle_packet(AVFormatContext *ctx, PayloadContext *data, if (data->timestamp != *timestamp) { // skip if fragmented timestamp is incorrect; // a start packet has been lost somewhere - free_fragment(data); + ffio_free_dyn_buf(&data->fragment); av_log(ctx, AV_LOG_ERROR, "RTP timestamps don't match!\n"); return AVERROR_INVALIDDATA; } |