From 9cd3766f6e715b15275240490da39090bfee55e6 Mon Sep 17 00:00:00 2001
From: Juanjo <pulento@users.sourceforge.net>
Date: Sat, 11 May 2002 23:42:16 +0000
Subject: [PATCH] - pict_type exported to AVCodecContext - Added real_pict_num
 to AVCodecContext, it represent the number of the   previous encoded frame,
 usefull when coding with B frames. - Warning fix in motion_est.c

Originally committed as revision 484 to svn://svn.ffmpeg.org/ffmpeg/trunk
---
 libavcodec/avcodec.h    | 25 ++++++++++++++++++-------
 libavcodec/motion_est.c |  2 +-
 libavcodec/mpegvideo.c  |  4 +++-
 libavcodec/mpegvideo.h  |  6 ------
 4 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 803963c6381..a3efe81c5b7 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -5,8 +5,8 @@
 
 #define LIBAVCODEC_VERSION_INT 0x000406
 #define LIBAVCODEC_VERSION     "0.4.6"
-#define LIBAVCODEC_BUILD       4605
-#define LIBAVCODEC_BUILD_STR   "4605"
+#define LIBAVCODEC_BUILD       4606
+#define LIBAVCODEC_BUILD_STR   "4606"
 
 enum CodecID {
     CODEC_ID_NONE, 
@@ -145,11 +145,22 @@ typedef struct AVCodecContext {
     int sample_fmt;  /* sample format, currenly unused */
 
     /* the following data should not be initialized */
-    int frame_size; /* in samples, initialized when calling 'init' */
-    int frame_number; /* audio or video frame number */
-    int key_frame;    /* true if the previous compressed frame was 
-                         a key frame (intra, or seekable) */
-    int delay;        /* number of frames the decoded output will be delayed relative to the encoded input */
+    int frame_size;     /* in samples, initialized when calling 'init' */
+    int frame_number;   /* audio or video frame number */
+    int real_pict_num;  /* returns the real picture number of
+                           previous encoded frame */
+    int key_frame;      /* true if the previous compressed frame was 
+                           a key frame (intra, or seekable) */
+    int pict_type;      /* picture type of the previous 
+                           encoded frame */
+/* FIXME: these should have FF_ */
+#define I_TYPE 1 // Intra
+#define P_TYPE 2 // Predicted
+#define B_TYPE 3 // Bi-dir predicted
+#define S_TYPE 4 // S(GMC)-VOP MPEG4
+
+    int delay;          /* number of frames the decoded output 
+                           will be delayed relative to the encoded input */
     uint8_t *mbskip_table; /* =1 if MB didnt change, is only valid for I/P frames 
                               stride= mb_width = (width+15)>>4 */
     
diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c
index 1ba246ae5cd..0cd815bc57a 100644
--- a/libavcodec/motion_est.c
+++ b/libavcodec/motion_est.c
@@ -25,7 +25,7 @@
 #include "dsputil.h"
 #include "mpegvideo.h"
 
-#define ABS(a) ((a)>0 ? (a) : -(a))
+//#define ABS(a) ((a)>0 ? (a) : -(a))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 #define INTER_BIAS	257
 
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 19deb2da99a..d4b22138b59 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -793,7 +793,9 @@ int MPV_encode_picture(AVCodecContext *avctx,
         MPV_frame_start(s);
 
         encode_picture(s, s->picture_number);
-        avctx->key_frame = (s->pict_type == I_TYPE);
+        avctx->key_frame   = (s->pict_type == I_TYPE);
+        avctx->pict_type   = s->pict_type;
+        avctx->real_pict_num  = s->picture_number;
         avctx->header_bits = s->header_bits;
         avctx->mv_bits     = s->mv_bits;
         avctx->misc_bits   = s->misc_bits;
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 1a3c853e266..3b44644def7 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -17,12 +17,6 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-/* Macros for picture code type. */
-#define I_TYPE 1
-#define P_TYPE 2
-#define B_TYPE 3
-#define S_TYPE 4 //S(GMC)-VOP MPEG4
-
 #define FRAME_SKIPED 100 // return value for header parsers if frame is not coded
 
 enum OutputFormat {
-- 
GitLab