summaryrefslogtreecommitdiff
path: root/libavformat/ty.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2019-12-10 22:59:53 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2019-12-12 19:25:33 +0100
commitc1e439d7e9abab3cebdc937636393b1656e095d9 (patch)
treebe0ae941a23b62c42b152e2b9aa0a22f8c793d4e /libavformat/ty.c
parentcb88cdf7730e309df22ddbbc1ae4ebcd9ebc529e (diff)
avformat: Forward errors where possible
It is not uncommon to find code where the caller thinks to know better what the return value should be than the callee. E.g. something like "if (av_new_packet(pkt, size) < 0) return AVERROR(ENOMEM);". This commit changes several instances of this to instead forward the actual error. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat/ty.c')
-rw-r--r--libavformat/ty.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/libavformat/ty.c b/libavformat/ty.c
index bbb2e28a93..738a22e7de 100644
--- a/libavformat/ty.c
+++ b/libavformat/ty.c
@@ -454,7 +454,7 @@ static int demux_video(AVFormatContext *s, TyRecHdr *rec_hdr, AVPacket *pkt)
TYDemuxContext *ty = s->priv_data;
const int subrec_type = rec_hdr->subrec_type;
const int64_t rec_size = rec_hdr->rec_size;
- int es_offset1;
+ int es_offset1, ret;
int got_packet = 0;
if (subrec_type != 0x02 && subrec_type != 0x0c &&
@@ -474,8 +474,8 @@ static int demux_video(AVFormatContext *s, TyRecHdr *rec_hdr, AVPacket *pkt)
int size = rec_hdr->rec_size - VIDEO_PES_LENGTH - es_offset1;
ty->cur_chunk_pos += VIDEO_PES_LENGTH + es_offset1;
- if (av_new_packet(pkt, size) < 0)
- return AVERROR(ENOMEM);
+ if ((ret = av_new_packet(pkt, size)) < 0)
+ return ret;
memcpy(pkt->data, ty->chunk + ty->cur_chunk_pos, size);
ty->cur_chunk_pos += size;
pkt->stream_index = 0;
@@ -498,8 +498,8 @@ static int demux_video(AVFormatContext *s, TyRecHdr *rec_hdr, AVPacket *pkt)
}
if (!got_packet) {
- if (av_new_packet(pkt, rec_size) < 0)
- return AVERROR(ENOMEM);
+ if ((ret = av_new_packet(pkt, rec_size)) < 0)
+ return ret;
memcpy(pkt->data, ty->chunk + ty->cur_chunk_pos, rec_size);
ty->cur_chunk_pos += rec_size;
pkt->stream_index = 0;
@@ -578,7 +578,7 @@ static int demux_audio(AVFormatContext *s, TyRecHdr *rec_hdr, AVPacket *pkt)
TYDemuxContext *ty = s->priv_data;
const int subrec_type = rec_hdr->subrec_type;
const int64_t rec_size = rec_hdr->rec_size;
- int es_offset1;
+ int es_offset1, ret;
if (subrec_type == 2) {
int need = 0;
@@ -621,8 +621,8 @@ static int demux_audio(AVFormatContext *s, TyRecHdr *rec_hdr, AVPacket *pkt)
ty->pes_buf_cnt = 0;
}
- if (av_new_packet(pkt, rec_size - need) < 0)
- return AVERROR(ENOMEM);
+ if ((ret = av_new_packet(pkt, rec_size - need)) < 0)
+ return ret;
memcpy(pkt->data, ty->chunk + ty->cur_chunk_pos, rec_size - need);
ty->cur_chunk_pos += rec_size - need;
pkt->stream_index = 1;
@@ -643,8 +643,8 @@ static int demux_audio(AVFormatContext *s, TyRecHdr *rec_hdr, AVPacket *pkt)
}
}
} else if (subrec_type == 0x03) {
- if (av_new_packet(pkt, rec_size) < 0)
- return AVERROR(ENOMEM);
+ if ((ret = av_new_packet(pkt, rec_size)) < 0)
+ return ret;
memcpy(pkt->data, ty->chunk + ty->cur_chunk_pos, rec_size);
ty->cur_chunk_pos += rec_size;
pkt->stream_index = 1;
@@ -674,15 +674,15 @@ static int demux_audio(AVFormatContext *s, TyRecHdr *rec_hdr, AVPacket *pkt)
} else if (subrec_type == 0x04) {
/* SA Audio with no PES Header */
/* ================================================ */
- if (av_new_packet(pkt, rec_size) < 0)
- return AVERROR(ENOMEM);
+ if ((ret = av_new_packet(pkt, rec_size)) < 0)
+ return ret;
memcpy(pkt->data, ty->chunk + ty->cur_chunk_pos, rec_size);
ty->cur_chunk_pos += rec_size;
pkt->stream_index = 1;
pkt->pts = ty->last_audio_pts;
} else if (subrec_type == 0x09) {
- if (av_new_packet(pkt, rec_size) < 0)
- return AVERROR(ENOMEM);
+ if ((ret = av_new_packet(pkt, rec_size)) < 0)
+ return ret;
memcpy(pkt->data, ty->chunk + ty->cur_chunk_pos, rec_size);
ty->cur_chunk_pos += rec_size ;
pkt->stream_index = 1;