* 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"
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;
} DSSDemuxContext;
-static int dss_probe(AVProbeData *p)
+static int dss_probe(const AVProbeData *p)
{
if ( AV_RL32(p->buf) != MKTAG(0x2, 'd', 's', 's')
&& AV_RL32(p->buf) != MKTAG(0x3, 'd', 's', 's'))
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)
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;
}
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;
}
ret = avio_read(s->pb, pkt->data + offset,
size2 - offset);
if (ret < size2 - offset) {
- av_packet_unref(pkt);
return ret < 0 ? ret : AVERROR_EOF;
}
ret = avio_read(s->pb, pkt->data + offset, size - offset);
if (ret < size - offset) {
- av_packet_unref(pkt);
return ret < 0 ? ret : AVERROR_EOF;
}
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)
{
.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"
};