From 0dd4386d77b5c66c065af69a2a8fcd849f5d1b70 Mon Sep 17 00:00:00 2001
From: Alexander Reshetnikov <no@email>
Date: Wed, 21 Mar 2012 18:07:34 +0000
Subject: [PATCH] Updated new ffmpeg wrapper; restored NEW_FFMPEG in the root
 cmake file

---
 CMakeLists.txt                             |  6 +++---
 modules/highgui/src/cap_ffmpeg_impl_v2.hpp | 21 +++++++--------------
 2 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 25eae782df..9108d70b44 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -394,9 +394,9 @@ if(UNIX)
       endif()
     endif()
 
-    #if(HAVE_FFMPEG)
-    #CHECK_MODULE(libavformat>=52.111.0 NEW_FFMPEG)
-    #endif()
+    if(HAVE_FFMPEG)
+    CHECK_MODULE(libavformat>=52.111.0 NEW_FFMPEG)
+    endif()
 
     if(WITH_1394)
       CHECK_MODULE(libdc1394-2 HAVE_DC1394_2)
diff --git a/modules/highgui/src/cap_ffmpeg_impl_v2.hpp b/modules/highgui/src/cap_ffmpeg_impl_v2.hpp
index ddf30323eb..0dc13b2ade 100755
--- a/modules/highgui/src/cap_ffmpeg_impl_v2.hpp
+++ b/modules/highgui/src/cap_ffmpeg_impl_v2.hpp
@@ -545,11 +545,11 @@ bool CvCapture_FFMPEG::reopen()
 	#endif
 
 	AVCodec *codec = avcodec_find_decoder(enc->codec_id);
-	#if FF_API_AVCODEC_OPEN
-		avcodec_open(enc, codec);
-	#else
-		avcodec_open_2(enc, codec, NULL);
-	#endif
+    #if LIBAVCODEC_VERSION_INT >= ((53<<16)+(8<<8)+0)
+        avcodec_open2(enc, codec, NULL);
+    #else
+        avcodec_open(enc, codec);
+    #endif
 	video_st = ic->streams[video_stream];
 
 	// reset framenumber to zero
@@ -742,15 +742,8 @@ bool CvCapture_FFMPEG::retrieveFrame(int, unsigned char** data, int* step, int*
 
     avpicture_fill((AVPicture*)&rgb_picture, rgb_picture.data[0], PIX_FMT_RGB24, video_st->codec->width, video_st->codec->height);
 
-    #if LIBAVCODEC_VERSION_INT >= ((52<<16)+(123<<8)+0)
-
-                    frame.width  = picture->width;
-                    frame.height = picture->height;
-
-    #else
-                    frame.width = video_st->codec->width;
-                    frame.height = video_st->codec->height;
-    #endif
+    frame.width = video_st->codec->width;
+    frame.height = video_st->codec->height;
 
    img_convert_ctx = sws_getContext(
                                                          video_st->codec->width, video_st->codec->height,