I.e. if the packet was only partially consumed, pass the rest of it into
the decoder again.
Also simplify the code so it's the same for video/audio/subs.
---
avconv.c | 21 ++++++++-------------
1 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/avconv.c b/avconv.c
index 3ba8534..9cba708 100644
--- a/avconv.c
+++ b/avconv.c
@@ -1634,15 +1634,13 @@ static int transcode_audio(InputStream *ist, AVPacket
*pkt, int *got_output)
pkt);
if (ret < 0)
return ret;
- pkt->data += ret;
- pkt->size -= ret;
*got_output = decoded_data_size > 0;
/* Some bug in mpeg audio decoder gives */
/* decoded_data_size < 0, it seems they are overflows */
if (!*got_output) {
/* no audio frame */
- return 0;
+ return ret;
}
decoded_data_buf = (uint8_t *)samples;
@@ -1715,7 +1713,7 @@ static int transcode_audio(InputStream *ist, AVPacket
*pkt, int *got_output)
do_audio_out(output_files[ost->file_index].ctx, ost, ist,
decoded_data_buf, decoded_data_size);
}
- return 0;
+ return ret;
}
static int transcode_video(InputStream *ist, AVPacket *pkt, int *got_output,
int64_t *pkt_pts)
@@ -1743,7 +1741,7 @@ static int transcode_video(InputStream *ist, AVPacket
*pkt, int *got_output, int
if (!*got_output) {
/* no picture yet */
av_freep(&decoded_frame);
- return 0;
+ return ret;
}
ist->next_pts = ist->pts = guess_correct_pts(&ist->pts_ctx,
decoded_frame->pkt_pts,
decoded_frame->pkt_dts);
@@ -1819,9 +1817,7 @@ static int transcode_subtitles(InputStream *ist, AVPacket
*pkt, int *got_output)
if (ret < 0)
return ret;
if (!*got_output)
- return 0;
-
- pkt->size = 0;
+ return ret;
rate_emu_sleep(ist);
@@ -1835,7 +1831,7 @@ static int transcode_subtitles(InputStream *ist, AVPacket
*pkt, int *got_output)
}
avsubtitle_free(&subtitle);
- return 0;
+ return ret;
}
/* pkt = NULL means EOF (needed to flush decoder buffers) */
@@ -1891,13 +1887,12 @@ static int output_packet(InputStream *ist, int
ist_index,
if (ret < 0)
return ret;
+ avpkt.data += ret;
+ avpkt.size -= ret;
if (!got_output) {
- if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
- continue;
- goto discard_packet;
+ continue;
}
}
- discard_packet:
/* handle stream copy */
if (!ist->decoding_needed) {
--
1.7.7
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel