avconv: use the same behavior when decoding audio/video/subs
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.
This commit is contained in:
parent
3eedd29bd7
commit
af8ad892bf
19
avconv.c
19
avconv.c
@ -1635,15 +1635,13 @@ static int transcode_audio(InputStream *ist, AVPacket *pkt, int *got_output)
|
|||||||
pkt);
|
pkt);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
pkt->data += ret;
|
|
||||||
pkt->size -= ret;
|
|
||||||
*got_output = decoded_data_size > 0;
|
*got_output = decoded_data_size > 0;
|
||||||
|
|
||||||
/* Some bug in mpeg audio decoder gives */
|
/* Some bug in mpeg audio decoder gives */
|
||||||
/* decoded_data_size < 0, it seems they are overflows */
|
/* decoded_data_size < 0, it seems they are overflows */
|
||||||
if (!*got_output) {
|
if (!*got_output) {
|
||||||
/* no audio frame */
|
/* no audio frame */
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
decoded_data_buf = (uint8_t *)samples;
|
decoded_data_buf = (uint8_t *)samples;
|
||||||
@ -1716,7 +1714,7 @@ static int transcode_audio(InputStream *ist, AVPacket *pkt, int *got_output)
|
|||||||
do_audio_out(output_files[ost->file_index].ctx, ost, ist,
|
do_audio_out(output_files[ost->file_index].ctx, ost, ist,
|
||||||
decoded_data_buf, decoded_data_size);
|
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)
|
static int transcode_video(InputStream *ist, AVPacket *pkt, int *got_output, int64_t *pkt_pts)
|
||||||
@ -1744,7 +1742,7 @@ static int transcode_video(InputStream *ist, AVPacket *pkt, int *got_output, int
|
|||||||
if (!*got_output) {
|
if (!*got_output) {
|
||||||
/* no picture yet */
|
/* no picture yet */
|
||||||
av_freep(&decoded_frame);
|
av_freep(&decoded_frame);
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
ist->next_pts = ist->pts = guess_correct_pts(&ist->pts_ctx, decoded_frame->pkt_pts,
|
ist->next_pts = ist->pts = guess_correct_pts(&ist->pts_ctx, decoded_frame->pkt_pts,
|
||||||
decoded_frame->pkt_dts);
|
decoded_frame->pkt_dts);
|
||||||
@ -1820,9 +1818,7 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
if (!*got_output)
|
if (!*got_output)
|
||||||
return 0;
|
return ret;
|
||||||
|
|
||||||
pkt->size = 0;
|
|
||||||
|
|
||||||
rate_emu_sleep(ist);
|
rate_emu_sleep(ist);
|
||||||
|
|
||||||
@ -1836,7 +1832,7 @@ static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output)
|
|||||||
}
|
}
|
||||||
|
|
||||||
avsubtitle_free(&subtitle);
|
avsubtitle_free(&subtitle);
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* pkt = NULL means EOF (needed to flush decoder buffers) */
|
/* pkt = NULL means EOF (needed to flush decoder buffers) */
|
||||||
@ -1895,13 +1891,12 @@ static int output_packet(InputStream *ist, int ist_index,
|
|||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
avpkt.data += ret;
|
||||||
|
avpkt.size -= ret;
|
||||||
if (!got_output) {
|
if (!got_output) {
|
||||||
if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
|
|
||||||
continue;
|
continue;
|
||||||
goto discard_packet;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
discard_packet:
|
|
||||||
|
|
||||||
/* handle stream copy */
|
/* handle stream copy */
|
||||||
if (!ist->decoding_needed) {
|
if (!ist->decoding_needed) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user