OSDN Git Service

CLI: remove 'L' from short opts so that getopt_long properly flags it as an invalid...
[handbrake-jp/handbrake-jp-git.git] / libhb / muxmkv.c
index f179cb7..aa320e9 100644 (file)
@@ -34,27 +34,6 @@ struct hb_mux_data_s
     int       sub_format;
 };
 
-static int yuv2rgb(int yuv)
-{
-    double y, Cr, Cb;
-    int r, g, b;
-
-    y =  (yuv >> 16) & 0xff;
-    Cb = (yuv >>  8) & 0xff;
-    Cr = (yuv      ) & 0xff;
-
-    r = 1.164 * (y - 16)                      + 2.018 * (Cb - 128);
-    g = 1.164 * (y - 16) - 0.813 * (Cr - 128) - 0.391 * (Cb - 128);
-    b = 1.164 * (y - 16) + 1.596 * (Cr - 128);
-    r = (r < 0) ? 0 : r;
-    g = (g < 0) ? 0 : g;
-    b = (b < 0) ? 0 : b;
-    r = (r > 255) ? 255 : r;
-    g = (g > 255) ? 255 : g;
-    b = (b > 255) ? 255 : b;
-    return (r << 16) | (g << 8) | b;
-}
-
 /**********************************************************************
  * MKVInit
  **********************************************************************
@@ -296,9 +275,9 @@ static int MKVInit( hb_mux_object_t * m )
             case PICTURESUB:
                 track->codecID = MK_SUBTITLE_VOBSUB;
                 for (j = 0; j < 16; j++)
-                    rgb[j] = yuv2rgb(title->palette[j]);
+                    rgb[j] = hb_yuv2rgb(subtitle->palette[j]);
                 len = snprintf(subidx, 2048, subidx_fmt, 
-                        title->width, title->height,
+                        subtitle->width, subtitle->height,
                         0, 0, "OFF",
                         rgb[0], rgb[1], rgb[2], rgb[3],
                         rgb[4], rgb[5], rgb[6], rgb[7],
@@ -399,6 +378,7 @@ static int MKVMux( hb_mux_object_t * m, hb_mux_data_t * mux_data,
             }
             mk_addFrameData(m->file, mux_data->track, op->packet, op->bytes);
             mk_setFrameFlags(m->file, mux_data->track, timecode, 1, 0);
+            hb_buffer_close( &buf );
             return 0;
         }
     }
@@ -424,6 +404,7 @@ static int MKVMux( hb_mux_object_t * m, hb_mux_data_t * mux_data,
             mk_setFrameFlags(m->file, mux_data->track, timecode, 1, duration);
         }
         mk_flushFrame(m->file, mux_data->track);
+        hb_buffer_close( &buf );
         return 0;
     }
     else
@@ -442,6 +423,7 @@ static int MKVMux( hb_mux_object_t * m, hb_mux_data_t * mux_data,
             }
             mk_addFrameData(m->file, mux_data->track, op->packet, op->bytes);
             mk_setFrameFlags(m->file, mux_data->track, timecode, 1, 0);
+            hb_buffer_close( &buf );
             return 0;
         }
     }
@@ -457,6 +439,7 @@ static int MKVMux( hb_mux_object_t * m, hb_mux_data_t * mux_data,
                        mux_data == job->mux_data) ? 
                             (buf->frametype == HB_FRAME_IDR) : 
                             ((buf->frametype & HB_FRAME_KEY) != 0)), 0 );
+    hb_buffer_close( &buf );
     return 0;
 }