static int read_video( lsmash_handler_t *h, int sample_number, void *buf ) { avs_handler_t *hp = (avs_handler_t *)h->video_private; int buf_linesize = MAKE_AVIUTL_PITCH( hp->vi->width * avs_bits_per_pixel( hp->vi ) ); AVS_VideoFrame *frame = hp->func.avs_get_frame( hp->clip, sample_number ); if( hp->func.avs_clip_get_error( hp->clip ) ) return 0; hp->func.avs_bit_blt( hp->env, buf, buf_linesize, avs_get_read_ptr( frame ), avs_get_pitch( frame ), avs_get_row_size( frame ), hp->vi->height ); hp->func.avs_release_video_frame( frame ); return avs_bmp_size( hp->vi ); }
static int read_video( lsmash_handler_t *h, int sample_number, void *buf ) { avs_handler_t *hp = (avs_handler_t *)h->video_private; AVS_VideoFrame *as_frame = hp->func.avs_get_frame( hp->clip, sample_number ); if( hp->func.avs_clip_get_error( hp->clip ) ) return 0; if( avs_is_interleaved( hp->vi ) ) { uint8_t *read_ptr = (uint8_t *)avs_get_read_ptr( as_frame ); int pitch = avs_get_pitch( as_frame ); if( avs_is_rgb( hp->vi ) ) { hp->av_frame->data [0] = read_ptr + pitch * (hp->vi->height - 1); hp->av_frame->linesize[0] = -pitch; } else { hp->av_frame->data [0] = read_ptr; hp->av_frame->linesize[0] = pitch; } } else for( int i = 0; i < 3; i++ ) { static const int as_plane[3] = { AVS_PLANAR_Y, AVS_PLANAR_U, AVS_PLANAR_V }; hp->av_frame->data [i] = (uint8_t *)avs_get_read_ptr_p( as_frame, as_plane[i] ); hp->av_frame->linesize[i] = avs_get_pitch_p( as_frame, as_plane[i] ); } hp->av_frame->width = hp->vi->width; hp->av_frame->height = hp->vi->height; hp->av_frame->format = as_to_av_input_pixel_format( hp->vi->pixel_type, hp->bit_depth, &hp->av_frame->width ); hp->av_frame->color_range = AVCOL_RANGE_UNSPECIFIED; hp->av_frame->colorspace = AVCOL_SPC_UNSPECIFIED; /* Here, update_scaler_configuration_if_needed() is required to activate the scaler. */ if( update_scaler_configuration_if_needed( &hp->voh.scaler, NULL, hp->av_frame ) < 0 ) return 0; int frame_size = convert_colorspace( &hp->voh, hp->av_frame, buf ); hp->func.avs_release_video_frame( as_frame ); return frame_size; }