# HG changeset patch # User John Tsiombikas # Date 1601119599 -10800 # Node ID 8fc045d33d62b78f2896b680c12bad1e46db1d12 # Parent ba7d221f67250061a812626ba8ca17942af5acea updated the code to work with more recent ffmpeg versions diff -r ba7d221f6725 -r 8fc045d33d62 .hgignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgignore Sat Sep 26 14:26:39 2020 +0300 @@ -0,0 +1,3 @@ +\.o +\.swp +^stereoplay$ diff -r ba7d221f6725 -r 8fc045d33d62 Makefile --- a/Makefile Thu Nov 03 22:01:01 2011 +0200 +++ b/Makefile Sat Sep 26 14:26:39 2020 +0300 @@ -8,7 +8,7 @@ CC = gcc CFLAGS = -pedantic -Wall -g -O2 -LDFLAGS = $(gllibs_$(shell uname -s)) -lavformat -lavcodec -lswscale +LDFLAGS = $(gllibs_$(shell uname -s)) -lavformat -lavcodec -lavutil -lswscale gllibs_Linux = -lGL -lGLU -lglut -lGLEW gllibs_Darwin = -framework OpenGL -framework GLUT -lGLEW diff -r ba7d221f6725 -r 8fc045d33d62 src/stereoplay.c --- a/src/stereoplay.c Thu Nov 03 22:01:01 2011 +0200 +++ b/src/stereoplay.c Sat Sep 26 14:26:39 2020 +0300 @@ -146,11 +146,13 @@ _exit(0); } + fcntl(pfd[0], F_SETFL, fcntl(pfd[0], F_GETFL) | O_NONBLOCK); + dpy = glXGetCurrentDisplay(); xsock = ConnectionNumber(dpy); for(;;) { - int res; + /*int res; fd_set rdset; FD_ZERO(&rdset); @@ -171,8 +173,9 @@ upd_frame = 1; glutPostRedisplay(); } - } + }*/ + upd_frame = 1; glutMainLoopEvent(); if(busy_loop) { glutPostRedisplay(); diff -r ba7d221f6725 -r 8fc045d33d62 src/vid.c --- a/src/vid.c Thu Nov 03 22:01:01 2011 +0200 +++ b/src/vid.c Sat Sep 26 14:26:39 2020 +0300 @@ -1,6 +1,6 @@ /* Stereoplay - an OpenGL stereoscopic video player. -Copyright (C) 2011 John Tsiombikas +Copyright (C) 2011-2020 John Tsiombikas This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,11 +15,11 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ - #include #include #include #include +#include #include "vid.h" struct video_file { @@ -49,13 +49,13 @@ } memset(vf, 0, sizeof *vf); - if(av_open_input_file(&vf->avctx, fname, 0, 0, 0) != 0) { + if(avformat_open_input(&vf->avctx, fname, 0, 0) != 0) { fprintf(stderr, "open_video(%s): failed to open file\n", fname); vid_close(vf); return 0; } - if(av_find_stream_info(vf->avctx) < 0) { + if(avformat_find_stream_info(vf->avctx, 0) < 0) { fprintf(stderr, "open_video(%s): failed to find stream info\n", fname); vid_close(vf); return 0; @@ -81,20 +81,20 @@ return 0; } - if(avcodec_open(vf->cctx, vf->codec) < 0) { + if(avcodec_open2(vf->cctx, vf->codec, 0) < 0) { fprintf(stderr, "open_video(%s): failed to open codec\n", fname); vid_close(vf); return 0; } - if(!(vf->frm = avcodec_alloc_frame()) || !(vf->rgbfrm = avcodec_alloc_frame())) { + if(!(vf->frm = av_frame_alloc()) || !(vf->rgbfrm = av_frame_alloc())) { fprintf(stderr, "open_video(%s): failed to allocate frame\n", fname); vid_close(vf); return 0; } vf->sws = sws_getContext(vf->cctx->width, vf->cctx->height, vf->cctx->pix_fmt, - vf->cctx->width, vf->cctx->height, PIX_FMT_RGB32, SWS_POINT, 0, 0, 0); + vf->cctx->width, vf->cctx->height, AV_PIX_FMT_RGB32, SWS_POINT, 0, 0, 0); if(!vf->sws) { fprintf(stderr, "open_video(%s): failed to allocate sws context\n", fname); vid_close(vf); @@ -117,7 +117,7 @@ if(vf->rgbfrm) av_free(vf->rgbfrm); if(vf->frm) av_free(vf->frm); if(vf->cctx) avcodec_close(vf->cctx); - if(vf->avctx) av_close_input_file(vf->avctx); + if(vf->avctx) avformat_close_input(&vf->avctx); free(vf); } @@ -153,22 +153,22 @@ { AVPacket packet; int frame_done = 0; - AVPicture *rgbfrm = (AVPicture*)vf->rgbfrm; - AVPicture *frm = (AVPicture*)vf->frm; - avpicture_fill((AVPicture*)vf->rgbfrm, (uint8_t*)img, PIX_FMT_RGB32, vf->cctx->width, vf->cctx->height); + av_image_fill_arrays(vf->rgbfrm->data, vf->rgbfrm->linesize, (unsigned char*)img, + AV_PIX_FMT_RGB32, vf->cctx->width, vf->cctx->height, 1); while(av_read_frame(vf->avctx, &packet) >= 0) { if(packet.stream_index == vf->vstream) { avcodec_decode_video2(vf->cctx, vf->frm, &frame_done, &packet); if(frame_done) { - sws_scale(vf->sws, frm->data, frm->linesize, 0, vf->cctx->height, rgbfrm->data, rgbfrm->linesize); - av_free_packet(&packet); + sws_scale(vf->sws, vf->frm->data, vf->frm->linesize, 0, vf->cctx->height, + vf->rgbfrm->data, vf->rgbfrm->linesize); + av_packet_unref(&packet); return 0; } } - av_free_packet(&packet); + av_packet_unref(&packet); } return -1;