X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fs337m.c;h=9d1b52eb614bcd1e1bd120eea5235fa8af64b27d;hb=704017d91ec8fbade0de072d222018c1a6013b70;hp=2e85d487b5ee932c6df8eb6809ee481bec2c6ede;hpb=4069096dd535ee99175c2a29c1a1f59c3fc110c1;p=ffmpeg diff --git a/libavformat/s337m.c b/libavformat/s337m.c index 2e85d487b5e..9d1b52eb614 100644 --- a/libavformat/s337m.c +++ b/libavformat/s337m.c @@ -31,7 +31,7 @@ #define IS_24LE_MARKER(state) ((state & 0xFFFFFFFFFFFF) == MARKER_24LE) #define IS_LE_MARKER(state) (IS_16LE_MARKER(state) || IS_20LE_MARKER(state) || IS_24LE_MARKER(state)) -static int s337m_get_offset_and_codec(AVFormatContext *s, +static int s337m_get_offset_and_codec(void *avc, uint64_t state, int data_type, int data_size, int *offset, enum AVCodecID *codec) @@ -50,8 +50,8 @@ static int s337m_get_offset_and_codec(AVFormatContext *s, } if ((data_type & 0x1F) != 0x1C) { - if (s) - avpriv_report_missing_feature(s, "Data type %#x in SMPTE 337M", data_type & 0x1F); + if (avc) + avpriv_report_missing_feature(avc, "Data type %#x in SMPTE 337M", data_type & 0x1F); return AVERROR_PATCHWELCOME; } @@ -72,8 +72,8 @@ static int s337m_get_offset_and_codec(AVFormatContext *s, *offset = 1601; break; default: - if (s) - avpriv_report_missing_feature(s, "Dolby E data size %d in SMPTE 337M", data_size); + if (avc) + avpriv_report_missing_feature(avc, "Dolby E data size %d in SMPTE 337M", data_size); return AVERROR_PATCHWELCOME; } @@ -82,7 +82,7 @@ static int s337m_get_offset_and_codec(AVFormatContext *s, return 0; } -static int s337m_probe(AVProbeData *p) +static int s337m_probe(const AVProbeData *p) { uint64_t state = 0; int markers[3] = { 0 }; @@ -147,7 +147,6 @@ static int s337m_read_packet(AVFormatContext *s, AVPacket *pkt) uint64_t state = 0; int ret, data_type, data_size, offset; enum AVCodecID codec; - int64_t pos; while (!IS_LE_MARKER(state)) { state = (state << 8) | avio_r8(pb); @@ -163,20 +162,11 @@ static int s337m_read_packet(AVFormatContext *s, AVPacket *pkt) data_size = avio_rl24(pb); } - pos = avio_tell(pb); - if ((ret = s337m_get_offset_and_codec(s, state, data_type, data_size, &offset, &codec)) < 0) return ret; - if ((ret = av_new_packet(pkt, offset)) < 0) - return ret; - - pkt->pos = pos; - - if (avio_read(pb, pkt->data, pkt->size) < pkt->size) { - av_packet_unref(pkt); - return AVERROR_EOF; - } + if ((ret = av_get_packet(pb, pkt, offset)) != offset) + return ret < 0 ? ret : AVERROR_EOF; if (IS_16LE_MARKER(state)) ff_spdif_bswap_buf16((uint16_t *)pkt->data, (uint16_t *)pkt->data, pkt->size >> 1); @@ -186,11 +176,11 @@ static int s337m_read_packet(AVFormatContext *s, AVPacket *pkt) if (!s->nb_streams) { AVStream *st = avformat_new_stream(s, NULL); if (!st) { - av_packet_unref(pkt); return AVERROR(ENOMEM); } st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; st->codecpar->codec_id = codec; + st->need_parsing = AVSTREAM_PARSE_HEADERS; } return 0;