changeset 41:0d76b2b962ad

added mpeg 1/2 postprocessing
author arpi_esp
date Mon, 05 Mar 2001 23:02:30 +0000
parents 2fed43f60181
children 71ac847ba504
files configure libmpeg2/decode.c libmpeg2/mpeg2_internal.h libmpeg2/slice.c mplayer.c
diffstat 5 files changed, 62 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/configure	Mon Mar 05 15:33:10 2001 +0000
+++ b/configure	Mon Mar 05 23:02:30 2001 +0000
@@ -683,6 +683,9 @@
 /* LIRC (remote control, see www.lirc.org) support: */
 $_lircdefs
 
+/* Define this to enable MPEG 1/2 image postprocessing (requires FAST cpu!) */
+#define MPEG12_POSTPROC
+
 /* Define if your processor stores words with the most significant
    byte first (like Motorola and SPARC, unlike Intel and VAX).  */
 /* #define WORDS_BIGENDIAN */
--- a/libmpeg2/decode.c	Mon Mar 05 15:33:10 2001 +0000
+++ b/libmpeg2/decode.c	Mon Mar 05 23:02:30 2001 +0000
@@ -51,7 +51,7 @@
 static int drop_flag = 0;
 static int drop_frame = 0;
 
-#ifdef POSTPROC
+#ifdef MPEG12_POSTPROC
 int quant_store[MBR+1][MBC+1]; // [Review]
 #endif
 
@@ -86,7 +86,7 @@
     motion_comp_init ();
 }
 
-static vo_frame_t frames[3];
+static vo_frame_t frames[4];
 
 void mpeg2_allocate_image_buffers (picture_t * picture)
 {
@@ -100,7 +100,11 @@
         buff_size = frame_size + (frame_size/4)*2; // 4Y + 1U + 1V
 
 	// allocate images in YV12 format
+#ifdef MPEG12_POSTPROC
+	for(i=0;i<4;i++){
+#else
 	for(i=0;i<3;i++){
+#endif
             base = shmem_alloc(buff_size);
 	    frames[i].base[0] = base;
 	    frames[i].base[1] = base + frame_size * 5 / 4;
@@ -114,13 +118,6 @@
 	picture->backward_reference_frame=&frames[1];
 	picture->current_frame=&frames[2];
 
-#ifdef POSTPROC
-        base = shmem_alloc(buff_size);
-	picture->pp_frame[0] = base;
-	picture->pp_frame[1] = base + frame_size * 5 / 4;
-	picture->pp_frame[2] = base + frame_size;
-#endif
-
 }
 
 static void copy_slice (vo_frame_t * frame, uint8_t ** src){
@@ -157,6 +154,23 @@
 	if (((picture->picture_structure == FRAME_PICTURE) ||
 		 (picture->second_field))
            ) {
+#ifdef MPEG12_POSTPROC
+	       if(picture->pp_options){
+                    // apply OpenDivX postprocess filter
+            	    int stride[3];
+            	    stride[0]=picture->coded_picture_width;
+            	    stride[1]=stride[2]=stride[0]/2;
+                    postprocess((picture->picture_coding_type == B_TYPE) ?
+			    picture->current_frame->base :
+			    picture->forward_reference_frame->base,
+			stride[0], frames[3].base, stride[0],
+                        picture->coded_picture_width, picture->coded_picture_height,
+                        &quant_store[1][1], (MBC+1), picture->pp_options);
+		    output->draw_slice (frames[3].base, stride, 
+                        picture->display_picture_width,
+                        picture->display_picture_height, 0, 0);
+	       } else
+#endif
 #if 1
 		if (picture->picture_coding_type != B_TYPE) {
             	    int stride[3];
@@ -215,6 +229,10 @@
 	    } else {
 		if (picture->picture_coding_type == B_TYPE){
 		    picture->current_frame = &frames[2];
+#ifdef MPEG12_POSTPROC
+	            if(picture->pp_options)
+			picture->current_frame->copy=NULL; else
+#endif
 		    picture->current_frame->copy=copy_slice;
 		} else {
 		    picture->current_frame = picture->forward_reference_frame;
--- a/libmpeg2/mpeg2_internal.h	Mon Mar 05 15:33:10 2001 +0000
+++ b/libmpeg2/mpeg2_internal.h	Mon Mar 05 23:02:30 2001 +0000
@@ -209,3 +209,9 @@
 
 /* stats.c */
 void stats_header (uint8_t code, uint8_t * buffer);
+
+#ifdef MPEG12_POSTPROC
+#define MBC 45
+#define MBR 36
+extern int quant_store[MBR+1][MBC+1]; // [Review]
+#endif
--- a/libmpeg2/slice.c	Mon Mar 05 15:33:10 2001 +0000
+++ b/libmpeg2/slice.c	Mon Mar 05 23:02:30 2001 +0000
@@ -1488,7 +1488,7 @@
 	    dest[1] += 4 * stride;					\
 	    dest[2] += 4 * stride;					\
 	} while (0);							\
-	offset = 0;							\
+	offset = 0; ++code;						\
     }									\
 } while (0)
 
@@ -1739,6 +1739,9 @@
 		picture->dc_dct_pred[2] = 1 << (picture->intra_dc_precision+7);
 	}
 
+#ifdef MPEG12_POSTPROC
+	quant_store[code][(offset>>4)+1] = picture->quantizer_scale;
+#endif
 	offset += 16;
 	CHECK_DISPLAY;
 
@@ -1769,6 +1772,10 @@
 		    else
 			MOTION (motion_fi_zero, MACROBLOCK_MOTION_FORWARD);
 
+#ifdef MPEG12_POSTPROC
+	quant_store[code][(offset>>4)+1] = picture->quantizer_scale;
+#endif
+
 		    offset += 16;
 		    CHECK_DISPLAY;
 		} while (--mba_inc);
@@ -1781,6 +1788,10 @@
 		    else
 			MOTION (motion_fi_reuse, macroblock_modes);
 
+#ifdef MPEG12_POSTPROC
+	quant_store[code][(offset>>4)+1] = picture->quantizer_scale;
+#endif
+
 		    offset += 16;
 		    CHECK_DISPLAY;
 		} while (--mba_inc);
--- a/mplayer.c	Mon Mar 05 15:33:10 2001 +0000
+++ b/mplayer.c	Mon Mar 05 23:02:30 2001 +0000
@@ -337,7 +337,11 @@
 
 for(i=1;i<argc;i++){
   if(strcmp(argv[i],"-o")==0){
-    printf("Option -o has been changed to -vo (video-out), use -vo !\n");
+    printf("Option -o has been renamed to -vo (video-out), use -vo !\n");
+    exit(1);
+  } else
+  if(strcmp(argv[i],"-divxq")==0){
+    printf("Option -divxq has been renamed to -pp (postprocessing), use -pp !\n");
     exit(1);
   } else
   if(strcmp(argv[i],"-vo")==0)  video_driver=argv[++i]; else
@@ -368,7 +372,7 @@
   if(strcmp(argv[i],"-fps")==0) force_fps=strtod(argv[++i],NULL); else
   if(strcmp(argv[i],"-afm")==0) audio_format=strtol(argv[++i],NULL,0); else
   if(strcmp(argv[i],"-vcd")==0) vcd_track=strtol(argv[++i],NULL,0); else
-  if(strcmp(argv[i],"-divxq")==0) divx_quality=strtol(argv[++i],NULL,0); else
+  if(strcmp(argv[i],"-pp")==0) divx_quality=strtol(argv[++i],NULL,0); else
   if(strcmp(argv[i],"-br")==0) encode_bitrate=strtol(argv[++i],NULL,0); else
   if(strcmp(argv[i],"-x")==0) screen_size_x=strtol(argv[++i],NULL,0); else
   if(strcmp(argv[i],"-y")==0) screen_size_y=strtol(argv[++i],NULL,0); else
@@ -847,7 +851,15 @@
    if(!videobuffer){ printf("Cannot allocate shared memory\n");exit(0);}
    // init libmpeg2:
    mpeg2_init();
+#ifdef MPEG12_POSTPROC
    picture->pp_options=divx_quality;
+#else
+   if(divx_quality){
+       printf("WARNING! You requested image postprocessing for an MPEG 1/2 video,\n");
+       printf("         but compiled MPlayer without MPEG 1/2 postprocessing support!\n");
+       printf("         #define MPEG12_POSTPROC in config.h, and recompile libmpeg2!\n");
+   }
+#endif
    if(verbose)  printf("mpeg2_init() ok\n");
    // ========= Read & process sequence header & extension ============
    videobuf_len=0;