summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2013-01-31 21:10:45 +0100
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2013-01-31 21:16:06 +0100
commit25803d8daa30bc8c113b72c7f11b831ca1bf249d (patch)
tree190a4f596516c4b9971f8cfff29fc3aa2b3c2fae /src
parent308acce5a2e925e016d3b3ed9cc32802fc71633f (diff)
downloadadvtime-25803d8daa30bc8c113b72c7f11b831ca1bf249d.tar.gz
advtime-25803d8daa30bc8c113b72c7f11b831ca1bf249d.tar.bz2
advtime-25803d8daa30bc8c113b72c7f11b831ca1bf249d.zip
video-decode: Fix the got_picture = 0 case
We actually tried to read the same packet again, but that doesnt work, so lets just drop it..
Diffstat (limited to 'src')
-rw-r--r--src/video_decode.c37
1 files changed, 16 insertions, 21 deletions
diff --git a/src/video_decode.c b/src/video_decode.c
index 7ce6f42..b923f93 100644
--- a/src/video_decode.c
+++ b/src/video_decode.c
@@ -117,7 +117,7 @@ video_decode_get_frame(struct video_decode *_vd, struct video_frame **frame)
struct video_decode_priv *vd = (struct video_decode_priv *) _vd;
struct video_frame_priv *f;
AVPacket packet;
- int decoded, got_picture;
+ int decoded, got_picture = 0;
int ret;
if (*frame != NULL) {
@@ -131,8 +131,6 @@ video_decode_get_frame(struct video_decode *_vd, struct video_frame **frame)
packet.data = NULL;
do {
- if (packet.data != NULL)
- av_free_packet(&packet);
ret = av_read_frame(vd->fmt_ctx, &packet);
if (ret < 0) {
if (ret == AVERROR_EOF) {
@@ -148,28 +146,25 @@ video_decode_get_frame(struct video_decode *_vd, struct video_frame **frame)
#endif
return -1;
}
- } while (packet.stream_index != vd->stream);
-
- do {
+ if (packet.stream_index == vd->stream) {
#if DEBUG
- printf("packet.data: %p, packet.siz: %d, packet.strm_idx: %d\n",
- packet.data, packet.size, packet.stream_index);
+ printf("packet.data: %p, packet.siz: %d, packet.strm_idx: %d\n",
+ packet.data, packet.size, packet.stream_index);
#endif
- decoded = avcodec_decode_video2(vd->codec_ctx, f->frame,
- &got_picture, &packet);
- if (decoded < 0) {
- fprintf(stderr, "Error while decoding frame!\n");
- return -2;
- }
+ decoded = avcodec_decode_video2(vd->codec_ctx, f->frame,
+ &got_picture, &packet);
+ if (decoded < 0) {
+ fprintf(stderr, "Error while decoding frame!\n");
+ return -2;
+ }
+
#if DEBUG
- printf("bytes_decoded: %d, got_picture: %d\n",
- decoded, got_picture);
+ printf("bytes_decoded: %d, got_picture: %d\n",
+ decoded, got_picture);
#endif
-
- } while (got_picture == 0 && packet.size > 0);
- av_free_packet(&packet);
- if (got_picture == 0)
- return -3;
+ }
+ av_free_packet(&packet);
+ } while (got_picture == 0);
f->base.data = f->frame->data[0];
f->base.width = vd->codec_ctx->width;