mirror of https://github.com/FFmpeg/FFmpeg.git
Compare commits
2 Commits
76827a6f3b
...
ee623a43e3
| Author | SHA1 | Date |
|---|---|---|
|
|
ee623a43e3 | |
|
|
c732564d2e |
|
|
@ -32,6 +32,7 @@
|
||||||
#include "libavutil/mem.h"
|
#include "libavutil/mem.h"
|
||||||
#include "libavcodec/internal.h"
|
#include "libavcodec/internal.h"
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
|
#include "avio_internal.h"
|
||||||
#include "demux.h"
|
#include "demux.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
@ -239,9 +240,10 @@ static int fourxm_read_header(AVFormatContext *s)
|
||||||
header = av_malloc(header_size);
|
header = av_malloc(header_size);
|
||||||
if (!header)
|
if (!header)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
if (avio_read(pb, header, header_size) != header_size) {
|
ret = ffio_read_size(pb, header, header_size);
|
||||||
|
if (ret < 0) {
|
||||||
av_free(header);
|
av_free(header);
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* take the lazy approach and search for any and all vtrk and strk chunks */
|
/* take the lazy approach and search for any and all vtrk and strk chunks */
|
||||||
|
|
@ -312,7 +314,7 @@ static int fourxm_read_packet(AVFormatContext *s,
|
||||||
fourcc_tag = AV_RL32(&header[0]);
|
fourcc_tag = AV_RL32(&header[0]);
|
||||||
size = AV_RL32(&header[4]);
|
size = AV_RL32(&header[4]);
|
||||||
if (avio_feof(pb))
|
if (avio_feof(pb))
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
switch (fourcc_tag) {
|
switch (fourcc_tag) {
|
||||||
case LIST_TAG:
|
case LIST_TAG:
|
||||||
/* this is a good time to bump the video pts */
|
/* this is a good time to bump the video pts */
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,7 @@ retry:
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (ret < ADTS_HEADER_SIZE)
|
if (ret < ADTS_HEADER_SIZE)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
if ((AV_RB16(pkt->data) >> 4) != 0xfff) {
|
if ((AV_RB16(pkt->data) >> 4) != 0xfff) {
|
||||||
// Parse all the ID3 headers between frames
|
// Parse all the ID3 headers between frames
|
||||||
|
|
@ -184,7 +184,7 @@ retry:
|
||||||
av_assert2(append > 0);
|
av_assert2(append > 0);
|
||||||
ret = av_append_packet(s->pb, pkt, append);
|
ret = av_append_packet(s->pb, pkt, append);
|
||||||
if (ret != append)
|
if (ret != append)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
if (!ff_id3v2_match(pkt->data, ID3v2_DEFAULT_MAGIC)) {
|
if (!ff_id3v2_match(pkt->data, ID3v2_DEFAULT_MAGIC)) {
|
||||||
av_packet_unref(pkt);
|
av_packet_unref(pkt);
|
||||||
ret = adts_aac_resync(s);
|
ret = adts_aac_resync(s);
|
||||||
|
|
|
||||||
|
|
@ -345,9 +345,10 @@ static int aax_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
extradata = av_malloc(extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
|
extradata = av_malloc(extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);
|
||||||
if (!extradata)
|
if (!extradata)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
if (avio_read(pb, extradata, extradata_size) != extradata_size) {
|
ret = ffio_read_size(pb, extradata, extradata_size);
|
||||||
|
if (ret < 0) {
|
||||||
av_free(extradata);
|
av_free(extradata);
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
}
|
}
|
||||||
memset(extradata + extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
|
memset(extradata + extradata_size, 0, AV_INPUT_BUFFER_PADDING_SIZE);
|
||||||
}
|
}
|
||||||
|
|
@ -356,7 +357,7 @@ static int aax_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
ret = av_get_packet(pb, pkt, size);
|
ret = av_get_packet(pb, pkt, size);
|
||||||
if (ret != size) {
|
if (ret != size) {
|
||||||
av_free(extradata);
|
av_free(extradata);
|
||||||
return ret < 0 ? ret : AVERROR(EIO);
|
return ret < 0 ? ret : AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
pkt->duration = 1;
|
pkt->duration = 1;
|
||||||
pkt->stream_index = 0;
|
pkt->stream_index = 0;
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ static int adx_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
av_shrink_packet(pkt, size);
|
av_shrink_packet(pkt, size);
|
||||||
pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
|
pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
|
||||||
} else if (ret < size) {
|
} else if (ret < size) {
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
} else {
|
} else {
|
||||||
size = ret;
|
size = ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ static int64_t get_tag(AVIOContext *pb, uint32_t * tag)
|
||||||
int64_t size;
|
int64_t size;
|
||||||
|
|
||||||
if (avio_feof(pb))
|
if (avio_feof(pb))
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
*tag = avio_rl32(pb);
|
*tag = avio_rl32(pb);
|
||||||
size = avio_rb32(pb);
|
size = avio_rb32(pb);
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#include "libavutil/channel_layout.h"
|
#include "libavutil/channel_layout.h"
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
|
#include "avio_internal.h"
|
||||||
#include "demux.h"
|
#include "demux.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "mux.h"
|
#include "mux.h"
|
||||||
|
|
@ -90,10 +91,8 @@ static int alp_read_header(AVFormatContext *s)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = avio_read(s->pb, hdr->adpcm, sizeof(hdr->adpcm))) < 0)
|
if ((ret = ffio_read_size(s->pb, hdr->adpcm, sizeof(hdr->adpcm))) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
else if (ret != sizeof(hdr->adpcm))
|
|
||||||
return AVERROR(EIO);
|
|
||||||
|
|
||||||
if (strncmp("ADPCM", hdr->adpcm, sizeof(hdr->adpcm)) != 0)
|
if (strncmp("ADPCM", hdr->adpcm, sizeof(hdr->adpcm)) != 0)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
|
||||||
|
|
@ -73,8 +73,11 @@ static int apc_read_header(AVFormatContext *s)
|
||||||
|
|
||||||
static int apc_read_packet(AVFormatContext *s, AVPacket *pkt)
|
static int apc_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
{
|
{
|
||||||
if (av_get_packet(s->pb, pkt, MAX_READ_SIZE) <= 0)
|
int ret = av_get_packet(s->pb, pkt, MAX_READ_SIZE);
|
||||||
return AVERROR(EIO);
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
else if (ret == 0)
|
||||||
|
return AVERROR_INVALIDDATA;
|
||||||
pkt->stream_index = 0;
|
pkt->stream_index = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -395,7 +395,7 @@ static int ape_read_packet(AVFormatContext * s, AVPacket * pkt)
|
||||||
av_log(s, AV_LOG_ERROR, "invalid packet size: %8"PRId64"\n",
|
av_log(s, AV_LOG_ERROR, "invalid packet size: %8"PRId64"\n",
|
||||||
ape->frames[ape->currentframe].size);
|
ape->frames[ape->currentframe].size);
|
||||||
ape->currentframe++;
|
ape->currentframe++;
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = av_new_packet(pkt, ape->frames[ape->currentframe].size + extra_size);
|
ret = av_new_packet(pkt, ape->frames[ape->currentframe].size + extra_size);
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
#include "config_components.h"
|
#include "config_components.h"
|
||||||
|
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
|
#include "avio_internal.h"
|
||||||
#include "demux.h"
|
#include "demux.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "mux.h"
|
#include "mux.h"
|
||||||
|
|
@ -153,10 +154,8 @@ static int apm_read_header(AVFormatContext *s)
|
||||||
(int64_t)par->sample_rate *
|
(int64_t)par->sample_rate *
|
||||||
par->bits_per_coded_sample;
|
par->bits_per_coded_sample;
|
||||||
|
|
||||||
if ((ret = avio_read(s->pb, buf, APM_FILE_EXTRADATA_SIZE)) < 0)
|
if ((ret = ffio_read_size(s->pb, buf, APM_FILE_EXTRADATA_SIZE)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
else if (ret != APM_FILE_EXTRADATA_SIZE)
|
|
||||||
return AVERROR(EIO);
|
|
||||||
|
|
||||||
apm_parse_extradata(&extradata, buf);
|
apm_parse_extradata(&extradata, buf);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#include "libavutil/avstring.h"
|
#include "libavutil/avstring.h"
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
|
#include "avio_internal.h"
|
||||||
#include "demux.h"
|
#include "demux.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "mux.h"
|
#include "mux.h"
|
||||||
|
|
@ -188,10 +189,8 @@ static int argo_asf_read_header(AVFormatContext *s)
|
||||||
if (!(st = avformat_new_stream(s, NULL)))
|
if (!(st = avformat_new_stream(s, NULL)))
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
if ((ret = avio_read(pb, buf, ASF_FILE_HEADER_SIZE)) < 0)
|
if ((ret = ffio_read_size(pb, buf, ASF_FILE_HEADER_SIZE)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
else if (ret != ASF_FILE_HEADER_SIZE)
|
|
||||||
return AVERROR(EIO);
|
|
||||||
|
|
||||||
ff_argo_asf_parse_file_header(&asf->fhdr, buf);
|
ff_argo_asf_parse_file_header(&asf->fhdr, buf);
|
||||||
|
|
||||||
|
|
@ -205,10 +204,8 @@ static int argo_asf_read_header(AVFormatContext *s)
|
||||||
if ((ret = avio_skip(pb, asf->fhdr.chunk_offset - ASF_FILE_HEADER_SIZE)) < 0)
|
if ((ret = avio_skip(pb, asf->fhdr.chunk_offset - ASF_FILE_HEADER_SIZE)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if ((ret = avio_read(pb, buf, ASF_CHUNK_HEADER_SIZE)) < 0)
|
if ((ret = ffio_read_size(pb, buf, ASF_CHUNK_HEADER_SIZE)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
else if (ret != ASF_CHUNK_HEADER_SIZE)
|
|
||||||
return AVERROR(EIO);
|
|
||||||
|
|
||||||
ff_argo_asf_parse_chunk_header(&asf->ckhdr, buf);
|
ff_argo_asf_parse_chunk_header(&asf->ckhdr, buf);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@
|
||||||
#include "libavutil/avstring.h"
|
#include "libavutil/avstring.h"
|
||||||
#include "libavutil/channel_layout.h"
|
#include "libavutil/channel_layout.h"
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
|
#include "avio_internal.h"
|
||||||
#include "demux.h"
|
#include "demux.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "mux.h"
|
#include "mux.h"
|
||||||
|
|
@ -139,10 +140,8 @@ static int argo_cvg_read_checksum(AVIOContext *pb, const ArgoCVGHeader *cvg, uin
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* NB: Not using avio_rl32() because no error checking. */
|
/* NB: Not using avio_rl32() because no error checking. */
|
||||||
if ((ret = avio_read(pb, buf, sizeof(buf))) < 0)
|
if ((ret = ffio_read_size(pb, buf, sizeof(buf))) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
else if (ret != sizeof(buf))
|
|
||||||
return AVERROR(EIO);
|
|
||||||
|
|
||||||
if ((ret = avio_seek(pb, ARGO_CVG_HEADER_SIZE, SEEK_SET)) < 0)
|
if ((ret = avio_seek(pb, ARGO_CVG_HEADER_SIZE, SEEK_SET)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
@ -163,10 +162,8 @@ static int argo_cvg_read_header(AVFormatContext *s)
|
||||||
if (!(st = avformat_new_stream(s, NULL)))
|
if (!(st = avformat_new_stream(s, NULL)))
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
if ((ret = avio_read(s->pb, buf, ARGO_CVG_HEADER_SIZE)) < 0)
|
if ((ret = ffio_read_size(s->pb, buf, ARGO_CVG_HEADER_SIZE)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
else if (ret != ARGO_CVG_HEADER_SIZE)
|
|
||||||
return AVERROR(EIO);
|
|
||||||
|
|
||||||
ctx->header.size = AV_RL32(buf + 0);
|
ctx->header.size = AV_RL32(buf + 0);
|
||||||
ctx->header.loop = AV_RL32(buf + 4);
|
ctx->header.loop = AV_RL32(buf + 4);
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
|
#include "avio_internal.h"
|
||||||
#include "demux.h"
|
#include "demux.h"
|
||||||
#include "voc.h"
|
#include "voc.h"
|
||||||
|
|
||||||
|
|
@ -113,10 +114,9 @@ avs_read_video_packet(AVFormatContext * s, AVPacket * pkt,
|
||||||
pkt->data[palette_size + 1] = type;
|
pkt->data[palette_size + 1] = type;
|
||||||
pkt->data[palette_size + 2] = size & 0xFF;
|
pkt->data[palette_size + 2] = size & 0xFF;
|
||||||
pkt->data[palette_size + 3] = (size >> 8) & 0xFF;
|
pkt->data[palette_size + 3] = (size >> 8) & 0xFF;
|
||||||
ret = avio_read(s->pb, pkt->data + palette_size + 4, size - 4) + 4;
|
ret = ffio_read_size(s->pb, pkt->data + palette_size + 4, size - 4) + 4;
|
||||||
if (ret < size) {
|
if (ret < 0)
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
}
|
|
||||||
|
|
||||||
pkt->size = ret + palette_size;
|
pkt->size = ret + palette_size;
|
||||||
pkt->stream_index = avs->st_video->index;
|
pkt->stream_index = avs->st_video->index;
|
||||||
|
|
@ -168,7 +168,7 @@ static int avs_read_packet(AVFormatContext * s, AVPacket * pkt)
|
||||||
while (1) {
|
while (1) {
|
||||||
if (avs->remaining_frame_size <= 0) {
|
if (avs->remaining_frame_size <= 0) {
|
||||||
if (!avio_rl16(s->pb)) /* found EOF */
|
if (!avio_rl16(s->pb)) /* found EOF */
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
avs->remaining_frame_size = avio_rl16(s->pb) - 4;
|
avs->remaining_frame_size = avio_rl16(s->pb) - 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -184,9 +184,9 @@ static int avs_read_packet(AVFormatContext * s, AVPacket * pkt)
|
||||||
case AVS_PALETTE:
|
case AVS_PALETTE:
|
||||||
if (size - 4 > sizeof(palette))
|
if (size - 4 > sizeof(palette))
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
ret = avio_read(s->pb, palette, size - 4);
|
ret = ffio_read_size(s->pb, palette, size - 4);
|
||||||
if (ret < size - 4)
|
if (ret < 0)
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
palette_size = size;
|
palette_size = size;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@
|
||||||
#include "libavutil/intreadwrite.h"
|
#include "libavutil/intreadwrite.h"
|
||||||
#include "libavutil/mem.h"
|
#include "libavutil/mem.h"
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
|
#include "avio_internal.h"
|
||||||
#include "demux.h"
|
#include "demux.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "libavcodec/bethsoftvideo.h"
|
#include "libavcodec/bethsoftvideo.h"
|
||||||
|
|
@ -147,10 +148,9 @@ static int read_frame(BVID_DemuxContext *vid, AVIOContext *pb, AVPacket *pkt,
|
||||||
|
|
||||||
// set the y offset if it exists (decoder header data should be in data section)
|
// set the y offset if it exists (decoder header data should be in data section)
|
||||||
if(block_type == VIDEO_YOFF_P_FRAME){
|
if(block_type == VIDEO_YOFF_P_FRAME){
|
||||||
if (avio_read(pb, &vidbuf_start[vidbuf_nbytes], 2) != 2) {
|
ret = ffio_read_size(pb, &vidbuf_start[vidbuf_nbytes], 2);
|
||||||
ret = AVERROR(EIO);
|
if (ret < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
|
||||||
vidbuf_nbytes += 2;
|
vidbuf_nbytes += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -170,10 +170,9 @@ static int read_frame(BVID_DemuxContext *vid, AVIOContext *pb, AVPacket *pkt,
|
||||||
if(block_type == VIDEO_I_FRAME)
|
if(block_type == VIDEO_I_FRAME)
|
||||||
vidbuf_start[vidbuf_nbytes++] = avio_r8(pb);
|
vidbuf_start[vidbuf_nbytes++] = avio_r8(pb);
|
||||||
} else if(code){ // plain sequence
|
} else if(code){ // plain sequence
|
||||||
if (avio_read(pb, &vidbuf_start[vidbuf_nbytes], code) != code) {
|
ret = ffio_read_size(pb, &vidbuf_start[vidbuf_nbytes], code);
|
||||||
ret = AVERROR(EIO);
|
if (ret < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
|
||||||
vidbuf_nbytes += code;
|
vidbuf_nbytes += code;
|
||||||
}
|
}
|
||||||
bytes_copied += code & 0x7F;
|
bytes_copied += code & 0x7F;
|
||||||
|
|
@ -238,9 +237,9 @@ static int vid_read_packet(AVFormatContext *s,
|
||||||
av_log(s, AV_LOG_WARNING, "discarding unused palette\n");
|
av_log(s, AV_LOG_WARNING, "discarding unused palette\n");
|
||||||
vid->has_palette = 0;
|
vid->has_palette = 0;
|
||||||
}
|
}
|
||||||
if (avio_read(pb, vid->palette, BVID_PALETTE_SIZE) != BVID_PALETTE_SIZE) {
|
ret_value = ffio_read_size(pb, vid->palette, BVID_PALETTE_SIZE);
|
||||||
return AVERROR(EIO);
|
if (ret_value < 0)
|
||||||
}
|
return ret_value;
|
||||||
vid->has_palette = 1;
|
vid->has_palette = 1;
|
||||||
return vid_read_packet(s, pkt);
|
return vid_read_packet(s, pkt);
|
||||||
|
|
||||||
|
|
@ -268,7 +267,7 @@ static int vid_read_packet(AVFormatContext *s,
|
||||||
if (ret_value < 0)
|
if (ret_value < 0)
|
||||||
return ret_value;
|
return ret_value;
|
||||||
av_log(s, AV_LOG_ERROR, "incomplete audio block\n");
|
av_log(s, AV_LOG_ERROR, "incomplete audio block\n");
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
pkt->stream_index = vid->audio_index;
|
pkt->stream_index = vid->audio_index;
|
||||||
pkt->duration = audio_length;
|
pkt->duration = audio_length;
|
||||||
|
|
@ -284,7 +283,7 @@ static int vid_read_packet(AVFormatContext *s,
|
||||||
if(vid->nframes != 0)
|
if(vid->nframes != 0)
|
||||||
av_log(s, AV_LOG_VERBOSE, "reached terminating character but not all frames read.\n");
|
av_log(s, AV_LOG_VERBOSE, "reached terminating character but not all frames read.\n");
|
||||||
vid->is_finished = 1;
|
vid->is_finished = 1;
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
default:
|
default:
|
||||||
av_log(s, AV_LOG_ERROR, "unknown block (character = %c, decimal = %d, hex = %x)!!!\n",
|
av_log(s, AV_LOG_ERROR, "unknown block (character = %c, decimal = %d, hex = %x)!!!\n",
|
||||||
block_type, block_type, block_type);
|
block_type, block_type, block_type);
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ static int bfi_read_packet(AVFormatContext * s, AVPacket * pkt)
|
||||||
uint32_t state = 0;
|
uint32_t state = 0;
|
||||||
while(state != MKTAG('S','A','V','I')){
|
while(state != MKTAG('S','A','V','I')){
|
||||||
if (avio_feof(pb))
|
if (avio_feof(pb))
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
state = 256*state + avio_r8(pb);
|
state = 256*state + avio_r8(pb);
|
||||||
}
|
}
|
||||||
/* Now that the chunk's location is confirmed, we proceed... */
|
/* Now that the chunk's location is confirmed, we proceed... */
|
||||||
|
|
|
||||||
|
|
@ -120,13 +120,13 @@ static int read_header(AVFormatContext *s)
|
||||||
|
|
||||||
if (vst->duration > 1000000) {
|
if (vst->duration > 1000000) {
|
||||||
av_log(s, AV_LOG_ERROR, "invalid header: more than 1000000 frames\n");
|
av_log(s, AV_LOG_ERROR, "invalid header: more than 1000000 frames\n");
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (avio_rl32(pb) > bink->file_size) {
|
if (avio_rl32(pb) > bink->file_size) {
|
||||||
av_log(s, AV_LOG_ERROR,
|
av_log(s, AV_LOG_ERROR,
|
||||||
"invalid header: largest frame size greater than file size\n");
|
"invalid header: largest frame size greater than file size\n");
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
avio_skip(pb, 4);
|
avio_skip(pb, 4);
|
||||||
|
|
@ -140,7 +140,7 @@ static int read_header(AVFormatContext *s)
|
||||||
av_log(s, AV_LOG_ERROR,
|
av_log(s, AV_LOG_ERROR,
|
||||||
"invalid header: invalid fps (%"PRIu32"/%"PRIu32")\n",
|
"invalid header: invalid fps (%"PRIu32"/%"PRIu32")\n",
|
||||||
fps_num, fps_den);
|
fps_num, fps_den);
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
avpriv_set_pts_info(vst, 64, fps_den, fps_num);
|
avpriv_set_pts_info(vst, 64, fps_den, fps_num);
|
||||||
vst->avg_frame_rate = av_inv_q(vst->time_base);
|
vst->avg_frame_rate = av_inv_q(vst->time_base);
|
||||||
|
|
@ -162,7 +162,7 @@ static int read_header(AVFormatContext *s)
|
||||||
av_log(s, AV_LOG_ERROR,
|
av_log(s, AV_LOG_ERROR,
|
||||||
"invalid header: more than "AV_STRINGIFY(BINK_MAX_AUDIO_TRACKS)" audio tracks (%"PRIu32")\n",
|
"invalid header: more than "AV_STRINGIFY(BINK_MAX_AUDIO_TRACKS)" audio tracks (%"PRIu32")\n",
|
||||||
bink->num_audio_tracks);
|
bink->num_audio_tracks);
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
signature = (vst->codecpar->codec_tag & 0xFFFFFF);
|
signature = (vst->codecpar->codec_tag & 0xFFFFFF);
|
||||||
|
|
@ -217,7 +217,7 @@ static int read_header(AVFormatContext *s)
|
||||||
|
|
||||||
if (next_pos <= pos) {
|
if (next_pos <= pos) {
|
||||||
av_log(s, AV_LOG_ERROR, "invalid frame index table\n");
|
av_log(s, AV_LOG_ERROR, "invalid frame index table\n");
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
if ((ret = av_add_index_entry(vst, pos, i, next_pos - pos, 0,
|
if ((ret = av_add_index_entry(vst, pos, i, next_pos - pos, 0,
|
||||||
keyframe ? AVINDEX_KEYFRAME : 0)) < 0)
|
keyframe ? AVINDEX_KEYFRAME : 0)) < 0)
|
||||||
|
|
@ -253,7 +253,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
av_log(s, AV_LOG_ERROR,
|
av_log(s, AV_LOG_ERROR,
|
||||||
"could not find index entry for frame %"PRId64"\n",
|
"could not find index entry for frame %"PRId64"\n",
|
||||||
bink->video_pts);
|
bink->video_pts);
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
bink->remain_packet_size = sti->index_entries[index_entry].size;
|
bink->remain_packet_size = sti->index_entries[index_entry].size;
|
||||||
|
|
@ -267,7 +267,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
av_log(s, AV_LOG_ERROR,
|
av_log(s, AV_LOG_ERROR,
|
||||||
"frame %"PRId64": audio size in header (%"PRIu32") > size of packet left (%"PRIu32")\n",
|
"frame %"PRId64": audio size in header (%"PRIu32") > size of packet left (%"PRIu32")\n",
|
||||||
bink->video_pts, audio_size, bink->remain_packet_size);
|
bink->video_pts, audio_size, bink->remain_packet_size);
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
bink->remain_packet_size -= 4 + audio_size;
|
bink->remain_packet_size -= 4 + audio_size;
|
||||||
bink->current_track++;
|
bink->current_track++;
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ static int binka_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
avio_skip(pb, 2);
|
avio_skip(pb, 2);
|
||||||
pkt_size = avio_rl16(pb) + 4;
|
pkt_size = avio_rl16(pb) + 4;
|
||||||
if (pkt_size <= 4)
|
if (pkt_size <= 4)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
ret = av_new_packet(pkt, pkt_size);
|
ret = av_new_packet(pkt, pkt_size);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@
|
||||||
#include "libavutil/opt.h"
|
#include "libavutil/opt.h"
|
||||||
#include "libavutil/parseutils.h"
|
#include "libavutil/parseutils.h"
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
|
#include "avio_internal.h"
|
||||||
#include "demux.h"
|
#include "demux.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "sauce.h"
|
#include "sauce.h"
|
||||||
|
|
@ -99,8 +100,8 @@ static int next_tag_read(AVFormatContext *avctx, uint64_t *fsize)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
avio_seek(pb, start_pos - 256, SEEK_SET);
|
avio_seek(pb, start_pos - 256, SEEK_SET);
|
||||||
if (avio_read(pb, buf, sizeof(next_magic)) != sizeof(next_magic))
|
if ((len = ffio_read_size(pb, buf, sizeof(next_magic))) < 0)
|
||||||
return -1;
|
return len;
|
||||||
if (memcmp(buf, next_magic, sizeof(next_magic)))
|
if (memcmp(buf, next_magic, sizeof(next_magic)))
|
||||||
return -1;
|
return -1;
|
||||||
if (avio_r8(pb) != 0x01)
|
if (avio_r8(pb) != 0x01)
|
||||||
|
|
@ -244,8 +245,8 @@ static int xbin_read_header(AVFormatContext *s)
|
||||||
return ret;
|
return ret;
|
||||||
st->codecpar->extradata[0] = fontheight;
|
st->codecpar->extradata[0] = fontheight;
|
||||||
st->codecpar->extradata[1] = flags;
|
st->codecpar->extradata[1] = flags;
|
||||||
if (avio_read(pb, st->codecpar->extradata + 2, st->codecpar->extradata_size - 2) < 0)
|
if ((ret = ffio_read_size(pb, st->codecpar->extradata + 2, st->codecpar->extradata_size - 2)) < 0)
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
|
|
||||||
if (pb->seekable & AVIO_SEEKABLE_NORMAL) {
|
if (pb->seekable & AVIO_SEEKABLE_NORMAL) {
|
||||||
int64_t fsize = avio_size(pb);
|
int64_t fsize = avio_size(pb);
|
||||||
|
|
@ -281,13 +282,13 @@ static int adf_read_header(AVFormatContext *s)
|
||||||
st->codecpar->extradata[0] = 16;
|
st->codecpar->extradata[0] = 16;
|
||||||
st->codecpar->extradata[1] = BINTEXT_PALETTE|BINTEXT_FONT;
|
st->codecpar->extradata[1] = BINTEXT_PALETTE|BINTEXT_FONT;
|
||||||
|
|
||||||
if (avio_read(pb, st->codecpar->extradata + 2, 24) < 0)
|
if ((ret = ffio_read_size(pb, st->codecpar->extradata + 2, 24)) < 0)
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
avio_skip(pb, 144);
|
avio_skip(pb, 144);
|
||||||
if (avio_read(pb, st->codecpar->extradata + 2 + 24, 24) < 0)
|
if ((ret = ffio_read_size(pb, st->codecpar->extradata + 2 + 24, 24)) < 0)
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
if (avio_read(pb, st->codecpar->extradata + 2 + 48, 4096) < 0)
|
if ((ret = ffio_read_size(pb, st->codecpar->extradata + 2 + 48, 4096)) < 0)
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
|
|
||||||
if (pb->seekable & AVIO_SEEKABLE_NORMAL) {
|
if (pb->seekable & AVIO_SEEKABLE_NORMAL) {
|
||||||
int got_width = 0;
|
int got_width = 0;
|
||||||
|
|
@ -330,7 +331,7 @@ static int idf_read_header(AVFormatContext *s)
|
||||||
int64_t fsize;
|
int64_t fsize;
|
||||||
|
|
||||||
if (!(pb->seekable & AVIO_SEEKABLE_NORMAL))
|
if (!(pb->seekable & AVIO_SEEKABLE_NORMAL))
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
st = init_stream(s);
|
st = init_stream(s);
|
||||||
if (!st)
|
if (!st)
|
||||||
|
|
@ -349,10 +350,10 @@ static int idf_read_header(AVFormatContext *s)
|
||||||
|
|
||||||
avio_seek(pb, bin->fsize + 12, SEEK_SET);
|
avio_seek(pb, bin->fsize + 12, SEEK_SET);
|
||||||
|
|
||||||
if (avio_read(pb, st->codecpar->extradata + 2 + 48, 4096) < 0)
|
if ((ret = ffio_read_size(pb, st->codecpar->extradata + 2 + 48, 4096)) < 0)
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
if (avio_read(pb, st->codecpar->extradata + 2, 48) < 0)
|
if ((ret = ffio_read_size(pb, st->codecpar->extradata + 2, 48)) < 0)
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
|
|
||||||
ff_sauce_read(s, &bin->fsize, &got_width, 0);
|
ff_sauce_read(s, &bin->fsize, &got_width, 0);
|
||||||
if (st->codecpar->width < 8)
|
if (st->codecpar->width < 8)
|
||||||
|
|
@ -371,15 +372,15 @@ static int read_packet(AVFormatContext *s,
|
||||||
|
|
||||||
if (bin->fsize > 0) {
|
if (bin->fsize > 0) {
|
||||||
if (av_get_packet(s->pb, pkt, bin->fsize) < 0)
|
if (av_get_packet(s->pb, pkt, bin->fsize) < 0)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
bin->fsize = -1; /* done */
|
bin->fsize = -1; /* done */
|
||||||
} else if (!bin->fsize) {
|
} else if (!bin->fsize) {
|
||||||
if (avio_feof(s->pb))
|
if (avio_feof(s->pb))
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
if (av_get_packet(s->pb, pkt, bin->chars_per_frame) < 0)
|
if (av_get_packet(s->pb, pkt, bin->chars_per_frame) < 0)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
} else {
|
} else {
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
pkt->flags |= AV_PKT_FLAG_KEY;
|
pkt->flags |= AV_PKT_FLAG_KEY;
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
#include "config_components.h"
|
#include "config_components.h"
|
||||||
|
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
|
#include "avio_internal.h"
|
||||||
#include "demux.h"
|
#include "demux.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "mux.h"
|
#include "mux.h"
|
||||||
|
|
@ -93,11 +94,9 @@ static int read_packet(AVFormatContext *s,
|
||||||
if(packet_size > MAX_FRAME_SIZE)
|
if(packet_size > MAX_FRAME_SIZE)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
ret = avio_read(pb, (uint8_t*)buf, (8 * packet_size) * sizeof(uint16_t));
|
ret = ffio_read_size(pb, (uint8_t*)buf, (8 * packet_size) * sizeof(uint16_t));
|
||||||
if(ret<0)
|
if(ret<0)
|
||||||
return ret;
|
return ret;
|
||||||
if(ret != 8 * packet_size * sizeof(uint16_t))
|
|
||||||
return AVERROR(EIO);
|
|
||||||
|
|
||||||
if ((ret = av_new_packet(pkt, packet_size)) < 0)
|
if ((ret = av_new_packet(pkt, packet_size)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
#include "libavutil/channel_layout.h"
|
#include "libavutil/channel_layout.h"
|
||||||
#include "libavutil/mem.h"
|
#include "libavutil/mem.h"
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
|
#include "avio_internal.h"
|
||||||
#include "demux.h"
|
#include "demux.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
@ -88,8 +89,8 @@ static int bmv_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
if ((err = av_reallocp(&c->packet, c->size + 1)) < 0)
|
if ((err = av_reallocp(&c->packet, c->size + 1)) < 0)
|
||||||
return err;
|
return err;
|
||||||
c->packet[0] = type;
|
c->packet[0] = type;
|
||||||
if (avio_read(s->pb, c->packet + 1, c->size) != c->size)
|
if ((err = ffio_read_size(s->pb, c->packet + 1, c->size)) < 0)
|
||||||
return AVERROR(EIO);
|
return err;
|
||||||
if (type & BMV_AUDIO) {
|
if (type & BMV_AUDIO) {
|
||||||
int audio_size = c->packet[1] * 65 + 1;
|
int audio_size = c->packet[1] * 65 + 1;
|
||||||
if (audio_size >= c->size) {
|
if (audio_size >= c->size) {
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
#include "libavutil/mem.h"
|
#include "libavutil/mem.h"
|
||||||
#include "libavcodec/bytestream.h"
|
#include "libavcodec/bytestream.h"
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
|
#include "avio_internal.h"
|
||||||
#include "demux.h"
|
#include "demux.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
@ -425,11 +426,11 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
(b->current_block - 1), 4 * channels);
|
(b->current_block - 1), 4 * channels);
|
||||||
|
|
||||||
for (i = 0; i < channels; i++) {
|
for (i = 0; i < channels; i++) {
|
||||||
ret = avio_read(s->pb, dst, size);
|
ret = ffio_read_size(s->pb, dst, size);
|
||||||
dst += size;
|
dst += size;
|
||||||
avio_skip(s->pb, skip);
|
avio_skip(s->pb, skip);
|
||||||
if (ret != size) {
|
if (ret < 0) {
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pkt->duration = samples;
|
pkt->duration = samples;
|
||||||
|
|
@ -441,7 +442,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
pkt->stream_index = 0;
|
pkt->stream_index = 0;
|
||||||
|
|
||||||
if (ret != size)
|
if (ret != size)
|
||||||
ret = AVERROR(EIO);
|
ret = AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
|
#include "avio_internal.h"
|
||||||
#include "demux.h"
|
#include "demux.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "voc.h"
|
#include "voc.h"
|
||||||
|
|
@ -157,9 +158,9 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
pkt->data[0] = 0;
|
pkt->data[0] = 0;
|
||||||
pkt->size = datasize + 1;
|
pkt->size = datasize + 1;
|
||||||
|
|
||||||
ret = avio_read(pb, pkt->data + 1, datasize);
|
ret = ffio_read_size(pb, pkt->data + 1, datasize);
|
||||||
if (ret < datasize) {
|
if (ret < 0) {
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
datasize = avio_rl16(pb); /* palette size */
|
datasize = avio_rl16(pb); /* palette size */
|
||||||
|
|
@ -169,9 +170,9 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
pkt->data[0] |= C93_HAS_PALETTE;
|
pkt->data[0] |= C93_HAS_PALETTE;
|
||||||
ret = avio_read(pb, pkt->data + pkt->size, datasize);
|
ret = ffio_read_size(pb, pkt->data + pkt->size, datasize);
|
||||||
if (ret < datasize) {
|
if (ret < 0) {
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
}
|
}
|
||||||
pkt->size += 768;
|
pkt->size += 768;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
|
#include "avio_internal.h"
|
||||||
#include "demux.h"
|
#include "demux.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "isom.h"
|
#include "isom.h"
|
||||||
|
|
@ -142,9 +143,9 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size)
|
||||||
avio_skip(pb, size);
|
avio_skip(pb, size);
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
if (avio_read(pb, preamble, ALAC_PREAMBLE) != ALAC_PREAMBLE) {
|
if ((ret = ffio_read_size(pb, preamble, ALAC_PREAMBLE)) < 0) {
|
||||||
av_log(s, AV_LOG_ERROR, "failed to read preamble\n");
|
av_log(s, AV_LOG_ERROR, "failed to read preamble\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = ff_alloc_extradata(st->codecpar, ALAC_HEADER)) < 0)
|
if ((ret = ff_alloc_extradata(st->codecpar, ALAC_HEADER)) < 0)
|
||||||
|
|
@ -443,7 +444,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
if (!left)
|
if (!left)
|
||||||
return AVERROR_EOF;
|
return AVERROR_EOF;
|
||||||
if (left < 0)
|
if (left < 0)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
pkt_frames = caf->frames_per_packet;
|
pkt_frames = caf->frames_per_packet;
|
||||||
|
|
@ -461,12 +462,12 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
pkt_size = caf->num_bytes - sti->index_entries[caf->packet_cnt].pos;
|
pkt_size = caf->num_bytes - sti->index_entries[caf->packet_cnt].pos;
|
||||||
pkt_frames = st->duration - sti->index_entries[caf->packet_cnt].timestamp;
|
pkt_frames = st->duration - sti->index_entries[caf->packet_cnt].timestamp;
|
||||||
} else {
|
} else {
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pkt_size == 0 || pkt_frames == 0 || pkt_size > left)
|
if (pkt_size == 0 || pkt_frames == 0 || pkt_size > left)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
res = av_get_packet(pb, pkt, pkt_size);
|
res = av_get_packet(pb, pkt, pkt_size);
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
|
|
|
||||||
|
|
@ -354,7 +354,7 @@ static int cine_read_seek(AVFormatContext *avctx, int stream_index, int64_t time
|
||||||
return AVERROR(ENOSYS);
|
return AVERROR(ENOSYS);
|
||||||
|
|
||||||
if (!(avctx->pb->seekable & AVIO_SEEKABLE_NORMAL))
|
if (!(avctx->pb->seekable & AVIO_SEEKABLE_NORMAL))
|
||||||
return AVERROR(EIO);
|
return AVERROR(ENOSYS);
|
||||||
|
|
||||||
cine->pts = timestamp;
|
cine->pts = timestamp;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ static int dfa_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
return AVERROR_EOF;
|
return AVERROR_EOF;
|
||||||
|
|
||||||
if (av_get_packet(pb, pkt, 12) != 12)
|
if (av_get_packet(pb, pkt, 12) != 12)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
while (!avio_feof(pb)) {
|
while (!avio_feof(pb)) {
|
||||||
if (!first) {
|
if (!first) {
|
||||||
ret = av_append_packet(pb, pkt, 12);
|
ret = av_append_packet(pb, pkt, 12);
|
||||||
|
|
@ -101,7 +101,7 @@ static int dfa_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
frame_size = AV_RL32(pkt->data + pkt->size - 8);
|
frame_size = AV_RL32(pkt->data + pkt->size - 8);
|
||||||
if (frame_size > INT_MAX - 4) {
|
if (frame_size > INT_MAX - 4) {
|
||||||
av_log(s, AV_LOG_ERROR, "Too large chunk size: %"PRIu32"\n", frame_size);
|
av_log(s, AV_LOG_ERROR, "Too large chunk size: %"PRIu32"\n", frame_size);
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
if (AV_RL32(pkt->data + pkt->size - 12) == MKTAG('E', 'O', 'F', 'R')) {
|
if (AV_RL32(pkt->data + pkt->size - 12) == MKTAG('E', 'O', 'F', 'R')) {
|
||||||
if (frame_size) {
|
if (frame_size) {
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,7 @@ static int cin_read_frame_header(CinDemuxContext *cin, AVIOContext *pb) {
|
||||||
hdr->audio_frame_size = avio_rl32(pb);
|
hdr->audio_frame_size = avio_rl32(pb);
|
||||||
|
|
||||||
if (avio_feof(pb) || pb->error)
|
if (avio_feof(pb) || pb->error)
|
||||||
return AVERROR(EIO);
|
return pb->error ? pb->error : AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
if (avio_rl32(pb) != 0xAA55AA55)
|
if (avio_rl32(pb) != 0xAA55AA55)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,7 @@ static int dss_read_header(AVFormatContext *s)
|
||||||
DSSDemuxContext *ctx = s->priv_data;
|
DSSDemuxContext *ctx = s->priv_data;
|
||||||
AVIOContext *pb = s->pb;
|
AVIOContext *pb = s->pb;
|
||||||
AVStream *st;
|
AVStream *st;
|
||||||
|
int64_t ret64;
|
||||||
int ret, version;
|
int ret, version;
|
||||||
|
|
||||||
st = avformat_new_stream(s, NULL);
|
st = avformat_new_stream(s, NULL);
|
||||||
|
|
@ -164,8 +165,8 @@ static int dss_read_header(AVFormatContext *s)
|
||||||
|
|
||||||
/* Jump over header */
|
/* Jump over header */
|
||||||
|
|
||||||
if (avio_seek(pb, ctx->dss_header_size, SEEK_SET) != ctx->dss_header_size)
|
if ((ret64 = avio_seek(pb, ctx->dss_header_size, SEEK_SET)) < 0)
|
||||||
return AVERROR(EIO);
|
return (int)ret64;
|
||||||
|
|
||||||
ctx->counter = 0;
|
ctx->counter = 0;
|
||||||
ctx->swap = 0;
|
ctx->swap = 0;
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
|
#include "avio_internal.h"
|
||||||
#include "demux.h"
|
#include "demux.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "libavcodec/dv_profile.h"
|
#include "libavcodec/dv_profile.h"
|
||||||
|
|
@ -576,6 +577,7 @@ static int dv_read_header(AVFormatContext *s)
|
||||||
{
|
{
|
||||||
unsigned state, marker_pos = 0;
|
unsigned state, marker_pos = 0;
|
||||||
RawDVContext *c = s->priv_data;
|
RawDVContext *c = s->priv_data;
|
||||||
|
int64_t ret64;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if ((ret = dv_init_demux(s, &c->dv_demux)) < 0)
|
if ((ret = dv_init_demux(s, &c->dv_demux)) < 0)
|
||||||
|
|
@ -598,10 +600,10 @@ static int dv_read_header(AVFormatContext *s)
|
||||||
}
|
}
|
||||||
AV_WB32(c->buf, state);
|
AV_WB32(c->buf, state);
|
||||||
|
|
||||||
if (avio_read(s->pb, c->buf + 4, DV_PROFILE_BYTES - 4) != DV_PROFILE_BYTES - 4 ||
|
if ((ret = ffio_read_size(s->pb, c->buf + 4, DV_PROFILE_BYTES - 4)) < 0)
|
||||||
avio_seek(s->pb, -DV_PROFILE_BYTES, SEEK_CUR) < 0) {
|
return ret;
|
||||||
return AVERROR(EIO);
|
if ((ret64 = avio_seek(s->pb, -DV_PROFILE_BYTES, SEEK_CUR)) < 0)
|
||||||
}
|
return (int)ret64;
|
||||||
|
|
||||||
c->dv_demux.sys = av_dv_frame_profile(c->dv_demux.sys,
|
c->dv_demux.sys = av_dv_frame_profile(c->dv_demux.sys,
|
||||||
c->buf,
|
c->buf,
|
||||||
|
|
@ -633,13 +635,13 @@ static int dv_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
int ret;
|
int ret;
|
||||||
int64_t pos = avio_tell(s->pb);
|
int64_t pos = avio_tell(s->pb);
|
||||||
if (!c->dv_demux.sys)
|
if (!c->dv_demux.sys)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
size = c->dv_demux.sys->frame_size;
|
size = c->dv_demux.sys->frame_size;
|
||||||
ret = avio_read(s->pb, c->buf, size);
|
ret = avio_read(s->pb, c->buf, size);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
return ret;
|
return ret;
|
||||||
} else if (ret == 0) {
|
} else if (ret == 0) {
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
size = avpriv_dv_produce_packet(&c->dv_demux, pkt, c->buf, size, pos);
|
size = avpriv_dv_produce_packet(&c->dv_demux, pkt, c->buf, size, pos);
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
#include "libavutil/intreadwrite.h"
|
#include "libavutil/intreadwrite.h"
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
|
#include "avio_internal.h"
|
||||||
#include "demux.h"
|
#include "demux.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "riff.h"
|
#include "riff.h"
|
||||||
|
|
@ -170,7 +171,7 @@ static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
ret = av_get_packet(s->pb, pkt, size);
|
ret = av_get_packet(s->pb, pkt, size);
|
||||||
pkt->stream_index = 1;
|
pkt->stream_index = 1;
|
||||||
if(ret != size)
|
if(ret != size)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
c->bytes_left -= size;
|
c->bytes_left -= size;
|
||||||
c->wavpos = avio_tell(s->pb);
|
c->wavpos = avio_tell(s->pb);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -214,10 +215,9 @@ static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
memcpy(pkt->data + pal_size, buf, DXA_EXTRA_SIZE);
|
memcpy(pkt->data + pal_size, buf, DXA_EXTRA_SIZE);
|
||||||
ret = avio_read(s->pb, pkt->data + DXA_EXTRA_SIZE + pal_size, size);
|
ret = ffio_read_size(s->pb, pkt->data + DXA_EXTRA_SIZE + pal_size, size);
|
||||||
if(ret != size){
|
if (ret < 0)
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
}
|
|
||||||
if(pal_size) memcpy(pkt->data, pal, pal_size);
|
if(pal_size) memcpy(pkt->data, pal, pal_size);
|
||||||
pkt->stream_index = 0;
|
pkt->stream_index = 0;
|
||||||
c->frames--;
|
c->frames--;
|
||||||
|
|
|
||||||
|
|
@ -537,7 +537,7 @@ static int ea_read_header(AVFormatContext *s)
|
||||||
AVStream *st;
|
AVStream *st;
|
||||||
|
|
||||||
if (process_ea_header(s)<=0)
|
if (process_ea_header(s)<=0)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
if (init_video_stream(s, &ea->video) || init_video_stream(s, &ea->alpha))
|
if (init_video_stream(s, &ea->video) || init_video_stream(s, &ea->alpha))
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ static int read_header(AVFormatContext *s)
|
||||||
AVStream *st;
|
AVStream *st;
|
||||||
|
|
||||||
if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL))
|
if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL))
|
||||||
return AVERROR(EIO);
|
return AVERROR(ENOSYS);
|
||||||
|
|
||||||
avio_seek(pb, avio_size(pb) - 36, SEEK_SET);
|
avio_seek(pb, avio_size(pb) - 36, SEEK_SET);
|
||||||
if (avio_rb32(pb) != RAND_TAG) {
|
if (avio_rb32(pb) != RAND_TAG) {
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@
|
||||||
#include "libavutil/channel_layout.h"
|
#include "libavutil/channel_layout.h"
|
||||||
#include "libavutil/intreadwrite.h"
|
#include "libavutil/intreadwrite.h"
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
|
#include "avio_internal.h"
|
||||||
#include "demux.h"
|
#include "demux.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
@ -97,8 +98,8 @@ static int flic_read_header(AVFormatContext *s)
|
||||||
flic->frame_number = 0;
|
flic->frame_number = 0;
|
||||||
|
|
||||||
/* load the whole header and pull out the width and height */
|
/* load the whole header and pull out the width and height */
|
||||||
if (avio_read(pb, header, FLIC_HEADER_SIZE) != FLIC_HEADER_SIZE)
|
if ((ret = ffio_read_size(pb, header, FLIC_HEADER_SIZE)) < 0)
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
|
|
||||||
magic_number = AV_RL16(&header[4]);
|
magic_number = AV_RL16(&header[4]);
|
||||||
speed = AV_RL32(&header[0x10]);
|
speed = AV_RL32(&header[0x10]);
|
||||||
|
|
@ -131,9 +132,9 @@ static int flic_read_header(AVFormatContext *s)
|
||||||
memcpy(st->codecpar->extradata, header, FLIC_HEADER_SIZE);
|
memcpy(st->codecpar->extradata, header, FLIC_HEADER_SIZE);
|
||||||
|
|
||||||
/* peek at the preamble to detect TFTD videos - they seem to always start with an audio chunk */
|
/* peek at the preamble to detect TFTD videos - they seem to always start with an audio chunk */
|
||||||
if (avio_read(pb, preamble, FLIC_PREAMBLE_SIZE) != FLIC_PREAMBLE_SIZE) {
|
if ((ret = ffio_read_size(pb, preamble, FLIC_PREAMBLE_SIZE)) < 0) {
|
||||||
av_log(s, AV_LOG_ERROR, "Failed to peek at preamble\n");
|
av_log(s, AV_LOG_ERROR, "Failed to peek at preamble\n");
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
avio_seek(pb, -FLIC_PREAMBLE_SIZE, SEEK_CUR);
|
avio_seek(pb, -FLIC_PREAMBLE_SIZE, SEEK_CUR);
|
||||||
|
|
@ -206,11 +207,8 @@ static int flic_read_packet(AVFormatContext *s,
|
||||||
|
|
||||||
while (!packet_read && !avio_feof(pb)) {
|
while (!packet_read && !avio_feof(pb)) {
|
||||||
|
|
||||||
if ((ret = avio_read(pb, preamble, FLIC_PREAMBLE_SIZE)) !=
|
if ((ret = ffio_read_size(pb, preamble, FLIC_PREAMBLE_SIZE)) < 0)
|
||||||
FLIC_PREAMBLE_SIZE) {
|
|
||||||
ret = AVERROR(EIO);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
size = AV_RL32(&preamble[0]);
|
size = AV_RL32(&preamble[0]);
|
||||||
magic = AV_RL16(&preamble[4]);
|
magic = AV_RL16(&preamble[4]);
|
||||||
|
|
@ -222,11 +220,8 @@ static int flic_read_packet(AVFormatContext *s,
|
||||||
pkt->stream_index = flic->video_stream_index;
|
pkt->stream_index = flic->video_stream_index;
|
||||||
pkt->pos = pos;
|
pkt->pos = pos;
|
||||||
memcpy(pkt->data, preamble, FLIC_PREAMBLE_SIZE);
|
memcpy(pkt->data, preamble, FLIC_PREAMBLE_SIZE);
|
||||||
ret = avio_read(pb, pkt->data + FLIC_PREAMBLE_SIZE,
|
ret = ffio_read_size(pb, pkt->data + FLIC_PREAMBLE_SIZE,
|
||||||
size - FLIC_PREAMBLE_SIZE);
|
size - FLIC_PREAMBLE_SIZE);
|
||||||
if (ret != size - FLIC_PREAMBLE_SIZE) {
|
|
||||||
ret = AVERROR(EIO);
|
|
||||||
}
|
|
||||||
pkt->flags = flic->frame_number == 0 ? AV_PKT_FLAG_KEY : 0;
|
pkt->flags = flic->frame_number == 0 ? AV_PKT_FLAG_KEY : 0;
|
||||||
pkt->pts = flic->frame_number;
|
pkt->pts = flic->frame_number;
|
||||||
if (flic->frame_number == 0)
|
if (flic->frame_number == 0)
|
||||||
|
|
@ -243,12 +238,10 @@ static int flic_read_packet(AVFormatContext *s,
|
||||||
pkt->stream_index = flic->audio_stream_index;
|
pkt->stream_index = flic->audio_stream_index;
|
||||||
pkt->pos = pos;
|
pkt->pos = pos;
|
||||||
pkt->flags = AV_PKT_FLAG_KEY;
|
pkt->flags = AV_PKT_FLAG_KEY;
|
||||||
ret = avio_read(pb, pkt->data, size);
|
ret = ffio_read_size(pb, pkt->data, size);
|
||||||
|
|
||||||
if (ret != size) {
|
if (ret < 0)
|
||||||
ret = AVERROR(EIO);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
packet_read = 1;
|
packet_read = 1;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,7 @@ static int gif_read_header(AVFormatContext *s)
|
||||||
AVStream *st;
|
AVStream *st;
|
||||||
int type, width, height, ret, n, flags;
|
int type, width, height, ret, n, flags;
|
||||||
int64_t nb_frames = 0, duration = 0, pos;
|
int64_t nb_frames = 0, duration = 0, pos;
|
||||||
|
int64_t ret64;
|
||||||
|
|
||||||
if ((ret = resync(pb)) < 0)
|
if ((ret = resync(pb)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
@ -215,8 +216,9 @@ static int gif_read_header(AVFormatContext *s)
|
||||||
|
|
||||||
skip:
|
skip:
|
||||||
/* jump to start because gif decoder needs header data too */
|
/* jump to start because gif decoder needs header data too */
|
||||||
if (avio_seek(pb, pos - 6, SEEK_SET) != pos - 6)
|
ret64 = avio_seek(pb, pos - 6, SEEK_SET);
|
||||||
return AVERROR(EIO);
|
if (ret64 < 0)
|
||||||
|
return (int)ret64;
|
||||||
|
|
||||||
/* GIF format operates with time in "hundredths of second",
|
/* GIF format operates with time in "hundredths of second",
|
||||||
* therefore timebase is 1/100 */
|
* therefore timebase is 1/100 */
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ static int gsm_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
|
|
||||||
ret = av_get_packet(s->pb, pkt, size);
|
ret = av_get_packet(s->pb, pkt, size);
|
||||||
if (ret < GSM_BLOCK_SIZE) {
|
if (ret < GSM_BLOCK_SIZE) {
|
||||||
return ret < 0 ? ret : AVERROR(EIO);
|
return ret < 0 ? ret : AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
pkt->duration = 1;
|
pkt->duration = 1;
|
||||||
pkt->pts = pkt->pos / GSM_BLOCK_SIZE;
|
pkt->pts = pkt->pos / GSM_BLOCK_SIZE;
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
#include "libavcodec/bytestream.h"
|
#include "libavcodec/bytestream.h"
|
||||||
|
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
|
#include "avio_internal.h"
|
||||||
#include "demux.h"
|
#include "demux.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
@ -76,9 +77,9 @@ static int hca_read_header(AVFormatContext *s)
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = avio_read(pb, par->extradata + 8, par->extradata_size - 8 - 10);
|
ret = ffio_read_size(pb, par->extradata + 8, par->extradata_size - 8 - 10);
|
||||||
if (ret < par->extradata_size - 8 - 10)
|
if (ret < 0)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
AV_WL32(par->extradata, MKTAG('H', 'C', 'A', 0));
|
AV_WL32(par->extradata, MKTAG('H', 'C', 'A', 0));
|
||||||
AV_WB16(par->extradata + 4, version);
|
AV_WB16(par->extradata + 4, version);
|
||||||
AV_WB16(par->extradata + 6, data_offset);
|
AV_WB16(par->extradata + 6, data_offset);
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,7 @@ static int ico_write_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
|
|
||||||
if (ico->current_image >= ico->nb_images) {
|
if (ico->current_image >= ico->nb_images) {
|
||||||
av_log(s, AV_LOG_ERROR, "ICO already contains %d images\n", ico->current_image);
|
av_log(s, AV_LOG_ERROR, "ICO already contains %d images\n", ico->current_image);
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
image = &ico->images[ico->current_image++];
|
image = &ico->images[ico->current_image++];
|
||||||
|
|
|
||||||
|
|
@ -267,7 +267,7 @@ static int idcin_read_packet(AVFormatContext *s,
|
||||||
if (idcin->next_chunk_is_video) {
|
if (idcin->next_chunk_is_video) {
|
||||||
command = avio_rl32(pb);
|
command = avio_rl32(pb);
|
||||||
if (command == 2) {
|
if (command == 2) {
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
} else if (command == 1) {
|
} else if (command == 1) {
|
||||||
/* trigger a palette change */
|
/* trigger a palette change */
|
||||||
ret = avio_read(pb, palette_buffer, 768);
|
ret = avio_read(pb, palette_buffer, 768);
|
||||||
|
|
@ -275,7 +275,7 @@ static int idcin_read_packet(AVFormatContext *s,
|
||||||
return ret;
|
return ret;
|
||||||
} else if (ret != 768) {
|
} else if (ret != 768) {
|
||||||
av_log(s, AV_LOG_ERROR, "incomplete packet\n");
|
av_log(s, AV_LOG_ERROR, "incomplete packet\n");
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
/* scale the palette as necessary */
|
/* scale the palette as necessary */
|
||||||
palette_scale = 2;
|
palette_scale = 2;
|
||||||
|
|
@ -312,7 +312,7 @@ static int idcin_read_packet(AVFormatContext *s,
|
||||||
return ret;
|
return ret;
|
||||||
else if (ret != chunk_size) {
|
else if (ret != chunk_size) {
|
||||||
av_log(s, AV_LOG_ERROR, "incomplete packet\n");
|
av_log(s, AV_LOG_ERROR, "incomplete packet\n");
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
if (command == 1) {
|
if (command == 1) {
|
||||||
uint8_t *pal;
|
uint8_t *pal;
|
||||||
|
|
|
||||||
|
|
@ -74,11 +74,11 @@ static int roq_read_header(AVFormatContext *s)
|
||||||
RoqDemuxContext *roq = s->priv_data;
|
RoqDemuxContext *roq = s->priv_data;
|
||||||
AVIOContext *pb = s->pb;
|
AVIOContext *pb = s->pb;
|
||||||
unsigned char preamble[RoQ_CHUNK_PREAMBLE_SIZE];
|
unsigned char preamble[RoQ_CHUNK_PREAMBLE_SIZE];
|
||||||
|
int ret;
|
||||||
|
|
||||||
/* get the main header */
|
/* get the main header */
|
||||||
if (avio_read(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) !=
|
if ((ret = ffio_read_size(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE)) < 0)
|
||||||
RoQ_CHUNK_PREAMBLE_SIZE)
|
return ret;
|
||||||
return AVERROR(EIO);
|
|
||||||
roq->frame_rate = AV_RL16(&preamble[6]);
|
roq->frame_rate = AV_RL16(&preamble[6]);
|
||||||
|
|
||||||
/* init private context parameters */
|
/* init private context parameters */
|
||||||
|
|
@ -111,9 +111,8 @@ static int roq_read_packet(AVFormatContext *s,
|
||||||
return AVERROR_EOF;
|
return AVERROR_EOF;
|
||||||
|
|
||||||
/* get the next chunk preamble */
|
/* get the next chunk preamble */
|
||||||
if ((ret = avio_read(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE)) !=
|
if ((ret = ffio_read_size(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE)) < 0)
|
||||||
RoQ_CHUNK_PREAMBLE_SIZE)
|
return ret;
|
||||||
return AVERROR(EIO);
|
|
||||||
|
|
||||||
chunk_type = AV_RL16(&preamble[0]);
|
chunk_type = AV_RL16(&preamble[0]);
|
||||||
chunk_size = AV_RL32(&preamble[2]);
|
chunk_size = AV_RL32(&preamble[2]);
|
||||||
|
|
@ -135,8 +134,8 @@ static int roq_read_packet(AVFormatContext *s,
|
||||||
st->codecpar->codec_id = AV_CODEC_ID_ROQ;
|
st->codecpar->codec_id = AV_CODEC_ID_ROQ;
|
||||||
st->codecpar->codec_tag = 0; /* no fourcc */
|
st->codecpar->codec_tag = 0; /* no fourcc */
|
||||||
|
|
||||||
if (avio_read(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) != RoQ_CHUNK_PREAMBLE_SIZE)
|
if ((ret = ffio_read_size(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE)) < 0)
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
st->codecpar->width = roq->width = AV_RL16(preamble);
|
st->codecpar->width = roq->width = AV_RL16(preamble);
|
||||||
st->codecpar->height = roq->height = AV_RL16(preamble + 2);
|
st->codecpar->height = roq->height = AV_RL16(preamble + 2);
|
||||||
break;
|
break;
|
||||||
|
|
@ -152,9 +151,8 @@ static int roq_read_packet(AVFormatContext *s,
|
||||||
codebook_offset = avio_tell(pb) - RoQ_CHUNK_PREAMBLE_SIZE;
|
codebook_offset = avio_tell(pb) - RoQ_CHUNK_PREAMBLE_SIZE;
|
||||||
codebook_size = chunk_size;
|
codebook_size = chunk_size;
|
||||||
avio_skip(pb, codebook_size);
|
avio_skip(pb, codebook_size);
|
||||||
if (avio_read(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE) !=
|
if ((ret = ffio_read_size(pb, preamble, RoQ_CHUNK_PREAMBLE_SIZE)) < 0)
|
||||||
RoQ_CHUNK_PREAMBLE_SIZE)
|
return ret;
|
||||||
return AVERROR(EIO);
|
|
||||||
chunk_size = AV_RL32(&preamble[2]) + RoQ_CHUNK_PREAMBLE_SIZE * 2 +
|
chunk_size = AV_RL32(&preamble[2]) + RoQ_CHUNK_PREAMBLE_SIZE * 2 +
|
||||||
codebook_size;
|
codebook_size;
|
||||||
|
|
||||||
|
|
@ -167,7 +165,7 @@ static int roq_read_packet(AVFormatContext *s,
|
||||||
/* load up the packet */
|
/* load up the packet */
|
||||||
ret= av_get_packet(pb, pkt, chunk_size);
|
ret= av_get_packet(pb, pkt, chunk_size);
|
||||||
if (ret != chunk_size)
|
if (ret != chunk_size)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
pkt->stream_index = roq->video_stream_index;
|
pkt->stream_index = roq->video_stream_index;
|
||||||
pkt->pts = roq->video_pts++;
|
pkt->pts = roq->video_pts++;
|
||||||
|
|
||||||
|
|
@ -220,11 +218,10 @@ static int roq_read_packet(AVFormatContext *s,
|
||||||
}
|
}
|
||||||
|
|
||||||
pkt->pos= avio_tell(pb);
|
pkt->pos= avio_tell(pb);
|
||||||
ret = avio_read(pb, pkt->data + RoQ_CHUNK_PREAMBLE_SIZE,
|
ret = ffio_read_size(pb, pkt->data + RoQ_CHUNK_PREAMBLE_SIZE,
|
||||||
chunk_size);
|
chunk_size);
|
||||||
if (ret != chunk_size) {
|
if (ret < 0)
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
}
|
|
||||||
|
|
||||||
packet_read = 1;
|
packet_read = 1;
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@
|
||||||
#include "libavutil/mem.h"
|
#include "libavutil/mem.h"
|
||||||
#include "libavcodec/bytestream.h"
|
#include "libavcodec/bytestream.h"
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
|
#include "avio_internal.h"
|
||||||
#include "demux.h"
|
#include "demux.h"
|
||||||
#include "id3v2.h"
|
#include "id3v2.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
@ -135,13 +136,14 @@ static int get_metadata(AVFormatContext *s,
|
||||||
const unsigned data_size)
|
const unsigned data_size)
|
||||||
{
|
{
|
||||||
uint8_t *buf = ((data_size + 1) == 0) ? NULL : av_malloc(data_size + 1);
|
uint8_t *buf = ((data_size + 1) == 0) ? NULL : av_malloc(data_size + 1);
|
||||||
|
int res;
|
||||||
|
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
if (avio_read(s->pb, buf, data_size) != data_size) {
|
if ((res = ffio_read_size(s->pb, buf, data_size)) < 0) {
|
||||||
av_free(buf);
|
av_free(buf);
|
||||||
return AVERROR(EIO);
|
return res;
|
||||||
}
|
}
|
||||||
buf[data_size] = 0;
|
buf[data_size] = 0;
|
||||||
av_dict_set(&s->metadata, tag, buf, AV_DICT_DONT_STRDUP_VAL);
|
av_dict_set(&s->metadata, tag, buf, AV_DICT_DONT_STRDUP_VAL);
|
||||||
|
|
@ -563,10 +565,10 @@ static int iff_read_header(AVFormatContext *s)
|
||||||
data_size + IFF_EXTRA_VIDEO_SIZE);
|
data_size + IFF_EXTRA_VIDEO_SIZE);
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
return res;
|
return res;
|
||||||
if (avio_read(pb, stv->codecpar->extradata + IFF_EXTRA_VIDEO_SIZE, data_size) < 0) {
|
if ((res = avio_read(pb, stv->codecpar->extradata + IFF_EXTRA_VIDEO_SIZE, data_size)) < 0) {
|
||||||
av_freep(&stv->codecpar->extradata);
|
av_freep(&stv->codecpar->extradata);
|
||||||
stv->codecpar->extradata_size = 0;
|
stv->codecpar->extradata_size = 0;
|
||||||
return AVERROR(EIO);
|
return res;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -400,13 +400,13 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt)
|
||||||
!s->loop &&
|
!s->loop &&
|
||||||
!s->split_planes) {
|
!s->split_planes) {
|
||||||
f[i] = s1->pb;
|
f[i] = s1->pb;
|
||||||
} else if (s1->io_open(s1, &f[i], filename.str, AVIO_FLAG_READ, NULL) < 0) {
|
} else if ((res = s1->io_open(s1, &f[i], filename.str, AVIO_FLAG_READ, NULL)) < 0) {
|
||||||
if (i >= 1)
|
if (i >= 1)
|
||||||
break;
|
break;
|
||||||
av_log(s1, AV_LOG_ERROR, "Could not open file : %s\n",
|
av_log(s1, AV_LOG_ERROR, "Could not open file : %s\n",
|
||||||
filename.str);
|
filename.str);
|
||||||
av_bprint_finalize(&filename, NULL);
|
av_bprint_finalize(&filename, NULL);
|
||||||
return AVERROR(EIO);
|
return res;
|
||||||
}
|
}
|
||||||
size[i] = avio_size(f[i]);
|
size[i] = avio_size(f[i]);
|
||||||
|
|
||||||
|
|
@ -466,7 +466,7 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket *pkt)
|
||||||
struct stat img_stat;
|
struct stat img_stat;
|
||||||
av_assert0(!s->is_pipe); // The ts_from_file option is not supported by piped input demuxers
|
av_assert0(!s->is_pipe); // The ts_from_file option is not supported by piped input demuxers
|
||||||
if (stat(filename.str, &img_stat)) {
|
if (stat(filename.str, &img_stat)) {
|
||||||
res = AVERROR(EIO);
|
res = AVERROR(errno);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
pkt->pts = (int64_t)img_stat.st_mtime;
|
pkt->pts = (int64_t)img_stat.st_mtime;
|
||||||
|
|
|
||||||
|
|
@ -194,9 +194,8 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (s->io_open(s, &pb[i], tmp[i] ? tmp[i] : filename.str, AVIO_FLAG_WRITE, &options) < 0) {
|
if ((ret = s->io_open(s, &pb[i], tmp[i] ? tmp[i] : filename.str, AVIO_FLAG_WRITE, &options)) < 0) {
|
||||||
av_log(s, AV_LOG_ERROR, "Could not open file : %s\n", tmp[i] ? tmp[i] : filename.str);
|
av_log(s, AV_LOG_ERROR, "Could not open file : %s\n", tmp[i] ? tmp[i] : filename.str);
|
||||||
ret = AVERROR(EIO);
|
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
if (options) {
|
if (options) {
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ static int ingenient_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
int ret, size, w, h, unk1, unk2;
|
int ret, size, w, h, unk1, unk2;
|
||||||
|
|
||||||
if (avio_rl32(s->pb) != MKTAG('M', 'J', 'P', 'G'))
|
if (avio_rl32(s->pb) != MKTAG('M', 'J', 'P', 'G'))
|
||||||
return AVERROR(EIO); // FIXME
|
return AVERROR_INVALIDDATA; // FIXME
|
||||||
|
|
||||||
size = avio_rl32(s->pb);
|
size = avio_rl32(s->pb);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -639,9 +639,8 @@ static int ipmovie_read_header(AVFormatContext *s)
|
||||||
|
|
||||||
/* peek ahead to the next chunk-- if it is an init audio chunk, process
|
/* peek ahead to the next chunk-- if it is an init audio chunk, process
|
||||||
* it; if it is the first video chunk, this is a silent file */
|
* it; if it is the first video chunk, this is a silent file */
|
||||||
if (avio_read(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
|
if ((ret = ffio_read_size(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE)) < 0)
|
||||||
CHUNK_PREAMBLE_SIZE)
|
return ret;
|
||||||
return AVERROR(EIO);
|
|
||||||
chunk_type = AV_RL16(&chunk_preamble[2]);
|
chunk_type = AV_RL16(&chunk_preamble[2]);
|
||||||
avio_seek(pb, -CHUNK_PREAMBLE_SIZE, SEEK_CUR);
|
avio_seek(pb, -CHUNK_PREAMBLE_SIZE, SEEK_CUR);
|
||||||
|
|
||||||
|
|
@ -688,7 +687,7 @@ static int ipmovie_read_packet(AVFormatContext *s,
|
||||||
if (ret == CHUNK_BAD)
|
if (ret == CHUNK_BAD)
|
||||||
ret = AVERROR_INVALIDDATA;
|
ret = AVERROR_INVALIDDATA;
|
||||||
else if (ret == CHUNK_EOF)
|
else if (ret == CHUNK_EOF)
|
||||||
ret = AVERROR(EIO);
|
ret = AVERROR_INVALIDDATA;
|
||||||
else if (ret == CHUNK_NOMEM)
|
else if (ret == CHUNK_NOMEM)
|
||||||
ret = AVERROR(ENOMEM);
|
ret = AVERROR(ENOMEM);
|
||||||
else if (ret == CHUNK_END || ret == CHUNK_SHUTDOWN)
|
else if (ret == CHUNK_END || ret == CHUNK_SHUTDOWN)
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ static int iss_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
int ret = av_get_packet(s->pb, pkt, iss->packet_size);
|
int ret = av_get_packet(s->pb, pkt, iss->packet_size);
|
||||||
|
|
||||||
if(ret != iss->packet_size)
|
if(ret != iss->packet_size)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
pkt->stream_index = 0;
|
pkt->stream_index = 0;
|
||||||
pkt->pts = avio_tell(s->pb) - iss->sample_start_pos;
|
pkt->pts = avio_tell(s->pb) - iss->sample_start_pos;
|
||||||
|
|
|
||||||
|
|
@ -217,7 +217,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
if (s->pb->eof_reached)
|
if (s->pb->eof_reached)
|
||||||
return AVERROR_EOF;
|
return AVERROR_EOF;
|
||||||
|
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int read_seek(AVFormatContext *s, int stream_index,
|
static int read_seek(AVFormatContext *s, int stream_index,
|
||||||
|
|
|
||||||
|
|
@ -348,7 +348,7 @@ static int modplug_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
|
|
||||||
pkt->size = ModPlug_Read(modplug->f, pkt->data, AUDIO_PKT_SIZE);
|
pkt->size = ModPlug_Read(modplug->f, pkt->data, AUDIO_PKT_SIZE);
|
||||||
if (pkt->size <= 0) {
|
if (pkt->size <= 0) {
|
||||||
return pkt->size == 0 ? AVERROR_EOF : AVERROR(EIO);
|
return pkt->size == 0 ? AVERROR_EOF : AVERROR_EXTERNAL;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ static int lmlm4_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
|
|
||||||
frame_size = packet_size - 8;
|
frame_size = packet_size - 8;
|
||||||
if ((ret = av_get_packet(pb, pkt, frame_size)) <= 0)
|
if ((ret = av_get_packet(pb, pkt, frame_size)) <= 0)
|
||||||
return ret < 0 ? ret : AVERROR(EIO);
|
return ret < 0 ? ret : AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
avio_skip(pb, padding);
|
avio_skip(pb, padding);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ static int read_header(AVFormatContext *s)
|
||||||
if (version <= 4) {
|
if (version <= 4) {
|
||||||
// version <= 4 needs to use the file size to calculate the offsets
|
// version <= 4 needs to use the file size to calculate the offsets
|
||||||
if (file_size < 0) {
|
if (file_size < 0) {
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
if (file_size - data_size > UINT32_MAX)
|
if (file_size - data_size > UINT32_MAX)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ static int read_header(AVFormatContext *s)
|
||||||
avio_skip(pb, 4);
|
avio_skip(pb, 4);
|
||||||
chunk_size = avio_rb32(pb);
|
chunk_size = avio_rb32(pb);
|
||||||
if (chunk_size != 80)
|
if (chunk_size != 80)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
avio_skip(pb, 20);
|
avio_skip(pb, 20);
|
||||||
|
|
||||||
st = avformat_new_stream(s, 0);
|
st = avformat_new_stream(s, 0);
|
||||||
|
|
@ -84,7 +84,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
payload_size = avio_rb32(pb);
|
payload_size = avio_rb32(pb);
|
||||||
|
|
||||||
if (chunk_size < payload_size + 16)
|
if (chunk_size < payload_size + 16)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
ret = av_get_packet(pb, pkt, payload_size);
|
ret = av_get_packet(pb, pkt, payload_size);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
|
|
||||||
|
|
@ -548,7 +548,7 @@ static int read_packet(AVFormatContext *avctx, AVPacket *pkt)
|
||||||
index = av_index_search_timestamp(st, mlv->pts, AVSEEK_FLAG_ANY);
|
index = av_index_search_timestamp(st, mlv->pts, AVSEEK_FLAG_ANY);
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "could not find index entry for frame %"PRId64"\n", mlv->pts);
|
av_log(avctx, AV_LOG_ERROR, "could not find index entry for frame %"PRId64"\n", mlv->pts);
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
pb = mlv->pb[sti->index_entries[index].size];
|
pb = mlv->pb[sti->index_entries[index].size];
|
||||||
|
|
@ -611,7 +611,7 @@ static int read_seek(AVFormatContext *avctx, int stream_index, int64_t timestamp
|
||||||
return AVERROR(ENOSYS);
|
return AVERROR(ENOSYS);
|
||||||
|
|
||||||
if (!(avctx->pb->seekable & AVIO_SEEKABLE_NORMAL))
|
if (!(avctx->pb->seekable & AVIO_SEEKABLE_NORMAL))
|
||||||
return AVERROR(EIO);
|
return AVERROR(ENOSYS);
|
||||||
|
|
||||||
mlv->pts = timestamp;
|
mlv->pts = timestamp;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -171,7 +171,7 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
if(c->curbits)
|
if(c->curbits)
|
||||||
avio_seek(s->pb, -4, SEEK_CUR);
|
avio_seek(s->pb, -4, SEEK_CUR);
|
||||||
if(ret < size){
|
if(ret < size){
|
||||||
return ret < 0 ? ret : AVERROR(EIO);
|
return ret < 0 ? ret : AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
pkt->size = ret + 4;
|
pkt->size = ret + 4;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,7 @@ static int mtv_read_header(AVFormatContext *s)
|
||||||
AVIOContext *pb = s->pb;
|
AVIOContext *pb = s->pb;
|
||||||
AVStream *st;
|
AVStream *st;
|
||||||
unsigned int audio_subsegments;
|
unsigned int audio_subsegments;
|
||||||
|
int64_t ret64;
|
||||||
|
|
||||||
avio_skip(pb, 3);
|
avio_skip(pb, 3);
|
||||||
mtv->file_size = avio_rl32(pb);
|
mtv->file_size = avio_rl32(pb);
|
||||||
|
|
@ -190,8 +191,8 @@ static int mtv_read_header(AVFormatContext *s)
|
||||||
|
|
||||||
// Jump over header
|
// Jump over header
|
||||||
|
|
||||||
if(avio_seek(pb, MTV_HEADER_SIZE, SEEK_SET) != MTV_HEADER_SIZE)
|
if ((ret64 = avio_seek(pb, MTV_HEADER_SIZE, SEEK_SET)) < 0)
|
||||||
return AVERROR(EIO);
|
return (int)ret64;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -489,7 +489,7 @@ static int mv_read_packet(AVFormatContext *avctx, AVPacket *pkt)
|
||||||
avio_skip(pb, index->pos - pos);
|
avio_skip(pb, index->pos - pos);
|
||||||
else if (index->pos < pos) {
|
else if (index->pos < pos) {
|
||||||
if (!(pb->seekable & AVIO_SEEKABLE_NORMAL))
|
if (!(pb->seekable & AVIO_SEEKABLE_NORMAL))
|
||||||
return AVERROR(EIO);
|
return AVERROR(ENOSYS);
|
||||||
ret = avio_seek(pb, index->pos, SEEK_SET);
|
ret = avio_seek(pb, index->pos, SEEK_SET);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
@ -531,7 +531,7 @@ static int mv_read_seek(AVFormatContext *avctx, int stream_index,
|
||||||
return AVERROR(ENOSYS);
|
return AVERROR(ENOSYS);
|
||||||
|
|
||||||
if (!(avctx->pb->seekable & AVIO_SEEKABLE_NORMAL))
|
if (!(avctx->pb->seekable & AVIO_SEEKABLE_NORMAL))
|
||||||
return AVERROR(EIO);
|
return AVERROR(ENOSYS);
|
||||||
|
|
||||||
frame = av_index_search_timestamp(st, timestamp, flags);
|
frame = av_index_search_timestamp(st, timestamp, flags);
|
||||||
if (frame < 0)
|
if (frame < 0)
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
if (mvi->video_frame_size == 0) {
|
if (mvi->video_frame_size == 0) {
|
||||||
mvi->video_frame_size = (mvi->get_int)(pb);
|
mvi->video_frame_size = (mvi->get_int)(pb);
|
||||||
if (mvi->audio_size_left == 0)
|
if (mvi->audio_size_left == 0)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
if (mvi->audio_size_counter + 512 > UINT64_MAX - mvi->audio_frame_size ||
|
if (mvi->audio_size_counter + 512 > UINT64_MAX - mvi->audio_frame_size ||
|
||||||
mvi->audio_size_counter + 512 + mvi->audio_frame_size >= ((uint64_t)INT32_MAX) << MVI_FRAC_BITS)
|
mvi->audio_size_counter + 512 + mvi->audio_frame_size >= ((uint64_t)INT32_MAX) << MVI_FRAC_BITS)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ static int nc_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
uint32_t state=-1;
|
uint32_t state=-1;
|
||||||
while (state != NC_VIDEO_FLAG) {
|
while (state != NC_VIDEO_FLAG) {
|
||||||
if (avio_feof(s->pb))
|
if (avio_feof(s->pb))
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
state = (state<<8) + avio_r8(s->pb);
|
state = (state<<8) + avio_r8(s->pb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -84,7 +84,7 @@ static int nc_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
|
|
||||||
ret = av_get_packet(s->pb, pkt, size);
|
ret = av_get_packet(s->pb, pkt, size);
|
||||||
if (ret != size) {
|
if (ret != size) {
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
pkt->stream_index = 0;
|
pkt->stream_index = 0;
|
||||||
|
|
|
||||||
|
|
@ -320,7 +320,7 @@ static int nuv_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -112,7 +112,7 @@ static int pdv_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
return AVERROR_EOF;
|
return AVERROR_EOF;
|
||||||
|
|
||||||
if (p->current_frame >= sti->nb_index_entries)
|
if (p->current_frame >= sti->nb_index_entries)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
pos = sti->index_entries[p->current_frame].pos;
|
pos = sti->index_entries[p->current_frame].pos;
|
||||||
flags = sti->index_entries[p->current_frame].flags;
|
flags = sti->index_entries[p->current_frame].flags;
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
|
#include "avio_internal.h"
|
||||||
#include "demux.h"
|
#include "demux.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "libavutil/intreadwrite.h"
|
#include "libavutil/intreadwrite.h"
|
||||||
|
|
@ -117,10 +118,8 @@ static int pp_bnk_read_header(AVFormatContext *s)
|
||||||
uint8_t buf[FFMAX(PP_BNK_FILE_HEADER_SIZE, PP_BNK_TRACK_SIZE)];
|
uint8_t buf[FFMAX(PP_BNK_FILE_HEADER_SIZE, PP_BNK_TRACK_SIZE)];
|
||||||
PPBnkHeader hdr;
|
PPBnkHeader hdr;
|
||||||
|
|
||||||
if ((ret = avio_read(s->pb, buf, PP_BNK_FILE_HEADER_SIZE)) < 0)
|
if ((ret = ffio_read_size(s->pb, buf, PP_BNK_FILE_HEADER_SIZE)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
else if (ret != PP_BNK_FILE_HEADER_SIZE)
|
|
||||||
return AVERROR(EIO);
|
|
||||||
|
|
||||||
pp_bnk_parse_header(&hdr, buf);
|
pp_bnk_parse_header(&hdr, buf);
|
||||||
|
|
||||||
|
|
@ -246,7 +245,7 @@ static int pp_bnk_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
if ((ret = avio_seek(s->pb, trk->data_offset + trk->bytes_read, SEEK_SET)) < 0)
|
if ((ret = avio_seek(s->pb, trk->data_offset + trk->bytes_read, SEEK_SET)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
else if (ret != trk->data_offset + trk->bytes_read)
|
else if (ret != trk->data_offset + trk->bytes_read)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
size = FFMIN(trk->data_size - trk->bytes_read, PP_BNK_MAX_READ_SIZE);
|
size = FFMIN(trk->data_size - trk->bytes_read, PP_BNK_MAX_READ_SIZE);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@
|
||||||
#include "libavutil/internal.h"
|
#include "libavutil/internal.h"
|
||||||
#include "libavutil/intreadwrite.h"
|
#include "libavutil/intreadwrite.h"
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
|
#include "avio_internal.h"
|
||||||
#include "demux.h"
|
#include "demux.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
@ -134,11 +135,12 @@ static int str_read_header(AVFormatContext *s)
|
||||||
StrDemuxContext *str = s->priv_data;
|
StrDemuxContext *str = s->priv_data;
|
||||||
unsigned char sector[RAW_CD_SECTOR_SIZE];
|
unsigned char sector[RAW_CD_SECTOR_SIZE];
|
||||||
int start;
|
int start;
|
||||||
|
int ret;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* skip over any RIFF header */
|
/* skip over any RIFF header */
|
||||||
if (avio_read(pb, sector, RIFF_HEADER_SIZE) != RIFF_HEADER_SIZE)
|
if ((ret = ffio_read_size(pb, sector, RIFF_HEADER_SIZE)) < 0)
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
if (AV_RL32(§or[0]) == RIFF_TAG)
|
if (AV_RL32(§or[0]) == RIFF_TAG)
|
||||||
start = RIFF_HEADER_SIZE;
|
start = RIFF_HEADER_SIZE;
|
||||||
else
|
else
|
||||||
|
|
@ -173,7 +175,7 @@ static int str_read_packet(AVFormatContext *s,
|
||||||
return AVERROR_EOF;
|
return AVERROR_EOF;
|
||||||
|
|
||||||
if (read != RAW_CD_SECTOR_SIZE)
|
if (read != RAW_CD_SECTOR_SIZE)
|
||||||
return AVERROR(EIO);
|
return read < 0 ? read : AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
channel = sector[0x11];
|
channel = sector[0x11];
|
||||||
if (channel >= 32)
|
if (channel >= 32)
|
||||||
|
|
@ -287,7 +289,7 @@ static int str_read_packet(AVFormatContext *s,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (avio_feof(pb))
|
if (avio_feof(pb))
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -103,18 +103,18 @@ recover:
|
||||||
|
|
||||||
if (syncword != PVA_MAGIC) {
|
if (syncword != PVA_MAGIC) {
|
||||||
pva_log(s, AV_LOG_ERROR, "invalid syncword\n");
|
pva_log(s, AV_LOG_ERROR, "invalid syncword\n");
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
if (streamid != PVA_VIDEO_PAYLOAD && streamid != PVA_AUDIO_PAYLOAD) {
|
if (streamid != PVA_VIDEO_PAYLOAD && streamid != PVA_AUDIO_PAYLOAD) {
|
||||||
pva_log(s, AV_LOG_ERROR, "invalid streamid\n");
|
pva_log(s, AV_LOG_ERROR, "invalid streamid\n");
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
if (reserved != 0x55) {
|
if (reserved != 0x55) {
|
||||||
pva_log(s, AV_LOG_WARNING, "expected reserved byte to be 0x55\n");
|
pva_log(s, AV_LOG_WARNING, "expected reserved byte to be 0x55\n");
|
||||||
}
|
}
|
||||||
if (length > PVA_MAX_PAYLOAD_LENGTH) {
|
if (length > PVA_MAX_PAYLOAD_LENGTH) {
|
||||||
pva_log(s, AV_LOG_ERROR, "invalid payload length %u\n", length);
|
pva_log(s, AV_LOG_ERROR, "invalid payload length %u\n", length);
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (streamid == PVA_VIDEO_PAYLOAD && pts_flag) {
|
if (streamid == PVA_VIDEO_PAYLOAD && pts_flag) {
|
||||||
|
|
@ -145,7 +145,7 @@ recover:
|
||||||
"trying to recover\n");
|
"trying to recover\n");
|
||||||
avio_skip(pb, length - 9);
|
avio_skip(pb, length - 9);
|
||||||
if (!read_packet)
|
if (!read_packet)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
goto recover;
|
goto recover;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -192,7 +192,7 @@ static int pva_read_packet(AVFormatContext *s, AVPacket *pkt) {
|
||||||
|
|
||||||
if (read_part_of_packet(s, &pva_pts, &length, &streamid, 1) < 0 ||
|
if (read_part_of_packet(s, &pva_pts, &length, &streamid, 1) < 0 ||
|
||||||
(ret = av_get_packet(pb, pkt, length)) <= 0)
|
(ret = av_get_packet(pb, pkt, length)) <= 0)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
pkt->stream_index = streamid - 1;
|
pkt->stream_index = streamid - 1;
|
||||||
pkt->pts = pva_pts;
|
pkt->pts = pva_pts;
|
||||||
|
|
|
||||||
|
|
@ -93,9 +93,9 @@ static int qoa_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
memcpy(pkt->data, hdr, sizeof(hdr));
|
memcpy(pkt->data, hdr, sizeof(hdr));
|
||||||
ret = avio_read(pb, pkt->data + sizeof(hdr), size - sizeof(hdr));
|
ret = ffio_read_size(pb, pkt->data + sizeof(hdr), size - sizeof(hdr));
|
||||||
if (ret != size - sizeof(hdr))
|
if (ret < 0)
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
pkt->stream_index = 0;
|
pkt->stream_index = 0;
|
||||||
pkt->pos = pos;
|
pkt->pos = pos;
|
||||||
pkt->duration = duration;
|
pkt->duration = duration;
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,7 @@ static int redspark_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
|
|
||||||
ret = av_get_packet(s->pb, pkt, size);
|
ret = av_get_packet(s->pb, pkt, size);
|
||||||
if (ret != size) {
|
if (ret != size) {
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
pkt->duration = 14;
|
pkt->duration = 14;
|
||||||
|
|
|
||||||
|
|
@ -259,7 +259,7 @@ static int rl2_read_packet(AVFormatContext *s,
|
||||||
/** fill the packet */
|
/** fill the packet */
|
||||||
ret = av_get_packet(pb, pkt, sample->size);
|
ret = av_get_packet(pb, pkt, sample->size);
|
||||||
if(ret != sample->size){
|
if(ret != sample->size){
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
pkt->stream_index = stream_id;
|
pkt->stream_index = stream_id;
|
||||||
|
|
|
||||||
|
|
@ -569,7 +569,7 @@ static int rm_read_header(AVFormatContext *s)
|
||||||
/* very old .ra format */
|
/* very old .ra format */
|
||||||
return rm_read_header_old(s);
|
return rm_read_header_old(s);
|
||||||
} else if (tag != MKTAG('.', 'R', 'M', 'F') && tag != MKTAG('.', 'R', 'M', 'P')) {
|
} else if (tag != MKTAG('.', 'R', 'M', 'F') && tag != MKTAG('.', 'R', 'M', 'P')) {
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
tag_size = avio_rb32(pb);
|
tag_size = avio_rb32(pb);
|
||||||
|
|
@ -1064,7 +1064,7 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
if (avio_feof(s->pb))
|
if (avio_feof(s->pb))
|
||||||
return AVERROR_EOF;
|
return AVERROR_EOF;
|
||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
res = ff_rm_parse_packet (s, s->pb, st, st->priv_data, len, pkt,
|
res = ff_rm_parse_packet (s, s->pb, st, st->priv_data, len, pkt,
|
||||||
&seq, flags, timestamp);
|
&seq, flags, timestamp);
|
||||||
|
|
@ -1410,7 +1410,7 @@ static int ivr_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
av_log(s, AV_LOG_ERROR, "Unsupported opcode=%d at %"PRIX64"\n", opcode, avio_tell(pb) - 1);
|
av_log(s, AV_LOG_ERROR, "Unsupported opcode=%d at %"PRIX64"\n", opcode, avio_tell(pb) - 1);
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -313,7 +313,7 @@ static int rpl_read_header(AVFormatContext *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error)
|
if (error)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -341,8 +341,9 @@ static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
index_entry = &sti->index_entries[rpl->chunk_number];
|
index_entry = &sti->index_entries[rpl->chunk_number];
|
||||||
|
|
||||||
if (rpl->frame_in_part == 0) {
|
if (rpl->frame_in_part == 0) {
|
||||||
if (avio_seek(pb, index_entry->pos, SEEK_SET) < 0)
|
int64_t ret64 = avio_seek(pb, index_entry->pos, SEEK_SET);
|
||||||
return AVERROR(EIO);
|
if (ret64 < 0)
|
||||||
|
return (int)ret64;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
|
if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
|
||||||
|
|
@ -350,17 +351,20 @@ static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
// We have to split Escape 124 frames because there are
|
// We have to split Escape 124 frames because there are
|
||||||
// multiple frames per chunk in Escape 124 samples.
|
// multiple frames per chunk in Escape 124 samples.
|
||||||
uint32_t frame_size;
|
uint32_t frame_size;
|
||||||
|
int64_t ret64;
|
||||||
|
|
||||||
avio_skip(pb, 4); /* flags */
|
avio_skip(pb, 4); /* flags */
|
||||||
frame_size = avio_rl32(pb);
|
frame_size = avio_rl32(pb);
|
||||||
if (avio_feof(pb) || avio_seek(pb, -8, SEEK_CUR) < 0 || !frame_size)
|
if (avio_feof(pb) || !frame_size)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
|
if ((ret64 = avio_seek(pb, -8, SEEK_CUR)) < 0)
|
||||||
|
return (int)ret64;
|
||||||
|
|
||||||
ret = av_get_packet(pb, pkt, frame_size);
|
ret = av_get_packet(pb, pkt, frame_size);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
if (ret != frame_size)
|
if (ret != frame_size)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
pkt->duration = 1;
|
pkt->duration = 1;
|
||||||
pkt->pts = index_entry->timestamp + rpl->frame_in_part;
|
pkt->pts = index_entry->timestamp + rpl->frame_in_part;
|
||||||
|
|
@ -376,7 +380,7 @@ static int rpl_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
if (ret != index_entry->size)
|
if (ret != index_entry->size)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
|
if (stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
|
||||||
// frames_per_chunk should always be one here; the header
|
// frames_per_chunk should always be one here; the header
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@
|
||||||
#include "libavutil/intreadwrite.h"
|
#include "libavutil/intreadwrite.h"
|
||||||
#include "libavutil/mem.h"
|
#include "libavutil/mem.h"
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
|
#include "avio_internal.h"
|
||||||
#include "demux.h"
|
#include "demux.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
@ -95,20 +96,21 @@ static int film_read_header(AVFormatContext *s)
|
||||||
unsigned int data_offset;
|
unsigned int data_offset;
|
||||||
unsigned int audio_frame_counter;
|
unsigned int audio_frame_counter;
|
||||||
unsigned int video_frame_counter;
|
unsigned int video_frame_counter;
|
||||||
|
int ret;
|
||||||
|
|
||||||
film->sample_table = NULL;
|
film->sample_table = NULL;
|
||||||
|
|
||||||
/* load the main FILM header */
|
/* load the main FILM header */
|
||||||
if (avio_read(pb, scratch, 16) != 16)
|
if ((ret = ffio_read_size(pb, scratch, 16)) < 0)
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
data_offset = AV_RB32(&scratch[4]);
|
data_offset = AV_RB32(&scratch[4]);
|
||||||
film->version = AV_RB32(&scratch[8]);
|
film->version = AV_RB32(&scratch[8]);
|
||||||
|
|
||||||
/* load the FDSC chunk */
|
/* load the FDSC chunk */
|
||||||
if (film->version == 0) {
|
if (film->version == 0) {
|
||||||
/* special case for Lemmings .film files; 20-byte header */
|
/* special case for Lemmings .film files; 20-byte header */
|
||||||
if (avio_read(pb, scratch, 20) != 20)
|
if ((ret = ffio_read_size(pb, scratch, 20)) < 0)
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
/* make some assumptions about the audio parameters */
|
/* make some assumptions about the audio parameters */
|
||||||
film->audio_type = AV_CODEC_ID_PCM_S8;
|
film->audio_type = AV_CODEC_ID_PCM_S8;
|
||||||
film->audio_samplerate = 22050;
|
film->audio_samplerate = 22050;
|
||||||
|
|
@ -116,8 +118,8 @@ static int film_read_header(AVFormatContext *s)
|
||||||
film->audio_bits = 8;
|
film->audio_bits = 8;
|
||||||
} else {
|
} else {
|
||||||
/* normal Saturn .cpk files; 32-byte header */
|
/* normal Saturn .cpk files; 32-byte header */
|
||||||
if (avio_read(pb, scratch, 32) != 32)
|
if ((ret = ffio_read_size(pb, scratch, 32)) < 0)
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
film->audio_samplerate = AV_RB16(&scratch[24]);
|
film->audio_samplerate = AV_RB16(&scratch[24]);
|
||||||
film->audio_channels = scratch[21];
|
film->audio_channels = scratch[21];
|
||||||
film->audio_bits = scratch[22];
|
film->audio_bits = scratch[22];
|
||||||
|
|
@ -196,8 +198,8 @@ static int film_read_header(AVFormatContext *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* load the sample table */
|
/* load the sample table */
|
||||||
if (avio_read(pb, scratch, 16) != 16)
|
if ((ret = ffio_read_size(pb, scratch, 16)) < 0)
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
if (AV_RB32(&scratch[0]) != STAB_TAG)
|
if (AV_RB32(&scratch[0]) != STAB_TAG)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
film->base_clock = AV_RB32(&scratch[8]);
|
film->base_clock = AV_RB32(&scratch[8]);
|
||||||
|
|
@ -217,8 +219,8 @@ static int film_read_header(AVFormatContext *s)
|
||||||
audio_frame_counter = video_frame_counter = 0;
|
audio_frame_counter = video_frame_counter = 0;
|
||||||
for (i = 0; i < film->sample_count; i++) {
|
for (i = 0; i < film->sample_count; i++) {
|
||||||
/* load the next sample record and transfer it to an internal struct */
|
/* load the next sample record and transfer it to an internal struct */
|
||||||
if (avio_read(pb, scratch, 16) != 16)
|
if ((ret = ffio_read_size(pb, scratch, 16)) < 0)
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
film->sample_table[i].sample_offset =
|
film->sample_table[i].sample_offset =
|
||||||
data_offset + AV_RB32(&scratch[0]);
|
data_offset + AV_RB32(&scratch[0]);
|
||||||
film->sample_table[i].sample_size = AV_RB32(&scratch[4]);
|
film->sample_table[i].sample_size = AV_RB32(&scratch[4]);
|
||||||
|
|
@ -294,7 +296,7 @@ static int film_read_packet(AVFormatContext *s,
|
||||||
|
|
||||||
ret = av_get_packet(pb, pkt, sample->sample_size);
|
ret = av_get_packet(pb, pkt, sample->sample_size);
|
||||||
if (ret != sample->sample_size)
|
if (ret != sample->sample_size)
|
||||||
ret = AVERROR(EIO);
|
ret = AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
pkt->stream_index = sample->stream;
|
pkt->stream_index = sample->stream;
|
||||||
pkt->dts = sample->pts;
|
pkt->dts = sample->pts;
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@
|
||||||
#include "libavutil/intreadwrite.h"
|
#include "libavutil/intreadwrite.h"
|
||||||
#include "libavutil/mem.h"
|
#include "libavutil/mem.h"
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
|
#include "avio_internal.h"
|
||||||
#include "demux.h"
|
#include "demux.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "avio_internal.h"
|
#include "avio_internal.h"
|
||||||
|
|
@ -102,8 +103,8 @@ static int vmd_read_header(AVFormatContext *s)
|
||||||
|
|
||||||
/* fetch the main header, including the 2 header length bytes */
|
/* fetch the main header, including the 2 header length bytes */
|
||||||
avio_seek(pb, 0, SEEK_SET);
|
avio_seek(pb, 0, SEEK_SET);
|
||||||
if (avio_read(pb, vmd->vmd_header, VMD_HEADER_SIZE) != VMD_HEADER_SIZE)
|
if ((ret = ffio_read_size(pb, vmd->vmd_header, VMD_HEADER_SIZE) < 0))
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
|
|
||||||
width = AV_RL16(&vmd->vmd_header[12]);
|
width = AV_RL16(&vmd->vmd_header[12]);
|
||||||
height = AV_RL16(&vmd->vmd_header[14]);
|
height = AV_RL16(&vmd->vmd_header[14]);
|
||||||
|
|
@ -192,11 +193,8 @@ static int vmd_read_header(AVFormatContext *s)
|
||||||
ret = AVERROR(ENOMEM);
|
ret = AVERROR(ENOMEM);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (avio_read(pb, raw_frame_table, raw_frame_table_size) !=
|
if ((ret = ffio_read_size(pb, raw_frame_table, raw_frame_table_size)) < 0)
|
||||||
raw_frame_table_size) {
|
|
||||||
ret = AVERROR(EIO);
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
|
||||||
|
|
||||||
total_frames = 0;
|
total_frames = 0;
|
||||||
for (i = 0; i < vmd->frame_count; i++) {
|
for (i = 0; i < vmd->frame_count; i++) {
|
||||||
|
|
@ -279,21 +277,18 @@ static int vmd_read_packet(AVFormatContext *s,
|
||||||
avio_seek(pb, frame->frame_offset, SEEK_SET);
|
avio_seek(pb, frame->frame_offset, SEEK_SET);
|
||||||
|
|
||||||
if(ffio_limit(pb, frame->frame_size) != frame->frame_size)
|
if(ffio_limit(pb, frame->frame_size) != frame->frame_size)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
ret = av_new_packet(pkt, frame->frame_size + BYTES_PER_FRAME_RECORD);
|
ret = av_new_packet(pkt, frame->frame_size + BYTES_PER_FRAME_RECORD);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
pkt->pos= avio_tell(pb);
|
pkt->pos= avio_tell(pb);
|
||||||
memcpy(pkt->data, frame->frame_record, BYTES_PER_FRAME_RECORD);
|
memcpy(pkt->data, frame->frame_record, BYTES_PER_FRAME_RECORD);
|
||||||
if(vmd->is_indeo3 && frame->frame_record[0] == 0x02)
|
if(vmd->is_indeo3 && frame->frame_record[0] == 0x02)
|
||||||
ret = avio_read(pb, pkt->data, frame->frame_size);
|
ret = ffio_read_size(pb, pkt->data, frame->frame_size);
|
||||||
else
|
else
|
||||||
ret = avio_read(pb, pkt->data + BYTES_PER_FRAME_RECORD,
|
ret = ffio_read_size(pb, pkt->data + BYTES_PER_FRAME_RECORD,
|
||||||
frame->frame_size);
|
frame->frame_size);
|
||||||
|
|
||||||
if (ret != frame->frame_size) {
|
|
||||||
ret = AVERROR(EIO);
|
|
||||||
}
|
|
||||||
pkt->stream_index = frame->stream_index;
|
pkt->stream_index = frame->stream_index;
|
||||||
pkt->pts = frame->pts;
|
pkt->pts = frame->pts;
|
||||||
av_log(s, AV_LOG_DEBUG, " dispatching %s frame with %d bytes and pts %"PRId64"\n",
|
av_log(s, AV_LOG_DEBUG, " dispatching %s frame with %d bytes and pts %"PRId64"\n",
|
||||||
|
|
|
||||||
|
|
@ -232,7 +232,7 @@ static int siff_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
} else {
|
} else {
|
||||||
int pktsize = av_get_packet(s->pb, pkt, c->sndsize - 4);
|
int pktsize = av_get_packet(s->pb, pkt, c->sndsize - 4);
|
||||||
if (pktsize < 0)
|
if (pktsize < 0)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
pkt->stream_index = 1;
|
pkt->stream_index = 1;
|
||||||
pkt->duration = pktsize;
|
pkt->duration = pktsize;
|
||||||
c->curstrm = 0;
|
c->curstrm = 0;
|
||||||
|
|
@ -246,7 +246,7 @@ static int siff_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
if (!pktsize)
|
if (!pktsize)
|
||||||
return AVERROR_EOF;
|
return AVERROR_EOF;
|
||||||
if (pktsize <= 0)
|
if (pktsize <= 0)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
pkt->duration = pktsize;
|
pkt->duration = pktsize;
|
||||||
}
|
}
|
||||||
return pkt->size;
|
return pkt->size;
|
||||||
|
|
|
||||||
|
|
@ -235,7 +235,7 @@ static int smush_read_packet(AVFormatContext *ctx, AVPacket *pkt)
|
||||||
if (size < 13)
|
if (size < 13)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
if (av_get_packet(pb, pkt, size) < 13)
|
if (av_get_packet(pb, pkt, size) < 13)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
pkt->stream_index = smush->audio_stream_index;
|
pkt->stream_index = smush->audio_stream_index;
|
||||||
pkt->flags |= AV_PKT_FLAG_KEY;
|
pkt->flags |= AV_PKT_FLAG_KEY;
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@
|
||||||
#include "libavutil/dict.h"
|
#include "libavutil/dict.h"
|
||||||
#include "libavutil/mem.h"
|
#include "libavutil/mem.h"
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
|
#include "avio_internal.h"
|
||||||
#include "demux.h"
|
#include "demux.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "pcm.h"
|
#include "pcm.h"
|
||||||
|
|
@ -106,11 +107,12 @@ static int sox_read_header(AVFormatContext *s)
|
||||||
|
|
||||||
if (comment_size && comment_size < UINT_MAX) {
|
if (comment_size && comment_size < UINT_MAX) {
|
||||||
char *comment = av_malloc(comment_size+1);
|
char *comment = av_malloc(comment_size+1);
|
||||||
|
int ret;
|
||||||
if(!comment)
|
if(!comment)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
if (avio_read(pb, comment, comment_size) != comment_size) {
|
if ((ret = ffio_read_size(pb, comment, comment_size)) < 0) {
|
||||||
av_freep(&comment);
|
av_freep(&comment);
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
}
|
}
|
||||||
comment[comment_size] = 0;
|
comment[comment_size] = 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -174,10 +174,10 @@ static int swf_read_header(AVFormatContext *s)
|
||||||
pb = swf->zpb;
|
pb = swf->zpb;
|
||||||
#else
|
#else
|
||||||
av_log(s, AV_LOG_ERROR, "zlib support is required to read SWF compressed files\n");
|
av_log(s, AV_LOG_ERROR, "zlib support is required to read SWF compressed files\n");
|
||||||
return AVERROR(EIO);
|
return AVERROR(ENOSYS);
|
||||||
#endif
|
#endif
|
||||||
} else if (tag != MKBETAG('F', 'W', 'S', 0))
|
} else if (tag != MKBETAG('F', 'W', 'S', 0))
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
/* skip rectangle size */
|
/* skip rectangle size */
|
||||||
nbits = avio_r8(pb) >> 3;
|
nbits = avio_r8(pb) >> 3;
|
||||||
len = (4 * nbits - 3 + 7) / 8;
|
len = (4 * nbits - 3 + 7) / 8;
|
||||||
|
|
|
||||||
|
|
@ -193,7 +193,7 @@ static int thp_read_packet(AVFormatContext *s,
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
if (ret != size) {
|
if (ret != size) {
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
pkt->stream_index = thp->video_stream_index;
|
pkt->stream_index = thp->video_stream_index;
|
||||||
|
|
@ -202,7 +202,7 @@ static int thp_read_packet(AVFormatContext *s,
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
if (ret != thp->audiosize) {
|
if (ret != thp->audiosize) {
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
pkt->stream_index = thp->audio_stream_index;
|
pkt->stream_index = thp->audio_stream_index;
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@
|
||||||
#include "libavutil/channel_layout.h"
|
#include "libavutil/channel_layout.h"
|
||||||
#include "libavutil/mem.h"
|
#include "libavutil/mem.h"
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
|
#include "avio_internal.h"
|
||||||
#include "demux.h"
|
#include "demux.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
@ -109,6 +110,7 @@ static int seq_init_frame_buffers(SeqDemuxContext *seq, AVIOContext *pb)
|
||||||
static int seq_fill_buffer(SeqDemuxContext *seq, AVIOContext *pb, int buffer_num, unsigned int data_offs, int data_size)
|
static int seq_fill_buffer(SeqDemuxContext *seq, AVIOContext *pb, int buffer_num, unsigned int data_offs, int data_size)
|
||||||
{
|
{
|
||||||
TiertexSeqFrameBuffer *seq_buffer;
|
TiertexSeqFrameBuffer *seq_buffer;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (buffer_num >= SEQ_NUM_FRAME_BUFFERS)
|
if (buffer_num >= SEQ_NUM_FRAME_BUFFERS)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
@ -118,8 +120,8 @@ static int seq_fill_buffer(SeqDemuxContext *seq, AVIOContext *pb, int buffer_num
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
avio_seek(pb, seq->current_frame_offs + data_offs, SEEK_SET);
|
avio_seek(pb, seq->current_frame_offs + data_offs, SEEK_SET);
|
||||||
if (avio_read(pb, seq_buffer->data + seq_buffer->fill_size, data_size) != data_size)
|
if ((ret = ffio_read_size(pb, seq_buffer->data + seq_buffer->fill_size, data_size)) < 0)
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
|
|
||||||
seq_buffer->fill_size += data_size;
|
seq_buffer->fill_size += data_size;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -273,10 +275,11 @@ static int seq_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
|
|
||||||
pkt->data[0] = 0;
|
pkt->data[0] = 0;
|
||||||
if (seq->current_pal_data_size) {
|
if (seq->current_pal_data_size) {
|
||||||
|
int ret;
|
||||||
pkt->data[0] |= 1;
|
pkt->data[0] |= 1;
|
||||||
avio_seek(pb, seq->current_frame_offs + seq->current_pal_data_offs, SEEK_SET);
|
avio_seek(pb, seq->current_frame_offs + seq->current_pal_data_offs, SEEK_SET);
|
||||||
if (avio_read(pb, &pkt->data[1], seq->current_pal_data_size) != seq->current_pal_data_size)
|
if ((ret = ffio_read_size(pb, &pkt->data[1], seq->current_pal_data_size)) < 0)
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
}
|
}
|
||||||
if (seq->current_video_data_size) {
|
if (seq->current_video_data_size) {
|
||||||
pkt->data[0] |= 2;
|
pkt->data[0] |= 2;
|
||||||
|
|
@ -295,7 +298,7 @@ static int seq_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
|
|
||||||
/* audio packet */
|
/* audio packet */
|
||||||
if (seq->current_audio_data_offs == 0) /* end of data reached */
|
if (seq->current_audio_data_offs == 0) /* end of data reached */
|
||||||
return AVERROR(EIO);
|
return AVERROR_EOF;
|
||||||
|
|
||||||
avio_seek(pb, seq->current_frame_offs + seq->current_audio_data_offs, SEEK_SET);
|
avio_seek(pb, seq->current_frame_offs + seq->current_audio_data_offs, SEEK_SET);
|
||||||
rc = av_get_packet(pb, pkt, seq->current_audio_data_size);
|
rc = av_get_packet(pb, pkt, seq->current_audio_data_size);
|
||||||
|
|
|
||||||
|
|
@ -303,7 +303,7 @@ static int ty_read_header(AVFormatContext *s)
|
||||||
if (ty->tivo_series == TIVO_SERIES_UNKNOWN ||
|
if (ty->tivo_series == TIVO_SERIES_UNKNOWN ||
|
||||||
ty->audio_type == TIVO_AUDIO_UNKNOWN ||
|
ty->audio_type == TIVO_AUDIO_UNKNOWN ||
|
||||||
ty->tivo_type == TIVO_TYPE_UNKNOWN)
|
ty->tivo_type == TIVO_TYPE_UNKNOWN)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
st = avformat_new_stream(s, NULL);
|
st = avformat_new_stream(s, NULL);
|
||||||
if (!st)
|
if (!st)
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ static int vc1t_read_packet(AVFormatContext *s,
|
||||||
keyframe = 1;
|
keyframe = 1;
|
||||||
pts = avio_rl32(pb);
|
pts = avio_rl32(pb);
|
||||||
if(av_get_packet(pb, pkt, frame_size) < 0)
|
if(av_get_packet(pb, pkt, frame_size) < 0)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
if(s->streams[0]->time_base.den == 1000)
|
if(s->streams[0]->time_base.den == 1000)
|
||||||
pkt->pts = pts;
|
pkt->pts = pts;
|
||||||
pkt->flags |= keyframe ? AV_PKT_FLAG_KEY : 0;
|
pkt->flags |= keyframe ? AV_PKT_FLAG_KEY : 0;
|
||||||
|
|
|
||||||
|
|
@ -601,7 +601,7 @@ static int viv_read_header(AVFormatContext *s)
|
||||||
k2 = b22_key;
|
k2 = b22_key;
|
||||||
buf = read_vblock(pb, &v, b22_key, &k2, 0);
|
buf = read_vblock(pb, &v, b22_key, &k2, 0);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
av_free(buf);
|
av_free(buf);
|
||||||
}
|
}
|
||||||
|
|
@ -609,7 +609,7 @@ static int viv_read_header(AVFormatContext *s)
|
||||||
k2 = key;
|
k2 = key;
|
||||||
buf = read_vblock(pb, &v, key, &k2, 0);
|
buf = read_vblock(pb, &v, key, &k2, 0);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
ret = track_header(viv, s, buf, v);
|
ret = track_header(viv, s, buf, v);
|
||||||
av_free(buf);
|
av_free(buf);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
|
@ -617,7 +617,7 @@ static int viv_read_header(AVFormatContext *s)
|
||||||
|
|
||||||
buf = read_vblock(pb, &v, key, &k2, v);
|
buf = read_vblock(pb, &v, key, &k2, v);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
ret = track_index(viv, s, buf, v);
|
ret = track_index(viv, s, buf, v);
|
||||||
av_free(buf);
|
av_free(buf);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
|
@ -643,7 +643,7 @@ static int viv_read_packet(AVFormatContext *s,
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!viv->sb_pb)
|
if (!viv->sb_pb)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
if (avio_feof(viv->sb_pb))
|
if (avio_feof(viv->sb_pb))
|
||||||
return AVERROR_EOF;
|
return AVERROR_EOF;
|
||||||
|
|
||||||
|
|
@ -670,7 +670,7 @@ static int viv_read_packet(AVFormatContext *s,
|
||||||
|
|
||||||
if (viv->current_sb_entry >= viv->n_sb_entries) {
|
if (viv->current_sb_entry >= viv->n_sb_entries) {
|
||||||
if (viv->current_sb+1 >= viv->n_sb_blocks)
|
if (viv->current_sb+1 >= viv->n_sb_blocks)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
viv->current_sb++;
|
viv->current_sb++;
|
||||||
|
|
||||||
load_sb_block(s, viv, 0);
|
load_sb_block(s, viv, 0);
|
||||||
|
|
@ -679,7 +679,7 @@ static int viv_read_packet(AVFormatContext *s,
|
||||||
|
|
||||||
pb = viv->sb_pb;
|
pb = viv->sb_pb;
|
||||||
if (!pb)
|
if (!pb)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
off = avio_tell(pb);
|
off = avio_tell(pb);
|
||||||
|
|
||||||
if (viv->current_sb_entry >= viv->n_sb_entries)
|
if (viv->current_sb_entry >= viv->n_sb_entries)
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ ff_voc_get_packet(AVFormatContext *s, AVPacket *pkt, AVStream *st, int max_size)
|
||||||
if (!voc->remaining_size) {
|
if (!voc->remaining_size) {
|
||||||
int64_t filesize;
|
int64_t filesize;
|
||||||
if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL))
|
if (!(s->pb->seekable & AVIO_SEEKABLE_NORMAL))
|
||||||
return AVERROR(EIO);
|
return AVERROR(ENOSYS);
|
||||||
filesize = avio_size(pb);
|
filesize = avio_size(pb);
|
||||||
if (filesize - avio_tell(pb) > INT_MAX)
|
if (filesize - avio_tell(pb) > INT_MAX)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
#include "libavutil/intreadwrite.h"
|
#include "libavutil/intreadwrite.h"
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
|
#include "avio_internal.h"
|
||||||
#include "demux.h"
|
#include "demux.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
@ -94,10 +95,10 @@ static int vpk_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
for (i = 0; i < par->ch_layout.nb_channels; i++) {
|
for (i = 0; i < par->ch_layout.nb_channels; i++) {
|
||||||
ret = avio_read(s->pb, pkt->data + i * size, size);
|
ret = ffio_read_size(s->pb, pkt->data + i * size, size);
|
||||||
avio_skip(s->pb, skip);
|
avio_skip(s->pb, skip);
|
||||||
if (ret != size) {
|
if (ret < 0) {
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pkt->pos = pos;
|
pkt->pos = pos;
|
||||||
|
|
|
||||||
|
|
@ -71,8 +71,8 @@ static int wavarc_read_header(AVFormatContext *s)
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
id = avio_rl32(pb);
|
id = avio_rl32(pb);
|
||||||
w->data_end = avio_tell(pb);
|
w->data_end = avio_tell(pb);
|
||||||
if (avio_read(pb, data, sizeof(data)) != sizeof(data))
|
if ((ret = ffio_read_size(pb, data, sizeof(data))) < 0)
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
w->data_end += 16LL + AV_RL32(data + 4);
|
w->data_end += 16LL + AV_RL32(data + 4);
|
||||||
fmt_len = AV_RL32(data + 32);
|
fmt_len = AV_RL32(data + 32);
|
||||||
if (fmt_len < 12)
|
if (fmt_len < 12)
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@
|
||||||
#include "libavutil/dict.h"
|
#include "libavutil/dict.h"
|
||||||
#include "libavutil/mem.h"
|
#include "libavutil/mem.h"
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
|
#include "avio_internal.h"
|
||||||
#include "demux.h"
|
#include "demux.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
@ -141,9 +142,9 @@ static int wc3_read_header(AVFormatContext *s)
|
||||||
buffer = av_malloc(size+1);
|
buffer = av_malloc(size+1);
|
||||||
if (!buffer)
|
if (!buffer)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
if ((ret = avio_read(pb, buffer, size)) != size) {
|
if ((ret = ffio_read_size(pb, buffer, size)) < 0) {
|
||||||
av_freep(&buffer);
|
av_freep(&buffer);
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
}
|
}
|
||||||
buffer[size] = 0;
|
buffer[size] = 0;
|
||||||
av_dict_set(&s->metadata, "title", buffer,
|
av_dict_set(&s->metadata, "title", buffer,
|
||||||
|
|
@ -172,7 +173,7 @@ static int wc3_read_header(AVFormatContext *s)
|
||||||
/* chunk sizes are 16-bit aligned */
|
/* chunk sizes are 16-bit aligned */
|
||||||
size = (avio_rb32(pb) + 1) & (~1);
|
size = (avio_rb32(pb) + 1) & (~1);
|
||||||
if (avio_feof(pb))
|
if (avio_feof(pb))
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
} while (fourcc_tag != BRCH_TAG);
|
} while (fourcc_tag != BRCH_TAG);
|
||||||
|
|
||||||
|
|
@ -223,7 +224,7 @@ static int wc3_read_packet(AVFormatContext *s,
|
||||||
/* chunk sizes are 16-bit aligned */
|
/* chunk sizes are 16-bit aligned */
|
||||||
size = (avio_rb32(pb) + 1) & (~1);
|
size = (avio_rb32(pb) + 1) & (~1);
|
||||||
if (avio_feof(pb))
|
if (avio_feof(pb))
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
switch (fourcc_tag) {
|
switch (fourcc_tag) {
|
||||||
|
|
||||||
|
|
@ -252,9 +253,9 @@ static int wc3_read_packet(AVFormatContext *s,
|
||||||
|
|
||||||
case TEXT_TAG:
|
case TEXT_TAG:
|
||||||
/* subtitle chunk */
|
/* subtitle chunk */
|
||||||
if ((unsigned)size > sizeof(text) || (ret = avio_read(pb, text, size)) != size)
|
if ((unsigned)size > sizeof(text))
|
||||||
ret = AVERROR(EIO);
|
ret = AVERROR_INVALIDDATA;
|
||||||
else {
|
else if ((ret = ffio_read_size(pb, text, size)) == size) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
av_log (s, AV_LOG_DEBUG, "Subtitle time!\n");
|
av_log (s, AV_LOG_DEBUG, "Subtitle time!\n");
|
||||||
if (i >= size || av_strnlen(&text[i + 1], size - i - 1) >= size - i - 1)
|
if (i >= size || av_strnlen(&text[i + 1], size - i - 1) >= size - i - 1)
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@
|
||||||
#include "libavutil/channel_layout.h"
|
#include "libavutil/channel_layout.h"
|
||||||
#include "libavutil/intreadwrite.h"
|
#include "libavutil/intreadwrite.h"
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
|
#include "avio_internal.h"
|
||||||
#include "demux.h"
|
#include "demux.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
|
|
@ -87,9 +88,10 @@ static int wsaud_read_header(AVFormatContext *s)
|
||||||
AVStream *st;
|
AVStream *st;
|
||||||
unsigned char header[AUD_HEADER_SIZE];
|
unsigned char header[AUD_HEADER_SIZE];
|
||||||
int sample_rate, channels, codec;
|
int sample_rate, channels, codec;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (avio_read(pb, header, AUD_HEADER_SIZE) != AUD_HEADER_SIZE)
|
if ((ret = ffio_read_size(pb, header, AUD_HEADER_SIZE)) < 0)
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
|
|
||||||
sample_rate = AV_RL16(&header[0]);
|
sample_rate = AV_RL16(&header[0]);
|
||||||
channels = (header[10] & 0x1) + 1;
|
channels = (header[10] & 0x1) + 1;
|
||||||
|
|
@ -134,9 +136,8 @@ static int wsaud_read_packet(AVFormatContext *s,
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
AVStream *st = s->streams[0];
|
AVStream *st = s->streams[0];
|
||||||
|
|
||||||
if (avio_read(pb, preamble, AUD_CHUNK_PREAMBLE_SIZE) !=
|
if ((ret = ffio_read_size(pb, preamble, AUD_CHUNK_PREAMBLE_SIZE)) < 0)
|
||||||
AUD_CHUNK_PREAMBLE_SIZE)
|
return ret;
|
||||||
return AVERROR(EIO);
|
|
||||||
|
|
||||||
/* validate the chunk */
|
/* validate the chunk */
|
||||||
if (AV_RL32(&preamble[4]) != AUD_CHUNK_SIGNATURE)
|
if (AV_RL32(&preamble[4]) != AUD_CHUNK_SIGNATURE)
|
||||||
|
|
@ -152,8 +153,8 @@ static int wsaud_read_packet(AVFormatContext *s,
|
||||||
int out_size = AV_RL16(&preamble[2]);
|
int out_size = AV_RL16(&preamble[2]);
|
||||||
if ((ret = av_new_packet(pkt, chunk_size + 4)) < 0)
|
if ((ret = av_new_packet(pkt, chunk_size + 4)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
if ((ret = avio_read(pb, &pkt->data[4], chunk_size)) != chunk_size)
|
if ((ret = ffio_read_size(pb, &pkt->data[4], chunk_size)) < 0)
|
||||||
return ret < 0 ? ret : AVERROR(EIO);
|
return ret;
|
||||||
AV_WL16(&pkt->data[0], out_size);
|
AV_WL16(&pkt->data[0], out_size);
|
||||||
AV_WL16(&pkt->data[2], chunk_size);
|
AV_WL16(&pkt->data[2], chunk_size);
|
||||||
|
|
||||||
|
|
@ -161,7 +162,7 @@ static int wsaud_read_packet(AVFormatContext *s,
|
||||||
} else {
|
} else {
|
||||||
ret = av_get_packet(pb, pkt, chunk_size);
|
ret = av_get_packet(pb, pkt, chunk_size);
|
||||||
if (ret != chunk_size)
|
if (ret != chunk_size)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
if (st->codecpar->ch_layout.nb_channels <= 0) {
|
if (st->codecpar->ch_layout.nb_channels <= 0) {
|
||||||
av_log(s, AV_LOG_ERROR, "invalid number of channels %d\n",
|
av_log(s, AV_LOG_ERROR, "invalid number of channels %d\n",
|
||||||
|
|
|
||||||
|
|
@ -138,8 +138,8 @@ static int wsvqa_read_header(AVFormatContext *s)
|
||||||
/* there are 0 or more chunks before the FINF chunk; iterate until
|
/* there are 0 or more chunks before the FINF chunk; iterate until
|
||||||
* FINF has been skipped and the file will be ready to be demuxed */
|
* FINF has been skipped and the file will be ready to be demuxed */
|
||||||
do {
|
do {
|
||||||
if (avio_read(pb, scratch, VQA_PREAMBLE_SIZE) != VQA_PREAMBLE_SIZE)
|
if ((ret = ffio_read_size(pb, scratch, VQA_PREAMBLE_SIZE)) < 0)
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
chunk_tag = AV_RB32(&scratch[0]);
|
chunk_tag = AV_RB32(&scratch[0]);
|
||||||
chunk_size = AV_RB32(&scratch[4]);
|
chunk_size = AV_RB32(&scratch[4]);
|
||||||
|
|
||||||
|
|
@ -211,7 +211,7 @@ static int wsvqa_read_packet(AVFormatContext *s,
|
||||||
|
|
||||||
ret= av_get_packet(pb, pkt, chunk_size);
|
ret= av_get_packet(pb, pkt, chunk_size);
|
||||||
if (ret<0)
|
if (ret<0)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
switch (chunk_type) {
|
switch (chunk_type) {
|
||||||
case SND0_TAG:
|
case SND0_TAG:
|
||||||
|
|
@ -272,20 +272,20 @@ static int wsvqa_read_packet(AVFormatContext *s,
|
||||||
/* if a new codebook is available inside an earlier a VQFL chunk then
|
/* if a new codebook is available inside an earlier a VQFL chunk then
|
||||||
* append it to 'pkt' */
|
* append it to 'pkt' */
|
||||||
if (wsvqa->vqfl_chunk_size > 0) {
|
if (wsvqa->vqfl_chunk_size > 0) {
|
||||||
int64_t current_pos = pkt->pos;
|
int64_t ret64, current_pos = pkt->pos;
|
||||||
|
|
||||||
if (avio_seek(pb, wsvqa->vqfl_chunk_pos, SEEK_SET) < 0)
|
if ((ret64 = avio_seek(pb, wsvqa->vqfl_chunk_pos, SEEK_SET)) < 0)
|
||||||
return AVERROR(EIO);
|
return (int)ret64;
|
||||||
|
|
||||||
/* the decoder expects chunks to be 16-bit aligned */
|
/* the decoder expects chunks to be 16-bit aligned */
|
||||||
if (wsvqa->vqfl_chunk_size % 2 == 1)
|
if (wsvqa->vqfl_chunk_size % 2 == 1)
|
||||||
wsvqa->vqfl_chunk_size++;
|
wsvqa->vqfl_chunk_size++;
|
||||||
|
|
||||||
if (av_append_packet(pb, pkt, wsvqa->vqfl_chunk_size) < 0)
|
if (av_append_packet(pb, pkt, wsvqa->vqfl_chunk_size) < 0)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
if (avio_seek(pb, current_pos, SEEK_SET) < 0)
|
if ((ret64 = avio_seek(pb, current_pos, SEEK_SET)) < 0)
|
||||||
return AVERROR(EIO);
|
return (int)ret64;
|
||||||
|
|
||||||
wsvqa->vqfl_chunk_pos = 0;
|
wsvqa->vqfl_chunk_pos = 0;
|
||||||
wsvqa->vqfl_chunk_size = 0;
|
wsvqa->vqfl_chunk_size = 0;
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
#include "libavutil/mem.h"
|
#include "libavutil/mem.h"
|
||||||
#include "libavutil/timecode.h"
|
#include "libavutil/timecode.h"
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
|
#include "avio_internal.h"
|
||||||
#include "demux.h"
|
#include "demux.h"
|
||||||
#include "rawdec.h"
|
#include "rawdec.h"
|
||||||
|
|
||||||
|
|
@ -73,6 +74,7 @@ static int wsd_to_av_channel_layoyt(AVFormatContext *s, int bit)
|
||||||
static int get_metadata(AVFormatContext *s, const char *const tag, const unsigned size)
|
static int get_metadata(AVFormatContext *s, const char *const tag, const unsigned size)
|
||||||
{
|
{
|
||||||
uint8_t *buf;
|
uint8_t *buf;
|
||||||
|
int ret;
|
||||||
if (!(size + 1))
|
if (!(size + 1))
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
|
|
@ -80,9 +82,9 @@ static int get_metadata(AVFormatContext *s, const char *const tag, const unsigne
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
|
||||||
if (avio_read(s->pb, buf, size) != size) {
|
if ((ret = avio_read(s->pb, buf, size)) < 0) {
|
||||||
av_free(buf);
|
av_free(buf);
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty_string(buf, size)) {
|
if (empty_string(buf, size)) {
|
||||||
|
|
|
||||||
|
|
@ -761,7 +761,7 @@ static int recover(WtvContext *wtv, uint64_t broken_pos)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
#include "libavutil/intreadwrite.h"
|
#include "libavutil/intreadwrite.h"
|
||||||
#include "libavutil/dict.h"
|
#include "libavutil/dict.h"
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
|
#include "avio_internal.h"
|
||||||
#include "demux.h"
|
#include "demux.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "apetag.h"
|
#include "apetag.h"
|
||||||
|
|
@ -295,9 +296,9 @@ static int wv_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
if ((ret = av_new_packet(pkt, wc->header.blocksize + WV_HEADER_SIZE)) < 0)
|
if ((ret = av_new_packet(pkt, wc->header.blocksize + WV_HEADER_SIZE)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
memcpy(pkt->data, wc->block_header, WV_HEADER_SIZE);
|
memcpy(pkt->data, wc->block_header, WV_HEADER_SIZE);
|
||||||
ret = avio_read(s->pb, pkt->data + WV_HEADER_SIZE, wc->header.blocksize);
|
ret = ffio_read_size(s->pb, pkt->data + WV_HEADER_SIZE, wc->header.blocksize);
|
||||||
if (ret != wc->header.blocksize) {
|
if (ret < 0) {
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
}
|
}
|
||||||
while (!(wc->header.flags & WV_FLAG_FINAL_BLOCK)) {
|
while (!(wc->header.flags & WV_FLAG_FINAL_BLOCK)) {
|
||||||
if ((ret = wv_read_block_header(s, s->pb)) < 0) {
|
if ((ret = wv_read_block_header(s, s->pb)) < 0) {
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@
|
||||||
#include "libavutil/mem.h"
|
#include "libavutil/mem.h"
|
||||||
|
|
||||||
#include "avformat.h"
|
#include "avformat.h"
|
||||||
|
#include "avio_internal.h"
|
||||||
#include "demux.h"
|
#include "demux.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "riff.h"
|
#include "riff.h"
|
||||||
|
|
@ -273,8 +274,8 @@ static int xmv_process_packet_header(AVFormatContext *s)
|
||||||
|
|
||||||
/* Packet video header */
|
/* Packet video header */
|
||||||
|
|
||||||
if (avio_read(pb, data, 8) != 8)
|
if ((ret = ffio_read_size(pb, data, 8)) < 0)
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
|
|
||||||
xmv->video.data_size = AV_RL32(data) & 0x007FFFFF;
|
xmv->video.data_size = AV_RL32(data) & 0x007FFFFF;
|
||||||
|
|
||||||
|
|
@ -325,8 +326,8 @@ static int xmv_process_packet_header(AVFormatContext *s)
|
||||||
for (audio_track = 0; audio_track < xmv->audio_track_count; audio_track++) {
|
for (audio_track = 0; audio_track < xmv->audio_track_count; audio_track++) {
|
||||||
XMVAudioPacket *packet = &xmv->audio[audio_track];
|
XMVAudioPacket *packet = &xmv->audio[audio_track];
|
||||||
|
|
||||||
if (avio_read(pb, data, 4) != 4)
|
if ((ret = ffio_read_size(pb, data, 4)) < 0)
|
||||||
return AVERROR(EIO);
|
return ret;
|
||||||
|
|
||||||
if (!packet->created) {
|
if (!packet->created) {
|
||||||
AVStream *ast = avformat_new_stream(s, NULL);
|
AVStream *ast = avformat_new_stream(s, NULL);
|
||||||
|
|
@ -417,12 +418,12 @@ static int xmv_fetch_new_packet(AVFormatContext *s)
|
||||||
/* Seek to it */
|
/* Seek to it */
|
||||||
xmv->this_packet_offset = xmv->next_packet_offset;
|
xmv->this_packet_offset = xmv->next_packet_offset;
|
||||||
if (avio_seek(pb, xmv->this_packet_offset, SEEK_SET) != xmv->this_packet_offset)
|
if (avio_seek(pb, xmv->this_packet_offset, SEEK_SET) != xmv->this_packet_offset)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
/* Update the size */
|
/* Update the size */
|
||||||
xmv->this_packet_size = xmv->next_packet_size;
|
xmv->this_packet_size = xmv->next_packet_size;
|
||||||
if (xmv->this_packet_size < (12 + xmv->audio_track_count * 4))
|
if (xmv->this_packet_size < (12 + xmv->audio_track_count * 4))
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
/* Process the header */
|
/* Process the header */
|
||||||
result = xmv_process_packet_header(s);
|
result = xmv_process_packet_header(s);
|
||||||
|
|
@ -448,7 +449,7 @@ static int xmv_fetch_audio_packet(AVFormatContext *s,
|
||||||
|
|
||||||
/* Seek to it */
|
/* Seek to it */
|
||||||
if (avio_seek(pb, audio->data_offset, SEEK_SET) != audio->data_offset)
|
if (avio_seek(pb, audio->data_offset, SEEK_SET) != audio->data_offset)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
if ((xmv->video.current_frame + 1) < xmv->video.frame_count)
|
if ((xmv->video.current_frame + 1) < xmv->video.frame_count)
|
||||||
/* Not the last frame, get at most frame_size bytes. */
|
/* Not the last frame, get at most frame_size bytes. */
|
||||||
|
|
@ -495,7 +496,7 @@ static int xmv_fetch_video_packet(AVFormatContext *s,
|
||||||
|
|
||||||
/* Seek to it */
|
/* Seek to it */
|
||||||
if (avio_seek(pb, video->data_offset, SEEK_SET) != video->data_offset)
|
if (avio_seek(pb, video->data_offset, SEEK_SET) != video->data_offset)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
/* Read the frame header */
|
/* Read the frame header */
|
||||||
frame_header = avio_rl32(pb);
|
frame_header = avio_rl32(pb);
|
||||||
|
|
@ -504,7 +505,7 @@ static int xmv_fetch_video_packet(AVFormatContext *s,
|
||||||
frame_timestamp = (frame_header >> 17);
|
frame_timestamp = (frame_header >> 17);
|
||||||
|
|
||||||
if ((frame_size + 4) > video->data_size)
|
if ((frame_size + 4) > video->data_size)
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
|
|
||||||
/* Get the packet data */
|
/* Get the packet data */
|
||||||
result = av_get_packet(pb, pkt, frame_size);
|
result = av_get_packet(pb, pkt, frame_size);
|
||||||
|
|
|
||||||
|
|
@ -291,7 +291,7 @@ static int yuv4_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
else if (ret != s->packet_size - Y4M_FRAME_MAGIC_LEN) {
|
else if (ret != s->packet_size - Y4M_FRAME_MAGIC_LEN) {
|
||||||
return s->pb->eof_reached ? AVERROR_EOF : AVERROR(EIO);
|
return s->pb->eof_reached ? AVERROR_EOF : AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
pkt->stream_index = 0;
|
pkt->stream_index = 0;
|
||||||
pkt->pts = (off - ffformatcontext(s)->data_offset) / s->packet_size;
|
pkt->pts = (off - ffformatcontext(s)->data_offset) / s->packet_size;
|
||||||
|
|
|
||||||
|
|
@ -282,7 +282,7 @@ static int yuv4_init(AVFormatContext *s)
|
||||||
"gray9, gray10, gray12 "
|
"gray9, gray10, gray12 "
|
||||||
"and gray16 pixel formats. "
|
"and gray16 pixel formats. "
|
||||||
"Use -pix_fmt to select one.\n");
|
"Use -pix_fmt to select one.\n");
|
||||||
return AVERROR(EIO);
|
return AVERROR_INVALIDDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -195,12 +195,17 @@ static const VAAPIFormatDescriptor *
|
||||||
}
|
}
|
||||||
|
|
||||||
static const VAAPIFormatDescriptor *
|
static const VAAPIFormatDescriptor *
|
||||||
vaapi_format_from_pix_fmt(enum AVPixelFormat pix_fmt)
|
vaapi_format_from_pix_fmt(enum AVPixelFormat pix_fmt, const VAAPIFormatDescriptor *prev)
|
||||||
{
|
{
|
||||||
int i;
|
const VAAPIFormatDescriptor *end = &vaapi_format_map[FF_ARRAY_ELEMS(vaapi_format_map)];
|
||||||
for (i = 0; i < FF_ARRAY_ELEMS(vaapi_format_map); i++)
|
if (!prev)
|
||||||
if (vaapi_format_map[i].pix_fmt == pix_fmt)
|
prev = vaapi_format_map;
|
||||||
return &vaapi_format_map[i];
|
else
|
||||||
|
prev++;
|
||||||
|
|
||||||
|
for (; prev < end; prev++)
|
||||||
|
if (prev->pix_fmt == pix_fmt)
|
||||||
|
return prev;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -214,27 +219,37 @@ static enum AVPixelFormat vaapi_pix_fmt_from_fourcc(unsigned int fourcc)
|
||||||
return AV_PIX_FMT_NONE;
|
return AV_PIX_FMT_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int vaapi_get_img_desc_and_format(AVHWDeviceContext *hwdev,
|
||||||
|
enum AVPixelFormat pix_fmt,
|
||||||
|
const VAAPIFormatDescriptor **_desc,
|
||||||
|
VAImageFormat **image_format)
|
||||||
|
{
|
||||||
|
VAAPIDeviceContext *ctx = hwdev->hwctx;
|
||||||
|
const VAAPIFormatDescriptor *desc = NULL;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
while ((desc = vaapi_format_from_pix_fmt(pix_fmt, desc))) {
|
||||||
|
for (i = 0; i < ctx->nb_formats; i++) {
|
||||||
|
if (ctx->formats[i].fourcc == desc->fourcc) {
|
||||||
|
if (_desc)
|
||||||
|
*_desc = desc;
|
||||||
|
if (image_format)
|
||||||
|
*image_format = &ctx->formats[i].image_format;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return AVERROR(ENOSYS);
|
||||||
|
}
|
||||||
|
|
||||||
static int vaapi_get_image_format(AVHWDeviceContext *hwdev,
|
static int vaapi_get_image_format(AVHWDeviceContext *hwdev,
|
||||||
enum AVPixelFormat pix_fmt,
|
enum AVPixelFormat pix_fmt,
|
||||||
VAImageFormat **image_format)
|
VAImageFormat **image_format)
|
||||||
{
|
{
|
||||||
VAAPIDeviceContext *ctx = hwdev->hwctx;
|
if (!image_format)
|
||||||
const VAAPIFormatDescriptor *desc;
|
return AVERROR(EINVAL);
|
||||||
int i;
|
return vaapi_get_img_desc_and_format(hwdev, pix_fmt, NULL, image_format);
|
||||||
|
|
||||||
desc = vaapi_format_from_pix_fmt(pix_fmt);
|
|
||||||
if (!desc || !image_format)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
for (i = 0; i < ctx->nb_formats; i++) {
|
|
||||||
if (ctx->formats[i].fourcc == desc->fourcc) {
|
|
||||||
*image_format = &ctx->formats[i].image_format;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fail:
|
|
||||||
return AVERROR(ENOSYS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vaapi_frames_get_constraints(AVHWDeviceContext *hwdev,
|
static int vaapi_frames_get_constraints(AVHWDeviceContext *hwdev,
|
||||||
|
|
@ -562,19 +577,23 @@ static int vaapi_frames_init(AVHWFramesContext *hwfc)
|
||||||
VAAPIFramesContext *ctx = hwfc->hwctx;
|
VAAPIFramesContext *ctx = hwfc->hwctx;
|
||||||
AVVAAPIFramesContext *avfc = &ctx->p;
|
AVVAAPIFramesContext *avfc = &ctx->p;
|
||||||
AVVAAPIDeviceContext *hwctx = hwfc->device_ctx->hwctx;
|
AVVAAPIDeviceContext *hwctx = hwfc->device_ctx->hwctx;
|
||||||
const VAAPIFormatDescriptor *desc;
|
const VAAPIFormatDescriptor *desc = NULL;
|
||||||
VAImageFormat *expected_format;
|
VAImageFormat *expected_format = NULL;
|
||||||
AVBufferRef *test_surface = NULL;
|
AVBufferRef *test_surface = NULL;
|
||||||
VASurfaceID test_surface_id;
|
VASurfaceID test_surface_id;
|
||||||
VAImage test_image;
|
VAImage test_image;
|
||||||
VAStatus vas;
|
VAStatus vas;
|
||||||
int err, i;
|
int err, i;
|
||||||
|
|
||||||
desc = vaapi_format_from_pix_fmt(hwfc->sw_format);
|
err = vaapi_get_img_desc_and_format(hwfc->device_ctx, hwfc->sw_format,
|
||||||
if (!desc) {
|
&desc, &expected_format);
|
||||||
av_log(hwfc, AV_LOG_ERROR, "Unsupported format: %s.\n",
|
if (err < 0) {
|
||||||
av_get_pix_fmt_name(hwfc->sw_format));
|
// Use a relaxed check when pool exist. It can be an external pool.
|
||||||
return AVERROR(EINVAL);
|
if (!hwfc->pool || !vaapi_format_from_pix_fmt(hwfc->sw_format, NULL)) {
|
||||||
|
av_log(hwfc, AV_LOG_ERROR, "Unsupported format: %s.\n",
|
||||||
|
av_get_pix_fmt_name(hwfc->sw_format));
|
||||||
|
return AVERROR(EINVAL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hwfc->pool) {
|
if (!hwfc->pool) {
|
||||||
|
|
@ -673,10 +692,7 @@ static int vaapi_frames_init(AVHWFramesContext *hwfc)
|
||||||
test_surface_id = (VASurfaceID)(uintptr_t)test_surface->data;
|
test_surface_id = (VASurfaceID)(uintptr_t)test_surface->data;
|
||||||
|
|
||||||
ctx->derive_works = 0;
|
ctx->derive_works = 0;
|
||||||
|
if (expected_format) {
|
||||||
err = vaapi_get_image_format(hwfc->device_ctx,
|
|
||||||
hwfc->sw_format, &expected_format);
|
|
||||||
if (err == 0) {
|
|
||||||
vas = vaDeriveImage(hwctx->display, test_surface_id, &test_image);
|
vas = vaDeriveImage(hwctx->display, test_surface_id, &test_image);
|
||||||
if (vas == VA_STATUS_SUCCESS) {
|
if (vas == VA_STATUS_SUCCESS) {
|
||||||
if (expected_format->fourcc == test_image.format.fourcc) {
|
if (expected_format->fourcc == test_image.format.fourcc) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue