bool check_routine_level_acl ( THD * thd , const char * db , const char * name , bool is_proc ) {
 bool no_routine_acl = 1 ;
 GRANT_NAME * grant_proc ;
 Security_context * sctx = thd -> security_ctx ;
 rw_rdlock ( & LOCK_grant ) ;
 if ( ( grant_proc = routine_hash_search ( sctx -> priv_host , sctx -> ip , db , sctx -> priv_user , name , is_proc , 0 ) ) ) no_routine_acl = ! ( grant_proc -> privs & SHOW_PROC_ACLS ) ;
 rw_unlock ( & LOCK_grant ) ;
 return no_routine_acl ;
 }


static av_cold int on2avc_decode_init(AVCodecContext *avctx) { On2AVCContext *c = avctx->priv_data; int i; c->avctx = avctx; avctx->sample_fmt = AV_SAMPLE_FMT_FLTP; avctx->channel_layout = (avctx->channels == 2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO; c->is_av500 = (avctx->codec_tag == 0x500); if (c->is_av500 && avctx->channels == 2) { av_log(avctx, AV_LOG_ERROR, "0x500 version should be mono\n"); return AVERROR_INVALIDDATA; if (avctx->channels == 2) av_log(avctx, AV_LOG_WARNING, "Stereo mode support is not good, patch is welcome\n"); for (i = 0; i < 20; i++) c->scale_tab[i] = ceil(pow(10.0, i * 0.1) * 16) / 32; for (; i < 128; i++) c->scale_tab[i] = ceil(pow(10.0, i * 0.1) * 0.5); if (avctx->sample_rate < 32000 || avctx->channels == 1) memcpy(c->long_win, ff_on2avc_window_long_24000, 1024 * sizeof(*c->long_win)); else memcpy(c->long_win, ff_on2avc_window_long_32000, 1024 * sizeof(*c->long_win)); memcpy(c->short_win, ff_on2avc_window_short, 128 * sizeof(*c->short_win)); c->modes = (avctx->sample_rate <= 40000) ? ff_on2avc_modes_40 : ff_on2avc_modes_44; c->wtf = (avctx->sample_rate <= 40000) ? wtf_40 : wtf_44; ff_mdct_init(&c->mdct, 11, 1, 1.0 / (32768.0 * 1024.0)); ff_mdct_init(&c->mdct_half, 10, 1, 1.0 / (32768.0 * 512.0)); ff_mdct_init(&c->mdct_small, 8, 1, 1.0 / (32768.0 * 128.0)); ff_fft_init(&c->fft128, 6, 0); ff_fft_init(&c->fft256, 7, 0); ff_fft_init(&c->fft512, 8, 1); ff_fft_init(&c->fft1024, 9, 1); avpriv_float_dsp_init(&c->fdsp, avctx->flags & CODEC_FLAG_BITEXACT); if (init_vlc(&c->scale_diff, 9, ON2AVC_SCALE_DIFFS, ff_on2avc_scale_diff_bits, 1, 1, ff_on2avc_scale_diff_codes, 4, 4, 0)) { av_log(avctx, AV_LOG_ERROR, "Cannot init VLC\n"); return AVERROR(ENOMEM); for (i = 1; i < 9; i++) { int idx = i - 1; if (ff_init_vlc_sparse(&c->cb_vlc[i], 9, ff_on2avc_quad_cb_elems[idx], ff_on2avc_quad_cb_bits[idx], 1, 1, ff_on2avc_quad_cb_codes[idx], 4, 4, ff_on2avc_quad_cb_syms[idx], 2, 2, 0)) { av_log(avctx, AV_LOG_ERROR, "Cannot init VLC\n"); on2avc_free_vlcs(c); return AVERROR(ENOMEM); for (i = 9; i < 16; i++) { int idx = i - 9; if (ff_init_vlc_sparse(&c->cb_vlc[i], 9, ff_on2avc_pair_cb_elems[idx], ff_on2avc_pair_cb_bits[idx], 1, 1, ff_on2avc_pair_cb_codes[idx], 2, 2, ff_on2avc_pair_cb_syms[idx], 2, 2, 0)) { av_log(avctx, AV_LOG_ERROR, "Cannot init VLC\n"); on2avc_free_vlcs(c); return AVERROR(ENOMEM); return 0;


TPMI_TDES_KEY_BITS_Unmarshal(TPMI_SM4_KEY_BITS *target, BYTE **buffer, INT32 *size)
{
    TPM_RC rc = TPM_RC_SUCCESS;

    if (rc == TPM_RC_SUCCESS) {
	rc = TPM_KEY_BITS_Unmarshal(target, buffer, size);
    }
    if (rc == TPM_RC_SUCCESS) {
	switch (*target) {
	  case 128:
	  case 192:
	    break;
	  default:
	    rc = TPM_RC_VALUE;
	}
    }
    return rc;
}


static int tipc_nl_compat_doit ( struct tipc_nl_compat_cmd_doit * cmd , struct tipc_nl_compat_msg * msg ) {
 int err ;
 if ( msg -> req_type && ! TLV_CHECK_TYPE ( msg -> req , msg -> req_type ) ) return - EINVAL ;
 err = __tipc_nl_compat_doit ( cmd , msg ) ;
 if ( err ) return err ;
 msg -> rep = tipc_tlv_alloc ( 0 ) ;
 if ( ! msg -> rep ) return - ENOMEM ;
 return 0 ;
 }


static int ram_find_and_save_block(RAMState *rs, bool last_stage) { PageSearchStatus pss; int pages = 0; bool again, found; ram_addr_t dirty_ram_abs; /* Address of the start of the dirty page in ram_addr_t space */ /* No dirty page as there is zero RAM */ if (!ram_bytes_total()) { return pages; } pss.block = rs->last_seen_block; pss.offset = rs->last_offset; pss.complete_round = false; if (!pss.block) { pss.block = QLIST_FIRST_RCU(&ram_list.blocks); } do { again = true; found = get_queued_page(rs, &pss, &dirty_ram_abs); if (!found) { /* priority queue empty, so just search for something dirty */ found = find_dirty_block(rs, &pss, &again, &dirty_ram_abs); } if (found) { pages = ram_save_host_page(rs, &pss, last_stage, dirty_ram_abs); } } while (!pages && again); rs->last_seen_block = pss.block; rs->last_offset = pss.offset; return pages; }


ikev1_cert_print(netdissect_options *ndo, u_char tpay _U_,
		 const struct isakmp_gen *ext, u_int item_len,
		 const u_char *ep _U_, uint32_t phase _U_,
		 uint32_t doi0 _U_,
		 uint32_t proto0 _U_, int depth _U_)
{
	const struct ikev1_pl_cert *p;
	struct ikev1_pl_cert cert;
	static const char *certstr[] = {
		"none",	"pkcs7", "pgp", "dns",
		"x509sign", "x509ke", "kerberos", "crl",
		"arl", "spki", "x509attr",
	};

	ND_PRINT((ndo,"%s:", NPSTR(ISAKMP_NPTYPE_CERT)));

	p = (const struct ikev1_pl_cert *)ext;
	ND_TCHECK(*p);
	UNALIGNED_MEMCPY(&cert, ext, sizeof(cert));
	ND_PRINT((ndo," len=%d", item_len - 4));
	ND_PRINT((ndo," type=%s", STR_OR_ID((cert.encode), certstr)));
	if (2 < ndo->ndo_vflag && 4 < item_len) {
		ND_PRINT((ndo," "));
		if (!rawprint(ndo, (const uint8_t *)(ext + 1), item_len - 4))
			goto trunc;
	}
	return (const u_char *)ext + item_len;
trunc:
	ND_PRINT((ndo," [|%s]", NPSTR(ISAKMP_NPTYPE_CERT)));
	return NULL;
}


static gcry_err_code_t sexp_data_to_mpi ( gcry_sexp_t input , gcry_mpi_t * ret_mpi , struct pk_encoding_ctx * ctx ) {
 gcry_err_code_t rc = 0 ;
 gcry_sexp_t ldata , lhash , lvalue ;
 int i ;
 size_t n ;
 const char * s ;
 int unknown_flag = 0 ;
 int parsed_flags = 0 ;
 int explicit_raw = 0 ;
 * ret_mpi = NULL ;
 ldata = gcry_sexp_find_token ( input , "data" , 0 ) ;
 if ( ! ldata ) {
 * ret_mpi = gcry_sexp_nth_mpi ( input , 0 , 0 ) ;
 return * ret_mpi ? GPG_ERR_NO_ERROR : GPG_ERR_INV_OBJ ;
 }
 {
 gcry_sexp_t lflags = gcry_sexp_find_token ( ldata , "flags" , 0 ) ;
 if ( lflags ) {
 for ( i = gcry_sexp_length ( lflags ) - 1 ;
 i > 0 ;
 i -- ) {
 s = gcry_sexp_nth_data ( lflags , i , & n ) ;
 if ( ! s ) ;
 else if ( n == 7 && ! memcmp ( s , "rfc6979" , 7 ) ) parsed_flags |= PUBKEY_FLAG_RFC6979 ;
 else if ( n == 5 && ! memcmp ( s , "eddsa" , 5 ) ) {
 ctx -> encoding = PUBKEY_ENC_RAW ;
 parsed_flags |= PUBKEY_FLAG_EDDSA ;
 }
 else if ( n == 3 && ! memcmp ( s , "raw" , 3 ) && ctx -> encoding == PUBKEY_ENC_UNKNOWN ) {
 ctx -> encoding = PUBKEY_ENC_RAW ;
 explicit_raw = 1 ;
 }
 else if ( n == 5 && ! memcmp ( s , "pkcs1" , 5 ) && ctx -> encoding == PUBKEY_ENC_UNKNOWN ) ctx -> encoding = PUBKEY_ENC_PKCS1 ;
 else if ( n == 4 && ! memcmp ( s , "oaep" , 4 ) && ctx -> encoding == PUBKEY_ENC_UNKNOWN ) ctx -> encoding = PUBKEY_ENC_OAEP ;
 else if ( n == 3 && ! memcmp ( s , "pss" , 3 ) && ctx -> encoding == PUBKEY_ENC_UNKNOWN ) ctx -> encoding = PUBKEY_ENC_PSS ;
 else if ( n == 11 && ! memcmp ( s , "no-blinding" , 11 ) ) parsed_flags |= PUBKEY_FLAG_NO_BLINDING ;
 else unknown_flag = 1 ;
 }
 gcry_sexp_release ( lflags ) ;
 }
 }
 if ( ctx -> encoding == PUBKEY_ENC_UNKNOWN ) ctx -> encoding = PUBKEY_ENC_RAW ;
 lhash = gcry_sexp_find_token ( ldata , "hash" , 0 ) ;
 lvalue = lhash ? NULL : gcry_sexp_find_token ( ldata , "value" , 0 ) ;
 if ( ! ( ! lhash ^ ! lvalue ) ) rc = GPG_ERR_INV_OBJ ;
 else if ( unknown_flag ) rc = GPG_ERR_INV_FLAG ;
 else if ( ctx -> encoding == PUBKEY_ENC_RAW && ( parsed_flags & PUBKEY_FLAG_EDDSA ) ) {
 gcry_sexp_t list ;
 void * value ;
 size_t valuelen ;
 if ( ! lvalue ) {
 rc = GPG_ERR_INV_OBJ ;
 goto leave ;
 }
 list = gcry_sexp_find_token ( ldata , "hash-algo" , 0 ) ;
 if ( list ) {
 s = gcry_sexp_nth_data ( list , 1 , & n ) ;
 if ( ! s ) rc = GPG_ERR_NO_OBJ ;
 else {
 ctx -> hash_algo = get_hash_algo ( s , n ) ;
 if ( ! ctx -> hash_algo ) rc = GPG_ERR_DIGEST_ALGO ;
 }
 gcry_sexp_release ( list ) ;
 }
 else rc = GPG_ERR_INV_OBJ ;
 if ( rc ) goto leave ;
 value = gcry_sexp_nth_buffer ( lvalue , 1 , & valuelen ) ;
 if ( ! value ) rc = GPG_ERR_INV_OBJ ;
 else if ( ( valuelen * 8 ) < valuelen ) {
 gcry_free ( value ) ;
 rc = GPG_ERR_TOO_LARGE ;
 }
 if ( rc ) goto leave ;
 * ret_mpi = gcry_mpi_set_opaque ( NULL , value , valuelen * 8 ) ;
 }
 else if ( ctx -> encoding == PUBKEY_ENC_RAW && lhash && ( explicit_raw || ( parsed_flags & PUBKEY_FLAG_RFC6979 ) ) ) {
 if ( gcry_sexp_length ( lhash ) != 3 ) rc = GPG_ERR_INV_OBJ ;
 else if ( ! ( s = gcry_sexp_nth_data ( lhash , 1 , & n ) ) || ! n ) rc = GPG_ERR_INV_OBJ ;
 else {
 void * value ;
 size_t valuelen ;
 ctx -> hash_algo = get_hash_algo ( s , n ) ;
 if ( ! ctx -> hash_algo ) rc = GPG_ERR_DIGEST_ALGO ;
 else if ( ! ( value = gcry_sexp_nth_buffer ( lhash , 2 , & valuelen ) ) ) rc = GPG_ERR_INV_OBJ ;
 else if ( ( valuelen * 8 ) < valuelen ) {
 gcry_free ( value ) ;
 rc = GPG_ERR_TOO_LARGE ;
 }
 else * ret_mpi = gcry_mpi_set_opaque ( NULL , value , valuelen * 8 ) ;
 }
 }
 else if ( ctx -> encoding == PUBKEY_ENC_RAW && lvalue ) {
 if ( parsed_flags & PUBKEY_FLAG_RFC6979 ) {
 rc = GPG_ERR_CONFLICT ;
 goto leave ;
 }
 * ret_mpi = gcry_sexp_nth_mpi ( lvalue , 1 , GCRYMPI_FMT_USG ) ;
 if ( ! * ret_mpi ) rc = GPG_ERR_INV_OBJ ;
 }
 else if ( ctx -> encoding == PUBKEY_ENC_PKCS1 && lvalue && ctx -> op == PUBKEY_OP_ENCRYPT ) {
 const void * value ;
 size_t valuelen ;
 gcry_sexp_t list ;
 void * random_override = NULL ;
 size_t random_override_len = 0 ;
 if ( ! ( value = gcry_sexp_nth_data ( lvalue , 1 , & valuelen ) ) || ! valuelen ) rc = GPG_ERR_INV_OBJ ;
 else {
 list = gcry_sexp_find_token ( ldata , "random-override" , 0 ) ;
 if ( list ) {
 s = gcry_sexp_nth_data ( list , 1 , & n ) ;
 if ( ! s ) rc = GPG_ERR_NO_OBJ ;
 else if ( n > 0 ) {
 random_override = gcry_malloc ( n ) ;
 if ( ! random_override ) rc = gpg_err_code_from_syserror ( ) ;
 else {
 memcpy ( random_override , s , n ) ;
 random_override_len = n ;
 }
 }
 gcry_sexp_release ( list ) ;
 if ( rc ) goto leave ;
 }
 rc = pkcs1_encode_for_encryption ( ret_mpi , ctx -> nbits , value , valuelen , random_override , random_override_len ) ;
 gcry_free ( random_override ) ;
 }
 }
 else if ( ctx -> encoding == PUBKEY_ENC_PKCS1 && lhash && ( ctx -> op == PUBKEY_OP_SIGN || ctx -> op == PUBKEY_OP_VERIFY ) ) {
 if ( gcry_sexp_length ( lhash ) != 3 ) rc = GPG_ERR_INV_OBJ ;
 else if ( ! ( s = gcry_sexp_nth_data ( lhash , 1 , & n ) ) || ! n ) rc = GPG_ERR_INV_OBJ ;
 else {
 const void * value ;
 size_t valuelen ;
 ctx -> hash_algo = get_hash_algo ( s , n ) ;
 if ( ! ctx -> hash_algo ) rc = GPG_ERR_DIGEST_ALGO ;
 else if ( ! ( value = gcry_sexp_nth_data ( lhash , 2 , & valuelen ) ) || ! valuelen ) rc = GPG_ERR_INV_OBJ ;
 else rc = pkcs1_encode_for_signature ( ret_mpi , ctx -> nbits , value , valuelen , ctx -> hash_algo ) ;
 }
 }
 else if ( ctx -> encoding == PUBKEY_ENC_OAEP && lvalue && ctx -> op == PUBKEY_OP_ENCRYPT ) {
 const void * value ;
 size_t valuelen ;
 if ( ! ( value = gcry_sexp_nth_data ( lvalue , 1 , & valuelen ) ) || ! valuelen ) rc = GPG_ERR_INV_OBJ ;
 else {
 gcry_sexp_t list ;
 void * random_override = NULL ;
 size_t random_override_len = 0 ;
 list = gcry_sexp_find_token ( ldata , "hash-algo" , 0 ) ;
 if ( list ) {
 s = gcry_sexp_nth_data ( list , 1 , & n ) ;
 if ( ! s ) rc = GPG_ERR_NO_OBJ ;
 else {
 ctx -> hash_algo = get_hash_algo ( s , n ) ;
 if ( ! ctx -> hash_algo ) rc = GPG_ERR_DIGEST_ALGO ;
 }
 gcry_sexp_release ( list ) ;
 if ( rc ) goto leave ;
 }
 list = gcry_sexp_find_token ( ldata , "label" , 0 ) ;
 if ( list ) {
 s = gcry_sexp_nth_data ( list , 1 , & n ) ;
 if ( ! s ) rc = GPG_ERR_NO_OBJ ;
 else if ( n > 0 ) {
 ctx -> label = gcry_malloc ( n ) ;
 if ( ! ctx -> label ) rc = gpg_err_code_from_syserror ( ) ;
 else {
 memcpy ( ctx -> label , s , n ) ;
 ctx -> labellen = n ;
 }
 }
 gcry_sexp_release ( list ) ;
 if ( rc ) goto leave ;
 }
 list = gcry_sexp_find_token ( ldata , "random-override" , 0 ) ;
 if ( list ) {
 s = gcry_sexp_nth_data ( list , 1 , & n ) ;
 if ( ! s ) rc = GPG_ERR_NO_OBJ ;
 else if ( n > 0 ) {
 random_override = gcry_malloc ( n ) ;
 if ( ! random_override ) rc = gpg_err_code_from_syserror ( ) ;
 else {
 memcpy ( random_override , s , n ) ;
 random_override_len = n ;
 }
 }
 gcry_sexp_release ( list ) ;
 if ( rc ) goto leave ;
 }
 rc = oaep_encode ( ret_mpi , ctx -> nbits , ctx -> hash_algo , value , valuelen , ctx -> label , ctx -> labellen , random_override , random_override_len ) ;
 gcry_free ( random_override ) ;
 }
 }
 else if ( ctx -> encoding == PUBKEY_ENC_PSS && lhash && ctx -> op == PUBKEY_OP_SIGN ) {
 if ( gcry_sexp_length ( lhash ) != 3 ) rc = GPG_ERR_INV_OBJ ;
 else if ( ! ( s = gcry_sexp_nth_data ( lhash , 1 , & n ) ) || ! n ) rc = GPG_ERR_INV_OBJ ;
 else {
 const void * value ;
 size_t valuelen ;
 void * random_override = NULL ;
 size_t random_override_len = 0 ;
 ctx -> hash_algo = get_hash_algo ( s , n ) ;
 if ( ! ctx -> hash_algo ) rc = GPG_ERR_DIGEST_ALGO ;
 else if ( ! ( value = gcry_sexp_nth_data ( lhash , 2 , & valuelen ) ) || ! valuelen ) rc = GPG_ERR_INV_OBJ ;
 else {
 gcry_sexp_t list ;
 list = gcry_sexp_find_token ( ldata , "salt-length" , 0 ) ;
 if ( list ) {
 s = gcry_sexp_nth_data ( list , 1 , & n ) ;
 if ( ! s ) {
 rc = GPG_ERR_NO_OBJ ;
 goto leave ;
 }
 ctx -> saltlen = ( unsigned int ) strtoul ( s , NULL , 10 ) ;
 gcry_sexp_release ( list ) ;
 }
 list = gcry_sexp_find_token ( ldata , "random-override" , 0 ) ;
 if ( list ) {
 s = gcry_sexp_nth_data ( list , 1 , & n ) ;
 if ( ! s ) rc = GPG_ERR_NO_OBJ ;
 else if ( n > 0 ) {
 random_override = gcry_malloc ( n ) ;
 if ( ! random_override ) rc = gpg_err_code_from_syserror ( ) ;
 else {
 memcpy ( random_override , s , n ) ;
 random_override_len = n ;
 }
 }
 gcry_sexp_release ( list ) ;
 if ( rc ) goto leave ;
 }
 rc = pss_encode ( ret_mpi , ctx -> nbits - 1 , ctx -> hash_algo , value , valuelen , ctx -> saltlen , random_override , random_override_len ) ;
 gcry_free ( random_override ) ;
 }
 }
 }
 else if ( ctx -> encoding == PUBKEY_ENC_PSS && lhash && ctx -> op == PUBKEY_OP_VERIFY ) {
 if ( gcry_sexp_length ( lhash ) != 3 ) rc = GPG_ERR_INV_OBJ ;
 else if ( ! ( s = gcry_sexp_nth_data ( lhash , 1 , & n ) ) || ! n ) rc = GPG_ERR_INV_OBJ ;
 else {
 ctx -> hash_algo = get_hash_algo ( s , n ) ;
 if ( ! ctx -> hash_algo ) rc = GPG_ERR_DIGEST_ALGO ;
 else {
 * ret_mpi = gcry_sexp_nth_mpi ( lhash , 2 , GCRYMPI_FMT_USG ) ;
 if ( ! * ret_mpi ) rc = GPG_ERR_INV_OBJ ;
 ctx -> verify_cmp = pss_verify_cmp ;
 ctx -> verify_arg = * ret_mpi ;
 }
 }
 }
 else rc = GPG_ERR_CONFLICT ;
 leave : gcry_sexp_release ( ldata ) ;
 gcry_sexp_release ( lhash ) ;
 gcry_sexp_release ( lvalue ) ;
 if ( ! rc ) ctx -> flags = parsed_flags ;
 else {
 gcry_free ( ctx -> label ) ;
 ctx -> label = NULL ;
 }
 return rc ;
 }


void ff_tls_init(void) { avpriv_lock_avformat(); #if CONFIG_OPENSSL if (!openssl_init) { SSL_library_init(); SSL_load_error_strings(); #if HAVE_THREADS if (!CRYPTO_get_locking_callback()) { int i; openssl_mutexes = av_malloc_array(sizeof(pthread_mutex_t), CRYPTO_num_locks()); for (i = 0; i < CRYPTO_num_locks(); i++) pthread_mutex_init(&openssl_mutexes[i], NULL); CRYPTO_set_locking_callback(openssl_lock); #if !defined(WIN32) && OPENSSL_VERSION_NUMBER < 0x10000000 CRYPTO_set_id_callback(openssl_thread_id); #endif } #endif } openssl_init++; #endif #if CONFIG_GNUTLS #if HAVE_THREADS && GNUTLS_VERSION_NUMBER < 0x020b00 if (gcry_control(GCRYCTL_ANY_INITIALIZATION_P) == 0) gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); #endif gnutls_global_init(); #endif avpriv_unlock_avformat(); }


MagickBooleanType SyncExifProfile(Image *image,StringInfo *profile)
{
#define MaxDirectoryStack  16
#define EXIF_DELIMITER  "\n"
#define EXIF_NUM_FORMATS  12
#define TAG_EXIF_OFFSET  0x8769
#define TAG_INTEROP_OFFSET  0xa005

  typedef struct _DirectoryInfo
  {
    unsigned char
      *directory;

    size_t
      entry;
  } DirectoryInfo;

  DirectoryInfo
    directory_stack[MaxDirectoryStack];

  EndianType
    endian;

  size_t
    entry,
    length,
    number_entries;

  ssize_t
    id,
    level,
    offset;

  static int
    format_bytes[] = {0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8};

  unsigned char
    *directory,
    *exif;

  /*
    Set EXIF resolution tag.
  */
  length=GetStringInfoLength(profile);
  exif=GetStringInfoDatum(profile);
  if (length < 16)
    return(MagickFalse);
  id=(ssize_t) ReadProfileShort(LSBEndian,exif);
  if ((id != 0x4949) && (id != 0x4D4D))
    {
      while (length != 0)
      {
        if (ReadProfileByte(&exif,&length) != 0x45)
          continue;
        if (ReadProfileByte(&exif,&length) != 0x78)
          continue;
        if (ReadProfileByte(&exif,&length) != 0x69)
          continue;
        if (ReadProfileByte(&exif,&length) != 0x66)
          continue;
        if (ReadProfileByte(&exif,&length) != 0x00)
          continue;
        if (ReadProfileByte(&exif,&length) != 0x00)
          continue;
        break;
      }
      if (length < 16)
        return(MagickFalse);
      id=(ssize_t) ReadProfileShort(LSBEndian,exif);
    }
  endian=LSBEndian;
  if (id == 0x4949)
    endian=LSBEndian;
  else
    if (id == 0x4D4D)
      endian=MSBEndian;
    else
      return(MagickFalse);
  if (ReadProfileShort(endian,exif+2) != 0x002a)
    return(MagickFalse);
  /*
    This the offset to the first IFD.
  */
  offset=(ssize_t) ReadProfileLong(endian,exif+4);
  if ((offset < 0) || (size_t) offset >= length)
    return(MagickFalse);
  directory=exif+offset;
  level=0;
  entry=0;
  do
  {
    if (level > 0)
      {
        level--;
        directory=directory_stack[level].directory;
        entry=directory_stack[level].entry;
      }
    if ((directory < exif) || (directory > (exif+length-2)))
      break;
    /*
      Determine how many entries there are in the current IFD.
    */
    number_entries=ReadProfileShort(endian,directory);
    for ( ; entry < number_entries; entry++)
    {
      int
        components;

      register unsigned char
        *p,
        *q;

      size_t
        number_bytes;

      ssize_t
        format,
        tag_value;

      q=(unsigned char *) (directory+2+(12*entry));
      if (q > (exif+length-12))
        break;  /* corrupt EXIF */
      tag_value=(ssize_t) ReadProfileShort(endian,q);
      format=(ssize_t) ReadProfileShort(endian,q+2);
      if ((format < 0) || ((format-1) >= EXIF_NUM_FORMATS))
        break;
      components=(ssize_t) ReadProfileLong(endian,q+4);
      if (components < 0)
        break;  /* corrupt EXIF */
      number_bytes=(size_t) components*format_bytes[format];
      if ((ssize_t) number_bytes < components)
        break;  /* prevent overflow */
      if (number_bytes <= 4)
        p=q+8;
      else
        {
          /*
            The directory entry contains an offset.
          */
          offset=(ssize_t)  ReadProfileLong(endian,q+8);
          if ((size_t) (offset+number_bytes) > length)
            continue;
          if (~length < number_bytes)
            continue;  /* prevent overflow */
          p=(unsigned char *) (exif+offset);
        }
      switch (tag_value)
      {
        case 0x011a:
        {
          (void) WriteProfileLong(endian,(size_t) (image->resolution.x+0.5),p);
          (void) WriteProfileLong(endian,1UL,p+4);
          break;
        }
        case 0x011b:
        {
          (void) WriteProfileLong(endian,(size_t) (image->resolution.y+0.5),p);
          (void) WriteProfileLong(endian,1UL,p+4);
          break;
        }
        case 0x0112:
        {
          if (number_bytes == 4)
            {
              (void) WriteProfileLong(endian,(size_t) image->orientation,p);
              break;
            }
          (void) WriteProfileShort(endian,(unsigned short) image->orientation,
            p);
          break;
        }
        case 0x0128:
        {
          if (number_bytes == 4)
            {
              (void) WriteProfileLong(endian,(size_t) (image->units+1),p);
              break;
            }
          (void) WriteProfileShort(endian,(unsigned short) (image->units+1),p);
          break;
        }
        default:
          break;
      }
      if ((tag_value == TAG_EXIF_OFFSET) || (tag_value == TAG_INTEROP_OFFSET))
        {
          offset=(ssize_t)  ReadProfileLong(endian,p);
          if (((size_t) offset < length) && (level < (MaxDirectoryStack-2)))
            {
              directory_stack[level].directory=directory;
              entry++;
              directory_stack[level].entry=entry;
              level++;
              directory_stack[level].directory=exif+offset;
              directory_stack[level].entry=0;
              level++;
              if ((directory+2+(12*number_entries)) > (exif+length))
                break;
              offset=(ssize_t)  ReadProfileLong(endian,directory+2+(12*
                number_entries));
              if ((offset != 0) && ((size_t) offset < length) &&
                  (level < (MaxDirectoryStack-2)))
                {
                  directory_stack[level].directory=exif+offset;
                  directory_stack[level].entry=0;
                  level++;
                }
            }
          break;
        }
    }
  } while (level > 0);
  return(MagickTrue);
}


static void nlm_register_unmatched_msg ( packet_info * pinfo , tvbuff_t * tvb , int offset ) {
 nlm_msg_res_unmatched_data * umd ;
 nlm_msg_res_unmatched_data * old_umd ;
 umd = ( nlm_msg_res_unmatched_data * ) g_malloc ( sizeof ( nlm_msg_res_unmatched_data ) ) ;
 umd -> req_frame = pinfo -> fd -> num ;
 umd -> ns = pinfo -> fd -> abs_ts ;
 umd -> cookie_len = tvb_get_ntohl ( tvb , offset ) ;
 umd -> cookie = ( const guint8 * ) tvb_memdup ( NULL , tvb , offset + 4 , umd -> cookie_len ) ;
 old_umd = ( nlm_msg_res_unmatched_data * ) g_hash_table_lookup ( nlm_msg_res_unmatched , ( gconstpointer ) umd ) ;
 if ( old_umd ) {
 g_hash_table_remove ( nlm_msg_res_unmatched , ( gconstpointer ) old_umd ) ;
 }
 g_hash_table_insert ( nlm_msg_res_unmatched , ( gpointer ) umd , ( gpointer ) umd ) ;
 }


static struct net_device *_init_airo_card( unsigned short irq, int port,
					   int is_pcmcia, struct pci_dev *pci,
					   struct device *dmdev )
{
	struct net_device *dev;
	struct airo_info *ai;
	int i, rc;
	CapabilityRid cap_rid;

	/* Create the network device object. */
	dev = alloc_netdev(sizeof(*ai), "", ether_setup);
	if (!dev) {
		airo_print_err("", "Couldn't alloc_etherdev");
		return NULL;
	}

	ai = dev->ml_priv = netdev_priv(dev);
	ai->wifidev = NULL;
	ai->flags = 1 << FLAG_RADIO_DOWN;
	ai->jobs = 0;
	ai->dev = dev;
	if (pci && (pci->device == 0x5000 || pci->device == 0xa504)) {
		airo_print_dbg("", "Found an MPI350 card");
		set_bit(FLAG_MPI, &ai->flags);
	}
	spin_lock_init(&ai->aux_lock);
	sema_init(&ai->sem, 1);
	ai->config.len = 0;
	ai->pci = pci;
	init_waitqueue_head (&ai->thr_wait);
	ai->tfm = NULL;
	add_airo_dev(ai);

	if (airo_networks_allocate (ai))
		goto err_out_free;
	airo_networks_initialize (ai);

	skb_queue_head_init (&ai->txq);

	/* The Airo-specific entries in the device structure. */
	if (test_bit(FLAG_MPI,&ai->flags))
		dev->netdev_ops = &mpi_netdev_ops;
	else
		dev->netdev_ops = &airo_netdev_ops;
	dev->wireless_handlers = &airo_handler_def;
	ai->wireless_data.spy_data = &ai->spy_data;
	dev->wireless_data = &ai->wireless_data;
	dev->irq = irq;
	dev->base_addr = port;

	SET_NETDEV_DEV(dev, dmdev);

	reset_card (dev, 1);
	msleep(400);

	if (!is_pcmcia) {
		if (!request_region(dev->base_addr, 64, DRV_NAME)) {
			rc = -EBUSY;
			airo_print_err(dev->name, "Couldn't request region");
			goto err_out_nets;
		}
	}

	if (test_bit(FLAG_MPI,&ai->flags)) {
		if (mpi_map_card(ai, pci)) {
			airo_print_err("", "Could not map memory");
			goto err_out_res;
		}
	}

	if (probe) {
		if (setup_card(ai, dev->dev_addr, 1) != SUCCESS) {
			airo_print_err(dev->name, "MAC could not be enabled" );
			rc = -EIO;
			goto err_out_map;
		}
	} else if (!test_bit(FLAG_MPI,&ai->flags)) {
		ai->bap_read = fast_bap_read;
		set_bit(FLAG_FLASHING, &ai->flags);
	}

	strcpy(dev->name, "eth%d");
	rc = register_netdev(dev);
	if (rc) {
		airo_print_err(dev->name, "Couldn't register_netdev");
		goto err_out_map;
	}
	ai->wifidev = init_wifidev(ai, dev);
	if (!ai->wifidev)
		goto err_out_reg;

	rc = readCapabilityRid(ai, &cap_rid, 1);
	if (rc != SUCCESS) {
		rc = -EIO;
		goto err_out_wifi;
	}
	/* WEP capability discovery */
	ai->wep_capable = (cap_rid.softCap & cpu_to_le16(0x02)) ? 1 : 0;
	ai->max_wep_idx = (cap_rid.softCap & cpu_to_le16(0x80)) ? 3 : 0;

	airo_print_info(dev->name, "Firmware version %x.%x.%02d",
	                ((le16_to_cpu(cap_rid.softVer) >> 8) & 0xF),
	                (le16_to_cpu(cap_rid.softVer) & 0xFF),
	                le16_to_cpu(cap_rid.softSubVer));

	/* Test for WPA support */
	/* Only firmware versions 5.30.17 or better can do WPA */
	if (le16_to_cpu(cap_rid.softVer) > 0x530
	 || (le16_to_cpu(cap_rid.softVer) == 0x530
	      && le16_to_cpu(cap_rid.softSubVer) >= 17)) {
		airo_print_info(ai->dev->name, "WPA supported.");

		set_bit(FLAG_WPA_CAPABLE, &ai->flags);
		ai->bssListFirst = RID_WPA_BSSLISTFIRST;
		ai->bssListNext = RID_WPA_BSSLISTNEXT;
		ai->bssListRidLen = sizeof(BSSListRid);
	} else {
		airo_print_info(ai->dev->name, "WPA unsupported with firmware "
			"versions older than 5.30.17.");

		ai->bssListFirst = RID_BSSLISTFIRST;
		ai->bssListNext = RID_BSSLISTNEXT;
		ai->bssListRidLen = sizeof(BSSListRid) - sizeof(BSSListRidExtra);
	}

	set_bit(FLAG_REGISTERED,&ai->flags);
	airo_print_info(dev->name, "MAC enabled %pM", dev->dev_addr);

	/* Allocate the transmit buffers */
	if (probe && !test_bit(FLAG_MPI,&ai->flags))
		for( i = 0; i < MAX_FIDS; i++ )
			ai->fids[i] = transmit_allocate(ai,AIRO_DEF_MTU,i>=MAX_FIDS/2);

	if (setup_proc_entry(dev, dev->ml_priv) < 0)
		goto err_out_wifi;

	return dev;

err_out_wifi:
	unregister_netdev(ai->wifidev);
	free_netdev(ai->wifidev);
err_out_reg:
	unregister_netdev(dev);
err_out_map:
	if (test_bit(FLAG_MPI,&ai->flags) && pci) {
		pci_free_consistent(pci, PCI_SHARED_LEN, ai->shared, ai->shared_dma);
		iounmap(ai->pciaux);
		iounmap(ai->pcimem);
		mpi_unmap_card(ai->pci);
	}
err_out_res:
	if (!is_pcmcia)
	        release_region( dev->base_addr, 64 );
err_out_nets:
	airo_networks_free(ai);
err_out_free:
	del_airo_dev(ai);
	free_netdev(dev);
	return NULL;
}


SplinePointList * SplinesFromEntityChar ( EntityChar * ec , int * flags , int is_stroked ) {
 Entity * ent , * next ;
 SplinePointList * head = NULL , * last , * new , * nlast , * temp , * each , * transed ;
 StrokeInfo si ;
 real inversetrans [ 6 ] ;
 int handle_eraser = false ;
 int ask = false ;
 EntityDefaultStrokeFill ( ec -> splines ) ;
 if ( ! is_stroked ) {
 if ( * flags == - 1 ) {
 for ( ent = ec -> splines ;
 ent != NULL ;
 ent = ent -> next ) {
 if ( ent -> type == et_splines && ( ent -> u . splines . fill . col == 0xffffff || ( ent -> u . splines . stroke_width != 0 && ent -> u . splines . stroke . col != 0xffffffff ) ) ) {
 ask = true ;
 break ;
 }
 }
 if ( ask ) * flags = PsStrokeFlagsDlg ( ) ;
 }
 if ( * flags & sf_correctdir ) EntityCharCorrectDir ( ec ) ;
 handle_eraser = * flags != - 1 && ( * flags & sf_handle_eraser ) ;
 if ( handle_eraser ) ec -> splines = EntityReverse ( ec -> splines ) ;
 }
 for ( ent = ec -> splines ;
 ent != NULL ;
 ent = next ) {
 next = ent -> next ;
 if ( ent -> type == et_splines && is_stroked ) {
 if ( head == NULL ) head = ent -> u . splines . splines ;
 else last -> next = ent -> u . splines . splines ;
 if ( ent -> u . splines . splines != NULL ) for ( last = ent -> u . splines . splines ;
 last -> next != NULL ;
 last = last -> next ) ;
 ent -> u . splines . splines = NULL ;
 }
 else if ( ent -> type == et_splines ) {
 if ( ent -> u . splines . stroke . col != 0xffffffff && ( ent -> u . splines . fill . col == 0xffffffff || ent -> u . splines . stroke_width != 0 ) ) {
 memset ( & si , '\0' , sizeof ( si ) ) ;
 si . join = ent -> u . splines . join ;
 si . cap = ent -> u . splines . cap ;
 si . radius = ent -> u . splines . stroke_width / 2 ;
 if ( ent -> u . splines . stroke_width == WIDTH_INHERITED ) si . radius = .5 ;
 if ( si . cap == lc_inherited ) si . cap = lc_butt ;
 if ( si . join == lj_inherited ) si . join = lj_miter ;
 new = NULL ;
 MatInverse ( inversetrans , ent -> u . splines . transform ) ;
 transed = SplinePointListTransform ( SplinePointListCopy ( ent -> u . splines . splines ) , inversetrans , tpt_AllPoints ) ;
 for ( each = transed ;
 each != NULL ;
 each = each -> next ) {
 temp = SplineSetStroke ( each , & si , false ) ;
 if ( new == NULL ) new = temp ;
 else nlast -> next = temp ;
 if ( temp != NULL ) for ( nlast = temp ;
 nlast -> next != NULL ;
 nlast = nlast -> next ) ;
 }
 new = SplinePointListTransform ( new , ent -> u . splines . transform , tpt_AllPoints ) ;
 SplinePointListsFree ( transed ) ;
 if ( handle_eraser && ent -> u . splines . stroke . col == 0xffffff ) {
 head = EraseStroke ( ec -> sc , head , new ) ;
 last = head ;
 if ( last != NULL ) for ( ;
 last -> next != NULL ;
 last = last -> next ) ;
 }
 else {
 if ( head == NULL ) head = new ;
 else last -> next = new ;
 if ( new != NULL ) for ( last = new ;
 last -> next != NULL ;
 last = last -> next ) ;
 }
 }
 if ( ent -> u . splines . fill . col == 0xffffffff && ent -> u . splines . stroke . col != 0xffffffff ) SplinePointListsFree ( ent -> u . splines . splines ) ;
 else if ( handle_eraser && ent -> u . splines . fill . col == 0xffffff ) {
 head = EraseStroke ( ec -> sc , head , ent -> u . splines . splines ) ;
 last = head ;
 if ( last != NULL ) for ( ;
 last -> next != NULL ;
 last = last -> next ) ;
 }
 else {
 new = ent -> u . splines . splines ;
 if ( head == NULL ) head = new ;
 else last -> next = new ;
 if ( new != NULL ) for ( last = new ;
 last -> next != NULL ;
 last = last -> next ) ;
 }
 }
 SplinePointListsFree ( ent -> clippath ) ;
 free ( ent ) ;
 }
 return ( head ) ;
 }


int ar6000_create_ap_interface(struct ar6_softc *ar, char *ap_ifname)
{
    struct net_device *dev;
    struct ar_virtual_interface *arApDev;

    dev = alloc_etherdev(sizeof(struct ar_virtual_interface));
    if (dev == NULL) {
        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_create_ap_interface: can't alloc etherdev\n"));
        return A_ERROR;
    }

    ether_setup(dev);
    init_netdev(dev, ap_ifname);

    if (register_netdev(dev)) {
        AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("ar6000_create_ap_interface: register_netdev failed\n"));
        return A_ERROR;
    }

    arApDev = netdev_priv(dev);
    arApDev->arDev = ar;
    arApDev->arNetDev = dev;
    arApDev->arStaNetDev = ar->arNetDev;

    ar->arApDev = arApDev;
    arApNetDev = dev;

    /* Copy the MAC address */
    memcpy(dev->dev_addr, ar->arNetDev->dev_addr, AR6000_ETH_ADDR_LEN);

    return 0;
}


const QEMUSizedBuffer *qemu_buf_get(QEMUFile *f) { QEMUBuffer *p; qemu_fflush(f); p = f->opaque; return p->qsb; }


static uint32_t virtio_pci_config_readl ( void * opaque , uint32_t addr ) {
 VirtIOPCIProxy * proxy = opaque ;
 uint32_t config = VIRTIO_PCI_CONFIG ( & proxy -> pci_dev ) ;
 addr -= proxy -> addr ;
 if ( addr < config ) return virtio_ioport_read ( proxy , addr ) ;
 addr -= config ;
 return virtio_config_readl ( proxy -> vdev , addr ) ;
 }


static int mov_read_stsd(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; MOVStreamContext *sc; int ret; if (c->fc->nb_streams < 1) return 0; st = c->fc->streams[c->fc->nb_streams - 1]; sc = st->priv_data; avio_r8(pb); /* version */ avio_rb24(pb); /* flags */ sc->stsd_count = avio_rb32(pb); /* entries */ /* Prepare space for hosting multiple extradata. */ sc->extradata = av_mallocz_array(sc->stsd_count, sizeof(*sc->extradata)); if (!sc->extradata) return AVERROR(ENOMEM); sc->extradata_size = av_mallocz_array(sc->stsd_count, sizeof(*sc->extradata_size)); if (!sc->extradata_size) return AVERROR(ENOMEM); ret = ff_mov_read_stsd_entries(c, pb, sc->stsd_count); if (ret < 0) return ret; /* Restore back the primary extradata. */ av_freep(&st->codecpar->extradata); st->codecpar->extradata_size = sc->extradata_size[0]; if (sc->extradata_size[0]) { st->codecpar->extradata = av_mallocz(sc->extradata_size[0] + AV_INPUT_BUFFER_PADDING_SIZE); if (!st->codecpar->extradata) return AVERROR(ENOMEM); memcpy(st->codecpar->extradata, sc->extradata[0], sc->extradata_size[0]); } return 0; }


smb_send_rqst(struct TCP_Server_Info *server, struct smb_rqst *rqst)
{
	int rc;
	struct kvec *iov = rqst->rq_iov;
	int n_vec = rqst->rq_nvec;
	unsigned int smb_buf_length = get_rfc1002_length(iov[0].iov_base);
	unsigned int i;
	size_t total_len = 0, sent;
	struct socket *ssocket = server->ssocket;
	int val = 1;

	cFYI(1, "Sending smb: smb_len=%u", smb_buf_length);
	dump_smb(iov[0].iov_base, iov[0].iov_len);

	/* cork the socket */
	kernel_setsockopt(ssocket, SOL_TCP, TCP_CORK,
				(char *)&val, sizeof(val));

	rc = smb_send_kvec(server, iov, n_vec, &sent);
	if (rc < 0)
		goto uncork;

	total_len += sent;

	/* now walk the page array and send each page in it */
	for (i = 0; i < rqst->rq_npages; i++) {
		struct kvec p_iov;

		cifs_rqst_page_to_kvec(rqst, i, &p_iov);
		rc = smb_send_kvec(server, &p_iov, 1, &sent);
		kunmap(rqst->rq_pages[i]);
		if (rc < 0)
			break;

		total_len += sent;
	}

uncork:
	/* uncork it */
	val = 0;
	kernel_setsockopt(ssocket, SOL_TCP, TCP_CORK,
				(char *)&val, sizeof(val));

	if ((total_len > 0) && (total_len != smb_buf_length + 4)) {
		cFYI(1, "partial send (wanted=%u sent=%zu): terminating "
			"session", smb_buf_length + 4, total_len);
		/*
		 * If we have only sent part of an SMB then the next SMB could
		 * be taken as the remainder of this one. We need to kill the
		 * socket so the server throws away the partial SMB
		 */
		server->tcpStatus = CifsNeedReconnect;
	}

	if (rc < 0 && rc != -EINTR)
		cERROR(1, "Error %d sending data on socket to server", rc);
	else
		rc = 0;

	return rc;
}


find_abbrev_list_by_abbrev_offset (dwarf_vma abbrev_base,
				   dwarf_vma abbrev_offset)
{
  abbrev_list * list;

  for (list = abbrev_lists; list != NULL; list = list->next)
    if (list->abbrev_base == abbrev_base
	&& list->abbrev_offset == abbrev_offset)
      return list;

  return NULL;
}


static int mov_write_stbl_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track) { int64_t pos = avio_tell(pb); int ret; avio_wb32(pb, 0); /* size */ ffio_wfourcc(pb, "stbl"); mov_write_stsd_tag(s, pb, mov, track); mov_write_stts_tag(pb, track); if ((track->par->codec_type == AVMEDIA_TYPE_VIDEO || track->par->codec_tag == MKTAG('r','t','p',' ')) && track->has_keyframes && track->has_keyframes < track->entry) mov_write_stss_tag(pb, track, MOV_SYNC_SAMPLE); if (track->mode == MODE_MOV && track->flags & MOV_TRACK_STPS) mov_write_stss_tag(pb, track, MOV_PARTIAL_SYNC_SAMPLE); if (track->par->codec_type == AVMEDIA_TYPE_VIDEO && track->flags & MOV_TRACK_CTTS && track->entry) { if ((ret = mov_write_ctts_tag(pb, track)) < 0) return ret; } mov_write_stsc_tag(pb, track); mov_write_stsz_tag(pb, track); mov_write_stco_tag(pb, track); if (mov->encryption_scheme == MOV_ENC_CENC_AES_CTR) { ff_mov_cenc_write_stbl_atoms(&track->cenc, pb); } if (track->par->codec_id == AV_CODEC_ID_OPUS) { mov_preroll_write_stbl_atoms(pb, track); } return update_size(pb, pos); }


ssize_t qemu_sendv_packet(VLANClientState *vc1, const struct iovec *iov, int iovcnt) { VLANState *vlan = vc1->vlan; VLANClientState *vc; ssize_t max_len = 0; if (vc1->link_down) return calc_iov_length(iov, iovcnt); for (vc = vlan->first_client; vc != NULL; vc = vc->next) { ssize_t len = 0; if (vc == vc1) continue; if (vc->link_down) len = calc_iov_length(iov, iovcnt); else if (vc->fd_readv) len = vc->fd_readv(vc->opaque, iov, iovcnt); else if (vc->fd_read) len = vc_sendv_compat(vc, iov, iovcnt); max_len = MAX(max_len, len); } return max_len; }


static void qio_channel_websock_handshake_send_res_ok ( QIOChannelWebsock * ioc , const char * key , Error * * errp ) {
 char combined_key [ QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN + QIO_CHANNEL_WEBSOCK_GUID_LEN + 1 ] ;
 char * accept = NULL ;
 char * date = qio_channel_websock_date_str ( ) ;
 g_strlcpy ( combined_key , key , QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN + 1 ) ;
 g_strlcat ( combined_key , QIO_CHANNEL_WEBSOCK_GUID , QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN + QIO_CHANNEL_WEBSOCK_GUID_LEN + 1 ) ;
 if ( qcrypto_hash_base64 ( QCRYPTO_HASH_ALG_SHA1 , combined_key , QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN + QIO_CHANNEL_WEBSOCK_GUID_LEN , & accept , errp ) < 0 ) {
 qio_channel_websock_handshake_send_res_err ( ioc , QIO_CHANNEL_WEBSOCK_HANDSHAKE_RES_SERVER_ERR ) ;
 return ;
 }
 qio_channel_websock_handshake_send_res ( ioc , QIO_CHANNEL_WEBSOCK_HANDSHAKE_RES_OK , date , accept ) ;
 g_free ( date ) ;
 g_free ( accept ) ;
 }


static void U_CALLCONV strprepProfileLineFn ( void * context , char * fields [ ] [ 2 ] , int32_t fieldCount , UErrorCode * pErrorCode ) {
 uint32_t mapping [ 40 ] ;
 char * end , * map ;
 uint32_t code ;
 int32_t length ;
 const char * typeName ;
 uint32_t rangeStart = 0 , rangeEnd = 0 ;
 const char * filename = ( const char * ) context ;
 const char * s ;
 s = u_skipWhitespace ( fields [ 0 ] [ 0 ] ) ;
 if ( * s == '@' ) {
 s ++ ;
 length = fields [ 0 ] [ 1 ] - s ;
 if ( length >= NORMALIZE_DIRECTIVE_LEN && uprv_strncmp ( s , NORMALIZE_DIRECTIVE , NORMALIZE_DIRECTIVE_LEN ) == 0 ) {
 options [ NORMALIZE ] . doesOccur = TRUE ;
 return ;
 }
 else if ( length >= CHECK_BIDI_DIRECTIVE_LEN && uprv_strncmp ( s , CHECK_BIDI_DIRECTIVE , CHECK_BIDI_DIRECTIVE_LEN ) == 0 ) {
 options [ CHECK_BIDI ] . doesOccur = TRUE ;
 return ;
 }
 else {
 fprintf ( stderr , "gensprep error parsing a directive %s." , fields [ 0 ] [ 0 ] ) ;
 }
 }
 typeName = fields [ 2 ] [ 0 ] ;
 map = fields [ 1 ] [ 0 ] ;
 if ( uprv_strstr ( typeName , usprepTypeNames [ USPREP_UNASSIGNED ] ) != NULL ) {
 u_parseCodePointRange ( s , & rangeStart , & rangeEnd , pErrorCode ) ;
 if ( U_FAILURE ( * pErrorCode ) ) {
 fprintf ( stderr , "Could not parse code point range. Error: %s\n" , u_errorName ( * pErrorCode ) ) ;
 return ;
 }
 storeRange ( rangeStart , rangeEnd , USPREP_UNASSIGNED , pErrorCode ) ;
 }
 else if ( uprv_strstr ( typeName , usprepTypeNames [ USPREP_PROHIBITED ] ) != NULL ) {
 u_parseCodePointRange ( s , & rangeStart , & rangeEnd , pErrorCode ) ;
 if ( U_FAILURE ( * pErrorCode ) ) {
 fprintf ( stderr , "Could not parse code point range. Error: %s\n" , u_errorName ( * pErrorCode ) ) ;
 return ;
 }
 storeRange ( rangeStart , rangeEnd , USPREP_PROHIBITED , pErrorCode ) ;
 }
 else if ( uprv_strstr ( typeName , usprepTypeNames [ USPREP_MAP ] ) != NULL ) {
 code = ( uint32_t ) uprv_strtoul ( s , & end , 16 ) ;
 if ( end <= s || end != fields [ 0 ] [ 1 ] ) {
 fprintf ( stderr , "gensprep: syntax error in field 0 at %s\n" , fields [ 0 ] [ 0 ] ) ;
 * pErrorCode = U_PARSE_ERROR ;
 exit ( U_PARSE_ERROR ) ;
 }
 length = u_parseCodePoints ( map , mapping , sizeof ( mapping ) / 4 , pErrorCode ) ;
 storeMapping ( code , mapping , length , USPREP_MAP , pErrorCode ) ;
 }
 else {
 * pErrorCode = U_INVALID_FORMAT_ERROR ;
 }
 if ( U_FAILURE ( * pErrorCode ) ) {
 fprintf ( stderr , "gensprep error parsing %s line %s at %s. Error: %s\n" , filename , fields [ 0 ] [ 0 ] , fields [ 2 ] [ 0 ] , u_errorName ( * pErrorCode ) ) ;
 exit ( * pErrorCode ) ;
 }
 }


static PyObject * string_isspace ( PyStringObject * self ) {
 register const unsigned char * p = ( unsigned char * ) PyString_AS_STRING ( self ) ;
 register const unsigned char * e ;
 if ( PyString_GET_SIZE ( self ) == 1 && isspace ( * p ) ) return PyBool_FromLong ( 1 ) ;
 if ( PyString_GET_SIZE ( self ) == 0 ) return PyBool_FromLong ( 0 ) ;
 e = p + PyString_GET_SIZE ( self ) ;
 for ( ;
 p < e ;
 p ++ ) {
 if ( ! isspace ( * p ) ) return PyBool_FromLong ( 0 ) ;
 }
 return PyBool_FromLong ( 1 ) ;
 }


static void pxa2xx_fir_save ( QEMUFile * f , void * opaque ) {
 PXA2xxFIrState * s = ( PXA2xxFIrState * ) opaque ;
 int i ;
 qemu_put_be32 ( f , s -> enable ) ;
 qemu_put_8s ( f , & s -> control [ 0 ] ) ;
 qemu_put_8s ( f , & s -> control [ 1 ] ) ;
 qemu_put_8s ( f , & s -> control [ 2 ] ) ;
 qemu_put_8s ( f , & s -> status [ 0 ] ) ;
 qemu_put_8s ( f , & s -> status [ 1 ] ) ;
 qemu_put_byte ( f , s -> rx_len ) ;
 for ( i = 0 ;
 i < s -> rx_len ;
 i ++ ) qemu_put_byte ( f , s -> rx_fifo [ ( s -> rx_start + i ) & 63 ] ) ;
 }


int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt, int has_alpha) { const PixFmtInfo *pf, *ps; int loss; ps = &pix_fmt_info[src_pix_fmt]; pf = &pix_fmt_info[dst_pix_fmt]; /* compute loss */ loss = 0; pf = &pix_fmt_info[dst_pix_fmt]; if (pf->depth < ps->depth) loss |= FF_LOSS_DEPTH; if (pf->x_chroma_shift >= ps->x_chroma_shift || pf->y_chroma_shift >= ps->y_chroma_shift) loss |= FF_LOSS_RESOLUTION; switch(pf->color_type) { case FF_COLOR_RGB: if (ps->color_type != FF_COLOR_RGB && ps->color_type != FF_COLOR_GRAY) loss |= FF_LOSS_COLORSPACE; break; case FF_COLOR_GRAY: if (ps->color_type != FF_COLOR_GRAY) loss |= FF_LOSS_COLORSPACE; break; case FF_COLOR_YUV: if (ps->color_type != FF_COLOR_YUV) loss |= FF_LOSS_COLORSPACE; break; case FF_COLOR_YUV_JPEG: if (ps->color_type != FF_COLOR_YUV_JPEG && ps->color_type != FF_COLOR_YUV) loss |= FF_LOSS_COLORSPACE; break; default: /* fail safe test */ if (ps->color_type != pf->color_type) loss |= FF_LOSS_COLORSPACE; break; } if (pf->color_type == FF_COLOR_GRAY && ps->color_type != FF_COLOR_GRAY) loss |= FF_LOSS_CHROMA; if (!pf->is_alpha && (ps->is_alpha && has_alpha)) loss |= FF_LOSS_ALPHA; if (pf->is_paletted && (!ps->is_paletted && ps->color_type != FF_COLOR_GRAY)) loss |= FF_LOSS_COLORQUANT; return loss; }


static guint8 * get_value ( packet_info * pinfo , guint32 handle , bluetooth_data_t * bluetooth_data , guint * length ) {
 wmem_tree_key_t key [ 4 ] ;
 guint32 frame_number ;
 fragment_data_t * fragment_data ;
 wmem_tree_t * sub_wmemtree ;
 guint last_offset = G_MAXUINT ;
 guint size ;
 gboolean first = TRUE ;
 guint8 * data = NULL ;
 frame_number = pinfo -> num ;
 key [ 0 ] . length = 1 ;
 key [ 0 ] . key = & bluetooth_data -> interface_id ;
 key [ 1 ] . length = 1 ;
 key [ 1 ] . key = & bluetooth_data -> adapter_id ;
 key [ 2 ] . length = 1 ;
 key [ 2 ] . key = & handle ;
 key [ 3 ] . length = 0 ;
 key [ 3 ] . key = NULL ;
 sub_wmemtree = ( wmem_tree_t * ) wmem_tree_lookup32_array ( fragments , key ) ;
 while ( 1 ) {
 fragment_data = ( sub_wmemtree ) ? ( fragment_data_t * ) wmem_tree_lookup32_le ( sub_wmemtree , frame_number ) : NULL ;
 if ( ! fragment_data || ( fragment_data && fragment_data -> offset >= last_offset ) ) break ;
 if ( first ) {
 size = fragment_data -> offset + fragment_data -> length ;
 data = ( guint8 * ) wmem_alloc ( pinfo -> pool , size ) ;
 if ( length ) * length = size ;
 first = FALSE ;
 }
 else if ( fragment_data -> offset + fragment_data -> length != last_offset ) {
 break ;
 }
 memcpy ( data + fragment_data -> offset , fragment_data -> data , fragment_data -> length ) ;
 if ( fragment_data -> offset == 0 ) return data ;
 frame_number = fragment_data -> data_in_frame - 1 ;
 last_offset = fragment_data -> offset ;
 }
 if ( length ) * length = 0 ;
 return NULL ;
 }


parser_post_processing (parser_context_t *context_p) /**< context */
{
  uint16_t literal_one_byte_limit;
  uint16_t ident_end;
  uint16_t const_literal_end;
  parser_mem_page_t *page_p;
  parser_mem_page_t *last_page_p;
  size_t last_position;
  size_t offset;
  size_t length;
  size_t literal_length;
  size_t total_size;
  uint8_t real_offset;
  uint8_t *byte_code_p;
  bool needs_uint16_arguments;
  cbc_opcode_t last_opcode = CBC_EXT_OPCODE;
  ecma_compiled_code_t *compiled_code_p;
  ecma_value_t *literal_pool_p;
  uint8_t *dst_p;

#if JERRY_ESNEXT
  if ((context_p->status_flags & (PARSER_IS_FUNCTION | PARSER_LEXICAL_BLOCK_NEEDED))
      == (PARSER_IS_FUNCTION | PARSER_LEXICAL_BLOCK_NEEDED))
  {
    PARSER_MINUS_EQUAL_U16 (context_p->stack_depth, PARSER_BLOCK_CONTEXT_STACK_ALLOCATION);
#ifndef JERRY_NDEBUG
    PARSER_MINUS_EQUAL_U16 (context_p->context_stack_depth, PARSER_BLOCK_CONTEXT_STACK_ALLOCATION);
#endif /* !JERRY_NDEBUG */

    context_p->status_flags &= (uint32_t) ~PARSER_LEXICAL_BLOCK_NEEDED;

    parser_emit_cbc (context_p, CBC_CONTEXT_END);

    parser_branch_t branch;
    parser_stack_pop (context_p, &branch, sizeof (parser_branch_t));
    parser_set_branch_to_current_position (context_p, &branch);

    JERRY_ASSERT (!(context_p->status_flags & PARSER_NO_END_LABEL));
  }

  if (PARSER_IS_NORMAL_ASYNC_FUNCTION (context_p->status_flags))
  {
    PARSER_MINUS_EQUAL_U16 (context_p->stack_depth, PARSER_TRY_CONTEXT_STACK_ALLOCATION);
#ifndef JERRY_NDEBUG
    PARSER_MINUS_EQUAL_U16 (context_p->context_stack_depth, PARSER_TRY_CONTEXT_STACK_ALLOCATION);
#endif /* !JERRY_NDEBUG */

    if (context_p->stack_limit < PARSER_FINALLY_CONTEXT_STACK_ALLOCATION)
    {
      context_p->stack_limit = PARSER_FINALLY_CONTEXT_STACK_ALLOCATION;
    }

    parser_branch_t branch;

    parser_stack_pop (context_p, &branch, sizeof (parser_branch_t));
    parser_set_branch_to_current_position (context_p, &branch);

    JERRY_ASSERT (!(context_p->status_flags & PARSER_NO_END_LABEL));
  }
#endif /* JERRY_ESNEXT */

#if JERRY_LINE_INFO
  JERRY_ASSERT (context_p->line_info_p != NULL);
#endif /* JERRY_LINE_INFO */

  JERRY_ASSERT (context_p->stack_depth == 0);
#ifndef JERRY_NDEBUG
  JERRY_ASSERT (context_p->context_stack_depth == 0);
#endif /* !JERRY_NDEBUG */

  if ((size_t) context_p->stack_limit + (size_t) context_p->register_count > PARSER_MAXIMUM_STACK_LIMIT)
  {
    parser_raise_error (context_p, PARSER_ERR_STACK_LIMIT_REACHED);
  }

  if (JERRY_UNLIKELY (context_p->script_p->refs_and_type >= CBC_SCRIPT_REF_MAX))
  {
    /* This is probably never happens in practice. */
    jerry_fatal (ERR_REF_COUNT_LIMIT);
  }

  context_p->script_p->refs_and_type += CBC_SCRIPT_REF_ONE;

  JERRY_ASSERT (context_p->literal_count <= PARSER_MAXIMUM_NUMBER_OF_LITERALS);

#if JERRY_DEBUGGER
  if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
      && !(context_p->status_flags & PARSER_DEBUGGER_BREAKPOINT_APPENDED))
  {
    /* Always provide at least one breakpoint. */
    parser_emit_cbc (context_p, CBC_BREAKPOINT_DISABLED);
    parser_flush_cbc (context_p);

    parser_append_breakpoint_info (context_p, JERRY_DEBUGGER_BREAKPOINT_LIST, context_p->token.line);

    context_p->last_breakpoint_line = context_p->token.line;
  }

  if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
      && context_p->breakpoint_info_count > 0)
  {
    parser_send_breakpoints (context_p, JERRY_DEBUGGER_BREAKPOINT_LIST);
    JERRY_ASSERT (context_p->breakpoint_info_count == 0);
  }
#endif /* JERRY_DEBUGGER */

  parser_compute_indicies (context_p, &ident_end, &const_literal_end);

  if (context_p->literal_count <= CBC_MAXIMUM_SMALL_VALUE)
  {
    literal_one_byte_limit = CBC_MAXIMUM_BYTE_VALUE - 1;
  }
  else
  {
    literal_one_byte_limit = CBC_LOWER_SEVEN_BIT_MASK;
  }

  last_page_p = context_p->byte_code.last_p;
  last_position = context_p->byte_code.last_position;

  if (last_position >= PARSER_CBC_STREAM_PAGE_SIZE)
  {
    last_page_p = NULL;
    last_position = 0;
  }

  page_p = context_p->byte_code.first_p;
  offset = 0;
  length = 0;

  while (page_p != last_page_p || offset < last_position)
  {
    uint8_t *opcode_p;
    uint8_t flags;
    size_t branch_offset_length;

    opcode_p = page_p->bytes + offset;
    last_opcode = (cbc_opcode_t) (*opcode_p);
    PARSER_NEXT_BYTE (page_p, offset);
    branch_offset_length = CBC_BRANCH_OFFSET_LENGTH (last_opcode);
    flags = cbc_flags[last_opcode];
    length++;

    switch (last_opcode)
    {
      case CBC_EXT_OPCODE:
      {
        cbc_ext_opcode_t ext_opcode;

        ext_opcode = (cbc_ext_opcode_t) page_p->bytes[offset];
        branch_offset_length = CBC_BRANCH_OFFSET_LENGTH (ext_opcode);
        flags = cbc_ext_flags[ext_opcode];
        PARSER_NEXT_BYTE (page_p, offset);
        length++;
        break;
      }
      case CBC_POST_DECR:
      {
        *opcode_p = CBC_PRE_DECR;
        break;
      }
      case CBC_POST_INCR:
      {
        *opcode_p = CBC_PRE_INCR;
        break;
      }
      case CBC_POST_DECR_IDENT:
      {
        *opcode_p = CBC_PRE_DECR_IDENT;
        break;
      }
      case CBC_POST_INCR_IDENT:
      {
        *opcode_p = CBC_PRE_INCR_IDENT;
        break;
      }
      default:
      {
        break;
      }
    }

    while (flags & (CBC_HAS_LITERAL_ARG | CBC_HAS_LITERAL_ARG2))
    {
      uint8_t *first_byte = page_p->bytes + offset;
      uint32_t literal_index = *first_byte;

      PARSER_NEXT_BYTE (page_p, offset);
      length++;

      literal_index |= ((uint32_t) page_p->bytes[offset]) << 8;

      if (literal_index >= PARSER_REGISTER_START)
      {
        literal_index -= PARSER_REGISTER_START;
      }
      else
      {
        literal_index = (PARSER_GET_LITERAL (literal_index))->prop.index;
      }

      if (literal_index <= literal_one_byte_limit)
      {
        *first_byte = (uint8_t) literal_index;
      }
      else
      {
        if (context_p->literal_count <= CBC_MAXIMUM_SMALL_VALUE)
        {
          JERRY_ASSERT (literal_index <= CBC_MAXIMUM_SMALL_VALUE);
          *first_byte = CBC_MAXIMUM_BYTE_VALUE;
          page_p->bytes[offset] = (uint8_t) (literal_index - CBC_MAXIMUM_BYTE_VALUE);
          length++;
        }
        else
        {
          JERRY_ASSERT (literal_index <= CBC_MAXIMUM_FULL_VALUE);
          *first_byte = (uint8_t) ((literal_index >> 8) | CBC_HIGHEST_BIT_MASK);
          page_p->bytes[offset] = (uint8_t) (literal_index & 0xff);
          length++;
        }
      }
      PARSER_NEXT_BYTE (page_p, offset);

      if (flags & CBC_HAS_LITERAL_ARG2)
      {
        if (flags & CBC_HAS_LITERAL_ARG)
        {
          flags = CBC_HAS_LITERAL_ARG;
        }
        else
        {
          flags = CBC_HAS_LITERAL_ARG | CBC_HAS_LITERAL_ARG2;
        }
      }
      else
      {
        break;
      }
    }

    if (flags & CBC_HAS_BYTE_ARG)
    {
      /* This argument will be copied without modification. */
      PARSER_NEXT_BYTE (page_p, offset);
      length++;
    }

    if (flags & CBC_HAS_BRANCH_ARG)
    {
      bool prefix_zero = true;

      /* The leading zeroes are dropped from the stream.
       * Although dropping these zeroes for backward
       * branches are unnecessary, we use the same
       * code path for simplicity. */
      JERRY_ASSERT (branch_offset_length > 0 && branch_offset_length <= 3);

      while (--branch_offset_length > 0)
      {
        uint8_t byte = page_p->bytes[offset];
        if (byte > 0 || !prefix_zero)
        {
          prefix_zero = false;
          length++;
        }
        else
        {
          JERRY_ASSERT (CBC_BRANCH_IS_FORWARD (flags));
        }
        PARSER_NEXT_BYTE (page_p, offset);
      }

      if (last_opcode == (cbc_opcode_t) (CBC_JUMP_FORWARD + PARSER_MAX_BRANCH_LENGTH - 1)
          && prefix_zero
          && page_p->bytes[offset] == PARSER_MAX_BRANCH_LENGTH + 1)
      {
        /* Uncoditional jumps which jump right after the instruction
         * are effectively NOPs. These jumps are removed from the
         * stream. The 1 byte long CBC_JUMP_FORWARD form marks these
         * instructions, since this form is constructed during post
         * processing and cannot be emitted directly. */
        *opcode_p = CBC_JUMP_FORWARD;
        length--;
      }
      else
      {
        /* Other last bytes are always copied. */
        length++;
      }

      PARSER_NEXT_BYTE (page_p, offset);
    }
  }

  if (!(context_p->status_flags & PARSER_NO_END_LABEL)
      || !(PARSER_OPCODE_IS_RETURN (last_opcode)))
  {
    context_p->status_flags &= (uint32_t) ~PARSER_NO_END_LABEL;

#if JERRY_ESNEXT
    if (PARSER_IS_NORMAL_ASYNC_FUNCTION (context_p->status_flags))
    {
      length++;
    }
#endif /* JERRY_ESNEXT */

    length++;
  }

  needs_uint16_arguments = false;
  total_size = sizeof (cbc_uint8_arguments_t);

  if (context_p->stack_limit > CBC_MAXIMUM_BYTE_VALUE
      || context_p->register_count > CBC_MAXIMUM_BYTE_VALUE
      || context_p->literal_count > CBC_MAXIMUM_BYTE_VALUE)
  {
    needs_uint16_arguments = true;
    total_size = sizeof (cbc_uint16_arguments_t);
  }

  literal_length = (size_t) (context_p->literal_count - context_p->register_count) * sizeof (ecma_value_t);

  total_size += literal_length + length;

  if (PARSER_NEEDS_MAPPED_ARGUMENTS (context_p->status_flags))
  {
    total_size += context_p->argument_count * sizeof (ecma_value_t);
  }

#if JERRY_ESNEXT
  /* function.name */
  if (!(context_p->status_flags & PARSER_CLASS_CONSTRUCTOR))
  {
    total_size += sizeof (ecma_value_t);
  }

  if (context_p->argument_length != UINT16_MAX)
  {
    total_size += sizeof (ecma_value_t);
  }

  if (context_p->tagged_template_literal_cp != JMEM_CP_NULL)
  {
    total_size += sizeof (ecma_value_t);
  }
#endif /* JERRY_ESNEXT */

#if JERRY_LINE_INFO
  total_size += sizeof (ecma_value_t);
#endif /* JERRY_LINE_INFO */

  total_size = JERRY_ALIGNUP (total_size, JMEM_ALIGNMENT);

  compiled_code_p = (ecma_compiled_code_t *) parser_malloc (context_p, total_size);

#if JERRY_SNAPSHOT_SAVE || JERRY_PARSER_DUMP_BYTE_CODE
  // Avoid getting junk bytes
  memset (compiled_code_p, 0, total_size);
#endif /* JERRY_SNAPSHOT_SAVE || JERRY_PARSER_DUMP_BYTE_CODE */

#if JERRY_MEM_STATS
  jmem_stats_allocate_byte_code_bytes (total_size);
#endif /* JERRY_MEM_STATS */

  byte_code_p = (uint8_t *) compiled_code_p;
  compiled_code_p->size = (uint16_t) (total_size >> JMEM_ALIGNMENT_LOG);
  compiled_code_p->refs = 1;
  compiled_code_p->status_flags = 0;

#if JERRY_ESNEXT
  if (context_p->status_flags & PARSER_FUNCTION_HAS_REST_PARAM)
  {
    JERRY_ASSERT (context_p->argument_count > 0);
    context_p->argument_count--;
  }
#endif /* JERRY_ESNEXT */

  if (needs_uint16_arguments)
  {
    cbc_uint16_arguments_t *args_p = (cbc_uint16_arguments_t *) compiled_code_p;

    args_p->stack_limit = context_p->stack_limit;
    args_p->script_value = context_p->script_value;
    args_p->argument_end = context_p->argument_count;
    args_p->register_end = context_p->register_count;
    args_p->ident_end = ident_end;
    args_p->const_literal_end = const_literal_end;
    args_p->literal_end = context_p->literal_count;

    compiled_code_p->status_flags |= CBC_CODE_FLAGS_UINT16_ARGUMENTS;
    byte_code_p += sizeof (cbc_uint16_arguments_t);
  }
  else
  {
    cbc_uint8_arguments_t *args_p = (cbc_uint8_arguments_t *) compiled_code_p;

    args_p->stack_limit = (uint8_t) context_p->stack_limit;
    args_p->argument_end = (uint8_t) context_p->argument_count;
    args_p->script_value = context_p->script_value;
    args_p->register_end = (uint8_t) context_p->register_count;
    args_p->ident_end = (uint8_t) ident_end;
    args_p->const_literal_end = (uint8_t) const_literal_end;
    args_p->literal_end = (uint8_t) context_p->literal_count;

    byte_code_p += sizeof (cbc_uint8_arguments_t);
  }

  uint16_t encoding_limit;
  uint16_t encoding_delta;

  if (context_p->literal_count > CBC_MAXIMUM_SMALL_VALUE)
  {
    compiled_code_p->status_flags |= CBC_CODE_FLAGS_FULL_LITERAL_ENCODING;
    encoding_limit = CBC_FULL_LITERAL_ENCODING_LIMIT;
    encoding_delta = CBC_FULL_LITERAL_ENCODING_DELTA;
  }
  else
  {
    encoding_limit = CBC_SMALL_LITERAL_ENCODING_LIMIT;
    encoding_delta = CBC_SMALL_LITERAL_ENCODING_DELTA;
  }

  if (context_p->status_flags & PARSER_IS_STRICT)
  {
    compiled_code_p->status_flags |= CBC_CODE_FLAGS_STRICT_MODE;
  }

  if ((context_p->status_flags & PARSER_ARGUMENTS_NEEDED)
      && PARSER_NEEDS_MAPPED_ARGUMENTS (context_p->status_flags))
  {
    compiled_code_p->status_flags |= CBC_CODE_FLAGS_MAPPED_ARGUMENTS_NEEDED;
  }

  if (!(context_p->status_flags & PARSER_LEXICAL_ENV_NEEDED))
  {
    compiled_code_p->status_flags |= CBC_CODE_FLAGS_LEXICAL_ENV_NOT_NEEDED;
  }

  uint16_t function_type = CBC_FUNCTION_TO_TYPE_BITS (CBC_FUNCTION_NORMAL);

  if (context_p->status_flags & (PARSER_IS_PROPERTY_GETTER | PARSER_IS_PROPERTY_SETTER))
  {
    function_type = CBC_FUNCTION_TO_TYPE_BITS (CBC_FUNCTION_ACCESSOR);
  }
  else if (!(context_p->status_flags & PARSER_IS_FUNCTION))
  {
    function_type = CBC_FUNCTION_TO_TYPE_BITS (CBC_FUNCTION_SCRIPT);
  }
#if JERRY_ESNEXT
  else if (context_p->status_flags & PARSER_IS_ARROW_FUNCTION)
  {
    if (context_p->status_flags & PARSER_IS_ASYNC_FUNCTION)
    {
      function_type = CBC_FUNCTION_TO_TYPE_BITS (CBC_FUNCTION_ASYNC_ARROW);
    }
    else
    {
      function_type = CBC_FUNCTION_TO_TYPE_BITS (CBC_FUNCTION_ARROW);
    }
  }
  else if (context_p->status_flags & PARSER_IS_GENERATOR_FUNCTION)
  {
    if (context_p->status_flags & PARSER_IS_ASYNC_FUNCTION)
    {
      function_type = CBC_FUNCTION_TO_TYPE_BITS (CBC_FUNCTION_ASYNC_GENERATOR);
    }
    else
    {
      function_type = CBC_FUNCTION_TO_TYPE_BITS (CBC_FUNCTION_GENERATOR);
    }
  }
  else if (context_p->status_flags & PARSER_IS_ASYNC_FUNCTION)
  {
    function_type = CBC_FUNCTION_TO_TYPE_BITS (CBC_FUNCTION_ASYNC);
  }
  else if (context_p->status_flags & PARSER_CLASS_CONSTRUCTOR)
  {
    function_type = CBC_FUNCTION_TO_TYPE_BITS (CBC_FUNCTION_CONSTRUCTOR);
  }
  else if (context_p->status_flags & PARSER_IS_METHOD)
  {
    function_type = CBC_FUNCTION_TO_TYPE_BITS (CBC_FUNCTION_METHOD);
  }

  if (context_p->status_flags & PARSER_LEXICAL_BLOCK_NEEDED)
  {
    JERRY_ASSERT (!(context_p->status_flags & PARSER_IS_FUNCTION));
    compiled_code_p->status_flags |= CBC_CODE_FLAGS_LEXICAL_BLOCK_NEEDED;
  }
#endif /* JERRY_ESNEXT */

  compiled_code_p->status_flags |= function_type;

#if JERRY_LINE_INFO
  compiled_code_p->status_flags |= CBC_CODE_FLAGS_HAS_LINE_INFO;
#endif /* JERRY_LINE_INFO */

  literal_pool_p = ((ecma_value_t *) byte_code_p) - context_p->register_count;
  byte_code_p += literal_length;
  dst_p = byte_code_p;

  parser_init_literal_pool (context_p, literal_pool_p);

  page_p = context_p->byte_code.first_p;
  offset = 0;
  real_offset = 0;
  uint8_t last_register_index = (uint8_t) JERRY_MIN (context_p->register_count,
                                                     (PARSER_MAXIMUM_NUMBER_OF_REGISTERS - 1));

  while (page_p != last_page_p || offset < last_position)
  {
    uint8_t flags;
    uint8_t *opcode_p;
    uint8_t *branch_mark_p;
    cbc_opcode_t opcode;
    size_t branch_offset_length;

    opcode_p = dst_p;
    branch_mark_p = page_p->bytes + offset;
    opcode = (cbc_opcode_t) (*branch_mark_p);
    branch_offset_length = CBC_BRANCH_OFFSET_LENGTH (opcode);

    if (opcode == CBC_JUMP_FORWARD)
    {
      /* These opcodes are deleted from the stream. */
      size_t counter = PARSER_MAX_BRANCH_LENGTH + 1;

      do
      {
        PARSER_NEXT_BYTE_UPDATE (page_p, offset, real_offset);
      }
      while (--counter > 0);

      continue;
    }

    /* Storing the opcode */
    *dst_p++ = (uint8_t) opcode;
    real_offset++;
    PARSER_NEXT_BYTE_UPDATE (page_p, offset, real_offset);
    flags = cbc_flags[opcode];

#if JERRY_DEBUGGER
    if (opcode == CBC_BREAKPOINT_DISABLED)
    {
      uint32_t bp_offset = (uint32_t) (((uint8_t *) dst_p) - ((uint8_t *) compiled_code_p) - 1);
      parser_append_breakpoint_info (context_p, JERRY_DEBUGGER_BREAKPOINT_OFFSET_LIST, bp_offset);
    }
#endif /* JERRY_DEBUGGER */

    if (opcode == CBC_EXT_OPCODE)
    {
      cbc_ext_opcode_t ext_opcode;

      ext_opcode = (cbc_ext_opcode_t) page_p->bytes[offset];
      flags = cbc_ext_flags[ext_opcode];
      branch_offset_length = CBC_BRANCH_OFFSET_LENGTH (ext_opcode);

      /* Storing the extended opcode */
      *dst_p++ = (uint8_t) ext_opcode;
      opcode_p++;
      real_offset++;
      PARSER_NEXT_BYTE_UPDATE (page_p, offset, real_offset);
    }

    /* Only literal and call arguments can be combined. */
    JERRY_ASSERT (!(flags & CBC_HAS_BRANCH_ARG)
                   || !(flags & (CBC_HAS_BYTE_ARG | CBC_HAS_LITERAL_ARG)));

    while (flags & (CBC_HAS_LITERAL_ARG | CBC_HAS_LITERAL_ARG2))
    {
      uint16_t first_byte = page_p->bytes[offset];

      uint8_t *opcode_pos_p = dst_p - 1;
      *dst_p++ = (uint8_t) first_byte;
      real_offset++;
      PARSER_NEXT_BYTE_UPDATE (page_p, offset, real_offset);

      if (first_byte > literal_one_byte_limit)
      {
        *dst_p++ = page_p->bytes[offset];

        if (first_byte >= encoding_limit)
        {
          first_byte = (uint16_t) (((first_byte << 8) | dst_p[-1]) - encoding_delta);
        }
        real_offset++;
      }
      PARSER_NEXT_BYTE_UPDATE (page_p, offset, real_offset);

      if (flags & CBC_HAS_LITERAL_ARG2)
      {
        if (flags & CBC_HAS_LITERAL_ARG)
        {
          flags = CBC_HAS_LITERAL_ARG;
        }
        else
        {
          flags = CBC_HAS_LITERAL_ARG | CBC_HAS_LITERAL_ARG2;
        }
      }
      else
      {
        if (opcode == CBC_ASSIGN_SET_IDENT && JERRY_LIKELY (first_byte < last_register_index))
        {
          *opcode_pos_p = CBC_MOV_IDENT;
        }

        break;
      }
    }

    if (flags & CBC_HAS_BYTE_ARG)
    {
      /* This argument will be copied without modification. */
      *dst_p++ = page_p->bytes[offset];
      real_offset++;
      PARSER_NEXT_BYTE_UPDATE (page_p, offset, real_offset);
      continue;
    }

    if (flags & CBC_HAS_BRANCH_ARG)
    {
      *branch_mark_p |= CBC_HIGHEST_BIT_MASK;
      bool prefix_zero = true;

      /* The leading zeroes are dropped from the stream. */
      JERRY_ASSERT (branch_offset_length > 0 && branch_offset_length <= 3);

      while (--branch_offset_length > 0)
      {
        uint8_t byte = page_p->bytes[offset];
        if (byte > 0 || !prefix_zero)
        {
          prefix_zero = false;
          *dst_p++ = page_p->bytes[offset];
          real_offset++;
        }
        else
        {
          /* When a leading zero is dropped, the branch
           * offset length must be decreased as well. */
          (*opcode_p)--;
        }
        PARSER_NEXT_BYTE_UPDATE (page_p, offset, real_offset);
      }

      *dst_p++ = page_p->bytes[offset];
      real_offset++;
      PARSER_NEXT_BYTE_UPDATE (page_p, offset, real_offset);
      continue;
    }
  }

#if JERRY_DEBUGGER
  if ((JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
      && context_p->breakpoint_info_count > 0)
  {
    parser_send_breakpoints (context_p, JERRY_DEBUGGER_BREAKPOINT_OFFSET_LIST);
    JERRY_ASSERT (context_p->breakpoint_info_count == 0);
  }
#endif /* JERRY_DEBUGGER */

  if (!(context_p->status_flags & PARSER_NO_END_LABEL))
  {
    *dst_p++ = CBC_RETURN_WITH_BLOCK;

#if JERRY_ESNEXT
    if (PARSER_IS_NORMAL_ASYNC_FUNCTION (context_p->status_flags))
    {
      dst_p[-1] = CBC_EXT_OPCODE;
      dst_p[0] = CBC_EXT_ASYNC_EXIT;
      dst_p++;
    }
#endif /* JERRY_ESNEXT */
  }
  JERRY_ASSERT (dst_p == byte_code_p + length);

#if JERRY_LINE_INFO
  uint8_t *line_info_p = parser_line_info_generate (context_p);
#endif /* JERRY_LINE_INFO */

  parse_update_branches (context_p, byte_code_p);

  parser_cbc_stream_free (&context_p->byte_code);

  if (context_p->status_flags & PARSER_HAS_LATE_LIT_INIT)
  {
    parser_list_iterator_t literal_iterator;
    lexer_literal_t *literal_p;
    uint16_t register_count = context_p->register_count;

    parser_list_iterator_init (&context_p->literal_pool, &literal_iterator);
    while ((literal_p = (lexer_literal_t *) parser_list_iterator_next (&literal_iterator)))
    {
      if ((literal_p->status_flags & LEXER_FLAG_LATE_INIT)
          && literal_p->prop.index >= register_count)
      {
        uint32_t source_data = literal_p->u.source_data;
        const uint8_t *char_p = context_p->source_end_p - (source_data & 0xfffff);
        ecma_value_t lit_value = ecma_find_or_create_literal_string (char_p,
                                                                     source_data >> 20);
        literal_pool_p[literal_p->prop.index] = lit_value;
      }
    }
  }

  ecma_value_t *base_p = (ecma_value_t *) (((uint8_t *) compiled_code_p) + total_size);

  if (PARSER_NEEDS_MAPPED_ARGUMENTS (context_p->status_flags))
  {
    parser_list_iterator_t literal_iterator;
    uint16_t argument_count = 0;
    uint16_t register_count = context_p->register_count;
    base_p -= context_p->argument_count;

    parser_list_iterator_init (&context_p->literal_pool, &literal_iterator);
    while (argument_count < context_p->argument_count)
    {
      lexer_literal_t *literal_p;
      literal_p = (lexer_literal_t *) parser_list_iterator_next (&literal_iterator);

      JERRY_ASSERT (literal_p != NULL);

      if (!(literal_p->status_flags & LEXER_FLAG_FUNCTION_ARGUMENT))
      {
        continue;
      }

      /* All arguments must be moved to initialized registers. */
      if (literal_p->type == LEXER_UNUSED_LITERAL)
      {
        base_p[argument_count] = ECMA_VALUE_EMPTY;
        argument_count++;
        continue;
      }

      JERRY_ASSERT (literal_p->type == LEXER_IDENT_LITERAL);

      JERRY_ASSERT (literal_p->prop.index >= register_count);

      base_p[argument_count] = literal_pool_p[literal_p->prop.index];
      argument_count++;
    }
  }

#if JERRY_ESNEXT
  if (!(context_p->status_flags & PARSER_CLASS_CONSTRUCTOR))
  {
    *(--base_p) = ecma_make_magic_string_value (LIT_MAGIC_STRING__EMPTY);
  }

  if (context_p->argument_length != UINT16_MAX)
  {
    compiled_code_p->status_flags |= CBC_CODE_FLAGS_HAS_EXTENDED_INFO;
    *(--base_p) = context_p->argument_length;
  }

  if (context_p->tagged_template_literal_cp != JMEM_CP_NULL)
  {
    compiled_code_p->status_flags |= CBC_CODE_FLAGS_HAS_TAGGED_LITERALS;
    base_p[-1] = (ecma_value_t) context_p->tagged_template_literal_cp;
#if JERRY_LINE_INFO
    --base_p;
#endif /* JERRY_LINE_INFO */
  }
#endif /* JERRY_ESNEXT */

#if JERRY_LINE_INFO
  ECMA_SET_INTERNAL_VALUE_POINTER (base_p[-1], line_info_p);
#endif /* JERRY_LINE_INFO */

#if JERRY_PARSER_DUMP_BYTE_CODE
  if (context_p->is_show_opcodes)
  {
    util_print_cbc (compiled_code_p);
    JERRY_DEBUG_MSG ("\nByte code size: %d bytes\n", (int) length);
    context_p->total_byte_code_size += (uint32_t) length;
  }
#endif /* JERRY_PARSER_DUMP_BYTE_CODE */

#if JERRY_DEBUGGER
  if (JERRY_CONTEXT (debugger_flags) & JERRY_DEBUGGER_CONNECTED)
  {
    jerry_debugger_send_function_cp (JERRY_DEBUGGER_BYTE_CODE_CP, compiled_code_p);
  }
#endif /* JERRY_DEBUGGER */

  return compiled_code_p;
} /* parser_post_processing */


static cmsBool WritePositionTable ( struct _cms_typehandler_struct * self , cmsIOHANDLER * io , cmsUInt32Number SizeOfTag , cmsUInt32Number Count , cmsUInt32Number BaseOffset , void * Cargo , PositionTableEntryFn ElementFn ) {
 cmsUInt32Number i ;
 cmsUInt32Number DirectoryPos , CurrentPos , Before ;
 cmsUInt32Number * ElementOffsets = NULL , * ElementSizes = NULL ;
 ElementOffsets = ( cmsUInt32Number * ) _cmsCalloc ( io -> ContextID , Count , sizeof ( cmsUInt32Number ) ) ;
 if ( ElementOffsets == NULL ) goto Error ;
 ElementSizes = ( cmsUInt32Number * ) _cmsCalloc ( io -> ContextID , Count , sizeof ( cmsUInt32Number ) ) ;
 if ( ElementSizes == NULL ) goto Error ;
 DirectoryPos = io -> Tell ( io ) ;
 for ( i = 0 ;
 i < Count ;
 i ++ ) {
 if ( ! _cmsWriteUInt32Number ( io , 0 ) ) goto Error ;
 if ( ! _cmsWriteUInt32Number ( io , 0 ) ) goto Error ;
 }
 for ( i = 0 ;
 i < Count ;
 i ++ ) {
 Before = io -> Tell ( io ) ;
 ElementOffsets [ i ] = Before - BaseOffset ;
 if ( ! ElementFn ( self , io , Cargo , i , SizeOfTag ) ) goto Error ;
 ElementSizes [ i ] = io -> Tell ( io ) - Before ;
 }
 CurrentPos = io -> Tell ( io ) ;
 if ( ! io -> Seek ( io , DirectoryPos ) ) goto Error ;
 for ( i = 0 ;
 i < Count ;
 i ++ ) {
 if ( ! _cmsWriteUInt32Number ( io , ElementOffsets [ i ] ) ) goto Error ;
 if ( ! _cmsWriteUInt32Number ( io , ElementSizes [ i ] ) ) goto Error ;
 }
 if ( ! io -> Seek ( io , CurrentPos ) ) goto Error ;
 if ( ElementOffsets != NULL ) _cmsFree ( io -> ContextID , ElementOffsets ) ;
 if ( ElementSizes != NULL ) _cmsFree ( io -> ContextID , ElementSizes ) ;
 return TRUE ;
 Error : if ( ElementOffsets != NULL ) _cmsFree ( io -> ContextID , ElementOffsets ) ;
 if ( ElementSizes != NULL ) _cmsFree ( io -> ContextID , ElementSizes ) ;
 return FALSE ;
 }


static void mpegts_write_pes(AVFormatContext *s, AVStream *st, const uint8_t *payload, int payload_size, int64_t pts, int64_t dts, int key, int stream_id) { MpegTSWriteStream *ts_st = st->priv_data; MpegTSWrite *ts = s->priv_data; uint8_t buf[TS_PACKET_SIZE]; uint8_t *q; int val, is_start, len, header_len, write_pcr, is_dvb_subtitle, is_dvb_teletext, flags; int afc_len, stuffing_len; int64_t pcr = -1; /* avoid warning */ int64_t delay = av_rescale(s->max_delay, 90000, AV_TIME_BASE); int force_pat = st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && key && !ts_st->prev_payload_key; av_assert0(ts_st->payload != buf || st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO); if (ts->flags & MPEGTS_FLAG_PAT_PMT_AT_FRAMES && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { force_pat = 1; is_start = 1; while (payload_size > 0) { retransmit_si_info(s, force_pat, dts); force_pat = 0; write_pcr = 0; if (ts_st->pid == ts_st->service->pcr_pid) { if (ts->mux_rate > 1 || is_start) // VBR pcr period is based on frames ts_st->service->pcr_packet_count++; if (ts_st->service->pcr_packet_count >= ts_st->service->pcr_packet_period) { ts_st->service->pcr_packet_count = 0; write_pcr = 1; if (ts->mux_rate > 1 && dts != AV_NOPTS_VALUE && (dts - get_pcr(ts, s->pb) / 300) > delay) { /* pcr insert gets priority over null packet insert */ if (write_pcr) mpegts_insert_pcr_only(s, st); else mpegts_insert_null_packet(s); /* recalculate write_pcr and possibly retransmit si_info */ continue; /* prepare packet header */ q = buf; *q++ = 0x47; val = ts_st->pid >> 8; if (is_start) val |= 0x40; *q++ = val; *q++ = ts_st->pid; ts_st->cc = ts_st->cc + 1 & 0xf; *q++ = 0x10 | ts_st->cc; // payload indicator + CC if (key && is_start && pts != AV_NOPTS_VALUE) { // set Random Access for key frames if (ts_st->pid == ts_st->service->pcr_pid) write_pcr = 1; set_af_flag(buf, 0x40); if (write_pcr) { set_af_flag(buf, 0x10); // add 11, pcr references the last byte of program clock reference base if (ts->mux_rate > 1) pcr = get_pcr(ts, s->pb); else pcr = (dts - delay) * 300; if (dts != AV_NOPTS_VALUE && dts < pcr / 300) av_log(s, AV_LOG_WARNING, "dts < pcr, TS is invalid\n"); extend_af(buf, write_pcr_bits(q, pcr)); if (is_start) { int pes_extension = 0; int pes_header_stuffing_bytes = 0; /* write PES header */ *q++ = 0x00; *q++ = 0x00; *q++ = 0x01; is_dvb_subtitle = 0; is_dvb_teletext = 0; if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { if (st->codecpar->codec_id == AV_CODEC_ID_DIRAC) *q++ = 0xfd; else *q++ = 0xe0; } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && (st->codecpar->codec_id == AV_CODEC_ID_MP2 || st->codecpar->codec_id == AV_CODEC_ID_MP3 || st->codecpar->codec_id == AV_CODEC_ID_AAC)) { *q++ = 0xc0; } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && st->codecpar->codec_id == AV_CODEC_ID_AC3 && ts->m2ts_mode) { *q++ = 0xfd; } else if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA && st->codecpar->codec_id == AV_CODEC_ID_TIMED_ID3) { *q++ = 0xbd; } else if (st->codecpar->codec_type == AVMEDIA_TYPE_DATA) { *q++ = stream_id != -1 ? stream_id : 0xfc; if (stream_id == 0xbd) /* asynchronous KLV */ pts = dts = AV_NOPTS_VALUE; } else { *q++ = 0xbd; if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) { if (st->codecpar->codec_id == AV_CODEC_ID_DVB_SUBTITLE) { is_dvb_subtitle = 1; } else if (st->codecpar->codec_id == AV_CODEC_ID_DVB_TELETEXT) { is_dvb_teletext = 1; header_len = 0; flags = 0; if (pts != AV_NOPTS_VALUE) { header_len += 5; flags |= 0x80; if (dts != AV_NOPTS_VALUE && pts != AV_NOPTS_VALUE && dts != pts) { header_len += 5; flags |= 0x40; if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && st->codecpar->codec_id == AV_CODEC_ID_DIRAC) { /* set PES_extension_flag */ pes_extension = 1; flags |= 0x01; /* One byte for PES2 extension flag + * one byte for extension length + * one byte for extension id */ header_len += 3; /* for Blu-ray AC3 Audio the PES Extension flag should be as follow * otherwise it will not play sound on blu-ray */ if (ts->m2ts_mode && st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && st->codecpar->codec_id == AV_CODEC_ID_AC3) { /* set PES_extension_flag */ pes_extension = 1; flags |= 0x01; header_len += 3; if (is_dvb_teletext) { pes_header_stuffing_bytes = 0x24 - header_len; header_len = 0x24; len = payload_size + header_len + 3; /* 3 extra bytes should be added to DVB subtitle payload: 0x20 0x00 at the beginning and trailing 0xff */ if (is_dvb_subtitle) { len += 3; payload_size++; if (len > 0xffff) len = 0; if (ts->omit_video_pes_length && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { len = 0; *q++ = len >> 8; *q++ = len; val = 0x80; /* data alignment indicator is required for subtitle and data streams */ if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE || st->codecpar->codec_type == AVMEDIA_TYPE_DATA) val |= 0x04; *q++ = val; *q++ = flags; *q++ = header_len; if (pts != AV_NOPTS_VALUE) { write_pts(q, flags >> 6, pts); q += 5; if (dts != AV_NOPTS_VALUE && pts != AV_NOPTS_VALUE && dts != pts) { write_pts(q, 1, dts); q += 5; if (pes_extension && st->codecpar->codec_id == AV_CODEC_ID_DIRAC) { flags = 0x01; /* set PES_extension_flag_2 */ *q++ = flags; *q++ = 0x80 | 0x01; /* marker bit + extension length */ /* Set the stream ID extension flag bit to 0 and * write the extended stream ID. */ *q++ = 0x00 | 0x60; /* For Blu-ray AC3 Audio Setting extended flags */ if (ts->m2ts_mode && pes_extension && st->codecpar->codec_id == AV_CODEC_ID_AC3) { flags = 0x01; /* set PES_extension_flag_2 */ *q++ = flags; *q++ = 0x80 | 0x01; /* marker bit + extension length */ *q++ = 0x00 | 0x71; /* for AC3 Audio (specifically on blue-rays) */ if (is_dvb_subtitle) { /* First two fields of DVB subtitles PES data: * data_identifier: for DVB subtitle streams shall be coded with the value 0x20 * subtitle_stream_id: for DVB subtitle stream shall be identified by the value 0x00 */ *q++ = 0x20; *q++ = 0x00; if (is_dvb_teletext) { memset(q, 0xff, pes_header_stuffing_bytes); q += pes_header_stuffing_bytes; is_start = 0; /* header size */ header_len = q - buf; /* data len */ len = TS_PACKET_SIZE - header_len; if (len > payload_size) len = payload_size; stuffing_len = TS_PACKET_SIZE - header_len - len; if (stuffing_len > 0) { /* add stuffing with AFC */ if (buf[3] & 0x20) { /* stuffing already present: increase its size */ afc_len = buf[4] + 1; memmove(buf + 4 + afc_len + stuffing_len, buf + 4 + afc_len, header_len - (4 + afc_len)); buf[4] += stuffing_len; memset(buf + 4 + afc_len, 0xff, stuffing_len); } else { /* add stuffing */ memmove(buf + 4 + stuffing_len, buf + 4, header_len - 4); buf[3] |= 0x20; buf[4] = stuffing_len - 1; if (stuffing_len >= 2) { buf[5] = 0x00; memset(buf + 6, 0xff, stuffing_len - 2); if (is_dvb_subtitle && payload_size == len) { memcpy(buf + TS_PACKET_SIZE - len, payload, len - 1); buf[TS_PACKET_SIZE - 1] = 0xff; /* end_of_PES_data_field_marker: an 8-bit field with fixed contents 0xff for DVB subtitle */ } else { memcpy(buf + TS_PACKET_SIZE - len, payload, len); payload += len; payload_size -= len; mpegts_prefix_m2ts_header(s); avio_write(s->pb, buf, TS_PACKET_SIZE); ts_st->prev_payload_key = key;


lexer_string_is_use_strict (parser_context_t *context_p) /**< context */
{
  JERRY_ASSERT (context_p->token.type == LEXER_LITERAL
                && context_p->token.lit_location.type == LEXER_STRING_LITERAL);

  return (context_p->token.lit_location.length == 10
          && !context_p->token.lit_location.has_escape
          && memcmp (context_p->token.lit_location.char_p, "use strict", 10) == 0);
} /* lexer_string_is_use_strict */


scanner_detect_invalid_var (parser_context_t *context_p, /**< context */
                            scanner_context_t *scanner_context_p, /**< scanner context */
                            lexer_lit_location_t *var_literal_p) /**< var literal */
{
  if (var_literal_p->type & SCANNER_LITERAL_IS_LOCAL
      && !(var_literal_p->type & (SCANNER_LITERAL_IS_FUNC | SCANNER_LITERAL_IS_ARG))
      && (var_literal_p->type & SCANNER_LITERAL_IS_LOCAL) != SCANNER_LITERAL_IS_LOCAL)
  {
    scanner_raise_redeclaration_error (context_p);
  }

  scanner_literal_pool_t *literal_pool_p = scanner_context_p->active_literal_pool_p;

  if (!(literal_pool_p->status_flags & SCANNER_LITERAL_POOL_FUNCTION)
      && ((var_literal_p->type & SCANNER_LITERAL_IS_LOCAL_FUNC) == SCANNER_LITERAL_IS_LOCAL_FUNC))
  {
    scanner_raise_redeclaration_error (context_p);
  }

  const uint8_t *char_p = var_literal_p->char_p;
  prop_length_t length = var_literal_p->length;

  while (!(literal_pool_p->status_flags & SCANNER_LITERAL_POOL_FUNCTION))
  {
    literal_pool_p = literal_pool_p->prev_p;

    parser_list_iterator_t literal_iterator;
    parser_list_iterator_init (&literal_pool_p->literal_pool, &literal_iterator);
    lexer_lit_location_t *literal_p;

    if (JERRY_LIKELY (!context_p->token.lit_location.has_escape))
    {
      while ((literal_p = (lexer_lit_location_t *) parser_list_iterator_next (&literal_iterator)) != NULL)
      {
        if ((literal_p->type & SCANNER_LITERAL_IS_LOCAL)
            && !(literal_p->type & SCANNER_LITERAL_IS_ARG)
            && !((literal_p->type & SCANNER_LITERAL_IS_FUNC)
                 && (literal_pool_p->status_flags & SCANNER_LITERAL_POOL_FUNCTION))
            && (literal_p->type & SCANNER_LITERAL_IS_LOCAL) != SCANNER_LITERAL_IS_LOCAL
            && literal_p->length == length)
        {
          if (JERRY_LIKELY (!literal_p->has_escape))
          {
            if (memcmp (literal_p->char_p, char_p, length) == 0)
            {
              scanner_raise_redeclaration_error (context_p);
              return;
            }
          }
          else if (lexer_compare_identifier_to_string (literal_p, char_p, length))
          {
            scanner_raise_redeclaration_error (context_p);
            return;
          }
        }
      }
    }
    else
    {
      while ((literal_p = (lexer_lit_location_t *) parser_list_iterator_next (&literal_iterator)) != NULL)
      {
        if ((literal_p->type & SCANNER_LITERAL_IS_LOCAL)
            && !(literal_p->type & SCANNER_LITERAL_IS_ARG)
            && !((literal_p->type & SCANNER_LITERAL_IS_FUNC)
                 && (literal_pool_p->status_flags & SCANNER_LITERAL_POOL_FUNCTION))
            && (literal_p->type & SCANNER_LITERAL_IS_LOCAL) != SCANNER_LITERAL_IS_LOCAL
            && lexer_compare_identifiers (context_p, literal_p, var_literal_p))
        {
          scanner_raise_redeclaration_error (context_p);
          return;
        }
      }
    }
  }

  if (scanner_scope_find_lexical_declaration (context_p, var_literal_p))
  {
    scanner_raise_redeclaration_error (context_p);
  }
} /* scanner_detect_invalid_var */


static int decode_mb_cavlc(H264Context *h){ MpegEncContext * const s = &h->s; int mb_xy; int partition_count; unsigned int mb_type, cbp; int dct8x8_allowed= h->pps.transform_8x8_mode; mb_xy = h->mb_xy = s->mb_x + s->mb_y*s->mb_stride; s->dsp.clear_blocks(h->mb); //FIXME avoid if already clear (move after skip handlong? tprintf(s->avctx, "pic:%d mb:%d/%d\n", h->frame_num, s->mb_x, s->mb_y); cbp = 0; /* avoid warning. FIXME: find a solution without slowing down the code */ if(h->slice_type_nos != FF_I_TYPE){ if(s->mb_skip_run==-1) s->mb_skip_run= get_ue_golomb(&s->gb); if (s->mb_skip_run--) { if(FRAME_MBAFF && (s->mb_y&1) == 0){ if(s->mb_skip_run==0) h->mb_mbaff = h->mb_field_decoding_flag = get_bits1(&s->gb); else predict_field_decoding_flag(h); } decode_mb_skip(h); return 0; } } if(FRAME_MBAFF){ if( (s->mb_y&1) == 0 ) h->mb_mbaff = h->mb_field_decoding_flag = get_bits1(&s->gb); }else h->mb_field_decoding_flag= (s->picture_structure!=PICT_FRAME); h->prev_mb_skipped= 0; mb_type= get_ue_golomb(&s->gb); if(h->slice_type_nos == FF_B_TYPE){ if(mb_type < 23){ partition_count= b_mb_type_info[mb_type].partition_count; mb_type= b_mb_type_info[mb_type].type; }else{ mb_type -= 23; goto decode_intra_mb; } }else if(h->slice_type_nos == FF_P_TYPE){ if(mb_type < 5){ partition_count= p_mb_type_info[mb_type].partition_count; mb_type= p_mb_type_info[mb_type].type; }else{ mb_type -= 5; goto decode_intra_mb; } }else{ assert(h->slice_type_nos == FF_I_TYPE); if(h->slice_type == FF_SI_TYPE && mb_type) mb_type--; decode_intra_mb: if(mb_type > 25){ av_log(h->s.avctx, AV_LOG_ERROR, "mb_type %d in %c slice too large at %d %d\n", mb_type, av_get_pict_type_char(h->slice_type), s->mb_x, s->mb_y); return -1; } partition_count=0; cbp= i_mb_type_info[mb_type].cbp; h->intra16x16_pred_mode= i_mb_type_info[mb_type].pred_mode; mb_type= i_mb_type_info[mb_type].type; } if(MB_FIELD) mb_type |= MB_TYPE_INTERLACED; h->slice_table[ mb_xy ]= h->slice_num; if(IS_INTRA_PCM(mb_type)){ unsigned int x, y; // We assume these blocks are very rare so we do not optimize it. align_get_bits(&s->gb); // The pixels are stored in the same order as levels in h->mb array. for(y=0; y<16; y++){ const int index= 4*(y&3) + 32*((y>>2)&1) + 128*(y>>3); for(x=0; x<16; x++){ tprintf(s->avctx, "LUMA ICPM LEVEL (%3d)\n", show_bits(&s->gb, 8)); h->mb[index + (x&3) + 16*((x>>2)&1) + 64*(x>>3)]= get_bits(&s->gb, 8); } } for(y=0; y<8; y++){ const int index= 256 + 4*(y&3) + 32*(y>>2); for(x=0; x<8; x++){ tprintf(s->avctx, "CHROMA U ICPM LEVEL (%3d)\n", show_bits(&s->gb, 8)); h->mb[index + (x&3) + 16*(x>>2)]= get_bits(&s->gb, 8); } } for(y=0; y<8; y++){ const int index= 256 + 64 + 4*(y&3) + 32*(y>>2); for(x=0; x<8; x++){ tprintf(s->avctx, "CHROMA V ICPM LEVEL (%3d)\n", show_bits(&s->gb, 8)); h->mb[index + (x&3) + 16*(x>>2)]= get_bits(&s->gb, 8); } } // In deblocking, the quantizer is 0 s->current_picture.qscale_table[mb_xy]= 0; // All coeffs are present memset(h->non_zero_count[mb_xy], 16, 16); s->current_picture.mb_type[mb_xy]= mb_type; return 0; } if(MB_MBAFF){ h->ref_count[0] <<= 1; h->ref_count[1] <<= 1; } fill_caches(h, mb_type, 0); //mb_pred if(IS_INTRA(mb_type)){ int pred_mode; // init_top_left_availability(h); if(IS_INTRA4x4(mb_type)){ int i; int di = 1; if(dct8x8_allowed && get_bits1(&s->gb)){ mb_type |= MB_TYPE_8x8DCT; di = 4; } // fill_intra4x4_pred_table(h); for(i=0; i<16; i+=di){ int mode= pred_intra_mode(h, i); if(!get_bits1(&s->gb)){ const int rem_mode= get_bits(&s->gb, 3); mode = rem_mode + (rem_mode >= mode); } if(di==4) fill_rectangle( &h->intra4x4_pred_mode_cache[ scan8[i] ], 2, 2, 8, mode, 1 ); else h->intra4x4_pred_mode_cache[ scan8[i] ] = mode; } write_back_intra_pred_mode(h); if( check_intra4x4_pred_mode(h) < 0) return -1; }else{ h->intra16x16_pred_mode= check_intra_pred_mode(h, h->intra16x16_pred_mode); if(h->intra16x16_pred_mode < 0) return -1; } pred_mode= check_intra_pred_mode(h, get_ue_golomb(&s->gb)); if(pred_mode < 0) return -1; h->chroma_pred_mode= pred_mode; }else if(partition_count==4){ int i, j, sub_partition_count[4], list, ref[2][4]; if(h->slice_type_nos == FF_B_TYPE){ for(i=0; i<4; i++){ h->sub_mb_type[i]= get_ue_golomb(&s->gb); if(h->sub_mb_type[i] >=13){ av_log(h->s.avctx, AV_LOG_ERROR, "B sub_mb_type %u out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y); return -1; } sub_partition_count[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count; h->sub_mb_type[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].type; } if( IS_DIRECT(h->sub_mb_type[0]) || IS_DIRECT(h->sub_mb_type[1]) || IS_DIRECT(h->sub_mb_type[2]) || IS_DIRECT(h->sub_mb_type[3])) { pred_direct_motion(h, &mb_type); h->ref_cache[0][scan8[4]] = h->ref_cache[1][scan8[4]] = h->ref_cache[0][scan8[12]] = h->ref_cache[1][scan8[12]] = PART_NOT_AVAILABLE; } }else{ assert(h->slice_type_nos == FF_P_TYPE); //FIXME SP correct ? for(i=0; i<4; i++){ h->sub_mb_type[i]= get_ue_golomb(&s->gb); if(h->sub_mb_type[i] >=4){ av_log(h->s.avctx, AV_LOG_ERROR, "P sub_mb_type %u out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y); return -1; } sub_partition_count[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count; h->sub_mb_type[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].type; } } for(list=0; list<h->list_count; list++){ int ref_count= IS_REF0(mb_type) ? 1 : h->ref_count[list]; for(i=0; i<4; i++){ if(IS_DIRECT(h->sub_mb_type[i])) continue; if(IS_DIR(h->sub_mb_type[i], 0, list)){ unsigned int tmp = get_te0_golomb(&s->gb, ref_count); //FIXME init to 0 before and skip? if(tmp>=ref_count){ av_log(h->s.avctx, AV_LOG_ERROR, "ref %u overflow\n", tmp); return -1; } ref[list][i]= tmp; }else{ //FIXME ref[list][i] = -1; } } } if(dct8x8_allowed) dct8x8_allowed = get_dct8x8_allowed(h); for(list=0; list<h->list_count; list++){ for(i=0; i<4; i++){ if(IS_DIRECT(h->sub_mb_type[i])) { h->ref_cache[list][ scan8[4*i] ] = h->ref_cache[list][ scan8[4*i]+1 ]; continue; } h->ref_cache[list][ scan8[4*i] ]=h->ref_cache[list][ scan8[4*i]+1 ]= h->ref_cache[list][ scan8[4*i]+8 ]=h->ref_cache[list][ scan8[4*i]+9 ]= ref[list][i]; if(IS_DIR(h->sub_mb_type[i], 0, list)){ const int sub_mb_type= h->sub_mb_type[i]; const int block_width= (sub_mb_type & (MB_TYPE_16x16|MB_TYPE_16x8)) ? 2 : 1; for(j=0; j<sub_partition_count[i]; j++){ int mx, my; const int index= 4*i + block_width*j; int16_t (* mv_cache)[2]= &h->mv_cache[list][ scan8[index] ]; pred_motion(h, index, block_width, list, h->ref_cache[list][ scan8[index] ], &mx, &my); mx += get_se_golomb(&s->gb); my += get_se_golomb(&s->gb); tprintf(s->avctx, "final mv:%d %d\n", mx, my); if(IS_SUB_8X8(sub_mb_type)){ mv_cache[ 1 ][0]= mv_cache[ 8 ][0]= mv_cache[ 9 ][0]= mx; mv_cache[ 1 ][1]= mv_cache[ 8 ][1]= mv_cache[ 9 ][1]= my; }else if(IS_SUB_8X4(sub_mb_type)){ mv_cache[ 1 ][0]= mx; mv_cache[ 1 ][1]= my; }else if(IS_SUB_4X8(sub_mb_type)){ mv_cache[ 8 ][0]= mx; mv_cache[ 8 ][1]= my; } mv_cache[ 0 ][0]= mx; mv_cache[ 0 ][1]= my; } }else{ uint32_t *p= (uint32_t *)&h->mv_cache[list][ scan8[4*i] ][0]; p[0] = p[1]= p[8] = p[9]= 0; } } } }else if(IS_DIRECT(mb_type)){ pred_direct_motion(h, &mb_type); dct8x8_allowed &= h->sps.direct_8x8_inference_flag; }else{ int list, mx, my, i; //FIXME we should set ref_idx_l? to 0 if we use that later ... if(IS_16X16(mb_type)){ for(list=0; list<h->list_count; list++){ unsigned int val; if(IS_DIR(mb_type, 0, list)){ val= get_te0_golomb(&s->gb, h->ref_count[list]); if(val >= h->ref_count[list]){ av_log(h->s.avctx, AV_LOG_ERROR, "ref %u overflow\n", val); return -1; } }else val= LIST_NOT_USED&0xFF; fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8, val, 1); } for(list=0; list<h->list_count; list++){ unsigned int val; if(IS_DIR(mb_type, 0, list)){ pred_motion(h, 0, 4, list, h->ref_cache[list][ scan8[0] ], &mx, &my); mx += get_se_golomb(&s->gb); my += get_se_golomb(&s->gb); tprintf(s->avctx, "final mv:%d %d\n", mx, my); val= pack16to32(mx,my); }else val=0; fill_rectangle(h->mv_cache[list][ scan8[0] ], 4, 4, 8, val, 4); } } else if(IS_16X8(mb_type)){ for(list=0; list<h->list_count; list++){ for(i=0; i<2; i++){ unsigned int val; if(IS_DIR(mb_type, i, list)){ val= get_te0_golomb(&s->gb, h->ref_count[list]); if(val >= h->ref_count[list]){ av_log(h->s.avctx, AV_LOG_ERROR, "ref %u overflow\n", val); return -1; } }else val= LIST_NOT_USED&0xFF; fill_rectangle(&h->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, val, 1); } } for(list=0; list<h->list_count; list++){ for(i=0; i<2; i++){ unsigned int val; if(IS_DIR(mb_type, i, list)){ pred_16x8_motion(h, 8*i, list, h->ref_cache[list][scan8[0] + 16*i], &mx, &my); mx += get_se_golomb(&s->gb); my += get_se_golomb(&s->gb); tprintf(s->avctx, "final mv:%d %d\n", mx, my); val= pack16to32(mx,my); }else val=0; fill_rectangle(h->mv_cache[list][ scan8[0] + 16*i ], 4, 2, 8, val, 4); } } }else{ assert(IS_8X16(mb_type)); for(list=0; list<h->list_count; list++){ for(i=0; i<2; i++){ unsigned int val; if(IS_DIR(mb_type, i, list)){ //FIXME optimize val= get_te0_golomb(&s->gb, h->ref_count[list]); if(val >= h->ref_count[list]){ av_log(h->s.avctx, AV_LOG_ERROR, "ref %u overflow\n", val); return -1; } }else val= LIST_NOT_USED&0xFF; fill_rectangle(&h->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, val, 1); } } for(list=0; list<h->list_count; list++){ for(i=0; i<2; i++){ unsigned int val; if(IS_DIR(mb_type, i, list)){ pred_8x16_motion(h, i*4, list, h->ref_cache[list][ scan8[0] + 2*i ], &mx, &my); mx += get_se_golomb(&s->gb); my += get_se_golomb(&s->gb); tprintf(s->avctx, "final mv:%d %d\n", mx, my); val= pack16to32(mx,my); }else val=0; fill_rectangle(h->mv_cache[list][ scan8[0] + 2*i ], 2, 4, 8, val, 4); } } } } if(IS_INTER(mb_type)) write_back_motion(h, mb_type); if(!IS_INTRA16x16(mb_type)){ cbp= get_ue_golomb(&s->gb); if(cbp > 47){ av_log(h->s.avctx, AV_LOG_ERROR, "cbp too large (%u) at %d %d\n", cbp, s->mb_x, s->mb_y); return -1; } if(IS_INTRA4x4(mb_type)) cbp= golomb_to_intra4x4_cbp[cbp]; else cbp= golomb_to_inter_cbp[cbp]; } h->cbp = cbp; if(dct8x8_allowed && (cbp&15) && !IS_INTRA(mb_type)){ if(get_bits1(&s->gb)) mb_type |= MB_TYPE_8x8DCT; } s->current_picture.mb_type[mb_xy]= mb_type; if(cbp || IS_INTRA16x16(mb_type)){ int i8x8, i4x4, chroma_idx; int dquant; GetBitContext *gb= IS_INTRA(mb_type) ? h->intra_gb_ptr : h->inter_gb_ptr; const uint8_t *scan, *scan8x8, *dc_scan; // fill_non_zero_count_cache(h); if(IS_INTERLACED(mb_type)){ scan8x8= s->qscale ? h->field_scan8x8_cavlc : h->field_scan8x8_cavlc_q0; scan= s->qscale ? h->field_scan : h->field_scan_q0; dc_scan= luma_dc_field_scan; }else{ scan8x8= s->qscale ? h->zigzag_scan8x8_cavlc : h->zigzag_scan8x8_cavlc_q0; scan= s->qscale ? h->zigzag_scan : h->zigzag_scan_q0; dc_scan= luma_dc_zigzag_scan; } dquant= get_se_golomb(&s->gb); if( dquant > 25 || dquant < -26 ){ av_log(h->s.avctx, AV_LOG_ERROR, "dquant out of range (%d) at %d %d\n", dquant, s->mb_x, s->mb_y); return -1; } s->qscale += dquant; if(((unsigned)s->qscale) > 51){ if(s->qscale<0) s->qscale+= 52; else s->qscale-= 52; } h->chroma_qp[0]= get_chroma_qp(h, 0, s->qscale); h->chroma_qp[1]= get_chroma_qp(h, 1, s->qscale); if(IS_INTRA16x16(mb_type)){ if( decode_residual(h, h->intra_gb_ptr, h->mb, LUMA_DC_BLOCK_INDEX, dc_scan, h->dequant4_coeff[0][s->qscale], 16) < 0){ return -1; //FIXME continue if partitioned and other return -1 too } assert((cbp&15) == 0 || (cbp&15) == 15); if(cbp&15){ for(i8x8=0; i8x8<4; i8x8++){ for(i4x4=0; i4x4<4; i4x4++){ const int index= i4x4 + 4*i8x8; if( decode_residual(h, h->intra_gb_ptr, h->mb + 16*index, index, scan + 1, h->dequant4_coeff[0][s->qscale], 15) < 0 ){ return -1; } } } }else{ fill_rectangle(&h->non_zero_count_cache[scan8[0]], 4, 4, 8, 0, 1); } }else{ for(i8x8=0; i8x8<4; i8x8++){ if(cbp & (1<<i8x8)){ if(IS_8x8DCT(mb_type)){ DCTELEM *buf = &h->mb[64*i8x8]; uint8_t *nnz; for(i4x4=0; i4x4<4; i4x4++){ if( decode_residual(h, gb, buf, i4x4+4*i8x8, scan8x8+16*i4x4, h->dequant8_coeff[IS_INTRA( mb_type ) ? 0:1][s->qscale], 16) <0 ) return -1; } nnz= &h->non_zero_count_cache[ scan8[4*i8x8] ]; nnz[0] += nnz[1] + nnz[8] + nnz[9]; }else{ for(i4x4=0; i4x4<4; i4x4++){ const int index= i4x4 + 4*i8x8; if( decode_residual(h, gb, h->mb + 16*index, index, scan, h->dequant4_coeff[IS_INTRA( mb_type ) ? 0:3][s->qscale], 16) <0 ){ return -1; } } } }else{ uint8_t * const nnz= &h->non_zero_count_cache[ scan8[4*i8x8] ]; nnz[0] = nnz[1] = nnz[8] = nnz[9] = 0; } } } if(cbp&0x30){ for(chroma_idx=0; chroma_idx<2; chroma_idx++) if( decode_residual(h, gb, h->mb + 256 + 16*4*chroma_idx, CHROMA_DC_BLOCK_INDEX, chroma_dc_scan, NULL, 4) < 0){ return -1; } } if(cbp&0x20){ for(chroma_idx=0; chroma_idx<2; chroma_idx++){ const uint32_t *qmul = h->dequant4_coeff[chroma_idx+1+(IS_INTRA( mb_type ) ? 0:3)][h->chroma_qp[chroma_idx]]; for(i4x4=0; i4x4<4; i4x4++){ const int index= 16 + 4*chroma_idx + i4x4; if( decode_residual(h, gb, h->mb + 16*index, index, scan + 1, qmul, 15) < 0){ return -1; } } } }else{ uint8_t * const nnz= &h->non_zero_count_cache[0]; nnz[ scan8[16]+0 ] = nnz[ scan8[16]+1 ] =nnz[ scan8[16]+8 ] =nnz[ scan8[16]+9 ] = nnz[ scan8[20]+0 ] = nnz[ scan8[20]+1 ] =nnz[ scan8[20]+8 ] =nnz[ scan8[20]+9 ] = 0; } }else{ uint8_t * const nnz= &h->non_zero_count_cache[0]; fill_rectangle(&nnz[scan8[0]], 4, 4, 8, 0, 1); nnz[ scan8[16]+0 ] = nnz[ scan8[16]+1 ] =nnz[ scan8[16]+8 ] =nnz[ scan8[16]+9 ] = nnz[ scan8[20]+0 ] = nnz[ scan8[20]+1 ] =nnz[ scan8[20]+8 ] =nnz[ scan8[20]+9 ] = 0; } s->current_picture.qscale_table[mb_xy]= s->qscale; write_back_non_zero_count(h); if(MB_MBAFF){ h->ref_count[0] >>= 1; h->ref_count[1] >>= 1; } return 0; }


static int pimv2_addr_print ( netdissect_options * ndo , const u_char * bp , enum pimv2_addrtype at , int silent ) {
 int af ;
 int len , hdrlen ;
 ND_TCHECK ( bp [ 0 ] ) ;
 if ( pimv2_addr_len == 0 ) {
 ND_TCHECK ( bp [ 1 ] ) ;
 switch ( bp [ 0 ] ) {
 case 1 : af = AF_INET ;
 len = sizeof ( struct in_addr ) ;
 break ;
 case 2 : af = AF_INET6 ;
 len = sizeof ( struct in6_addr ) ;
 break ;
 default : return - 1 ;
 }
 if ( bp [ 1 ] != 0 ) return - 1 ;
 hdrlen = 2 ;
 }
 else {
 switch ( pimv2_addr_len ) {
 case sizeof ( struct in_addr ) : af = AF_INET ;
 break ;
 case sizeof ( struct in6_addr ) : af = AF_INET6 ;
 break ;
 default : return - 1 ;
 break ;
 }
 len = pimv2_addr_len ;
 hdrlen = 0 ;
 }
 bp += hdrlen ;
 switch ( at ) {
 case pimv2_unicast : ND_TCHECK2 ( bp [ 0 ] , len ) ;
 if ( af == AF_INET ) {
 if ( ! silent ) ND_PRINT ( ( ndo , "%s" , ipaddr_string ( ndo , bp ) ) ) ;
 }
 else if ( af == AF_INET6 ) {
 if ( ! silent ) ND_PRINT ( ( ndo , "%s" , ip6addr_string ( ndo , bp ) ) ) ;
 }
 return hdrlen + len ;
 case pimv2_group : case pimv2_source : ND_TCHECK2 ( bp [ 0 ] , len + 2 ) ;
 if ( af == AF_INET ) {
 if ( ! silent ) {
 ND_PRINT ( ( ndo , "%s" , ipaddr_string ( ndo , bp + 2 ) ) ) ;
 if ( bp [ 1 ] != 32 ) ND_PRINT ( ( ndo , "/%u" , bp [ 1 ] ) ) ;
 }
 }
 else if ( af == AF_INET6 ) {
 if ( ! silent ) {
 ND_PRINT ( ( ndo , "%s" , ip6addr_string ( ndo , bp + 2 ) ) ) ;
 if ( bp [ 1 ] != 128 ) ND_PRINT ( ( ndo , "/%u" , bp [ 1 ] ) ) ;
 }
 }
 if ( bp [ 0 ] && ! silent ) {
 if ( at == pimv2_group ) {
 ND_PRINT ( ( ndo , "(0x%02x)" , bp [ 0 ] ) ) ;
 }
 else {
 ND_PRINT ( ( ndo , "(%s%s%s" , bp [ 0 ] & 0x04 ? "S" : "" , bp [ 0 ] & 0x02 ? "W" : "" , bp [ 0 ] & 0x01 ? "R" : "" ) ) ;
 if ( bp [ 0 ] & 0xf8 ) {
 ND_PRINT ( ( ndo , "+0x%02x" , bp [ 0 ] & 0xf8 ) ) ;
 }
 ND_PRINT ( ( ndo , ")" ) ) ;
 }
 }
 return hdrlen + 2 + len ;
 default : return - 1 ;
 }
 trunc : return - 1 ;
 }


int av_parse_color(uint8_t *rgba_color, const char *color_string, void *log_ctx) { if (!strcasecmp(color_string, "random") || !strcasecmp(color_string, "bikeshed")) { int rgba = ff_random_get_seed(); rgba_color[0] = rgba >> 24; rgba_color[1] = rgba >> 16; rgba_color[2] = rgba >> 8; rgba_color[3] = rgba; } else if (!strncmp(color_string, "0x", 2)) { char *tail; int len = strlen(color_string); int rgba = strtol(color_string, &tail, 16); if (*tail || (len != 8 && len != 10)) { av_log(log_ctx, AV_LOG_ERROR, "Invalid 0xRRGGBB[AA] color string: '%s'\n", color_string); return -1; } if (len == 10) { rgba_color[3] = rgba; rgba >>= 8; } rgba_color[0] = rgba >> 16; rgba_color[1] = rgba >> 8; rgba_color[2] = rgba; } else { const ColorEntry *entry = bsearch(color_string, color_table, FF_ARRAY_ELEMS(color_table), sizeof(ColorEntry), color_table_compare); if (!entry) { av_log(log_ctx, AV_LOG_ERROR, "Cannot find color '%s'\n", color_string); return -1; } memcpy(rgba_color, entry->rgba_color, 4); } return 0; }


static inline TranslationBlock * tb_find_fast ( CPUArchState * env ) {
 TranslationBlock * tb ;
 target_ulong cs_base , pc ;
 int flags ;
 cpu_get_tb_cpu_state ( env , & pc , & cs_base , & flags ) ;
 tb = env -> tb_jmp_cache [ tb_jmp_cache_hash_func ( pc ) ] ;
 if ( unlikely ( ! tb || tb -> pc != pc || tb -> cs_base != cs_base || tb -> flags != flags ) ) {
 tb = tb_find_slow ( env , pc , cs_base , flags ) ;
 }
 return tb ;
 }


static void audio_init (void) { size_t i; int done = 0; const char *drvname; VMChangeStateEntry *e; AudioState *s = &glob_audio_state; if (s->drv) { return; } QLIST_INIT (&s->hw_head_out); QLIST_INIT (&s->hw_head_in); QLIST_INIT (&s->cap_head); atexit (audio_atexit); s->ts = timer_new_ns(QEMU_CLOCK_VIRTUAL, audio_timer, s); if (!s->ts) { hw_error("Could not create audio timer\n"); } audio_process_options ("AUDIO", audio_options); s->nb_hw_voices_out = conf.fixed_out.nb_voices; s->nb_hw_voices_in = conf.fixed_in.nb_voices; if (s->nb_hw_voices_out <= 0) { dolog ("Bogus number of playback voices %d, setting to 1\n", s->nb_hw_voices_out); s->nb_hw_voices_out = 1; } if (s->nb_hw_voices_in <= 0) { dolog ("Bogus number of capture voices %d, setting to 0\n", s->nb_hw_voices_in); s->nb_hw_voices_in = 0; } { int def; drvname = audio_get_conf_str ("QEMU_AUDIO_DRV", NULL, &def); } if (drvname) { int found = 0; for (i = 0; i < ARRAY_SIZE (drvtab); i++) { if (!strcmp (drvname, drvtab[i]->name)) { done = !audio_driver_init (s, drvtab[i]); found = 1; break; } } if (!found) { dolog ("Unknown audio driver `%s'\n", drvname); dolog ("Run with -audio-help to list available drivers\n"); } } if (!done) { for (i = 0; !done && i < ARRAY_SIZE (drvtab); i++) { if (drvtab[i]->can_be_default) { done = !audio_driver_init (s, drvtab[i]); } } } if (!done) { done = !audio_driver_init (s, &no_audio_driver); if (!done) { hw_error("Could not initialize audio subsystem\n"); } else { dolog ("warning: Using timer based audio emulation\n"); } } if (conf.period.hertz <= 0) { if (conf.period.hertz < 0) { dolog ("warning: Timer period is negative - %d " "treating as zero\n", conf.period.hertz); } conf.period.ticks = 1; } else { conf.period.ticks = muldiv64 (1, get_ticks_per_sec (), conf.period.hertz); } e = qemu_add_vm_change_state_handler (audio_vm_change_state_handler, s); if (!e) { dolog ("warning: Could not register change state handler\n" "(Audio can continue looping even after stopping the VM)\n"); } QLIST_INIT (&s->card_head); vmstate_register (NULL, 0, &vmstate_audio, s); }


static int proc_free_streams ( struct usb_dev_state * ps , void __user * arg ) {
 unsigned num_eps ;
 struct usb_host_endpoint * * eps ;
 struct usb_interface * intf ;
 int r ;
 r = parse_usbdevfs_streams ( ps , arg , NULL , & num_eps , & eps , & intf ) ;
 if ( r ) return r ;
 destroy_async_on_interface ( ps , intf -> altsetting [ 0 ] . desc . bInterfaceNumber ) ;
 r = usb_free_streams ( intf , eps , num_eps , GFP_KERNEL ) ;
 kfree ( eps ) ;
 return r ;
 }