void vp9_ ## type ## _predictor_ ## size ## x ## size ## _c ( uint8_t * dst , ptrdiff_t stride , const uint8_t * above , const uint8_t * left ) {
 type ## _predictor ( dst , stride , size , above , left ) ;
 }
 # if CONFIG_VP9_HIGHBITDEPTH # define intra_pred_high_sized ( type , size ) void vp9_high_ ## type ## _predictor_ ## size ## x ## size ## _c ( uint16_t * dst , ptrdiff_t stride , const uint16_t * above , const uint16_t * left , int bd ) {
 high_ ## type ## _predictor ( dst , stride , size , above , left , bd ) ;
 }
 # define intra_pred_allsizes ( type ) intra_pred_sized ( type , 4 ) intra_pred_sized ( type , 8 ) intra_pred_sized ( type , 16 ) intra_pred_sized ( type , 32 ) intra_pred_high_sized ( type , 4 ) intra_pred_high_sized ( type , 8 ) intra_pred_high_sized ( type , 16 ) intra_pred_high_sized ( type , 32 ) # else # define intra_pred_allsizes ( type ) intra_pred_sized ( type , 4 ) intra_pred_sized ( type , 8 ) intra_pred_sized ( type , 16 ) intra_pred_sized ( type , 32 ) # endif # if CONFIG_VP9_HIGHBITDEPTH static INLINE void high_d207_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {
 int r , c ;
 ( void ) above ;
 ( void ) bd ;
 for ( r = 0 ;
 r < bs - 1 ;
 ++ r ) {
 dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r ] + left [ r + 1 ] , 1 ) ;
 }
 dst [ ( bs - 1 ) * stride ] = left [ bs - 1 ] ;
 dst ++ ;
 for ( r = 0 ;
 r < bs - 2 ;
 ++ r ) {
 dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r ] + left [ r + 1 ] * 2 + left [ r + 2 ] , 2 ) ;
 }
 dst [ ( bs - 2 ) * stride ] = ROUND_POWER_OF_TWO ( left [ bs - 2 ] + left [ bs - 1 ] * 3 , 2 ) ;
 dst [ ( bs - 1 ) * stride ] = left [ bs - 1 ] ;
 dst ++ ;
 for ( c = 0 ;
 c < bs - 2 ;
 ++ c ) dst [ ( bs - 1 ) * stride + c ] = left [ bs - 1 ] ;
 for ( r = bs - 2 ;
 r >= 0 ;
 -- r ) {
 for ( c = 0 ;
 c < bs - 2 ;
 ++ c ) dst [ r * stride + c ] = dst [ ( r + 1 ) * stride + c - 2 ] ;
 }
 }
 static INLINE void high_d63_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {
 int r , c ;
 ( void ) left ;
 ( void ) bd ;
 for ( r = 0 ;
 r < bs ;
 ++ r ) {
 for ( c = 0 ;
 c < bs ;
 ++ c ) {
 dst [ c ] = r & 1 ? ROUND_POWER_OF_TWO ( above [ r / 2 + c ] + above [ r / 2 + c + 1 ] * 2 + above [ r / 2 + c + 2 ] , 2 ) : ROUND_POWER_OF_TWO ( above [ r / 2 + c ] + above [ r / 2 + c + 1 ] , 1 ) ;
 }
 dst += stride ;
 }
 }
 static INLINE void high_d45_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {
 int r , c ;
 ( void ) left ;
 ( void ) bd ;
 for ( r = 0 ;
 r < bs ;
 ++ r ) {
 for ( c = 0 ;
 c < bs ;
 ++ c ) {
 dst [ c ] = r + c + 2 < bs * 2 ? ROUND_POWER_OF_TWO ( above [ r + c ] + above [ r + c + 1 ] * 2 + above [ r + c + 2 ] , 2 ) : above [ bs * 2 - 1 ] ;
 }
 dst += stride ;
 }
 }
 static INLINE void high_d117_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {
 int r , c ;
 ( void ) bd ;
 for ( c = 0 ;
 c < bs ;
 c ++ ) dst [ c ] = ROUND_POWER_OF_TWO ( above [ c - 1 ] + above [ c ] , 1 ) ;
 dst += stride ;
 dst [ 0 ] = ROUND_POWER_OF_TWO ( left [ 0 ] + above [ - 1 ] * 2 + above [ 0 ] , 2 ) ;
 for ( c = 1 ;
 c < bs ;
 c ++ ) dst [ c ] = ROUND_POWER_OF_TWO ( above [ c - 2 ] + above [ c - 1 ] * 2 + above [ c ] , 2 ) ;
 dst += stride ;
 dst [ 0 ] = ROUND_POWER_OF_TWO ( above [ - 1 ] + left [ 0 ] * 2 + left [ 1 ] , 2 ) ;
 for ( r = 3 ;
 r < bs ;
 ++ r ) dst [ ( r - 2 ) * stride ] = ROUND_POWER_OF_TWO ( left [ r - 3 ] + left [ r - 2 ] * 2 + left [ r - 1 ] , 2 ) ;
 for ( r = 2 ;
 r < bs ;
 ++ r ) {
 for ( c = 1 ;
 c < bs ;
 c ++ ) dst [ c ] = dst [ - 2 * stride + c - 1 ] ;
 dst += stride ;
 }
 }
 static INLINE void high_d135_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {
 int r , c ;
 ( void ) bd ;
 dst [ 0 ] = ROUND_POWER_OF_TWO ( left [ 0 ] + above [ - 1 ] * 2 + above [ 0 ] , 2 ) ;
 for ( c = 1 ;
 c < bs ;
 c ++ ) dst [ c ] = ROUND_POWER_OF_TWO ( above [ c - 2 ] + above [ c - 1 ] * 2 + above [ c ] , 2 ) ;
 dst [ stride ] = ROUND_POWER_OF_TWO ( above [ - 1 ] + left [ 0 ] * 2 + left [ 1 ] , 2 ) ;
 for ( r = 2 ;
 r < bs ;
 ++ r ) dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r - 2 ] + left [ r - 1 ] * 2 + left [ r ] , 2 ) ;
 dst += stride ;
 for ( r = 1 ;
 r < bs ;
 ++ r ) {
 for ( c = 1 ;
 c < bs ;
 c ++ ) dst [ c ] = dst [ - stride + c - 1 ] ;
 dst += stride ;
 }
 }
 static INLINE void high_d153_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {
 int r , c ;
 ( void ) bd ;
 dst [ 0 ] = ROUND_POWER_OF_TWO ( above [ - 1 ] + left [ 0 ] , 1 ) ;
 for ( r = 1 ;
 r < bs ;
 r ++ ) dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r - 1 ] + left [ r ] , 1 ) ;
 dst ++ ;
 dst [ 0 ] = ROUND_POWER_OF_TWO ( left [ 0 ] + above [ - 1 ] * 2 + above [ 0 ] , 2 ) ;
 dst [ stride ] = ROUND_POWER_OF_TWO ( above [ - 1 ] + left [ 0 ] * 2 + left [ 1 ] , 2 ) ;
 for ( r = 2 ;
 r < bs ;
 r ++ ) dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r - 2 ] + left [ r - 1 ] * 2 + left [ r ] , 2 ) ;
 dst ++ ;
 for ( c = 0 ;
 c < bs - 2 ;
 c ++ ) dst [ c ] = ROUND_POWER_OF_TWO ( above [ c - 1 ] + above [ c ] * 2 + above [ c + 1 ] , 2 ) ;
 dst += stride ;
 for ( r = 1 ;
 r < bs ;
 ++ r ) {
 for ( c = 0 ;
 c < bs - 2 ;
 c ++ ) dst [ c ] = dst [ - stride + c - 2 ] ;
 dst += stride ;
 }
 }
 static INLINE void high_v_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {
 int r ;
 ( void ) left ;
 ( void ) bd ;
 for ( r = 0 ;
 r < bs ;
 r ++ ) {
 vpx_memcpy ( dst , above , bs * sizeof ( uint16_t ) ) ;
 dst += stride ;
 }
 }
 static INLINE void high_h_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {
 int r ;
 ( void ) above ;
 ( void ) bd ;
 for ( r = 0 ;
 r < bs ;
 r ++ ) {
 vpx_memset16 ( dst , left [ r ] , bs ) ;
 dst += stride ;
 }
 }
 static INLINE void high_tm_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {
 int r , c ;
 int ytop_left = above [ - 1 ] ;
 ( void ) bd ;
 for ( r = 0 ;
 r < bs ;
 r ++ ) {
 for ( c = 0 ;
 c < bs ;
 c ++ ) dst [ c ] = clip_pixel_high ( left [ r ] + above [ c ] - ytop_left , bd ) ;
 dst += stride ;
 }
 }
 static INLINE void high_dc_128_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {
 int r ;
 ( void ) above ;
 ( void ) left ;
 for ( r = 0 ;
 r < bs ;
 r ++ ) {
 vpx_memset16 ( dst , 128 << ( bd - 8 ) , bs ) ;
 dst += stride ;
 }
 }
 static INLINE void high_dc_left_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {
 int i , r , expected_dc , sum = 0 ;
 ( void ) above ;
 ( void ) bd ;
 for ( i = 0 ;
 i < bs ;
 i ++ ) sum += left [ i ] ;
 expected_dc = ( sum + ( bs >> 1 ) ) / bs ;
 for ( r = 0 ;
 r < bs ;
 r ++ ) {
 vpx_memset16 ( dst , expected_dc , bs ) ;
 dst += stride ;
 }
 }
 static INLINE void high_dc_top_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {
 int i , r , expected_dc , sum = 0 ;
 ( void ) left ;
 ( void ) bd ;
 for ( i = 0 ;
 i < bs ;
 i ++ ) sum += above [ i ] ;
 expected_dc = ( sum + ( bs >> 1 ) ) / bs ;
 for ( r = 0 ;
 r < bs ;
 r ++ ) {
 vpx_memset16 ( dst , expected_dc , bs ) ;
 dst += stride ;
 }
 }
 static INLINE void high_dc_predictor ( uint16_t * dst , ptrdiff_t stride , int bs , const uint16_t * above , const uint16_t * left , int bd ) {
 int i , r , expected_dc , sum = 0 ;
 const int count = 2 * bs ;
 ( void ) bd ;
 for ( i = 0 ;
 i < bs ;
 i ++ ) {
 sum += above [ i ] ;
 sum += left [ i ] ;
 }
 expected_dc = ( sum + ( count >> 1 ) ) / count ;
 for ( r = 0 ;
 r < bs ;
 r ++ ) {
 vpx_memset16 ( dst , expected_dc , bs ) ;
 dst += stride ;
 }
 }
 # endif static INLINE void d207_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
 int r , c ;
 ( void ) above ;
 for ( r = 0 ;
 r < bs - 1 ;
 ++ r ) dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r ] + left [ r + 1 ] , 1 ) ;
 dst [ ( bs - 1 ) * stride ] = left [ bs - 1 ] ;
 dst ++ ;
 for ( r = 0 ;
 r < bs - 2 ;
 ++ r ) dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r ] + left [ r + 1 ] * 2 + left [ r + 2 ] , 2 ) ;
 dst [ ( bs - 2 ) * stride ] = ROUND_POWER_OF_TWO ( left [ bs - 2 ] + left [ bs - 1 ] * 3 , 2 ) ;
 dst [ ( bs - 1 ) * stride ] = left [ bs - 1 ] ;
 dst ++ ;
 for ( c = 0 ;
 c < bs - 2 ;
 ++ c ) dst [ ( bs - 1 ) * stride + c ] = left [ bs - 1 ] ;
 for ( r = bs - 2 ;
 r >= 0 ;
 -- r ) for ( c = 0 ;
 c < bs - 2 ;
 ++ c ) dst [ r * stride + c ] = dst [ ( r + 1 ) * stride + c - 2 ] ;
 }
 intra_pred_allsizes ( d207 ) static INLINE void d63_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
 int r , c ;
 ( void ) left ;
 for ( r = 0 ;
 r < bs ;
 ++ r ) {
 for ( c = 0 ;
 c < bs ;
 ++ c ) dst [ c ] = r & 1 ? ROUND_POWER_OF_TWO ( above [ r / 2 + c ] + above [ r / 2 + c + 1 ] * 2 + above [ r / 2 + c + 2 ] , 2 ) : ROUND_POWER_OF_TWO ( above [ r / 2 + c ] + above [ r / 2 + c + 1 ] , 1 ) ;
 dst += stride ;
 }
 }
 intra_pred_allsizes ( d63 ) static INLINE void d45_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
 int r , c ;
 ( void ) left ;
 for ( r = 0 ;
 r < bs ;
 ++ r ) {
 for ( c = 0 ;
 c < bs ;
 ++ c ) dst [ c ] = r + c + 2 < bs * 2 ? ROUND_POWER_OF_TWO ( above [ r + c ] + above [ r + c + 1 ] * 2 + above [ r + c + 2 ] , 2 ) : above [ bs * 2 - 1 ] ;
 dst += stride ;
 }
 }
 intra_pred_allsizes ( d45 ) static INLINE void d117_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
 int r , c ;
 for ( c = 0 ;
 c < bs ;
 c ++ ) dst [ c ] = ROUND_POWER_OF_TWO ( above [ c - 1 ] + above [ c ] , 1 ) ;
 dst += stride ;
 dst [ 0 ] = ROUND_POWER_OF_TWO ( left [ 0 ] + above [ - 1 ] * 2 + above [ 0 ] , 2 ) ;
 for ( c = 1 ;
 c < bs ;
 c ++ ) dst [ c ] = ROUND_POWER_OF_TWO ( above [ c - 2 ] + above [ c - 1 ] * 2 + above [ c ] , 2 ) ;
 dst += stride ;
 dst [ 0 ] = ROUND_POWER_OF_TWO ( above [ - 1 ] + left [ 0 ] * 2 + left [ 1 ] , 2 ) ;
 for ( r = 3 ;
 r < bs ;
 ++ r ) dst [ ( r - 2 ) * stride ] = ROUND_POWER_OF_TWO ( left [ r - 3 ] + left [ r - 2 ] * 2 + left [ r - 1 ] , 2 ) ;
 for ( r = 2 ;
 r < bs ;
 ++ r ) {
 for ( c = 1 ;
 c < bs ;
 c ++ ) dst [ c ] = dst [ - 2 * stride + c - 1 ] ;
 dst += stride ;
 }
 }
 intra_pred_allsizes ( d117 ) static INLINE void d135_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
 int r , c ;
 dst [ 0 ] = ROUND_POWER_OF_TWO ( left [ 0 ] + above [ - 1 ] * 2 + above [ 0 ] , 2 ) ;
 for ( c = 1 ;
 c < bs ;
 c ++ ) dst [ c ] = ROUND_POWER_OF_TWO ( above [ c - 2 ] + above [ c - 1 ] * 2 + above [ c ] , 2 ) ;
 dst [ stride ] = ROUND_POWER_OF_TWO ( above [ - 1 ] + left [ 0 ] * 2 + left [ 1 ] , 2 ) ;
 for ( r = 2 ;
 r < bs ;
 ++ r ) dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r - 2 ] + left [ r - 1 ] * 2 + left [ r ] , 2 ) ;
 dst += stride ;
 for ( r = 1 ;
 r < bs ;
 ++ r ) {
 for ( c = 1 ;
 c < bs ;
 c ++ ) dst [ c ] = dst [ - stride + c - 1 ] ;
 dst += stride ;
 }
 }
 intra_pred_allsizes ( d135 ) static INLINE void d153_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
 int r , c ;
 dst [ 0 ] = ROUND_POWER_OF_TWO ( above [ - 1 ] + left [ 0 ] , 1 ) ;
 for ( r = 1 ;
 r < bs ;
 r ++ ) dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r - 1 ] + left [ r ] , 1 ) ;
 dst ++ ;
 dst [ 0 ] = ROUND_POWER_OF_TWO ( left [ 0 ] + above [ - 1 ] * 2 + above [ 0 ] , 2 ) ;
 dst [ stride ] = ROUND_POWER_OF_TWO ( above [ - 1 ] + left [ 0 ] * 2 + left [ 1 ] , 2 ) ;
 for ( r = 2 ;
 r < bs ;
 r ++ ) dst [ r * stride ] = ROUND_POWER_OF_TWO ( left [ r - 2 ] + left [ r - 1 ] * 2 + left [ r ] , 2 ) ;
 dst ++ ;
 for ( c = 0 ;
 c < bs - 2 ;
 c ++ ) dst [ c ] = ROUND_POWER_OF_TWO ( above [ c - 1 ] + above [ c ] * 2 + above [ c + 1 ] , 2 ) ;
 dst += stride ;
 for ( r = 1 ;
 r < bs ;
 ++ r ) {
 for ( c = 0 ;
 c < bs - 2 ;
 c ++ ) dst [ c ] = dst [ - stride + c - 2 ] ;
 dst += stride ;
 }
 }
 intra_pred_allsizes ( d153 ) static INLINE void v_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
 int r ;
 ( void ) left ;
 for ( r = 0 ;
 r < bs ;
 r ++ ) {
 vpx_memcpy ( dst , above , bs ) ;
 dst += stride ;
 }
 }
 intra_pred_allsizes ( v ) static INLINE void h_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
 int r ;
 ( void ) above ;
 for ( r = 0 ;
 r < bs ;
 r ++ ) {
 vpx_memset ( dst , left [ r ] , bs ) ;
 dst += stride ;
 }
 }
 intra_pred_allsizes ( h ) static INLINE void tm_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
 int r , c ;
 int ytop_left = above [ - 1 ] ;
 for ( r = 0 ;
 r < bs ;
 r ++ ) {
 for ( c = 0 ;
 c < bs ;
 c ++ ) dst [ c ] = clip_pixel ( left [ r ] + above [ c ] - ytop_left ) ;
 dst += stride ;
 }
 }
 intra_pred_allsizes ( tm ) static INLINE void dc_128_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
 int r ;
 ( void ) above ;
 ( void ) left ;
 for ( r = 0 ;
 r < bs ;
 r ++ ) {
 vpx_memset ( dst , 128 , bs ) ;
 dst += stride ;
 }
 }
 intra_pred_allsizes ( dc_128 ) static INLINE void dc_left_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
 int i , r , expected_dc , sum = 0 ;
 ( void ) above ;
 for ( i = 0 ;
 i < bs ;
 i ++ ) sum += left [ i ] ;
 expected_dc = ( sum + ( bs >> 1 ) ) / bs ;
 for ( r = 0 ;
 r < bs ;
 r ++ ) {
 vpx_memset ( dst , expected_dc , bs ) ;
 dst += stride ;
 }
 }
 intra_pred_allsizes ( dc_left ) static INLINE void dc_top_predictor ( uint8_t * dst , ptrdiff_t stride , int bs , const uint8_t * above , const uint8_t * left ) {
 int i , r , expected_dc , sum = 0 ;
 ( void ) left ;
 for ( i = 0 ;
 i < bs ;
 i ++ ) sum += above [ i ] ;
 expected_dc = ( sum + ( bs >> 1 ) ) / bs ;
 for ( r = 0 ;
 r < bs ;
 r ++ ) {
 vpx_memset ( dst , expected_dc , bs ) ;
 dst += stride ;
 }
 }
 intra_pred_allsizes ( dc_top )


static int proxy_readdir_r(FsContext *ctx, V9fsFidOpenState *fs, struct dirent *entry, struct dirent **result) { return readdir_r(fs->dir, entry, result); }


int ff_h264_decode_slice_header(H264Context *h, H264SliceContext *sl) { const SPS *sps; const PPS *pps; unsigned int first_mb_in_slice; unsigned int pps_id; int ret; unsigned int slice_type, tmp, i, j; int last_pic_structure, last_pic_droppable; int needs_reinit = 0; int field_pic_flag, bottom_field_flag; int frame_num, droppable, picture_structure; int mb_aff_frame = 0; h->qpel_put = h->h264qpel.put_h264_qpel_pixels_tab; h->qpel_avg = h->h264qpel.avg_h264_qpel_pixels_tab; first_mb_in_slice = get_ue_golomb(&sl->gb); if (first_mb_in_slice == 0) { // FIXME better field boundary detection if (h->current_slice && h->cur_pic_ptr && FIELD_PICTURE(h)) { ff_h264_field_end(h, sl, 1); } h->current_slice = 0; if (!h->first_field) { if (h->cur_pic_ptr && !h->droppable) { ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, h->picture_structure == PICT_BOTTOM_FIELD); } h->cur_pic_ptr = NULL; } } slice_type = get_ue_golomb_31(&sl->gb); if (slice_type > 9) { av_log(h->avctx, AV_LOG_ERROR, "slice type %d too large at %d\n", slice_type, first_mb_in_slice); return AVERROR_INVALIDDATA; } if (slice_type > 4) { slice_type -= 5; sl->slice_type_fixed = 1; } else sl->slice_type_fixed = 0; slice_type = ff_h264_golomb_to_pict_type[slice_type]; sl->slice_type = slice_type; sl->slice_type_nos = slice_type & 3; if (h->nal_unit_type == NAL_IDR_SLICE && sl->slice_type_nos != AV_PICTURE_TYPE_I) { av_log(h->avctx, AV_LOG_ERROR, "A non-intra slice in an IDR NAL unit.\n"); return AVERROR_INVALIDDATA; } // to make a few old functions happy, it's wrong though if (!h->setup_finished) h->pict_type = sl->slice_type; pps_id = get_ue_golomb(&sl->gb); if (pps_id >= MAX_PPS_COUNT) { av_log(h->avctx, AV_LOG_ERROR, "pps_id %u out of range\n", pps_id); return AVERROR_INVALIDDATA; } if (!h->ps.pps_list[pps_id]) { av_log(h->avctx, AV_LOG_ERROR, "non-existing PPS %u referenced\n", pps_id); return AVERROR_INVALIDDATA; } if (!h->setup_finished) { h->ps.pps = (const PPS*)h->ps.pps_list[pps_id]->data; } else if (h->ps.pps != (const PPS*)h->ps.pps_list[pps_id]->data) { av_log(h->avctx, AV_LOG_ERROR, "PPS changed between slices\n"); return AVERROR_INVALIDDATA; } if (!h->ps.sps_list[h->ps.pps->sps_id]) { av_log(h->avctx, AV_LOG_ERROR, "non-existing SPS %u referenced\n", h->ps.pps->sps_id); return AVERROR_INVALIDDATA; } if (h->ps.sps != (const SPS*)h->ps.sps_list[h->ps.pps->sps_id]->data) { h->ps.sps = (SPS*)h->ps.sps_list[h->ps.pps->sps_id]->data; if (h->bit_depth_luma != h->ps.sps->bit_depth_luma || h->chroma_format_idc != h->ps.sps->chroma_format_idc) needs_reinit = 1; if (h->flags & AV_CODEC_FLAG_LOW_DELAY || (h->ps.sps->bitstream_restriction_flag && !h->ps.sps->num_reorder_frames)) { if (h->avctx->has_b_frames > 1 || h->delayed_pic[0]) av_log(h->avctx, AV_LOG_WARNING, "Delayed frames seen. " "Reenabling low delay requires a codec flush.\n"); else h->low_delay = 1; } if (h->avctx->has_b_frames < 2) h->avctx->has_b_frames = !h->low_delay; } pps = h->ps.pps; sps = h->ps.sps; if (!h->setup_finished) { h->avctx->profile = ff_h264_get_profile(sps); h->avctx->level = sps->level_idc; h->avctx->refs = sps->ref_frame_count; if (h->mb_width != sps->mb_width || h->mb_height != sps->mb_height * (2 - sps->frame_mbs_only_flag)) needs_reinit = 1; h->mb_width = sps->mb_width; h->mb_height = sps->mb_height * (2 - sps->frame_mbs_only_flag); h->mb_num = h->mb_width * h->mb_height; h->mb_stride = h->mb_width + 1; h->b_stride = h->mb_width * 4; h->chroma_y_shift = sps->chroma_format_idc <= 1; // 400 uses yuv420p h->width = 16 * h->mb_width; h->height = 16 * h->mb_height; ret = init_dimensions(h); if (ret < 0) return ret; if (sps->video_signal_type_present_flag) { h->avctx->color_range = sps->full_range ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG; if (sps->colour_description_present_flag) { if (h->avctx->colorspace != sps->colorspace) needs_reinit = 1; h->avctx->color_primaries = sps->color_primaries; h->avctx->color_trc = sps->color_trc; h->avctx->colorspace = sps->colorspace; } } } if (h->context_initialized && needs_reinit) { h->context_initialized = 0; if (sl != h->slice_ctx) { av_log(h->avctx, AV_LOG_ERROR, "changing width %d -> %d / height %d -> %d on " "slice %d\n", h->width, h->avctx->coded_width, h->height, h->avctx->coded_height, h->current_slice + 1); return AVERROR_INVALIDDATA; } ff_h264_flush_change(h); if ((ret = get_pixel_format(h)) < 0) return ret; h->avctx->pix_fmt = ret; av_log(h->avctx, AV_LOG_INFO, "Reinit context to %dx%d, " "pix_fmt: %d\n", h->width, h->height, h->avctx->pix_fmt); if ((ret = h264_slice_header_init(h)) < 0) { av_log(h->avctx, AV_LOG_ERROR, "h264_slice_header_init() failed\n"); return ret; } } if (!h->context_initialized) { if (sl != h->slice_ctx) { av_log(h->avctx, AV_LOG_ERROR, "Cannot (re-)initialize context during parallel decoding.\n"); return AVERROR_PATCHWELCOME; } if ((ret = get_pixel_format(h)) < 0) return ret; h->avctx->pix_fmt = ret; if ((ret = h264_slice_header_init(h)) < 0) { av_log(h->avctx, AV_LOG_ERROR, "h264_slice_header_init() failed\n"); return ret; } } frame_num = get_bits(&sl->gb, sps->log2_max_frame_num); if (!h->setup_finished) h->frame_num = frame_num; sl->mb_mbaff = 0; last_pic_structure = h->picture_structure; last_pic_droppable = h->droppable; droppable = h->nal_ref_idc == 0; if (sps->frame_mbs_only_flag) { picture_structure = PICT_FRAME; } else { field_pic_flag = get_bits1(&sl->gb); if (field_pic_flag) { bottom_field_flag = get_bits1(&sl->gb); picture_structure = PICT_TOP_FIELD + bottom_field_flag; } else { picture_structure = PICT_FRAME; mb_aff_frame = sps->mb_aff; } } if (!h->setup_finished) { h->droppable = droppable; h->picture_structure = picture_structure; h->mb_aff_frame = mb_aff_frame; } sl->mb_field_decoding_flag = h->picture_structure != PICT_FRAME; if (h->current_slice != 0) { if (last_pic_structure != picture_structure || last_pic_droppable != droppable) { av_log(h->avctx, AV_LOG_ERROR, "Changing field mode (%d -> %d) between slices is not allowed\n", last_pic_structure, h->picture_structure); return AVERROR_INVALIDDATA; } else if (!h->cur_pic_ptr) { av_log(h->avctx, AV_LOG_ERROR, "unset cur_pic_ptr on slice %d\n", h->current_slice + 1); return AVERROR_INVALIDDATA; } } else { /* Shorten frame num gaps so we don't have to allocate reference * frames just to throw them away */ if (h->frame_num != h->prev_frame_num) { int unwrap_prev_frame_num = h->prev_frame_num; int max_frame_num = 1 << sps->log2_max_frame_num; if (unwrap_prev_frame_num > h->frame_num) unwrap_prev_frame_num -= max_frame_num; if ((h->frame_num - unwrap_prev_frame_num) > sps->ref_frame_count) { unwrap_prev_frame_num = (h->frame_num - sps->ref_frame_count) - 1; if (unwrap_prev_frame_num < 0) unwrap_prev_frame_num += max_frame_num; h->prev_frame_num = unwrap_prev_frame_num; } } /* See if we have a decoded first field looking for a pair... * Here, we're using that to see if we should mark previously * decode frames as "finished". * We have to do that before the "dummy" in-between frame allocation, * since that can modify s->current_picture_ptr. */ if (h->first_field) { assert(h->cur_pic_ptr); assert(h->cur_pic_ptr->f->buf[0]); assert(h->cur_pic_ptr->reference != DELAYED_PIC_REF); /* figure out if we have a complementary field pair */ if (!FIELD_PICTURE(h) || h->picture_structure == last_pic_structure) { /* Previous field is unmatched. Don't display it, but let it * remain for reference if marked as such. */ if (!last_pic_droppable && last_pic_structure != PICT_FRAME) { ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, last_pic_structure == PICT_TOP_FIELD); } } else { if (h->cur_pic_ptr->frame_num != h->frame_num) { /* This and previous field were reference, but had * different frame_nums. Consider this field first in * pair. Throw away previous field except for reference * purposes. */ if (!last_pic_droppable && last_pic_structure != PICT_FRAME) { ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, last_pic_structure == PICT_TOP_FIELD); } } else { /* Second field in complementary pair */ if (!((last_pic_structure == PICT_TOP_FIELD && h->picture_structure == PICT_BOTTOM_FIELD) || (last_pic_structure == PICT_BOTTOM_FIELD && h->picture_structure == PICT_TOP_FIELD))) { av_log(h->avctx, AV_LOG_ERROR, "Invalid field mode combination %d/%d\n", last_pic_structure, h->picture_structure); h->picture_structure = last_pic_structure; h->droppable = last_pic_droppable; return AVERROR_INVALIDDATA; } else if (last_pic_droppable != h->droppable) { avpriv_request_sample(h->avctx, "Found reference and non-reference fields in the same frame, which"); h->picture_structure = last_pic_structure; h->droppable = last_pic_droppable; return AVERROR_PATCHWELCOME; } } } } while (h->frame_num != h->prev_frame_num && h->frame_num != (h->prev_frame_num + 1) % (1 << sps->log2_max_frame_num)) { H264Picture *prev = h->short_ref_count ? h->short_ref[0] : NULL; av_log(h->avctx, AV_LOG_DEBUG, "Frame num gap %d %d\n", h->frame_num, h->prev_frame_num); ret = initialize_cur_frame(h); if (ret < 0) { h->first_field = 0; return ret; } h->prev_frame_num++; h->prev_frame_num %= 1 << sps->log2_max_frame_num; h->cur_pic_ptr->frame_num = h->prev_frame_num; ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, 0); ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX, 1); ret = ff_generate_sliding_window_mmcos(h, 1); if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE)) return ret; ret = ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index); if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE)) return ret; /* Error concealment: If a ref is missing, copy the previous ref * in its place. * FIXME: Avoiding a memcpy would be nice, but ref handling makes * many assumptions about there being no actual duplicates. * FIXME: This does not copy padding for out-of-frame motion * vectors. Given we are concealing a lost frame, this probably * is not noticeable by comparison, but it should be fixed. */ if (h->short_ref_count) { if (prev && h->short_ref[0]->f->width == prev->f->width && h->short_ref[0]->f->height == prev->f->height && h->short_ref[0]->f->format == prev->f->format) { av_image_copy(h->short_ref[0]->f->data, h->short_ref[0]->f->linesize, (const uint8_t **)prev->f->data, prev->f->linesize, prev->f->format, h->mb_width * 16, h->mb_height * 16); h->short_ref[0]->poc = prev->poc + 2; } h->short_ref[0]->frame_num = h->prev_frame_num; } } /* See if we have a decoded first field looking for a pair... * We're using that to see whether to continue decoding in that * frame, or to allocate a new one. */ if (h->first_field) { assert(h->cur_pic_ptr); assert(h->cur_pic_ptr->f->buf[0]); assert(h->cur_pic_ptr->reference != DELAYED_PIC_REF); /* figure out if we have a complementary field pair */ if (!FIELD_PICTURE(h) || h->picture_structure == last_pic_structure) { /* Previous field is unmatched. Don't display it, but let it * remain for reference if marked as such. */ h->cur_pic_ptr = NULL; h->first_field = FIELD_PICTURE(h); } else { if (h->cur_pic_ptr->frame_num != h->frame_num) { /* This and the previous field had different frame_nums. * Consider this field first in pair. Throw away previous * one except for reference purposes. */ h->first_field = 1; h->cur_pic_ptr = NULL; } else { /* Second field in complementary pair */ h->first_field = 0; } } } else { /* Frame or first field in a potentially complementary pair */ h->first_field = FIELD_PICTURE(h); } if (!FIELD_PICTURE(h) || h->first_field) { if (h264_frame_start(h) < 0) { h->first_field = 0; return AVERROR_INVALIDDATA; } } else { release_unused_pictures(h, 0); } } assert(h->mb_num == h->mb_width * h->mb_height); if (first_mb_in_slice << FIELD_OR_MBAFF_PICTURE(h) >= h->mb_num || first_mb_in_slice >= h->mb_num) { av_log(h->avctx, AV_LOG_ERROR, "first_mb_in_slice overflow\n"); return AVERROR_INVALIDDATA; } sl->resync_mb_x = sl->mb_x = first_mb_in_slice % h->mb_width; sl->resync_mb_y = sl->mb_y = (first_mb_in_slice / h->mb_width) << FIELD_OR_MBAFF_PICTURE(h); if (h->picture_structure == PICT_BOTTOM_FIELD) sl->resync_mb_y = sl->mb_y = sl->mb_y + 1; assert(sl->mb_y < h->mb_height); if (h->picture_structure == PICT_FRAME) { h->curr_pic_num = h->frame_num; h->max_pic_num = 1 << sps->log2_max_frame_num; } else { h->curr_pic_num = 2 * h->frame_num + 1; h->max_pic_num = 1 << (sps->log2_max_frame_num + 1); } if (h->nal_unit_type == NAL_IDR_SLICE) get_ue_golomb(&sl->gb); /* idr_pic_id */ if (sps->poc_type == 0) { int poc_lsb = get_bits(&sl->gb, sps->log2_max_poc_lsb); if (!h->setup_finished) h->poc_lsb = poc_lsb; if (pps->pic_order_present == 1 && h->picture_structure == PICT_FRAME) { int delta_poc_bottom = get_se_golomb(&sl->gb); if (!h->setup_finished) h->delta_poc_bottom = delta_poc_bottom; } } if (sps->poc_type == 1 && !sps->delta_pic_order_always_zero_flag) { int delta_poc = get_se_golomb(&sl->gb); if (!h->setup_finished) h->delta_poc[0] = delta_poc; if (pps->pic_order_present == 1 && h->picture_structure == PICT_FRAME) { delta_poc = get_se_golomb(&sl->gb); if (!h->setup_finished) h->delta_poc[1] = delta_poc; } } if (!h->setup_finished) ff_init_poc(h, h->cur_pic_ptr->field_poc, &h->cur_pic_ptr->poc); if (pps->redundant_pic_cnt_present) sl->redundant_pic_count = get_ue_golomb(&sl->gb); if (sl->slice_type_nos == AV_PICTURE_TYPE_B) sl->direct_spatial_mv_pred = get_bits1(&sl->gb); ret = ff_h264_parse_ref_count(&sl->list_count, sl->ref_count, &sl->gb, pps, sl->slice_type_nos, h->picture_structure); if (ret < 0) return ret; if (sl->slice_type_nos != AV_PICTURE_TYPE_I) { ret = ff_h264_decode_ref_pic_list_reordering(h, sl); if (ret < 0) { sl->ref_count[1] = sl->ref_count[0] = 0; return ret; } } if ((pps->weighted_pred && sl->slice_type_nos == AV_PICTURE_TYPE_P) || (pps->weighted_bipred_idc == 1 && sl->slice_type_nos == AV_PICTURE_TYPE_B)) ff_h264_pred_weight_table(&sl->gb, sps, sl->ref_count, sl->slice_type_nos, &sl->pwt); else if (pps->weighted_bipred_idc == 2 && sl->slice_type_nos == AV_PICTURE_TYPE_B) { implicit_weight_table(h, sl, -1); } else { sl->pwt.use_weight = 0; for (i = 0; i < 2; i++) { sl->pwt.luma_weight_flag[i] = 0; sl->pwt.chroma_weight_flag[i] = 0; } } // If frame-mt is enabled, only update mmco tables for the first slice // in a field. Subsequent slices can temporarily clobber h->mmco_index // or h->mmco, which will cause ref list mix-ups and decoding errors // further down the line. This may break decoding if the first slice is // corrupt, thus we only do this if frame-mt is enabled. if (h->nal_ref_idc) { ret = ff_h264_decode_ref_pic_marking(h, &sl->gb, !(h->avctx->active_thread_type & FF_THREAD_FRAME) || h->current_slice == 0); if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE)) return AVERROR_INVALIDDATA; } if (FRAME_MBAFF(h)) { ff_h264_fill_mbaff_ref_list(h, sl); if (pps->weighted_bipred_idc == 2 && sl->slice_type_nos == AV_PICTURE_TYPE_B) { implicit_weight_table(h, sl, 0); implicit_weight_table(h, sl, 1); } } if (sl->slice_type_nos == AV_PICTURE_TYPE_B && !sl->direct_spatial_mv_pred) ff_h264_direct_dist_scale_factor(h, sl); ff_h264_direct_ref_list_init(h, sl); if (sl->slice_type_nos != AV_PICTURE_TYPE_I && pps->cabac) { tmp = get_ue_golomb_31(&sl->gb); if (tmp > 2) { av_log(h->avctx, AV_LOG_ERROR, "cabac_init_idc %u overflow\n", tmp); return AVERROR_INVALIDDATA; } sl->cabac_init_idc = tmp; } sl->last_qscale_diff = 0; tmp = pps->init_qp + get_se_golomb(&sl->gb); if (tmp > 51 + 6 * (sps->bit_depth_luma - 8)) { av_log(h->avctx, AV_LOG_ERROR, "QP %u out of range\n", tmp); return AVERROR_INVALIDDATA; } sl->qscale = tmp; sl->chroma_qp[0] = get_chroma_qp(h, 0, sl->qscale); sl->chroma_qp[1] = get_chroma_qp(h, 1, sl->qscale); // FIXME qscale / qp ... stuff if (sl->slice_type == AV_PICTURE_TYPE_SP) get_bits1(&sl->gb); /* sp_for_switch_flag */ if (sl->slice_type == AV_PICTURE_TYPE_SP || sl->slice_type == AV_PICTURE_TYPE_SI) get_se_golomb(&sl->gb); /* slice_qs_delta */ sl->deblocking_filter = 1; sl->slice_alpha_c0_offset = 0; sl->slice_beta_offset = 0; if (pps->deblocking_filter_parameters_present) { tmp = get_ue_golomb_31(&sl->gb); if (tmp > 2) { av_log(h->avctx, AV_LOG_ERROR, "deblocking_filter_idc %u out of range\n", tmp); return AVERROR_INVALIDDATA; } sl->deblocking_filter = tmp; if (sl->deblocking_filter < 2) sl->deblocking_filter ^= 1; // 1<->0 if (sl->deblocking_filter) { sl->slice_alpha_c0_offset = get_se_golomb(&sl->gb) * 2; sl->slice_beta_offset = get_se_golomb(&sl->gb) * 2; if (sl->slice_alpha_c0_offset > 12 || sl->slice_alpha_c0_offset < -12 || sl->slice_beta_offset > 12 || sl->slice_beta_offset < -12) { av_log(h->avctx, AV_LOG_ERROR, "deblocking filter parameters %d %d out of range\n", sl->slice_alpha_c0_offset, sl->slice_beta_offset); return AVERROR_INVALIDDATA; } } } if (h->avctx->skip_loop_filter >= AVDISCARD_ALL || (h->avctx->skip_loop_filter >= AVDISCARD_NONKEY && sl->slice_type_nos != AV_PICTURE_TYPE_I) || (h->avctx->skip_loop_filter >= AVDISCARD_BIDIR && sl->slice_type_nos == AV_PICTURE_TYPE_B) || (h->avctx->skip_loop_filter >= AVDISCARD_NONREF && h->nal_ref_idc == 0)) sl->deblocking_filter = 0; if (sl->deblocking_filter == 1 && h->max_contexts > 1) { if (h->avctx->flags2 & AV_CODEC_FLAG2_FAST) { /* Cheat slightly for speed: * Do not bother to deblock across slices. */ sl->deblocking_filter = 2; } else { h->max_contexts = 1; if (!h->single_decode_warning) { av_log(h->avctx, AV_LOG_INFO, "Cannot parallelize deblocking type 1, decoding such frames in sequential order\n"); h->single_decode_warning = 1; } if (sl != h->slice_ctx) { av_log(h->avctx, AV_LOG_ERROR, "Deblocking switched inside frame.\n"); return 1; } } } sl->qp_thresh = 15 - FFMIN(sl->slice_alpha_c0_offset, sl->slice_beta_offset) - FFMAX3(0, pps->chroma_qp_index_offset[0], pps->chroma_qp_index_offset[1]) + 6 * (sps->bit_depth_luma - 8); sl->slice_num = ++h->current_slice; if (sl->slice_num >= MAX_SLICES) { av_log(h->avctx, AV_LOG_ERROR, "Too many slices, increase MAX_SLICES and recompile\n"); } for (j = 0; j < 2; j++) { int id_list[16]; int *ref2frm = sl->ref2frm[sl->slice_num & (MAX_SLICES - 1)][j]; for (i = 0; i < 16; i++) { id_list[i] = 60; if (j < sl->list_count && i < sl->ref_count[j] && sl->ref_list[j][i].parent->f->buf[0]) { int k; AVBuffer *buf = sl->ref_list[j][i].parent->f->buf[0]->buffer; for (k = 0; k < h->short_ref_count; k++) if (h->short_ref[k]->f->buf[0]->buffer == buf) { id_list[i] = k; break; } for (k = 0; k < h->long_ref_count; k++) if (h->long_ref[k] && h->long_ref[k]->f->buf[0]->buffer == buf) { id_list[i] = h->short_ref_count + k; break; } } } ref2frm[0] = ref2frm[1] = -1; for (i = 0; i < 16; i++) ref2frm[i + 2] = 4 * id_list[i] + (sl->ref_list[j][i].reference & 3); ref2frm[18 + 0] = ref2frm[18 + 1] = -1; for (i = 16; i < 48; i++) ref2frm[i + 4] = 4 * id_list[(i - 16) >> 1] + (sl->ref_list[j][i].reference & 3); } if (h->avctx->debug & FF_DEBUG_PICT_INFO) { av_log(h->avctx, AV_LOG_DEBUG, "slice:%d %s mb:%d %c%s%s pps:%u frame:%d poc:%d/%d ref:%d/%d qp:%d loop:%d:%d:%d weight:%d%s %s\n", sl->slice_num, (h->picture_structure == PICT_FRAME ? "F" : h->picture_structure == PICT_TOP_FIELD ? "T" : "B"), first_mb_in_slice, av_get_picture_type_char(sl->slice_type), sl->slice_type_fixed ? " fix" : "", h->nal_unit_type == NAL_IDR_SLICE ? " IDR" : "", pps_id, h->frame_num, h->cur_pic_ptr->field_poc[0], h->cur_pic_ptr->field_poc[1], sl->ref_count[0], sl->ref_count[1], sl->qscale, sl->deblocking_filter, sl->slice_alpha_c0_offset, sl->slice_beta_offset, sl->pwt.use_weight, sl->pwt.use_weight == 1 && sl->pwt.use_weight_chroma ? "c" : "", sl->slice_type == AV_PICTURE_TYPE_B ? (sl->direct_spatial_mv_pred ? "SPAT" : "TEMP") : ""); } return 0; }


static void vmsvga_bios_write(void *opaque, uint32_t address, uint32_t data) { printf("%s: what are we supposed to do with (%08x)?\n", __FUNCTION__, data); }


static int vapic_init ( SysBusDevice * dev ) {
 VAPICROMState * s = VAPIC ( dev ) ;
 memory_region_init_io ( & s -> io , OBJECT ( s ) , & vapic_ops , s , "kvmvapic" , 2 ) ;
 sysbus_add_io ( dev , VAPIC_IO_PORT , & s -> io ) ;
 sysbus_init_ioports ( dev , VAPIC_IO_PORT , 2 ) ;
 option_rom [ nb_option_roms ] . name = "kvmvapic.bin" ;
 option_rom [ nb_option_roms ] . bootindex = - 1 ;
 nb_option_roms ++ ;
 return 0 ;
 }


static void qemu_chr_fire_open_event(void *opaque) { CharDriverState *s = opaque; qemu_chr_be_event(s, CHR_EVENT_OPENED); qemu_free_timer(s->open_timer); s->open_timer = NULL; }


int EVP_CipherFinal ( EVP_CIPHER_CTX * ctx , unsigned char * out , int * outl ) {
 if ( ctx -> encrypt ) return EVP_EncryptFinal ( ctx , out , outl ) ;
 else return EVP_DecryptFinal ( ctx , out , outl ) ;
 }


static void ehci_advance_state(EHCIState *ehci, int async) { EHCIQueue *q = NULL; int again; int iter = 0; do { if (ehci_get_state(ehci, async) == EST_FETCHQH) { iter++; /* if we are roaming a lot of QH without executing a qTD * something is wrong with the linked list. TO-DO: why is * this hack needed? */ assert(iter < MAX_ITERATIONS); #if 0 if (iter > MAX_ITERATIONS) { DPRINTF("\n*** advance_state: bailing on MAX ITERATIONS***\n"); ehci_set_state(ehci, async, EST_ACTIVE); break; } #endif } switch(ehci_get_state(ehci, async)) { case EST_WAITLISTHEAD: again = ehci_state_waitlisthead(ehci, async); break; case EST_FETCHENTRY: again = ehci_state_fetchentry(ehci, async); break; case EST_FETCHQH: q = ehci_state_fetchqh(ehci, async); again = q ? 1 : 0; break; case EST_FETCHITD: again = ehci_state_fetchitd(ehci, async); break; case EST_FETCHSITD: again = ehci_state_fetchsitd(ehci, async); break; case EST_ADVANCEQUEUE: again = ehci_state_advqueue(q, async); break; case EST_FETCHQTD: again = ehci_state_fetchqtd(q, async); break; case EST_HORIZONTALQH: again = ehci_state_horizqh(q, async); break; case EST_EXECUTE: iter = 0; again = ehci_state_execute(q, async); break; case EST_EXECUTING: assert(q != NULL); again = ehci_state_executing(q, async); break; case EST_WRITEBACK: assert(q != NULL); again = ehci_state_writeback(q, async); break; default: fprintf(stderr, "Bad state!\n"); again = -1; assert(0); break; } if (again < 0) { fprintf(stderr, "processing error - resetting ehci HC\n"); ehci_reset(ehci); again = 0; } } while (again); ehci_commit_interrupt(ehci); }


std::unique_ptr<BytecodeModule> BytecodeModuleGenerator::generate() {
  assert(
      valid_ &&
      "BytecodeModuleGenerator::generate() cannot be called more than once");
  valid_ = false;

  assert(
      functionIDMap_.getElements().size() == functionGenerators_.size() &&
      "Missing functions.");

  auto kinds = stringTable_.getStringKinds();
  auto hashes = stringTable_.getIdentifierHashes();

  BytecodeOptions bytecodeOptions;
  bytecodeOptions.staticBuiltins = options_.staticBuiltinsEnabled;
  bytecodeOptions.cjsModulesStaticallyResolved = !cjsModulesStatic_.empty();
  std::unique_ptr<BytecodeModule> BM{new BytecodeModule(
      functionGenerators_.size(),
      std::move(kinds),
      std::move(hashes),
      stringTable_.acquireStringTable(),
      stringTable_.acquireStringStorage(),
      regExpTable_.getEntryList(),
      regExpTable_.getBytecodeBuffer(),
      entryPointIndex_,
      std::move(arrayBuffer_),
      std::move(objKeyBuffer_),
      std::move(objValBuffer_),
      cjsModuleOffset_,
      std::move(cjsModules_),
      std::move(cjsModulesStatic_),
      bytecodeOptions)};

  DebugInfoGenerator debugInfoGen{std::move(filenameTable_)};

  const uint32_t strippedFunctionNameId =
      options_.stripFunctionNames ? getStringID(kStrippedFunctionName) : 0;
  auto functions = functionIDMap_.getElements();
  std::shared_ptr<Context> contextIfNeeded;
  for (unsigned i = 0, e = functions.size(); i < e; ++i) {
    auto *F = functions[i];
    auto &BFG = *functionGenerators_[F];

    uint32_t functionNameId = options_.stripFunctionNames
        ? strippedFunctionNameId
        : getStringID(functions[i]->getOriginalOrInferredName().str());

    std::unique_ptr<BytecodeFunction> func = BFG.generateBytecodeFunction(
        F->getDefinitionKind(),
        F->getKind(),
        F->isStrictMode(),
        F->getExpectedParamCountIncludingThis(),
        F->getFunctionScope()->getVariables().size(),
        functionNameId);

#ifndef HERMESVM_LEAN
    if (F->getParent()
            ->shareContext()
            ->allowFunctionToStringWithRuntimeSource() ||
        F->isLazy()) {
      auto context = F->getParent()->shareContext();
      assert(
          (!contextIfNeeded || contextIfNeeded.get() == context.get()) &&
          "Different instances of Context seen");
      contextIfNeeded = context;
      BM->setFunctionSourceRange(i, F->getSourceRange());
    }
#endif

    if (F->isLazy()) {
#ifdef HERMESVM_LEAN
      llvm_unreachable("Lazy support compiled out");
#else
      auto lazyData = llvh::make_unique<LazyCompilationData>();
      lazyData->parentScope = F->getLazyScope();
      lazyData->nodeKind = F->getLazySource().nodeKind;
      lazyData->bufferId = F->getLazySource().bufferId;
      lazyData->originalName = F->getOriginalOrInferredName();
      lazyData->closureAlias = F->getLazyClosureAlias()
          ? F->getLazyClosureAlias()->getName()
          : Identifier();
      lazyData->strictMode = F->isStrictMode();
      func->setLazyCompilationData(std::move(lazyData));
#endif
    }

    if (BFG.hasDebugInfo()) {
      uint32_t sourceLocOffset = debugInfoGen.appendSourceLocations(
          BFG.getSourceLocation(), i, BFG.getDebugLocations());
      uint32_t lexicalDataOffset = debugInfoGen.appendLexicalData(
          BFG.getLexicalParentID(), BFG.getDebugVariableNames());
      func->setDebugOffsets({sourceLocOffset, lexicalDataOffset});
    }
    BM->setFunction(i, std::move(func));
  }

  BM->setContext(contextIfNeeded);

  BM->setDebugInfo(debugInfoGen.serializeWithMove());
  return BM;
}


static inline PixelTrait GetPixelBlackTraits ( const Image * restrict image ) {
 return ( image -> channel_map [ BlackPixelChannel ] . traits ) ;
 }


static int mxf_parse_index(MXFContext *mxf, int track_id, AVStream *st) { int64_t accumulated_offset = 0; int j, k, ret, nb_sorted_segments; MXFIndexTableSegment **sorted_segments; int n_delta = track_id - 1; /* TrackID = 1-based stream index */ if (track_id < 1) { av_log(mxf->fc, AV_LOG_ERROR, "TrackID not positive: %i\n", track_id); return AVERROR_INVALIDDATA; } if ((ret = mxf_get_sorted_table_segments(mxf, &nb_sorted_segments, &sorted_segments))) return ret; for (j = 0; j < nb_sorted_segments; j++) { int duration, sample_duration = 1, last_sample_size = 0; int64_t segment_size; MXFIndexTableSegment *tableseg = sorted_segments[j]; /* reset accumulated_offset on BodySID change */ if (j > 0 && tableseg->body_sid != sorted_segments[j-1]->body_sid) accumulated_offset = 0; if (n_delta >= tableseg->nb_delta_entries && st->index != 0) continue; duration = tableseg->index_duration > 0 ? tableseg->index_duration : st->duration - st->nb_index_entries; segment_size = tableseg->edit_unit_byte_count * duration; /* check small EditUnitByteCount for audio */ if (tableseg->edit_unit_byte_count && tableseg->edit_unit_byte_count < 32 && !tableseg->index_duration) { /* duration might be prime relative to the new sample_duration, * which means we need to handle the last frame differently */ sample_duration = 8192; last_sample_size = (duration % sample_duration) * tableseg->edit_unit_byte_count; tableseg->edit_unit_byte_count *= sample_duration; duration /= sample_duration; if (last_sample_size) duration++; } for (k = 0; k < duration; k++) { int64_t pos; int size, flags = 0; if (k < tableseg->nb_index_entries) { pos = tableseg->stream_offset_entries[k]; if (n_delta < tableseg->nb_delta_entries) { if (n_delta < tableseg->nb_delta_entries - 1) { size = tableseg->slice_offset_entries[k][tableseg->slice[n_delta+1]-1] + tableseg->element_delta[n_delta+1] - tableseg->element_delta[n_delta]; if (tableseg->slice[n_delta] > 0) size -= tableseg->slice_offset_entries[k][tableseg->slice[n_delta]-1]; } else if (k < duration - 1) { size = tableseg->stream_offset_entries[k+1] - tableseg->stream_offset_entries[k] - tableseg->slice_offset_entries[k][tableseg->slice[tableseg->nb_delta_entries-1]-1] - tableseg->element_delta[tableseg->nb_delta_entries-1]; } else size = 0; if (tableseg->slice[n_delta] > 0) pos += tableseg->slice_offset_entries[k][tableseg->slice[n_delta]-1]; pos += tableseg->element_delta[n_delta]; } else size = 0; flags = !(tableseg->flag_entries[k] & 0x30) ? AVINDEX_KEYFRAME : 0; } else { pos = (int64_t)k * tableseg->edit_unit_byte_count + accumulated_offset; if (n_delta < tableseg->nb_delta_entries - 1) size = tableseg->element_delta[n_delta+1] - tableseg->element_delta[n_delta]; else { /* use smaller size for last sample if we should */ if (last_sample_size && k == duration - 1) size = last_sample_size; else size = tableseg->edit_unit_byte_count; if (tableseg->nb_delta_entries) size -= tableseg->element_delta[tableseg->nb_delta_entries-1]; } if (n_delta < tableseg->nb_delta_entries) pos += tableseg->element_delta[n_delta]; flags = AVINDEX_KEYFRAME; } if (mxf_absolute_bodysid_offset(mxf, tableseg->body_sid, pos, &pos) < 0) { /* probably partial file - no point going further for this stream */ break; } av_dlog(mxf->fc, "Stream %d IndexEntry %d TrackID %d Offset %"PRIx64" Timestamp %"PRId64"\n", st->index, st->nb_index_entries, track_id, pos, sample_duration * st->nb_index_entries); if ((ret = av_add_index_entry(st, pos, sample_duration * st->nb_index_entries, size, 0, flags)) < 0) return ret; } accumulated_offset += segment_size; } av_free(sorted_segments); return 0; }


static void build_chunks(MOVTrack *trk) { int i; MOVIentry *chunk= &trk->cluster[0]; uint64_t chunkSize = chunk->size; chunk->chunkNum= 1; trk->chunkCount= 1; for(i=1; i<trk->entry; i++){ if(chunk->pos + chunkSize == trk->cluster[i].pos){ chunkSize += trk->cluster[i].size; chunk->samplesInChunk += trk->cluster[i].entries; }else{ trk->cluster[i].chunkNum = chunk->chunkNum+1; chunk=&trk->cluster[i]; chunkSize = chunk->size; trk->chunkCount++; } } }


static void ctl_putcal ( const char * tag , const struct calendar * pcal ) {
 char buffer [ 100 ] ;
 unsigned numch ;
 numch = snprintf ( buffer , sizeof ( buffer ) , "%s=%04d%02d%02d%02d%02d" , tag , pcal -> year , pcal -> month , pcal -> monthday , pcal -> hour , pcal -> minute ) ;
 INSIST ( numch < sizeof ( buffer ) ) ;
 ctl_putdata ( buffer , numch , 0 ) ;
 return ;
 }


static void pci_device_reset(PCIDevice *dev) { int r; dev->irq_state = 0; pci_update_irq_status(dev); /* Clear all writeable bits */ pci_word_test_and_clear_mask(dev->config + PCI_COMMAND, pci_get_word(dev->wmask + PCI_COMMAND)); dev->config[PCI_CACHE_LINE_SIZE] = 0x0; dev->config[PCI_INTERRUPT_LINE] = 0x0; for (r = 0; r < PCI_NUM_REGIONS; ++r) { PCIIORegion *region = &dev->io_regions[r]; if (!region->size) { continue; } if (!(region->type & PCI_BASE_ADDRESS_SPACE_IO) && region->type & PCI_BASE_ADDRESS_MEM_TYPE_64) { pci_set_quad(dev->config + pci_bar(dev, r), region->type); } else { pci_set_long(dev->config + pci_bar(dev, r), region->type); } } pci_update_mappings(dev); }


static CharDriverState *qemu_chr_open_ringbuf(const char *id, ChardevBackend *backend, ChardevReturn *ret, Error **errp) { ChardevRingbuf *opts = backend->u.ringbuf; CharDriverState *chr; RingBufCharDriver *d; chr = qemu_chr_alloc(); d = g_malloc(sizeof(*d)); d->size = opts->has_size ? opts->size : 65536; /* The size must be power of 2 */ if (d->size & (d->size - 1)) { error_setg(errp, "size of ringbuf chardev must be power of two"); goto fail; } d->prod = 0; d->cons = 0; d->cbuf = g_malloc0(d->size); chr->opaque = d; chr->chr_write = ringbuf_chr_write; chr->chr_close = ringbuf_chr_close; return chr; fail: g_free(d); g_free(chr); return NULL; }


static void test_qemu_strtoul_negative(void) { const char *str = " \t -321"; char f = 'X'; const char *endptr = &f; unsigned long res = 999; int err; err = qemu_strtoul(str, &endptr, 0, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, -321ul); g_assert(endptr == str + strlen(str)); }


static void generate_len_table(uint8_t *dst, uint64_t *stats, int size){ heap_elem_t h[size]; int up[2*size]; int len[2*size]; int offset, i, next; for(offset=1; ; offset<<=1){ for(i=0; i<size; i++){ h[i].name = i; h[i].val = (stats[i] << 8) + offset; } for(i=size/2-1; i>=0; i--) heap_sift(h, i, size); for(next=size; next<size*2-1; next++){ // merge the two smallest entries, and put it back in the heap uint64_t min1v = h[0].val; up[h[0].name] = next; h[0].val = INT64_MAX; heap_sift(h, 0, size); up[h[0].name] = next; h[0].name = next; h[0].val += min1v; heap_sift(h, 0, size); } len[2*size-2] = 0; for(i=2*size-3; i>=size; i--) len[i] = len[up[i]] + 1; for(i=0; i<size; i++) { dst[i] = len[up[i]] + 1; if(dst[i] > 32) break; } if(i==size) break; } }


static int get_packet(URLContext *s, int for_header) { RTMPContext *rt = s->priv_data; int ret; uint8_t *p; const uint8_t *next; uint32_t data_size; uint32_t ts, cts, pts=0; if (rt->state == STATE_STOPPED) return AVERROR_EOF; for (;;) { RTMPPacket rpkt = { 0 }; if ((ret = ff_rtmp_packet_read(rt->stream, &rpkt, rt->chunk_size, rt->prev_pkt[0])) <= 0) { if (ret == 0) { return AVERROR(EAGAIN); } else { return AVERROR(EIO); } } rt->bytes_read += ret; if (rt->bytes_read > rt->last_bytes_read + rt->client_report_size) { av_log(s, AV_LOG_DEBUG, "Sending bytes read report\n"); gen_bytes_read(s, rt, rpkt.timestamp + 1); rt->last_bytes_read = rt->bytes_read; } ret = rtmp_parse_result(s, rt, &rpkt); if (ret < 0) {//serious error in current packet ff_rtmp_packet_destroy(&rpkt); return -1; } if (rt->state == STATE_STOPPED) { ff_rtmp_packet_destroy(&rpkt); return AVERROR_EOF; } if (for_header && (rt->state == STATE_PLAYING || rt->state == STATE_PUBLISHING)) { ff_rtmp_packet_destroy(&rpkt); return 0; } if (!rpkt.data_size || !rt->is_input) { ff_rtmp_packet_destroy(&rpkt); continue; } if (rpkt.type == RTMP_PT_VIDEO || rpkt.type == RTMP_PT_AUDIO || (rpkt.type == RTMP_PT_NOTIFY && !memcmp("\002\000\012onMetaData", rpkt.data, 13))) { ts = rpkt.timestamp; // generate packet header and put data into buffer for FLV demuxer rt->flv_off = 0; rt->flv_size = rpkt.data_size + 15; rt->flv_data = p = av_realloc(rt->flv_data, rt->flv_size); bytestream_put_byte(&p, rpkt.type); bytestream_put_be24(&p, rpkt.data_size); bytestream_put_be24(&p, ts); bytestream_put_byte(&p, ts >> 24); bytestream_put_be24(&p, 0); bytestream_put_buffer(&p, rpkt.data, rpkt.data_size); bytestream_put_be32(&p, 0); ff_rtmp_packet_destroy(&rpkt); return 0; } else if (rpkt.type == RTMP_PT_METADATA) { // we got raw FLV data, make it available for FLV demuxer rt->flv_off = 0; rt->flv_size = rpkt.data_size; rt->flv_data = av_realloc(rt->flv_data, rt->flv_size); /* rewrite timestamps */ next = rpkt.data; ts = rpkt.timestamp; while (next - rpkt.data < rpkt.data_size - 11) { next++; data_size = bytestream_get_be24(&next); p=next; cts = bytestream_get_be24(&next); cts |= bytestream_get_byte(&next) << 24; if (pts==0) pts=cts; ts += cts - pts; pts = cts; bytestream_put_be24(&p, ts); bytestream_put_byte(&p, ts >> 24); next += data_size + 3 + 4; } memcpy(rt->flv_data, rpkt.data, rpkt.data_size); ff_rtmp_packet_destroy(&rpkt); return 0; } ff_rtmp_packet_destroy(&rpkt); } }


static UINT drdynvc_process_data_first(drdynvcPlugin* drdynvc, int Sp,
                                       int cbChId, wStream* s)
{
	UINT status;
	UINT32 Length;
	UINT32 ChannelId;
	ChannelId = drdynvc_read_variable_uint(s, cbChId);
	Length = drdynvc_read_variable_uint(s, Sp);
	WLog_Print(drdynvc->log, WLOG_DEBUG,
	           "process_data_first: Sp=%d cbChId=%d, ChannelId=%"PRIu32" Length=%"PRIu32"", Sp,
	           cbChId, ChannelId, Length);
	status = dvcman_receive_channel_data_first(drdynvc, drdynvc->channel_mgr, ChannelId,
	         Length);

	if (status)
		return status;

	return dvcman_receive_channel_data(drdynvc, drdynvc->channel_mgr, ChannelId, s);
}


static void finishupcid ( SplineFont * sf , struct alltabs * at ) {
 int strlen , shlen , glen , csetlen , cstrlen , fdsellen , fdarrlen , prvlen ;
 int base , eotop , strhead ;
 int i ;
 storesid ( at , NULL ) ;
 strlen = ftell ( at -> sidf ) + ( shlen = ftell ( at -> sidh ) ) ;
 glen = ftell ( at -> globalsubrs ) ;
 csetlen = ftell ( at -> charset ) ;
 fdsellen = ftell ( at -> fdselect ) ;
 cstrlen = ftell ( at -> charstrings ) ;
 fdarrlen = ftell ( at -> fdarray ) ;
 base = ftell ( at -> cfff ) ;
 at -> cfflongoffset = true ;
 base += 5 * 4 + 4 + 2 ;
 strhead = 2 + ( at -> sidcnt > 1 ) ;
 base += strhead ;
 prvlen = 0 ;
 for ( i = 0 ;
 i < sf -> subfontcnt ;
 ++ i ) {
 fseek ( at -> fdarray , at -> fds [ i ] . fillindictmark , SEEK_SET ) ;
 dumpsizedint ( at -> fdarray , false , at -> fds [ i ] . privatelen , - 1 ) ;
 dumpsizedint ( at -> fdarray , true , base + strlen + glen + csetlen + fdsellen + cstrlen + fdarrlen + prvlen , 18 ) ;
 prvlen += ftell ( at -> fds [ i ] . private ) ;
 }
 dumpsizedint ( at -> cfff , at -> cfflongoffset , base + strlen + glen , 15 ) ;
 dumpsizedint ( at -> cfff , at -> cfflongoffset , base + strlen + glen + csetlen , ( 12 << 8 ) | 37 ) ;
 dumpsizedint ( at -> cfff , at -> cfflongoffset , base + strlen + glen + csetlen + fdsellen , 17 ) ;
 dumpsizedint ( at -> cfff , at -> cfflongoffset , base + strlen + glen + csetlen + fdsellen + cstrlen , ( 12 << 8 ) | 36 ) ;
 eotop = base - strhead - at -> lenpos - 1 ;
 fseek ( at -> cfff , at -> lenpos , SEEK_SET ) ;
 putshort ( at -> cfff , eotop ) ;
 fseek ( at -> cfff , 0 , SEEK_END ) ;
 putshort ( at -> cfff , at -> sidcnt - 1 ) ;
 if ( at -> sidcnt != 1 ) {
 putc ( at -> sidlongoffset ? 4 : 2 , at -> cfff ) ;
 if ( ! ttfcopyfile ( at -> cfff , at -> sidh , base , "CFF-StringBase" ) ) at -> error = true ;
 if ( ! ttfcopyfile ( at -> cfff , at -> sidf , base + shlen , "CFF-StringData" ) ) at -> error = true ;
 }
 if ( ! ttfcopyfile ( at -> cfff , at -> globalsubrs , base + strlen , "CFF-GlobalSubrs" ) ) at -> error = true ;
 if ( ! ttfcopyfile ( at -> cfff , at -> charset , base + strlen + glen , "CFF-Charset" ) ) at -> error = true ;
 if ( ! ttfcopyfile ( at -> cfff , at -> fdselect , base + strlen + glen + csetlen , "CFF-FDSelect" ) ) at -> error = true ;
 if ( ! ttfcopyfile ( at -> cfff , at -> charstrings , base + strlen + glen + csetlen + fdsellen , "CFF-CharStrings" ) ) at -> error = true ;
 if ( ! ttfcopyfile ( at -> cfff , at -> fdarray , base + strlen + glen + csetlen + fdsellen + cstrlen , "CFF-FDArray" ) ) at -> error = true ;
 prvlen = 0 ;
 for ( i = 0 ;
 i < sf -> subfontcnt ;
 ++ i ) {
 int temp = ftell ( at -> fds [ i ] . private ) ;
 if ( ! ttfcopyfile ( at -> cfff , at -> fds [ i ] . private , base + strlen + glen + csetlen + fdsellen + cstrlen + fdarrlen + prvlen , "CFF-PrivateSubrs" ) ) at -> error = true ;
 prvlen += temp ;
 }
 free ( at -> fds ) ;
 }


static void smbios_build_type_1_fields(void) { smbios_maybe_add_str(1, offsetof(struct smbios_type_1, manufacturer_str), type1.manufacturer); smbios_maybe_add_str(1, offsetof(struct smbios_type_1, product_name_str), type1.product); smbios_maybe_add_str(1, offsetof(struct smbios_type_1, version_str), type1.version); smbios_maybe_add_str(1, offsetof(struct smbios_type_1, serial_number_str), type1.serial); smbios_maybe_add_str(1, offsetof(struct smbios_type_1, sku_number_str), type1.sku); smbios_maybe_add_str(1, offsetof(struct smbios_type_1, family_str), type1.family); if (qemu_uuid_set) { /* We don't encode the UUID in the "wire format" here because this * function is for legacy mode and needs to keep the guest ABI, and * because we don't know what's the SMBIOS version advertised by the * BIOS. */ smbios_add_field(1, offsetof(struct smbios_type_1, uuid), qemu_uuid, 16); } }


static u32 mp4box_cleanup(u32 ret_code) {
	if (mpd_base_urls) {
		gf_free(mpd_base_urls);
		mpd_base_urls = NULL;
	}
	if (sdp_lines) {
		gf_free(sdp_lines);
		sdp_lines = NULL;
	}
	if (metas) {
		u32 i;
		for (i=0; i<nb_meta_act; i++) {
			if (metas[i].enc_type) gf_free(metas[i].enc_type);
			if (metas[i].mime_type) gf_free(metas[i].mime_type);
			if (metas[i].szName) gf_free(metas[i].szName);
			if (metas[i].szPath) gf_free(metas[i].szPath);
		}
		gf_free(metas);
		metas = NULL;
	}
	if (tracks) {
		u32 i;
		for (i = 0; i<nb_track_act; i++) {
			if (tracks[i].out_name)
				gf_free(tracks[i].out_name);
			if (tracks[i].src_name)
				gf_free(tracks[i].src_name);
			if (tracks[i].string)
				gf_free(tracks[i].string);
			if (tracks[i].kind_scheme)
				gf_free(tracks[i].kind_scheme);
			if (tracks[i].kind_value)
				gf_free(tracks[i].kind_value);
		}
		gf_free(tracks);
		tracks = NULL;
	}
	if (tsel_acts) {
		gf_free(tsel_acts);
		tsel_acts = NULL;
	}
	if (brand_add) {
		gf_free(brand_add);
		brand_add = NULL;
	}
	if (brand_rem) {
		gf_free(brand_rem);
		brand_rem = NULL;
	}
	if (dash_inputs) {
		u32 i, j;
		for (i = 0; i<nb_dash_inputs; i++) {
			GF_DashSegmenterInput *di = &dash_inputs[i];
			if (di->nb_baseURL) {
				for (j = 0; j<di->nb_baseURL; j++) {
					gf_free(di->baseURL[j]);
				}
				gf_free(di->baseURL);
			}
			if (di->rep_descs) {
				for (j = 0; j<di->nb_rep_descs; j++) {
					gf_free(di->rep_descs[j]);
				}
				gf_free(di->rep_descs);
			}
			if (di->as_descs) {
				for (j = 0; j<di->nb_as_descs; j++) {
					gf_free(di->as_descs[j]);
				}
				gf_free(di->as_descs);
			}
			if (di->as_c_descs) {
				for (j = 0; j<di->nb_as_c_descs; j++) {
					gf_free(di->as_c_descs[j]);
				}
				gf_free(di->as_c_descs);
			}
			if (di->p_descs) {
				for (j = 0; j<di->nb_p_descs; j++) {
					gf_free(di->p_descs[j]);
				}
				gf_free(di->p_descs);
			}
			if (di->representationID) gf_free(di->representationID);
			if (di->periodID) gf_free(di->periodID);
			if (di->xlink) gf_free(di->xlink);
			if (di->seg_template) gf_free(di->seg_template);
			if (di->hls_pl) gf_free(di->hls_pl);
			if (di->source_opts) gf_free(di->source_opts);
			if (di->filter_chain) gf_free(di->filter_chain);

			if (di->roles) {
				for (j = 0; j<di->nb_roles; j++) {
					gf_free(di->roles[j]);
				}
				gf_free(di->roles);
			}
		}
		gf_free(dash_inputs);
		dash_inputs = NULL;
	}
	if (logfile) gf_fclose(logfile);
	gf_sys_close();
	return ret_code;
}


static void print_warnings ( ) {
 const char * query ;
 MYSQL_RES * result ;
 MYSQL_ROW cur ;
 my_ulonglong num_rows ;
 uint error = mysql_errno ( & mysql ) ;
 query = "show warnings" ;
 mysql_real_query_for_lazy ( query , strlen ( query ) ) ;
 mysql_store_result_for_lazy ( & result ) ;
 if ( ! result || ! ( num_rows = mysql_num_rows ( result ) ) ) goto end ;
 cur = mysql_fetch_row ( result ) ;
 if ( ! cur || ( num_rows == 1 && error == ( uint ) strtoul ( cur [ 1 ] , NULL , 10 ) ) ) goto end ;
 init_pager ( ) ;
 do {
 tee_fprintf ( PAGER , "%s (Code %s): %s\n" , cur [ 0 ] , cur [ 1 ] , cur [ 2 ] ) ;
 }
 while ( ( cur = mysql_fetch_row ( result ) ) ) ;
 end_pager ( ) ;
 end : mysql_free_result ( result ) ;
 }


QDict *qdict_new(void) { QDict *qdict; qdict = g_malloc0(sizeof(*qdict)); QOBJECT_INIT(qdict, &qdict_type); return qdict; }


  bool has_capacity() const TF_EXCLUSIVE_LOCKS_REQUIRED(mu_) {
    return capacity_ > 0;
  }


static void exsltMathMinFunction ( xmlXPathParserContextPtr ctxt , int nargs ) {
 xmlNodeSetPtr ns ;
 double ret ;
 void * user = NULL ;
 if ( nargs != 1 ) {
 xsltGenericError ( xsltGenericErrorContext , "math:min: invalid number of arguments\n" ) ;
 ctxt -> error = XPATH_INVALID_ARITY ;
 return ;
 }
 if ( ( ctxt -> value != NULL ) && ( ctxt -> value -> boolval != 0 ) ) {
 user = ctxt -> value -> user ;
 ctxt -> value -> boolval = 0 ;
 ctxt -> value -> user = NULL ;
 }
 ns = xmlXPathPopNodeSet ( ctxt ) ;
 if ( xmlXPathCheckError ( ctxt ) ) return ;
 ret = exsltMathMin ( ns ) ;
 xmlXPathFreeNodeSet ( ns ) ;
 if ( user != NULL ) xmlFreeNodeList ( ( xmlNodePtr ) user ) ;
 xmlXPathReturnNumber ( ctxt , ret ) ;
 }


void bmdma_cmd_writeb(void *opaque, uint32_t addr, uint32_t val) { BMDMAState *bm = opaque; #ifdef DEBUG_IDE printf("%s: 0x%08x\n", __func__, val); #endif /* Ignore writes to SSBM if it keeps the old value */ if ((val & BM_CMD_START) != (bm->cmd & BM_CMD_START)) { if (!(val & BM_CMD_START)) { /* * We can't cancel Scatter Gather DMA in the middle of the * operation or a partial (not full) DMA transfer would reach * the storage so we wait for completion instead (we beahve * like if the DMA was completed by the time the guest trying * to cancel dma with bmdma_cmd_writeb with BM_CMD_START not * set). * * In the future we'll be able to safely cancel the I/O if the * whole DMA operation will be submitted to disk with a single * aio operation with preadv/pwritev. */ if (bm->bus->dma->aiocb) { qemu_aio_flush(); #ifdef DEBUG_IDE if (bm->bus->dma->aiocb) printf("ide_dma_cancel: aiocb still pending\n"); if (bm->status & BM_STATUS_DMAING) printf("ide_dma_cancel: BM_STATUS_DMAING still pending\n"); #endif } } else { bm->cur_addr = bm->addr; if (!(bm->status & BM_STATUS_DMAING)) { bm->status |= BM_STATUS_DMAING; /* start dma transfer if possible */ if (bm->dma_cb) bm->dma_cb(bmdma_active_if(bm), 0); } } } bm->cmd = val & 0x09; }


void raw6_icmp_error ( struct sk_buff * skb , int nexthdr , u8 type , u8 code , int inner_offset , __be32 info ) {
 struct sock * sk ;
 int hash ;
 struct in6_addr * saddr , * daddr ;
 struct net * net ;
 hash = nexthdr & ( RAW_HTABLE_SIZE - 1 ) ;
 read_lock ( & raw_v6_hashinfo . lock ) ;
 sk = sk_head ( & raw_v6_hashinfo . ht [ hash ] ) ;
 if ( sk != NULL ) {
 struct ipv6hdr * ip6h = ( struct ipv6hdr * ) skb -> data ;
 saddr = & ip6h -> saddr ;
 daddr = & ip6h -> daddr ;
 net = dev_net ( skb -> dev ) ;
 while ( ( sk = __raw_v6_lookup ( net , sk , nexthdr , saddr , daddr , IP6CB ( skb ) -> iif ) ) ) {
 rawv6_err ( sk , skb , NULL , type , code , inner_offset , info ) ;
 sk = sk_next ( sk ) ;
 }
 }
 read_unlock ( & raw_v6_hashinfo . lock ) ;
 }


static char *SocketAddress_to_str(const char *prefix, SocketAddressLegacy *addr, bool is_listen, bool is_telnet) { switch (addr->type) { case SOCKET_ADDRESS_LEGACY_KIND_INET: return g_strdup_printf("%s%s:%s:%s%s", prefix, is_telnet ? "telnet" : "tcp", addr->u.inet.data->host, addr->u.inet.data->port, is_listen ? ",server" : ""); break; case SOCKET_ADDRESS_LEGACY_KIND_UNIX: return g_strdup_printf("%sunix:%s%s", prefix, addr->u.q_unix.data->path, is_listen ? ",server" : ""); break; case SOCKET_ADDRESS_LEGACY_KIND_FD: return g_strdup_printf("%sfd:%s%s", prefix, addr->u.fd.data->str, is_listen ? ",server" : ""); break; case SOCKET_ADDRESS_LEGACY_KIND_VSOCK: return g_strdup_printf("%svsock:%s:%s", prefix, addr->u.vsock.data->cid, addr->u.vsock.data->port); default: abort(); } }


void vp9_idct4x4_16_add_c ( const tran_low_t * input , uint8_t * dest , int stride ) {
 tran_low_t out [ 4 * 4 ] ;
 tran_low_t * outptr = out ;
 int i , j ;
 tran_low_t temp_in [ 4 ] , temp_out [ 4 ] ;
 for ( i = 0 ;
 i < 4 ;
 ++ i ) {
 idct4 ( input , outptr ) ;
 input += 4 ;
 outptr += 4 ;
 }
 for ( i = 0 ;
 i < 4 ;
 ++ i ) {
 for ( j = 0 ;
 j < 4 ;
 ++ j ) temp_in [ j ] = out [ j * 4 + i ] ;
 idct4 ( temp_in , temp_out ) ;
 for ( j = 0 ;
 j < 4 ;
 ++ j ) dest [ j * stride + i ] = clip_pixel ( ROUND_POWER_OF_TWO ( temp_out [ j ] , 4 ) + dest [ j * stride + i ] ) ;
 }
 }


int qemu_init_main_loop(void) { int ret; qemu_init_sigbus(); ret = qemu_signal_init(); if (ret) { return ret; } /* Note eventfd must be drained before signalfd handlers run */ ret = qemu_event_init(); if (ret) { return ret; } qemu_cond_init(&qemu_cpu_cond); qemu_cond_init(&qemu_system_cond); qemu_cond_init(&qemu_pause_cond); qemu_cond_init(&qemu_work_cond); qemu_cond_init(&qemu_io_proceeded_cond); qemu_mutex_init(&qemu_global_mutex); qemu_mutex_lock(&qemu_global_mutex); qemu_thread_get_self(&io_thread); return 0; }


static int dissect_rsl_ie_ms_timing_offset ( tvbuff_t * tvb , packet_info * pinfo _U_ , proto_tree * tree , int offset , gboolean is_mandatory ) {
 proto_tree * ie_tree ;
 guint8 ie_id ;
 if ( is_mandatory == FALSE ) {
 ie_id = tvb_get_guint8 ( tvb , offset ) ;
 if ( ie_id != RSL_IE_FULL_MS_TIMING_OFFSET ) return offset ;
 }
 ie_tree = proto_tree_add_subtree ( tree , tvb , offset , 0 , ett_ie_ms_timing_offset , NULL , "MS Timing Offset IE" ) ;
 proto_tree_add_item ( ie_tree , hf_rsl_ie_id , tvb , offset , 1 , ENC_BIG_ENDIAN ) ;
 offset ++ ;
 proto_tree_add_item ( ie_tree , hf_rsl_timing_offset , tvb , offset , 1 , ENC_BIG_ENDIAN ) ;
 offset ++ ;
 return offset ;
 }


static bool blit_is_unsafe(struct CirrusVGAState *s, bool dst_only) { /* should be the case, see cirrus_bitblt_start */ assert(s->cirrus_blt_width > 0); assert(s->cirrus_blt_height > 0); if (s->cirrus_blt_width > CIRRUS_BLTBUFSIZE) { return true; } if (blit_region_is_unsafe(s, s->cirrus_blt_dstpitch, s->cirrus_blt_dstaddr & s->cirrus_addr_mask)) { return true; } if (dst_only) { return false; } if (blit_region_is_unsafe(s, s->cirrus_blt_srcpitch, s->cirrus_blt_srcaddr & s->cirrus_addr_mask)) { return true; } return false; }


IN_PROC_BROWSER_TEST_F ( FullscreenControllerInteractiveTest , DISABLED_TestFullscreenBubbleMouseLockState ) {
 ASSERT_TRUE ( test_server ( ) -> Start ( ) ) ;
 AddTabAtIndex ( 0 , GURL ( url : : kAboutBlankURL ) , PAGE_TRANSITION_TYPED ) ;
 AddTabAtIndex ( 1 , GURL ( url : : kAboutBlankURL ) , PAGE_TRANSITION_TYPED ) ;
 ASSERT_NO_FATAL_FAILURE ( ToggleTabFullscreen ( true ) ) ;
 RequestToLockMouse ( true , false ) ;
 ASSERT_TRUE ( IsMouseLockPermissionRequested ( ) ) ;
 AcceptCurrentFullscreenOrMouseLockRequest ( ) ;
 ASSERT_FALSE ( IsFullscreenBubbleDisplayingButtons ( ) ) ;
 }


static int dissect_h245_T_reverseLogicalChannelNumber ( tvbuff_t * tvb _U_ , int offset _U_ , asn1_ctx_t * actx _U_ , proto_tree * tree _U_ , int hf_index _U_ ) {
 offset = dissect_h245_LogicalChannelNumber ( tvb , offset , actx , tree , hf_index ) ;
 # line 288 "../../asn1/h245/h245.cnf" h223_rev_lc_num = h245_lc_temp ;
 return offset ;
 }


static void trash_files ( CommonJob * job , GList * files , int * files_skipped ) {
 GList * l ;
 GFile * file ;
 GList * to_delete ;
 SourceInfo source_info ;
 TransferInfo transfer_info ;
 gboolean skipped_file ;
 if ( job_aborted ( job ) ) {
 return ;
 }
 scan_sources ( files , & source_info , job , OP_KIND_TRASH ) ;
 if ( job_aborted ( job ) ) {
 return ;
 }
 g_timer_start ( job -> time ) ;
 memset ( & transfer_info , 0 , sizeof ( transfer_info ) ) ;
 report_trash_progress ( job , & source_info , & transfer_info ) ;
 to_delete = NULL ;
 for ( l = files ;
 l != NULL && ! job_aborted ( job ) ;
 l = l -> next ) {
 file = l -> data ;
 skipped_file = FALSE ;
 trash_file ( job , file , & skipped_file , & source_info , & transfer_info , TRUE , & to_delete ) ;
 if ( skipped_file ) {
 ( * files_skipped ) ++ ;
 transfer_add_file_to_count ( file , job , & transfer_info ) ;
 report_trash_progress ( job , & source_info , & transfer_info ) ;
 }
 }
 if ( to_delete ) {
 to_delete = g_list_reverse ( to_delete ) ;
 delete_files ( job , to_delete , files_skipped ) ;
 g_list_free ( to_delete ) ;
 }
 }


void evhttp_send_reply_chunk ( struct evhttp_request * req , struct evbuffer * databuf ) {
 if ( req -> chunked ) {
 evbuffer_add_printf ( req -> evcon -> output_buffer , "%x\r\n" , ( unsigned ) EVBUFFER_LENGTH ( databuf ) ) ;
 }
 evbuffer_add_buffer ( req -> evcon -> output_buffer , databuf ) ;
 if ( req -> chunked ) {
 evbuffer_add ( req -> evcon -> output_buffer , "\r\n" , 2 ) ;
 }
 evhttp_write_buffer ( req -> evcon , NULL , NULL ) ;
 }


static void coroutine_fn mirror_run(void *opaque) { MirrorBlockJob *s = opaque; MirrorExitData *data; BlockDriverState *bs = s->common.bs; int64_t sector_num, end, sectors_per_chunk, length; uint64_t last_pause_ns; BlockDriverInfo bdi; char backing_filename[1024]; int ret = 0; int n; if (block_job_is_cancelled(&s->common)) { goto immediate_exit; } s->bdev_length = bdrv_getlength(bs); if (s->bdev_length < 0) { ret = s->bdev_length; goto immediate_exit; } else if (s->bdev_length == 0) { /* Report BLOCK_JOB_READY and wait for complete. */ block_job_event_ready(&s->common); s->synced = true; while (!block_job_is_cancelled(&s->common) && !s->should_complete) { block_job_yield(&s->common); } s->common.cancelled = false; goto immediate_exit; } length = DIV_ROUND_UP(s->bdev_length, s->granularity); s->in_flight_bitmap = bitmap_new(length); /* If we have no backing file yet in the destination, we cannot let * the destination do COW. Instead, we copy sectors around the * dirty data if needed. We need a bitmap to do that. */ bdrv_get_backing_filename(s->target, backing_filename, sizeof(backing_filename)); if (backing_filename[0] && !s->target->backing_hd) { ret = bdrv_get_info(s->target, &bdi); if (ret < 0) { goto immediate_exit; } if (s->granularity < bdi.cluster_size) { s->buf_size = MAX(s->buf_size, bdi.cluster_size); s->cow_bitmap = bitmap_new(length); } } end = s->bdev_length / BDRV_SECTOR_SIZE; s->buf = qemu_try_blockalign(bs, s->buf_size); if (s->buf == NULL) { ret = -ENOMEM; goto immediate_exit; } sectors_per_chunk = s->granularity >> BDRV_SECTOR_BITS; mirror_free_init(s); if (!s->is_none_mode) { /* First part, loop on the sectors and initialize the dirty bitmap. */ BlockDriverState *base = s->base; for (sector_num = 0; sector_num < end; ) { int64_t next = (sector_num | (sectors_per_chunk - 1)) + 1; ret = bdrv_is_allocated_above(bs, base, sector_num, next - sector_num, &n); if (ret < 0) { goto immediate_exit; } assert(n > 0); if (ret == 1) { bdrv_set_dirty(bs, sector_num, n); sector_num = next; } else { sector_num += n; } } } bdrv_dirty_iter_init(bs, s->dirty_bitmap, &s->hbi); last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); for (;;) { uint64_t delay_ns = 0; int64_t cnt; bool should_complete; if (s->ret < 0) { ret = s->ret; goto immediate_exit; } cnt = bdrv_get_dirty_count(bs, s->dirty_bitmap); /* s->common.offset contains the number of bytes already processed so * far, cnt is the number of dirty sectors remaining and * s->sectors_in_flight is the number of sectors currently being * processed; together those are the current total operation length */ s->common.len = s->common.offset + (cnt + s->sectors_in_flight) * BDRV_SECTOR_SIZE; /* Note that even when no rate limit is applied we need to yield * periodically with no pending I/O so that qemu_aio_flush() returns. * We do so every SLICE_TIME nanoseconds, or when there is an error, * or when the source is clean, whichever comes first. */ if (qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - last_pause_ns < SLICE_TIME && s->common.iostatus == BLOCK_DEVICE_IO_STATUS_OK) { if (s->in_flight == MAX_IN_FLIGHT || s->buf_free_count == 0 || (cnt == 0 && s->in_flight > 0)) { trace_mirror_yield(s, s->in_flight, s->buf_free_count, cnt); qemu_coroutine_yield(); continue; } else if (cnt != 0) { delay_ns = mirror_iteration(s); if (delay_ns == 0) { continue; } } } should_complete = false; if (s->in_flight == 0 && cnt == 0) { trace_mirror_before_flush(s); ret = bdrv_flush(s->target); if (ret < 0) { if (mirror_error_action(s, false, -ret) == BLOCK_ERROR_ACTION_REPORT) { goto immediate_exit; } } else { /* We're out of the streaming phase. From now on, if the job * is cancelled we will actually complete all pending I/O and * report completion. This way, block-job-cancel will leave * the target in a consistent state. */ if (!s->synced) { block_job_event_ready(&s->common); s->synced = true; } should_complete = s->should_complete || block_job_is_cancelled(&s->common); cnt = bdrv_get_dirty_count(bs, s->dirty_bitmap); } } if (cnt == 0 && should_complete) { /* The dirty bitmap is not updated while operations are pending. * If we're about to exit, wait for pending operations before * calling bdrv_get_dirty_count(bs), or we may exit while the * source has dirty data to copy! * * Note that I/O can be submitted by the guest while * mirror_populate runs. */ trace_mirror_before_drain(s, cnt); bdrv_drain(bs); cnt = bdrv_get_dirty_count(bs, s->dirty_bitmap); } ret = 0; trace_mirror_before_sleep(s, cnt, s->synced, delay_ns); if (!s->synced) { block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns); if (block_job_is_cancelled(&s->common)) { break; } } else if (!should_complete) { delay_ns = (s->in_flight == 0 && cnt == 0 ? SLICE_TIME : 0); block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns); } else if (cnt == 0) { /* The two disks are in sync. Exit and report successful * completion. */ assert(QLIST_EMPTY(&bs->tracked_requests)); s->common.cancelled = false; break; } last_pause_ns = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); } immediate_exit: if (s->in_flight > 0) { /* We get here only if something went wrong. Either the job failed, * or it was cancelled prematurely so that we do not guarantee that * the target is a copy of the source. */ assert(ret < 0 || (!s->synced && block_job_is_cancelled(&s->common))); mirror_drain(s); } assert(s->in_flight == 0); qemu_vfree(s->buf); g_free(s->cow_bitmap); g_free(s->in_flight_bitmap); bdrv_release_dirty_bitmap(bs, s->dirty_bitmap); bdrv_iostatus_disable(s->target); data = g_malloc(sizeof(*data)); data->ret = ret; block_job_defer_to_main_loop(&s->common, mirror_exit, data); }


static int dissect_pcp_message_pmns_names ( tvbuff_t * tvb , packet_info * pinfo , proto_tree * tree , int offset ) {
 proto_item * pcp_pmns_names_item ;
 proto_tree * pcp_pmns_names_tree ;
 proto_item * pcp_pmns_names_name_item ;
 proto_tree * pcp_pmns_names_name_tree ;
 guint32 is_pmns_names_status ;
 guint32 num_names ;
 guint32 name_len ;
 guint32 full_name_len ;
 guint32 padding ;
 guint32 i ;
 col_append_fstr ( pinfo -> cinfo , COL_INFO , "[%s]" , val_to_str ( PCP_PDU_PMNS_NAMES , packettypenames , "Unknown Type:0x%02x" ) ) ;
 pcp_pmns_names_item = proto_tree_add_item ( tree , hf_pcp_pmns_names , tvb , offset , - 1 , ENC_NA ) ;
 pcp_pmns_names_tree = proto_item_add_subtree ( pcp_pmns_names_item , ett_pcp ) ;
 proto_tree_add_item ( pcp_pmns_names_tree , hf_pcp_pmns_names_nstrbytes , tvb , offset , 4 , ENC_BIG_ENDIAN ) ;
 offset += 4 ;
 proto_tree_add_item ( pcp_pmns_names_tree , hf_pcp_pmns_names_numstatus , tvb , offset , 4 , ENC_BIG_ENDIAN ) ;
 is_pmns_names_status = tvb_get_ntohl ( tvb , offset ) ;
 offset += 4 ;
 proto_tree_add_item ( pcp_pmns_names_tree , hf_pcp_pmns_names_numnames , tvb , offset , 4 , ENC_BIG_ENDIAN ) ;
 num_names = tvb_get_ntohl ( tvb , offset ) ;
 offset += 4 ;
 for ( i = 0 ;
 i < num_names ;
 i ++ ) {
 if ( is_pmns_names_status ) {
 name_len = tvb_get_ntohl ( tvb , offset + 4 ) ;
 full_name_len = name_len + 8 ;
 }
 else {
 name_len = tvb_get_ntohl ( tvb , offset ) ;
 full_name_len = name_len + 4 ;
 }
 pcp_pmns_names_name_item = proto_tree_add_item ( pcp_pmns_names_tree , hf_pcp_pmns_names_nametree , tvb , offset , full_name_len , ENC_NA ) ;
 pcp_pmns_names_name_tree = proto_item_add_subtree ( pcp_pmns_names_name_item , ett_pcp ) ;
 if ( is_pmns_names_status ) {
 proto_tree_add_item ( pcp_pmns_names_name_tree , hf_pcp_pmns_names_nametree_status , tvb , offset , 4 , ENC_BIG_ENDIAN ) ;
 offset += 4 ;
 }
 proto_tree_add_item ( pcp_pmns_names_name_tree , hf_pcp_pmns_names_nametree_namelen , tvb , offset , 4 , ENC_BIG_ENDIAN ) ;
 offset += 4 ;
 if ( client_to_server ( pinfo ) ) {
 add_candidate_name_for_pmid_resolution ( pinfo , tvb , offset , name_len ) ;
 }
 proto_tree_add_item ( pcp_pmns_names_name_tree , hf_pcp_pmns_names_nametree_name , tvb , offset , name_len , ENC_ASCII | ENC_NA ) ;
 offset += name_len ;
 padding = name_len % 4 ;
 if ( padding != 0 ) {
 padding = 4 - padding ;
 proto_tree_add_item ( pcp_pmns_names_name_tree , hf_pcp_pdu_padding , tvb , offset , padding , ENC_NA ) ;
 offset += padding ;
 }
 }
 if ( client_to_server ( pinfo ) ) {
 mark_this_frame_as_last_pmns_names_frame ( pinfo ) ;
 }
 return offset ;
 }


static inline void RENAME(yuv2rgb32_1)(SwsContext *c, const uint16_t *buf0, const uint16_t *ubuf0, const uint16_t *ubuf1, const uint16_t *vbuf0, const uint16_t *vbuf1, const uint16_t *abuf0, uint8_t *dest, int dstW, int uvalpha, enum PixelFormat dstFormat, int flags, int y) { x86_reg uv_off = c->uv_off << 1; const uint16_t *buf1= buf0; //FIXME needed for RGB1/BGR1 if (uvalpha < 2048) { // note this is not correct (shifts chrominance by 0.5 pixels) but it is a bit faster if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) { __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2RGB1(%%REGBP, %5, %6) YSCALEYUV2RGB1_ALPHA(%%REGBP) WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (abuf0), "S" (ubuf0), "D" (ubuf1), "m" (dest), "a" (&c->redDither), "m"(uv_off) ); } else { __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2RGB1(%%REGBP, %5, %6) "pcmpeqd %%mm7, %%mm7 \n\t" WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), "a" (&c->redDither), "m"(uv_off) ); } } else { if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) { __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2RGB1b(%%REGBP, %5, %6) YSCALEYUV2RGB1_ALPHA(%%REGBP) WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (abuf0), "S" (ubuf0), "D" (ubuf1), "m" (dest), "a" (&c->redDither), "m"(uv_off) ); } else { __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2RGB1b(%%REGBP, %5, %6) "pcmpeqd %%mm7, %%mm7 \n\t" WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), "a" (&c->redDither), "m"(uv_off) ); } } }


REGRESSION_TEST ( SDK_API_TSIOBufferCreate ) ( RegressionTest * test , int , int * pstatus ) {
 bool test_passed = false ;
 * pstatus = REGRESSION_TEST_INPROGRESS ;
 int64_t watermark = 1000 ;
 TSIOBuffer bufp = TSIOBufferCreate ( ) ;
 TSIOBufferWaterMarkSet ( bufp , watermark ) ;
 watermark = TSIOBufferWaterMarkGet ( bufp ) ;
 if ( watermark == 1000 ) {
 SDK_RPRINT ( test , "TSIOBufferCreate" , "TestCase1" , TC_PASS , "ok" ) ;
 SDK_RPRINT ( test , "TSIOBufferWaterMarkGet" , "TestCase1" , TC_PASS , "ok" ) ;
 SDK_RPRINT ( test , "TSIOBufferWaterMarkSet" , "TestCase1" , TC_PASS , "ok" ) ;
 test_passed = true ;
 }
 else {
 SDK_RPRINT ( test , "TSIOBufferCreate" , "TestCase1" , TC_FAIL , "watermark failed" ) ;
 SDK_RPRINT ( test , "TSIOBufferWaterMarkGet" , "TestCase1" , TC_FAIL , "watermark failed" ) ;
 SDK_RPRINT ( test , "TSIOBufferWaterMarkSet" , "TestCase1" , TC_FAIL , "watermark failed" ) ;
 }
 TSIOBufferDestroy ( bufp ) ;
 * pstatus = ( ( test_passed == true ) ? REGRESSION_TEST_PASSED : REGRESSION_TEST_FAILED ) ;
 return ;
 }


void evdns_shutdown ( int fail_requests ) {
 struct nameserver * server , * server_next ;
 struct search_domain * dom , * dom_next ;
 while ( req_head ) {
 if ( fail_requests ) reply_callback ( req_head , 0 , DNS_ERR_SHUTDOWN , NULL ) ;
 request_finished ( req_head , & req_head ) ;
 }
 while ( req_waiting_head ) {
 if ( fail_requests ) reply_callback ( req_waiting_head , 0 , DNS_ERR_SHUTDOWN , NULL ) ;
 request_finished ( req_waiting_head , & req_waiting_head ) ;
 }
 global_requests_inflight = global_requests_waiting = 0 ;
 for ( server = server_head ;
 server ;
 server = server_next ) {
 server_next = server -> next ;
 if ( server -> socket >= 0 ) CLOSE_SOCKET ( server -> socket ) ;
 ( void ) event_del ( & server -> event ) ;
 if ( server -> state == 0 ) ( void ) event_del ( & server -> timeout_event ) ;
 free ( server ) ;
 if ( server_next == server_head ) break ;
 }
 server_head = NULL ;
 global_good_nameservers = 0 ;
 if ( global_search_state ) {
 for ( dom = global_search_state -> head ;
 dom ;
 dom = dom_next ) {
 dom_next = dom -> next ;
 free ( dom ) ;
 }
 free ( global_search_state ) ;
 global_search_state = NULL ;
 }
 evdns_log_fn = NULL ;
 }


enum message_cte message_decoder_parse_cte ( struct message_header_line * hdr ) {
 struct rfc822_parser_context parser ;
 enum message_cte message_cte ;
 string_t * value ;
 value = t_str_new ( 64 ) ;
 rfc822_parser_init ( & parser , hdr -> full_value , hdr -> full_value_len , NULL ) ;
 rfc822_skip_lwsp ( & parser ) ;
 ( void ) rfc822_parse_mime_token ( & parser , value ) ;
 message_cte = MESSAGE_CTE_UNKNOWN ;
 switch ( str_len ( value ) ) {
 case 4 : if ( i_memcasecmp ( str_data ( value ) , "7bit" , 4 ) == 0 || i_memcasecmp ( str_data ( value ) , "8bit" , 4 ) == 0 ) message_cte = MESSAGE_CTE_78BIT ;
 break ;
 case 6 : if ( i_memcasecmp ( str_data ( value ) , "base64" , 6 ) == 0 ) message_cte = MESSAGE_CTE_BASE64 ;
 else if ( i_memcasecmp ( str_data ( value ) , "binary" , 6 ) == 0 ) message_cte = MESSAGE_CTE_BINARY ;
 break ;
 case 16 : if ( i_memcasecmp ( str_data ( value ) , "quoted-printable" , 16 ) == 0 ) message_cte = MESSAGE_CTE_QP ;
 break ;
 }
 rfc822_parser_deinit ( & parser ) ;
 return message_cte ;
 }


jas_image_fmtinfo_t * jas_image_lookupfmtbyid ( int id ) {
 int i ;
 jas_image_fmtinfo_t * fmtinfo ;
 for ( i = 0 , fmtinfo = jas_image_fmtinfos ;
 i < jas_image_numfmts ;
 ++ i , ++ fmtinfo ) {
 if ( fmtinfo -> id == id ) {
 return fmtinfo ;
 }
 }
 return 0 ;
 }


static int dissect_type_bitmap_nxt ( proto_tree * rr_tree , tvbuff_t * tvb , int cur_offset , int rr_len ) {
 int mask ;
 int i , initial_offset , rr_type ;
 guint8 bits ;
 initial_offset = cur_offset ;
 rr_type = 0 ;
 while ( rr_len != 0 ) {
 bits = tvb_get_guint8 ( tvb , cur_offset ) ;
 mask = 1 << 7 ;
 for ( i = 0 ;
 i < 8 ;
 i ++ ) {
 if ( bits & mask ) {
 proto_tree_add_uint_format ( rr_tree , hf_dns_rr_type , tvb , cur_offset , 1 , rr_type , "RR type in bit map: %s" , val_to_str_ext ( rr_type , & dns_types_description_vals_ext , "Unknown (%d)" ) ) ;
 }
 mask >>= 1 ;
 rr_type ++ ;
 }
 cur_offset += 1 ;
 rr_len -= 1 ;
 }
 return ( initial_offset - cur_offset ) ;
 }


static int dpcm_decode_frame ( AVCodecContext * avctx , void * data , int * got_frame_ptr , AVPacket * avpkt ) {
 int buf_size = avpkt -> size ;
 DPCMContext * s = avctx -> priv_data ;
 AVFrame * frame = data ;
 int out = 0 , ret ;
 int predictor [ 2 ] ;
 int ch = 0 ;
 int stereo = avctx -> channels - 1 ;
 int16_t * output_samples , * samples_end ;
 GetByteContext gb ;
 if ( stereo && ( buf_size & 1 ) ) buf_size -- ;
 bytestream2_init ( & gb , avpkt -> data , buf_size ) ;
 switch ( avctx -> codec -> id ) {
 case AV_CODEC_ID_ROQ_DPCM : out = buf_size - 8 ;
 break ;
 case AV_CODEC_ID_INTERPLAY_DPCM : out = buf_size - 6 - avctx -> channels ;
 break ;
 case AV_CODEC_ID_XAN_DPCM : out = buf_size - 2 * avctx -> channels ;
 break ;
 case AV_CODEC_ID_SOL_DPCM : if ( avctx -> codec_tag != 3 ) out = buf_size * 2 ;
 else out = buf_size ;
 break ;
 }
 if ( out <= 0 ) {
 av_log ( avctx , AV_LOG_ERROR , "packet is too small\n" ) ;
 return AVERROR ( EINVAL ) ;
 }
 frame -> nb_samples = out / avctx -> channels ;
 if ( ( ret = ff_get_buffer ( avctx , frame , 0 ) ) < 0 ) {
 av_log ( avctx , AV_LOG_ERROR , "get_buffer() failed\n" ) ;
 return ret ;
 }
 output_samples = ( int16_t * ) frame -> data [ 0 ] ;
 samples_end = output_samples + out ;
 switch ( avctx -> codec -> id ) {
 case AV_CODEC_ID_ROQ_DPCM : bytestream2_skipu ( & gb , 6 ) ;
 if ( stereo ) {
 predictor [ 1 ] = sign_extend ( bytestream2_get_byteu ( & gb ) << 8 , 16 ) ;
 predictor [ 0 ] = sign_extend ( bytestream2_get_byteu ( & gb ) << 8 , 16 ) ;
 }
 else {
 predictor [ 0 ] = sign_extend ( bytestream2_get_le16u ( & gb ) , 16 ) ;
 }
 while ( output_samples < samples_end ) {
 predictor [ ch ] += s -> roq_square_array [ bytestream2_get_byteu ( & gb ) ] ;
 predictor [ ch ] = av_clip_int16 ( predictor [ ch ] ) ;
 * output_samples ++ = predictor [ ch ] ;
 ch ^= stereo ;
 }
 break ;
 case AV_CODEC_ID_INTERPLAY_DPCM : bytestream2_skipu ( & gb , 6 ) ;
 for ( ch = 0 ;
 ch < avctx -> channels ;
 ch ++ ) {
 predictor [ ch ] = sign_extend ( bytestream2_get_le16u ( & gb ) , 16 ) ;
 * output_samples ++ = predictor [ ch ] ;
 }
 ch = 0 ;
 while ( output_samples < samples_end ) {
 predictor [ ch ] += interplay_delta_table [ bytestream2_get_byteu ( & gb ) ] ;
 predictor [ ch ] = av_clip_int16 ( predictor [ ch ] ) ;
 * output_samples ++ = predictor [ ch ] ;
 ch ^= stereo ;
 }
 break ;
 case AV_CODEC_ID_XAN_DPCM : {
 int shift [ 2 ] = {
 4 , 4 }
 ;
 for ( ch = 0 ;
 ch < avctx -> channels ;
 ch ++ ) predictor [ ch ] = sign_extend ( bytestream2_get_le16u ( & gb ) , 16 ) ;
 ch = 0 ;
 while ( output_samples < samples_end ) {
 int diff = bytestream2_get_byteu ( & gb ) ;
 int n = diff & 3 ;
 if ( n == 3 ) shift [ ch ] ++ ;
 else shift [ ch ] -= ( 2 * n ) ;
 diff = sign_extend ( ( diff & ~ 3 ) << 8 , 16 ) ;
 if ( shift [ ch ] < 0 ) shift [ ch ] = 0 ;
 diff >>= shift [ ch ] ;
 predictor [ ch ] += diff ;
 predictor [ ch ] = av_clip_int16 ( predictor [ ch ] ) ;
 * output_samples ++ = predictor [ ch ] ;
 ch ^= stereo ;
 }
 break ;
 }
 case AV_CODEC_ID_SOL_DPCM : if ( avctx -> codec_tag != 3 ) {
 uint8_t * output_samples_u8 = frame -> data [ 0 ] , * samples_end_u8 = output_samples_u8 + out ;
 while ( output_samples_u8 < samples_end_u8 ) {
 int n = bytestream2_get_byteu ( & gb ) ;
 s -> sample [ 0 ] += s -> sol_table [ n >> 4 ] ;
 s -> sample [ 0 ] = av_clip_uint8 ( s -> sample [ 0 ] ) ;
 * output_samples_u8 ++ = s -> sample [ 0 ] ;
 s -> sample [ stereo ] += s -> sol_table [ n & 0x0F ] ;
 s -> sample [ stereo ] = av_clip_uint8 ( s -> sample [ stereo ] ) ;
 * output_samples_u8 ++ = s -> sample [ stereo ] ;
 }
 }
 else {
 while ( output_samples < samples_end ) {
 int n = bytestream2_get_byteu ( & gb ) ;
 if ( n & 0x80 ) s -> sample [ ch ] -= sol_table_16 [ n & 0x7F ] ;
 else s -> sample [ ch ] += sol_table_16 [ n & 0x7F ] ;
 s -> sample [ ch ] = av_clip_int16 ( s -> sample [ ch ] ) ;
 * output_samples ++ = s -> sample [ ch ] ;
 ch ^= stereo ;
 }
 }
 break ;
 }
 * got_frame_ptr = 1 ;
 return avpkt -> size ;
 }