libav: extract frame from AVFormatContext

This commit is contained in:
nick black 2019-11-24 23:56:14 -05:00 committed by Nick Black
parent 66b06e9d91
commit 66432c37e1
2 changed files with 18 additions and 1 deletions

View File

@ -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)); fprintf(stderr, "Couldn't open %s (%s)\n", filename, av_err2str(ret));
return 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); avformat_free_context(ps);
return 0; return 0;
} }

View File

@ -149,7 +149,7 @@ TEST_F(NcplaneTest, VerticalLines) {
ASSERT_LT(0, y); ASSERT_LT(0, y);
ASSERT_LT(0, x); ASSERT_LT(0, x);
cell c{}; cell c{};
cell_load(n_, &c, "-"); cell_load(n_, &c, "|");
for(int xidx = 0 ; xidx < x - 1 ; ++xidx){ for(int xidx = 0 ; xidx < x - 1 ; ++xidx){
EXPECT_EQ(0, ncplane_cursor_move_yx(n_, 1, xidx)); EXPECT_EQ(0, ncplane_cursor_move_yx(n_, 1, xidx));
EXPECT_EQ(y - 2, ncplane_vline(n_, &c, y - 2)); EXPECT_EQ(y - 2, ncplane_vline(n_, &c, y - 2));