From 66432c37e100dd85922b9ece632f083aec0e3dad Mon Sep 17 00:00:00 2001 From: nick black Date: Sun, 24 Nov 2019 23:56:14 -0500 Subject: [PATCH] libav: extract frame from AVFormatContext --- src/lib/libav.c | 17 +++++++++++++++++ tests/ncplane.cpp | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/lib/libav.c b/src/lib/libav.c index 6f651b5b8..22e23f23b 100644 --- a/src/lib/libav.c +++ b/src/lib/libav.c @@ -9,6 +9,23 @@ int notcurses_image_open(struct notcurses* nc, const char* filename){ fprintf(stderr, "Couldn't open %s (%s)\n", filename, av_err2str(ret)); return ret; } + if((ret = avformat_find_stream_info(ps, NULL)) < 0){ + fprintf(stderr, "Error extracting stream info from %s (%s)\n", filename, + av_err2str(ret)); + avformat_free_context(ps); + return ret; + } + // av_dump_format(ps, 0, filename, false); + AVPacket* packet = av_packet_alloc(); + if((ret = av_read_frame(ps, packet)) < 0){ + fprintf(stderr, "Error reading frame info from %s (%s)\n", filename, + av_err2str(ret)); + av_packet_free(&packet); + avformat_free_context(ps); + return -1; + } + // FIXME + av_packet_free(&packet); avformat_free_context(ps); return 0; } diff --git a/tests/ncplane.cpp b/tests/ncplane.cpp index 971e940ca..4908cc278 100644 --- a/tests/ncplane.cpp +++ b/tests/ncplane.cpp @@ -149,7 +149,7 @@ TEST_F(NcplaneTest, VerticalLines) { ASSERT_LT(0, y); ASSERT_LT(0, x); cell c{}; - cell_load(n_, &c, "-"); + cell_load(n_, &c, "|"); for(int xidx = 0 ; xidx < x - 1 ; ++xidx){ EXPECT_EQ(0, ncplane_cursor_move_yx(n_, 1, xidx)); EXPECT_EQ(y - 2, ncplane_vline(n_, &c, y - 2));