Commit 6eeec6cb authored by Max Kellermann's avatar Max Kellermann

decoder/ffpmeg: simplify ffmpeg_send_packet()

parent 5e3f3b04
...@@ -370,7 +370,7 @@ ffmpeg_send_packet(Decoder &decoder, InputStream &is, ...@@ -370,7 +370,7 @@ ffmpeg_send_packet(Decoder &decoder, InputStream &is,
time_from_ffmpeg(pts, stream.time_base)); time_from_ffmpeg(pts, stream.time_base));
} }
uint8_t *output_buffer; uint8_t *output_buffer = nullptr;
DecoderCommand cmd = DecoderCommand::NONE; DecoderCommand cmd = DecoderCommand::NONE;
while (packet.size > 0 && cmd == DecoderCommand::NONE) { while (packet.size > 0 && cmd == DecoderCommand::NONE) {
...@@ -379,15 +379,6 @@ ffmpeg_send_packet(Decoder &decoder, InputStream &is, ...@@ -379,15 +379,6 @@ ffmpeg_send_packet(Decoder &decoder, InputStream &is,
int len = avcodec_decode_audio4(&codec_context, int len = avcodec_decode_audio4(&codec_context,
frame, &got_frame, frame, &got_frame,
&packet); &packet);
if (len >= 0 && got_frame) {
audio_size = copy_interleave_frame(codec_context,
*frame,
&output_buffer,
buffer, buffer_size);
if (audio_size < 0)
len = audio_size;
}
if (len < 0) { if (len < 0) {
/* if error, we skip the frame */ /* if error, we skip the frame */
LogDefault(ffmpeg_domain, LogDefault(ffmpeg_domain,
...@@ -395,6 +386,18 @@ ffmpeg_send_packet(Decoder &decoder, InputStream &is, ...@@ -395,6 +386,18 @@ ffmpeg_send_packet(Decoder &decoder, InputStream &is,
break; break;
} }
if (got_frame) {
audio_size = copy_interleave_frame(codec_context,
*frame,
&output_buffer,
buffer, buffer_size);
if (audio_size < 0) {
/* this must be a serious error,
e.g. OOM */
return DecoderCommand::STOP;
}
}
packet.data += len; packet.data += len;
packet.size -= len; packet.size -= len;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment