changeset 30543:ee0b9c3bbf29

Add support for decoding 4:2:2 and 4:4:4 Theora files. Patch by Giorgio Vazzana [mywing81 gmail com]
author reimar
date Sun, 14 Feb 2010 15:39:52 +0000
parents 4995c42045c9
children 97a52849df57
files etc/codecs.conf libmpcodecs/vd_theora.c
diffstat 2 files changed, 20 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/etc/codecs.conf	Sun Feb 14 15:17:24 2010 +0000
+++ b/etc/codecs.conf	Sun Feb 14 15:39:52 2010 +0000
@@ -584,7 +584,7 @@
   fourcc theo,Thra
   driver theora
   dll libtheora
-  out YV12
+  out YV12,422P,444P
 
 ; prefer native codecs over win32?
 ; the win32 codecs probably are (better) optimized and support direct
--- a/libmpcodecs/vd_theora.c	Sun Feb 14 15:17:24 2010 +0000
+++ b/libmpcodecs/vd_theora.c	Sun Feb 14 15:39:52 2010 +0000
@@ -41,11 +41,28 @@
 
 #define THEORA_NUM_HEADER_PACKETS 3
 
+typedef struct theora_struct_st {
+    theora_state st;
+    theora_comment cc;
+    theora_info inf;
+} theora_struct_t;
+
+/** Convert Theora pixelformat to the corresponding IMGFMT_ */
+static uint32_t theora_pixelformat2imgfmt(theora_pixelformat fmt){
+    switch(fmt) {
+       case OC_PF_420: return IMGFMT_YV12;
+       case OC_PF_422: return IMGFMT_422P;
+       case OC_PF_444: return IMGFMT_444P;
+    }
+    return 0;
+}
+
 // to set/get/query special features/parameters
 static int control(sh_video_t *sh,int cmd,void* arg,...){
+    theora_struct_t *context = sh->context;
     switch(cmd) {
     case VDCTRL_QUERY_FORMAT:
-        if (*(int*)arg == IMGFMT_YV12)
+        if (*(int*)arg == theora_pixelformat2imgfmt(context->inf.pixelformat))
 	    return CONTROL_TRUE;
 	return CONTROL_FALSE;
     }
@@ -53,12 +70,6 @@
     return CONTROL_UNKNOWN;
 }
 
-typedef struct theora_struct_st {
-    theora_state st;
-    theora_comment cc;
-    theora_info inf;
-} theora_struct_t;
-
 /*
  * init driver
  */
@@ -104,7 +115,7 @@
 
     mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Theora video init ok!\n");
 
-    return mpcodecs_config_vo (sh,context->inf.frame_width,context->inf.frame_height,IMGFMT_YV12);
+    return mpcodecs_config_vo (sh,context->inf.frame_width,context->inf.frame_height,theora_pixelformat2imgfmt(context->inf.pixelformat));
 
 err_out:
     free(context);