~ubuntu-branches/ubuntu/wily/x264/wily-proposed

« back to all changes in this revision

Viewing changes to input/avs.c

  • Committer: Package Import Robot
  • Author(s): Reinhard Tartler
  • Date: 2012-01-19 07:28:39 UTC
  • mfrom: (12.1.11 experimental)
  • Revision ID: package-import@ubuntu.com-20120119072839-0vj6g40ky09d9nru
Tags: 2:0.120.2127+gitf33c8cb-2ubuntu1
* Merge from Debian, remaining changes:
  - build against libgpac-dev to enable .mp4 output

Show diffs side-by-side

added added

removed removed

Lines of Context:
235
235
                       "input clip height not divisible by 4 (%dx%d)\n", vi->width, vi->height )
236
236
        FAIL_IF_ERROR( (opt->output_csp == X264_CSP_I420 || info->interlaced) && (vi->height&1),
237
237
                       "input clip height not divisible by 2 (%dx%d)\n", vi->width, vi->height )
238
 
        const char *arg_name[2] = { NULL, "interlaced" };
239
 
        AVS_Value arg_arr[2] = { res, avs_new_value_bool( info->interlaced ) };
240
238
        char conv_func[14] = { "ConvertTo" };
241
239
        strcat( conv_func, csp );
242
 
        AVS_Value res2 = h->func.avs_invoke( h->env, conv_func, avs_new_value_array( arg_arr, 2 ), arg_name );
 
240
        char matrix[7] = "";
 
241
        int arg_count = 2;
 
242
        /* if doing a rgb <-> yuv conversion then range is handled via 'matrix'. though it's only supported in 2.56+ */
 
243
        if( avs_version >= 2.56f && ((opt->output_csp == X264_CSP_RGB && avs_is_yuv( vi )) || (opt->output_csp != X264_CSP_RGB && avs_is_rgb( vi ))) )
 
244
        {
 
245
            // if converting from yuv, then we specify the matrix for the input, otherwise use the output's.
 
246
            int use_pc_matrix = avs_is_yuv( vi ) ? opt->input_range == RANGE_PC : opt->output_range == RANGE_PC;
 
247
            strcpy( matrix, use_pc_matrix ? "PC." : "Rec" );
 
248
            strcat( matrix, "601" ); /* FIXME: use correct coefficients */
 
249
            arg_count++;
 
250
            // notification that the input range has changed to the desired one
 
251
            opt->input_range = opt->output_range;
 
252
        }
 
253
        const char *arg_name[] = { NULL, "interlaced", "matrix" };
 
254
        AVS_Value arg_arr[] = { res, avs_new_value_bool( info->interlaced ), avs_new_value_string( matrix ) };
 
255
        AVS_Value res2 = h->func.avs_invoke( h->env, conv_func, avs_new_value_array( arg_arr, arg_count ), arg_name );
243
256
        FAIL_IF_ERROR( avs_is_error( res2 ), "couldn't convert input clip to %s\n", csp )
244
257
        res = update_clip( h, &vi, res2, res );
245
258
    }
 
259
    /* if swscale is not available, change the range if necessary. This only applies to YUV-based CSPs however */
 
260
    if( avs_is_yuv( vi ) && opt->output_range != RANGE_AUTO && ((opt->input_range == RANGE_PC) != opt->output_range) )
 
261
    {
 
262
        const char *levels = opt->output_range ? "TV->PC" : "PC->TV";
 
263
        x264_cli_log( "avs", X264_LOG_WARNING, "performing %s conversion\n", levels );
 
264
        AVS_Value arg_arr[] = { res, avs_new_value_string( levels ) };
 
265
        const char *arg_name[] = { NULL, "levels" };
 
266
        AVS_Value res2 = h->func.avs_invoke( h->env, "ColorYUV", avs_new_value_array( arg_arr, 2 ), arg_name );
 
267
        FAIL_IF_ERROR( avs_is_error( res2 ), "couldn't convert range: %s\n", avs_as_error( res2 ) )
 
268
        res = update_clip( h, &vi, res2, res );
 
269
        // notification that the input range has changed to the desired one
 
270
        opt->input_range = opt->output_range;
 
271
    }
246
272
#endif
247
273
    h->func.avs_release_value( res );
248
274