changeset 1349:3db173705860

DivX4Linux support
author arpi
date Thu, 19 Jul 2001 22:43:19 +0000
parents e7778832010d
children f32b294e41ad
files DOCS/codecs.conf Makefile codec-cfg.c configure dec_video.c
diffstat 5 files changed, 103 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/DOCS/codecs.conf	Thu Jul 19 22:02:06 2001 +0000
+++ b/DOCS/codecs.conf	Thu Jul 19 22:43:19 2001 +0000
@@ -81,6 +81,23 @@
   dll "divxc32.dll"
   out YUY2 yuvhack
   out BGR32,BGR24,BGR15
+
+videocodec divx4
+  info "DivX4Linux (MPEG-4 v2,v3)"
+  comment "with postprocessing"
+  status working
+  fourcc DIVX,divx
+  fourcc DIV1,div1 divx
+  fourcc MP4S,mp4s	; ISO MPEG-4 Video V1
+  fourcc MP43,mp43,DIV3,div3,DIV4,div4 DIV3  ; for DivX4Linux only!
+  format 0x4
+  driver divx4
+  dll "libdivxdecore.0"
+;  out YV12   ; works, but odivx driver is faster with YV12 (DEC_USER)
+  out I420
+  out YUY2
+  out UYVY
+  out BGR32,BGR24,BGR16,BGR15
   
 videocodec odivx
   info "OpenDivX (MPEG-4 v2)"
@@ -89,6 +106,7 @@
   fourcc DIVX,divx
   fourcc DIV1,div1 divx
   fourcc MP4S,mp4s	; ISO MPEG-4 Video V1
+  fourcc MP43,mp43,DIV3,div3,DIV4,div4 DIV3  ; for DivX4Linux only!
   format 0x4
   driver odivx
   dll "opendivx decore"
--- a/Makefile	Thu Jul 19 22:02:06 2001 +0000
+++ b/Makefile	Thu Jul 19 22:43:19 2001 +0000
@@ -81,7 +81,7 @@
 	@for a in mp3lib libac3 libmpeg2 libvo opendivx libavcodec encore loader/DirectShow ; do $(MAKE) -C $$a all ; done
 
 $(PRG):	$(MPLAYER_DEP)
-	$(CC) $(CFLAGS) -o $(PRG) mplayer.o $(OBJS) $(XMM_LIBS) $(LIRC_LIBS) $(A_LIBS) -lm $(TERMCAP_LIB) $(LIB_LOADER) $(AV_LIB) -Llibmpeg2 -lmpeg2 -Lopendivx -ldecore -Llibao2 -lao2 $(VO_LIBS) $(CSS_LIB) -Lencore -lencore $(ARCH_LIBS)
+	$(CC) $(CFLAGS) -o $(PRG) mplayer.o $(OBJS) $(XMM_LIBS) $(LIRC_LIBS) $(A_LIBS) -lm $(TERMCAP_LIB) $(LIB_LOADER) $(AV_LIB) -Llibmpeg2 -lmpeg2 -Llibao2 -lao2 $(VO_LIBS) $(CSS_LIB) -Lencore -lencore $(DECORE_LIBS) $(ARCH_LIBS)
 
 $(PRG_FIBMAP): fibmap_mplayer.o
 	$(CC) -o $(PRG_FIBMAP) fibmap_mplayer.o
--- a/codec-cfg.c	Thu Jul 19 22:02:06 2001 +0000
+++ b/codec-cfg.c	Thu Jul 19 22:43:19 2001 +0000
@@ -214,6 +214,7 @@
 		"dshow",
 		"ffmpeg",
 		"vfwex",
+		"divx4",
 		NULL
 	};
         char **drv=audioflag?audiodrv:videodrv;
--- a/configure	Thu Jul 19 22:02:06 2001 +0000
+++ b/configure	Thu Jul 19 22:43:19 2001 +0000
@@ -1703,6 +1703,8 @@
 ESD_LIB = $_esdlib
 ARCH_LIBS = $_archlibs
 STREAM_SRCS = $_streamingsrcs
+DECORE_LIBS = -Lopendivx -ldecore
+# DECORE_LIBS=-L/usr/local/lib -ldivxdecore
 
 # --- Some stuff for autoconfigure ----
 $_target_arch
@@ -1720,6 +1722,10 @@
 
 /* -------- Generated by ./configure ----------- */
 
+/* Define for using new DivX4Linux library, instead of open-source OpenDivX */
+/* You have to change DECORE_LIBS in config.mak too! */
+#undef NEW_DECORE
+
 /* Define this to enable avg. byte/sec-based AVI sync method by default:
    (use -bps or -nobps commandline option for run-time method selection)    */
 #undef AVI_SYNC_BPS
--- a/dec_video.c	Thu Jul 19 22:02:06 2001 +0000
+++ b/dec_video.c	Thu Jul 19 22:43:19 2001 +0000
@@ -45,7 +45,11 @@
     AVPicture lavc_picture;
 #endif
 
+#ifndef NEW_DECORE
 #include "opendivx/decore.h"
+#else
+#include <decore.h>
+#endif
 
 //**************************************************************************//
 //             The OpenDivX stuff:
@@ -156,29 +160,47 @@
    if(verbose) printf("OpenDivX video codec\n");
    { DEC_PARAM dec_param;
      DEC_SET dec_set;
+        memset(&dec_param,0,sizeof(dec_param));
 #ifdef NEW_DECORE
-     DEC_MEM_REQS dec_mem;
         dec_param.output_format=DEC_USER;
 #else
         dec_param.color_depth = 32;
 #endif
 	dec_param.x_dim = sh_video->bih->biWidth;
 	dec_param.y_dim = sh_video->bih->biHeight;
-#ifdef NEW_DECORE
-        // 0.50-CVS new malloc scheme
-        decore(0x123, DEC_OPT_MEMORY_REQS, &dec_param, &dec_mem);
-        dec_param.buffers.mp4_edged_ref_buffers=malloc(dec_mem.mp4_edged_ref_buffers_size);
-        dec_param.buffers.mp4_edged_for_buffers=malloc(dec_mem.mp4_edged_for_buffers_size);
-        dec_param.buffers.mp4_display_buffers=malloc(dec_mem.mp4_display_buffers_size);
-        dec_param.buffers.mp4_state=malloc(dec_mem.mp4_state_size);
-        dec_param.buffers.mp4_tables=malloc(dec_mem.mp4_tables_size);
-        dec_param.buffers.mp4_stream=malloc(dec_mem.mp4_stream_size);
-#endif
 	decore(0x123, DEC_OPT_INIT, &dec_param, NULL);
-
 	dec_set.postproc_level = divx_quality;
 	decore(0x123, DEC_OPT_SETPP, &dec_set, NULL);
-
+   }
+   if(verbose) printf("INFO: OpenDivX video codec init OK!\n");
+   break;
+ }
+ case 7: {  // DivX4Linux
+   if(verbose) printf("DivX4Linux video codec\n");
+   { DEC_PARAM dec_param;
+     DEC_SET dec_set;
+     int bits=16;
+        memset(&dec_param,0,sizeof(dec_param));
+	switch(out_fmt){
+	case IMGFMT_YV12: dec_param.output_format=DEC_YV12;bits=12;break;
+	case IMGFMT_YUY2: dec_param.output_format=DEC_YUY2;break;
+	case IMGFMT_UYVY: dec_param.output_format=DEC_UYVY;break;
+	case IMGFMT_I420: dec_param.output_format=DEC_420;bits=12;break;
+	case IMGFMT_BGR15: dec_param.output_format=DEC_RGB555_INV;break;
+	case IMGFMT_BGR16: dec_param.output_format=DEC_RGB565_INV;break;
+	case IMGFMT_BGR24: dec_param.output_format=DEC_RGB24_INV;bits=24;break;
+	case IMGFMT_BGR32: dec_param.output_format=DEC_RGB32_INV;bits=32;break;
+	default:
+	  fprintf(stderr,"Unsupported out_fmt: 0x%X\n",out_fmt);
+	  return 0;
+	}
+	dec_param.x_dim = sh_video->bih->biWidth;
+	dec_param.y_dim = sh_video->bih->biHeight;
+	decore(0x123, DEC_OPT_INIT, &dec_param, NULL);
+	dec_set.postproc_level = divx_quality;
+	decore(0x123, DEC_OPT_SETPP, &dec_set, NULL);
+//	sh_video->our_out_buffer = shmem_alloc(((bits*dec_param.x_dim+7)/8)*dec_param.y_dim);
+	sh_video->our_out_buffer = shmem_alloc(dec_param.x_dim*dec_param.y_dim*5);
    }
    if(verbose) printf("INFO: OpenDivX video codec init OK!\n");
    break;
@@ -247,14 +269,19 @@
     // let's decode
         dec_frame.length = in_size;
 	dec_frame.bitstream = start;
-	dec_frame.render_flag = 1;
+	dec_frame.render_flag = drop_frame?0:1;
+
 #ifdef NEW_DECORE
         dec_frame.bmp=&dec_pic;
         dec_pic.y=dec_pic.u=dec_pic.v=NULL;
+	decore(0x123, (sh_video->format==mmioFOURCC('D','I','V','3'))?DEC_OPT_FRAME_311:DEC_OPT_FRAME, &dec_frame, NULL);
+#else
+	decore(0x123, 0, &dec_frame, NULL);
 #endif
-	decore(0x123, 0, &dec_frame, NULL);
+
       t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f;
 
+    // let's display
 #ifdef NEW_DECORE
       if(dec_pic.y){
         void* src[3];
@@ -280,6 +307,41 @@
 
     break;
   }
+  case 7: {
+    // DivX4Linux
+    unsigned int t=GetTimer();
+    unsigned int t2;
+    DEC_FRAME dec_frame;
+    // let's decode
+        dec_frame.length = in_size;
+	dec_frame.bitstream = start;
+	dec_frame.render_flag = drop_frame?0:1;
+        dec_frame.bmp=sh_video->our_out_buffer;
+        dec_frame.stride=sh_video->disp_w;
+//	printf("Decoding DivX4 frame\n");
+	decore(0x123, (sh_video->format==mmioFOURCC('D','I','V','3'))?DEC_OPT_FRAME_311:DEC_OPT_FRAME, &dec_frame, NULL);
+      t2=GetTimer();t=t2-t;video_time_usage+=t*0.000001f;
+
+    if(!drop_frame && sh_video->our_out_buffer){
+//	printf("Displaying DivX4 frame\n");
+      if(out_fmt==IMGFMT_YV12||out_fmt==IMGFMT_IYUV||out_fmt==IMGFMT_I420){
+        uint8_t* dst[3];
+        int stride[3];
+        stride[0]=sh_video->disp_w;
+        stride[1]=stride[2]=sh_video->disp_w/2;
+        dst[0]=sh_video->our_out_buffer;
+        dst[2]=dst[0]+sh_video->disp_w*sh_video->disp_h;
+        dst[1]=dst[2]+sh_video->disp_w*sh_video->disp_h/4;
+        video_out->draw_slice(dst,stride,sh_video->disp_w,sh_video->disp_h,0,0);
+      } else
+        video_out->draw_frame((uint8_t **)&sh_video->our_out_buffer);
+      blit_frame=1;
+    }
+
+      t2=GetTimer()-t2;vout_time_usage+=t2*0.000001f;
+
+    break;
+  }
 #ifdef USE_DIRECTSHOW
   case 4: {        // W32/DirectShow
     unsigned int t=GetTimer();