X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fdss.c;h=0585049130234d0ac4fbe05387a98f8fbbcffb93;hb=5e518c741661f8663e89048d25edce288219f980;hp=e5b0be9debc6ebbd7961f413d79079851956c430;hpb=47e12966b75490cfa5fb8ed65a48a9a3d84a7bce;p=ffmpeg diff --git a/libavformat/dss.c b/libavformat/dss.c index e5b0be9debc..05850491302 100644 --- a/libavformat/dss.c +++ b/libavformat/dss.c @@ -19,8 +19,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavutil/attributes.h" -#include "libavutil/bswap.h" #include "libavutil/channel_layout.h" #include "libavutil/intreadwrite.h" @@ -52,7 +50,7 @@ typedef struct DSSDemuxContext { int counter; int swap; int dss_sp_swap_byte; - int8_t *dss_sp_buf; + int8_t dss_sp_buf[DSS_FRAME_SIZE + 1]; int packet_size; int dss_header_size; @@ -105,15 +103,11 @@ static int dss_read_metadata_string(AVFormatContext *s, unsigned int offset, ret = avio_read(s->pb, value, size); if (ret < size) { - ret = ret < 0 ? ret : AVERROR_EOF; - goto exit; + av_free(value); + return ret < 0 ? ret : AVERROR_EOF; } - ret = av_dict_set(&s->metadata, key, value, 0); - -exit: - av_free(value); - return ret; + return av_dict_set(&s->metadata, key, value, AV_DICT_DONT_STRDUP_VAL); } static int dss_read_header(AVFormatContext *s) @@ -174,10 +168,6 @@ static int dss_read_header(AVFormatContext *s) ctx->counter = 0; ctx->swap = 0; - ctx->dss_sp_buf = av_malloc(DSS_FRAME_SIZE + 1); - if (!ctx->dss_sp_buf) - return AVERROR(ENOMEM); - return 0; } @@ -261,14 +251,12 @@ static int dss_sp_read_packet(AVFormatContext *s, AVPacket *pkt) dss_sp_byte_swap(ctx, pkt->data, ctx->dss_sp_buf); if (ctx->dss_sp_swap_byte < 0) { - ret = AVERROR(EAGAIN); - goto error_eof; + return AVERROR(EAGAIN); } return pkt->size; error_eof: - av_packet_unref(pkt); return ret < 0 ? ret : AVERROR_EOF; } @@ -310,7 +298,6 @@ static int dss_723_1_read_packet(AVFormatContext *s, AVPacket *pkt) ret = avio_read(s->pb, pkt->data + offset, size2 - offset); if (ret < size2 - offset) { - av_packet_unref(pkt); return ret < 0 ? ret : AVERROR_EOF; } @@ -320,7 +307,6 @@ static int dss_723_1_read_packet(AVFormatContext *s, AVPacket *pkt) ret = avio_read(s->pb, pkt->data + offset, size - offset); if (ret < size - offset) { - av_packet_unref(pkt); return ret < 0 ? ret : AVERROR_EOF; } @@ -337,15 +323,6 @@ static int dss_read_packet(AVFormatContext *s, AVPacket *pkt) return dss_723_1_read_packet(s, pkt); } -static int dss_read_close(AVFormatContext *s) -{ - DSSDemuxContext *ctx = s->priv_data; - - av_freep(&ctx->dss_sp_buf); - - return 0; -} - static int dss_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) { @@ -392,7 +369,6 @@ AVInputFormat ff_dss_demuxer = { .read_probe = dss_probe, .read_header = dss_read_header, .read_packet = dss_read_packet, - .read_close = dss_read_close, .read_seek = dss_read_seek, .extensions = "dss" };