diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2012-11-17 11:50:53 +0100 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2012-11-17 11:54:07 +0100 |
commit | 9b4fb2d5458e6df3ab618f49ed302efa2699d279 (patch) | |
tree | 98af4b218c1570b7df902b06046a09b7c2bc7b20 /src | |
parent | 5f08555df71781b7be31032e7211b6c48e2055b8 (diff) | |
download | advtime-9b4fb2d5458e6df3ab618f49ed302efa2699d279.tar.gz advtime-9b4fb2d5458e6df3ab618f49ed302efa2699d279.tar.bz2 advtime-9b4fb2d5458e6df3ab618f49ed302efa2699d279.zip |
video_decode: Inidicate EOF in get_frame
..and do not print an error message.
Diffstat (limited to 'src')
-rw-r--r-- | src/advtime.c | 2 | ||||
-rw-r--r-- | src/frame_to_pgm.c | 2 | ||||
-rw-r--r-- | src/video_decode.c | 8 | ||||
-rw-r--r-- | src/video_decode.h | 6 |
4 files changed, 14 insertions, 4 deletions
diff --git a/src/advtime.c b/src/advtime.c index 402da31..265d18c 100644 --- a/src/advtime.c +++ b/src/advtime.c @@ -97,7 +97,7 @@ main(int argc, char **argv) if (ret < 0) return -ret; - for (int i = 0; video_decode_get_frame(vd, &frame_b) == 0; ++i) { + for (int i = 0; video_decode_get_frame(vd, &frame_b) > 0; ++i) { printf("%d\t", i); diff --git a/src/frame_to_pgm.c b/src/frame_to_pgm.c index 5295c56..36e9ac8 100644 --- a/src/frame_to_pgm.c +++ b/src/frame_to_pgm.c @@ -36,7 +36,7 @@ main(int argc, char **argv) return -ret; ret = video_decode_get_frame(vd, &frame); - if (ret < 0) + if (ret < 1) return -ret; pgm_save(frame->data, frame->stride, frame->width, frame->height, diff --git a/src/video_decode.c b/src/video_decode.c index 4a2eaf4..c1f7c5a 100644 --- a/src/video_decode.c +++ b/src/video_decode.c @@ -99,6 +99,7 @@ video_decode_get_frame(struct video_decode *vd, struct video_frame **frame) struct video_frame_priv *f; AVPacket packet; int decoded, got_picture; + int ret; f = calloc(1, sizeof *f); if (f == NULL) @@ -108,7 +109,10 @@ video_decode_get_frame(struct video_decode *vd, struct video_frame **frame) do { if (packet.data != NULL) av_free_packet(&packet); - if (av_read_frame(vd->fmt_ctx, &packet) < 0) { + ret = av_read_frame(vd->fmt_ctx, &packet); + if (ret < 0) { + if (ret == AVERROR_EOF) + return 0; #if DEBUG fprintf(stderr, "Found no video stream packet!\n"); #endif @@ -146,7 +150,7 @@ video_decode_get_frame(struct video_decode *vd, struct video_frame **frame) *frame = &f->base; - return 0; + return 1; } void diff --git a/src/video_decode.h b/src/video_decode.h index f9cdfb4..2505b8b 100644 --- a/src/video_decode.h +++ b/src/video_decode.h @@ -15,6 +15,12 @@ video_decode_init(struct video_decode **vd, char *file, int64_t timestamp); void video_decode_uninit(struct video_decode **vd); +/* + * Returns number of decoded frames: + * 1 - One frame decoded + * 0 - Zero frames decoded - EOF + * < 0 - Zero frames decoded - Error + */ int video_decode_get_frame(struct video_decode *vd, struct video_frame **frame); |