]> granicus.if.org Git - handbrake/commitdiff
QSV: use software decoding for 10-bit H.264 sources.
authorRodeo <tdskywalker@gmail.com>
Sat, 3 Aug 2013 11:07:40 +0000 (11:07 +0000)
committerRodeo <tdskywalker@gmail.com>
Sat, 3 Aug 2013 11:07:40 +0000 (11:07 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/branches/qsv@5681 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/common.h
libhb/decavcodec.c
libhb/decmpeg2.c
libhb/qsv_common.c
libhb/qsv_common.h
libhb/scan.c
libhb/work.c

index 5b364b6a79c1cc9d9537fe9f940c048bb51086a1..658f00f7059a8f5e615429cbc9b03d756d661d70 100644 (file)
@@ -847,6 +847,10 @@ struct hb_title_s
     char        *container_name;
     int         data_rate;
 
+#ifdef USE_QSV
+    int qsv_decode_support;
+#endif
+
     hb_metadata_t *metadata;
 
     hb_list_t * list_chapter;
@@ -943,6 +947,9 @@ typedef struct hb_work_info_s
             int color_prim;
             int color_transfer;
             int color_matrix;
+#ifdef USE_QSV
+            int qsv_decode_support;
+#endif
         };
         struct
         {    // info only valid for audio decoders
index 3dd76516eee4082ffd2681d2491b5e3aeac214a2..01c2760f4d54f96c833b3ce10f3fc50938fa490d 100644 (file)
@@ -1172,8 +1172,7 @@ static int decavcodecvInit( hb_work_object_t * w, hb_job_t * job )
     pv->list = hb_list_init();
 
 #ifdef USE_QSV
-    if (job != NULL && job->vcodec == HB_VCODEC_QSV_H264 &&
-        w->codec_param == AV_CODEC_ID_H264)
+    if (hb_qsv_decode_is_enabled(job))
     {
         int ret;
         hb_dict_t *qsv_opts = NULL;
@@ -1674,6 +1673,11 @@ static int decavcodecvInfo( hb_work_object_t *w, hb_work_info_t *info )
         }
     }
 
+#ifdef USE_QSV
+    info->qsv_decode_support = hb_qsv_decode_is_supported(pv->context->codec_id,
+                                                          pv->context->pix_fmt);
+#endif
+
     return 1;
 }
 
index 8844a09af89c02daa3bc820364c98f6204d27223..2a186295d8e036ba704237d461959a9b6eccc503 100644 (file)
@@ -911,6 +911,10 @@ static int decmpeg2Info( hb_work_object_t *w, hb_work_info_t *info )
         info->level = m->info->sequence->profile_level_id & 0xf;
         info->name = "mpeg2";
 
+#ifdef USE_QSV
+        info->qsv_decode_support = 0;
+#endif
+
         if( pv->libmpeg2->info->sequence->flags & SEQ_FLAG_COLOUR_DESCRIPTION )
         {
             switch( pv->libmpeg2->info->sequence->colour_primaries )
index 7054f1faa4dbce9c46611cf032fc03591daa502b..268eccce6e377fb5108d585466878c70879eed53 100644 (file)
@@ -244,3 +244,23 @@ const char* hb_qsv_decode_get_codec_name(enum AVCodecID codec_id)
             return NULL;
     }
 }
+
+int hb_qsv_decode_is_enabled(hb_job_t *job)
+{
+    return ((job != NULL && job->title->qsv_decode_support) &&
+            (job->vcodec & HB_VCODEC_QSV_MASK));
+}
+
+int hb_qsv_decode_is_supported(enum AVCodecID codec_id,
+                               enum AVPixelFormat pix_fmt)
+{
+    switch (codec_id)
+    {
+        case AV_CODEC_ID_H264:
+            return (pix_fmt == AV_PIX_FMT_YUV420P ||
+                    pix_fmt == AV_PIX_FMT_YUVJ420P);
+
+        default:
+            return 0;
+    }
+}
index 2ee5cbf1a7edc16e95a11d36cdc0475f8810b716..c2f4f710c9d5d9e766dc06f96aab9c4142b8ac5d 100644 (file)
@@ -61,5 +61,7 @@ void hb_qsv_info_print();
 
 /* Intel Quick Sync Video DECODE utilities */
 const char* hb_qsv_decode_get_codec_name(enum AVCodecID codec_id);
+int hb_qsv_decode_is_enabled(hb_job_t *job);
+int hb_qsv_decode_is_supported(enum AVCodecID codec_id, enum AVPixelFormat pix_fmt);
 
 #endif
index 0d7dde7ffaad8bb85a5168ac327ba04c5188a2fa..507662f36ae6bf437f344e5375b7fbd77423a81a 100644 (file)
@@ -865,6 +865,10 @@ skip_preview:
         title->color_transfer = vid_info.color_transfer;
         title->color_matrix = vid_info.color_matrix;
 
+#ifdef USE_QSV
+        title->qsv_decode_support = vid_info.qsv_decode_support;
+#endif
+
         // compute the aspect ratio based on the storage dimensions and the
         // pixel aspect ratio (if supplied) or just storage dimensions if no PAR.
         title->aspect = (double)title->width / (double)title->height;
index 418ac185dff139012b4c6f5b7ea30c19f06ec224..cfa75c2f96560a6a408321111eccdfab937b7a13 100644 (file)
@@ -12,7 +12,7 @@
 #include "libavformat/avformat.h"
 
 #ifdef USE_QSV
-#include "libavcodec/qsv.h"
+#include "qsv_common.h"
 #include "qsv_filter_pp.h"
 #endif
 
@@ -235,7 +235,17 @@ void hb_display_job_info(hb_job_t *job)
 
     hb_log(" * video track");
 
-    hb_log("   + decoder: %s", title->video_codec_name );
+#ifdef USE_QSV
+    if (hb_qsv_decode_is_enabled(job))
+    {
+        hb_log("   + decoder: %s",
+               hb_qsv_decode_get_codec_name(title->video_codec_param));
+    }
+    else
+#endif
+    {
+        hb_log("   + decoder: %s", title->video_codec_name);
+    }
 
     if( title->video_bitrate )
     {
@@ -679,9 +689,10 @@ static void do_job(hb_job_t *job)
         init.vrate = title->rate;
         init.cfr = 0;
 
+#ifdef USE_QSV
         int is_vpp_interlace = 0;
         int is_actual_crop_resize = 0;
-        if( job->vcodec == HB_VCODEC_QSV_H264 && title->video_codec_param == AV_CODEC_ID_H264 )
+        if (hb_qsv_decode_is_enabled(job))
         {
             for( i = 0; i < hb_list_count( job->list_filter ); i++ )
             {
@@ -715,15 +726,17 @@ static void do_job(hb_job_t *job)
             init.cfr = 0;
         }
         int is_additional_vpp_function = (is_actual_crop_resize || is_vpp_interlace);
+#endif
 
         for( i = 0; i < hb_list_count( job->list_filter ); )
         {
             hb_filter_object_t * filter = hb_list_item( job->list_filter, i );
 
+#ifdef USE_QSV
             // to do not use QSV related if not handled from its decode
             if( job->vcodec == HB_VCODEC_QSV_H264 )
              // for now, only h.264 related stuff
-             if( title->video_codec_param != AV_CODEC_ID_H264 )
+             if (!hb_qsv_decode_is_enabled(job))
              {
                 if( filter->id == HB_FILTER_QSV_PRE  ||
                     filter->id == HB_FILTER_QSV_POST ||
@@ -782,6 +795,7 @@ static void do_job(hb_job_t *job)
                     }
                 }
              }
+#endif
 
             if( filter->init( filter, &init ) )
             {
@@ -826,14 +840,18 @@ static void do_job(hb_job_t *job)
         }
     }
 
-    if( job->vcodec == HB_VCODEC_QSV_H264 && title->video_codec_param == AV_CODEC_ID_H264){
+#ifdef USE_QSV
+    if (hb_qsv_decode_is_enabled(job))
+    {
         job->fifo_mpeg2  = hb_fifo_init( FIFO_MINI, FIFO_MINI_WAKE );
         job->fifo_raw    = hb_fifo_init( FIFO_MINI, FIFO_MINI_WAKE );
         job->fifo_sync   = hb_fifo_init( FIFO_MINI, FIFO_MINI_WAKE );
         job->fifo_render = hb_fifo_init( FIFO_MINI, FIFO_MINI_WAKE );
-        job->fifo_mpeg4 = hb_fifo_init( FIFO_MINI, FIFO_MINI_WAKE );
+        job->fifo_mpeg4  = hb_fifo_init( FIFO_MINI, FIFO_MINI_WAKE );
     }
-    else{
+    else
+#endif
+    {
         job->fifo_mpeg2  = hb_fifo_init( FIFO_LARGE, FIFO_LARGE_WAKE );
         job->fifo_raw    = hb_fifo_init( FIFO_SMALL, FIFO_SMALL_WAKE );
         job->fifo_sync   = hb_fifo_init( FIFO_SMALL, FIFO_SMALL_WAKE );