id
stringlengths
22
22
content
stringlengths
75
11.3k
d2a_function_data_5840
static inline int mov_stsc_index_valid(unsigned int index, unsigned int count) { return index < count - 1; }
d2a_function_data_5841
static int jacosub_probe(AVProbeData *p) { const char *ptr = p->buf; const char *ptr_end = p->buf + p->buf_size; if (AV_RB24(ptr) == 0xEFBBBF) ptr += 3; /* skip UTF-8 BOM */ while (ptr < ptr_end) { while (jss_whitespace(*ptr)) ptr++; if (*ptr != '#' && *ptr != '\n') { if (timed_line(ptr)) return AVPROBE_SCORE_EXTENSION + 1; return 0; } ptr += strcspn(ptr, "\n") + 1; } return 0; }
d2a_function_data_5842
static int request_frame(AVFilterLink *outlink) { ShowWavesContext *showwaves = outlink->src->priv; AVFilterLink *inlink = outlink->src->inputs[0]; int ret; ret = ff_request_frame(inlink); if (ret == AVERROR_EOF && showwaves->outpicref) { if (showwaves->single_pic) push_single_pic(outlink); else push_frame(outlink); } return ret; }
d2a_function_data_5843
static void av_noinline filter_mb_edgev( uint8_t *pix, int stride, int16_t bS[4], unsigned int qp, H264Context *h) { const unsigned int index_a = 52 + qp + h->slice_alpha_c0_offset; const int alpha = alpha_table[index_a]; const int beta = (beta_table+52)[qp + h->slice_beta_offset]; if (alpha ==0 || beta == 0) return; if( bS[0] < 4 ) { int8_t tc[4]; tc[0] = tc0_table[index_a][bS[0]]; tc[1] = tc0_table[index_a][bS[1]]; tc[2] = tc0_table[index_a][bS[2]]; tc[3] = tc0_table[index_a][bS[3]]; h->s.dsp.h264_h_loop_filter_luma(pix, stride, alpha, beta, tc); } else { h->s.dsp.h264_h_loop_filter_luma_intra(pix, stride, alpha, beta); } }
d2a_function_data_5844
static void decode_v1_vector(CinepakEncContext *s, AVPicture *sub_pict, int v1_vector, strip_info *info) { int entry_size = s->pix_fmt == AV_PIX_FMT_RGB24 ? 6 : 4; sub_pict->data[0][0] = sub_pict->data[0][1] = sub_pict->data[0][ sub_pict->linesize[0]] = sub_pict->data[0][1+ sub_pict->linesize[0]] = info->v1_codebook[v1_vector*entry_size]; sub_pict->data[0][2] = sub_pict->data[0][3] = sub_pict->data[0][2+ sub_pict->linesize[0]] = sub_pict->data[0][3+ sub_pict->linesize[0]] = info->v1_codebook[v1_vector*entry_size+1]; sub_pict->data[0][2*sub_pict->linesize[0]] = sub_pict->data[0][1+2*sub_pict->linesize[0]] = sub_pict->data[0][ 3*sub_pict->linesize[0]] = sub_pict->data[0][1+3*sub_pict->linesize[0]] = info->v1_codebook[v1_vector*entry_size+2]; sub_pict->data[0][2+2*sub_pict->linesize[0]] = sub_pict->data[0][3+2*sub_pict->linesize[0]] = sub_pict->data[0][2+3*sub_pict->linesize[0]] = sub_pict->data[0][3+3*sub_pict->linesize[0]] = info->v1_codebook[v1_vector*entry_size+3]; if(s->pix_fmt == AV_PIX_FMT_RGB24) { sub_pict->data[1][0] = sub_pict->data[1][1] = sub_pict->data[1][ sub_pict->linesize[1]] = sub_pict->data[1][1+ sub_pict->linesize[1]] = info->v1_codebook[v1_vector*entry_size+4]; sub_pict->data[2][0] = sub_pict->data[2][1] = sub_pict->data[2][ sub_pict->linesize[2]] = sub_pict->data[2][1+ sub_pict->linesize[2]] = info->v1_codebook[v1_vector*entry_size+5]; } }
d2a_function_data_5845
SSL_CTX *SSL_CTX_new(SSL_METHOD *meth) { SSL_CTX *ret=NULL; if (meth == NULL) { SSLerr(SSL_F_SSL_CTX_NEW,SSL_R_NULL_SSL_METHOD_PASSED); return(NULL); } if (SSL_get_ex_data_X509_STORE_CTX_idx() < 0) { SSLerr(SSL_F_SSL_CTX_NEW,SSL_R_X509_VERIFICATION_SETUP_PROBLEMS); goto err; } ret=(SSL_CTX *)OPENSSL_malloc(sizeof(SSL_CTX)); if (ret == NULL) goto err; memset(ret,0,sizeof(SSL_CTX)); ret->method=meth; ret->cert_store=NULL; ret->session_cache_mode=SSL_SESS_CACHE_SERVER; ret->session_cache_size=SSL_SESSION_CACHE_MAX_SIZE_DEFAULT; ret->session_cache_head=NULL; ret->session_cache_tail=NULL; /* We take the system default */ ret->session_timeout=meth->get_timeout(); ret->new_session_cb=NULL; ret->remove_session_cb=NULL; ret->get_session_cb=NULL; ret->generate_session_id=NULL; memset((char *)&ret->stats,0,sizeof(ret->stats)); ret->references=1; ret->quiet_shutdown=0; /* ret->cipher=NULL;*/ /* ret->s2->challenge=NULL; ret->master_key=NULL; ret->key_arg=NULL; ret->s2->conn_id=NULL; */ ret->info_callback=NULL; ret->app_verify_callback=NULL; ret->app_verify_arg=NULL; ret->read_ahead=0; ret->verify_mode=SSL_VERIFY_NONE; ret->verify_depth=-1; /* Don't impose a limit (but x509_lu.c does) */ ret->default_verify_callback=NULL; if ((ret->cert=ssl_cert_new()) == NULL) goto err; ret->default_passwd_callback=NULL; ret->default_passwd_callback_userdata=NULL; ret->client_cert_cb=NULL; ret->sessions=lh_new(LHASH_HASH_FN(SSL_SESSION_hash), LHASH_COMP_FN(SSL_SESSION_cmp)); if (ret->sessions == NULL) goto err; ret->cert_store=X509_STORE_new(); if (ret->cert_store == NULL) goto err; ssl_create_cipher_list(ret->method, &ret->cipher_list,&ret->cipher_list_by_id, SSL_DEFAULT_CIPHER_LIST); if (ret->cipher_list == NULL || sk_SSL_CIPHER_num(ret->cipher_list) <= 0) { SSLerr(SSL_F_SSL_CTX_NEW,SSL_R_LIBRARY_HAS_NO_CIPHERS); goto err2; } if ((ret->rsa_md5=EVP_get_digestbyname("ssl2-md5")) == NULL) { SSLerr(SSL_F_SSL_CTX_NEW,SSL_R_UNABLE_TO_LOAD_SSL2_MD5_ROUTINES); goto err2; } if ((ret->md5=EVP_get_digestbyname("ssl3-md5")) == NULL) { SSLerr(SSL_F_SSL_CTX_NEW,SSL_R_UNABLE_TO_LOAD_SSL3_MD5_ROUTINES); goto err2; } if ((ret->sha1=EVP_get_digestbyname("ssl3-sha1")) == NULL) { SSLerr(SSL_F_SSL_CTX_NEW,SSL_R_UNABLE_TO_LOAD_SSL3_SHA1_ROUTINES); goto err2; } if ((ret->client_CA=sk_X509_NAME_new_null()) == NULL) goto err; CRYPTO_new_ex_data(ssl_ctx_meth,(char *)ret,&ret->ex_data); ret->extra_certs=NULL; ret->comp_methods=SSL_COMP_get_compression_methods(); return(ret); err: SSLerr(SSL_F_SSL_CTX_NEW,ERR_R_MALLOC_FAILURE); err2: if (ret != NULL) SSL_CTX_free(ret); return(NULL); }
d2a_function_data_5846
int ff_psy_init(FFPsyContext *ctx, AVCodecContext *avctx, int num_lens, const uint8_t **bands, const int* num_bands, int num_groups, const uint8_t *group_map) { int i, j, k = 0; ctx->avctx = avctx; ctx->ch = av_mallocz(sizeof(ctx->ch[0]) * avctx->channels * 2); ctx->group = av_mallocz(sizeof(ctx->group[0]) * num_groups); ctx->bands = av_malloc (sizeof(ctx->bands[0]) * num_lens); ctx->num_bands = av_malloc (sizeof(ctx->num_bands[0]) * num_lens); memcpy(ctx->bands, bands, sizeof(ctx->bands[0]) * num_lens); memcpy(ctx->num_bands, num_bands, sizeof(ctx->num_bands[0]) * num_lens); /* assign channels to groups (with virtual channels for coupling) */ for (i = 0; i < num_groups; i++) { /* NOTE: Add 1 to handle the AAC chan_config without modification. * This has the side effect of allowing an array of 0s to map * to one channel per group. */ ctx->group[i].num_ch = group_map[i] + 1; for (j = 0; j < ctx->group[i].num_ch * 2; j++) ctx->group[i].ch[j] = &ctx->ch[k++]; } switch (ctx->avctx->codec_id) { case CODEC_ID_AAC: ctx->model = &ff_aac_psy_model; break; } if (ctx->model->init) return ctx->model->init(ctx); return 0; }
d2a_function_data_5847
apr_status_t ap_core_output_filter(ap_filter_t *f, apr_bucket_brigade *bb) { conn_rec *c = f->c; core_net_rec *net = f->ctx; apr_socket_t *sock = net->client_socket; core_output_filter_ctx_t *ctx = net->out_ctx; apr_interval_time_t sock_timeout = 0; apr_status_t rv; /* Fail quickly if the connection has already been aborted. */ if (c->aborted) { apr_brigade_cleanup(bb); return APR_ECONNABORTED; } if (ctx == NULL) { ctx = apr_pcalloc(c->pool, sizeof(*ctx)); net->out_ctx = (core_output_filter_ctx_t *)ctx; /* * Need to create tmp brigade with correct lifetime. Passing * NULL to apr_brigade_split_ex would result in a brigade * allocated from bb->pool which might be wrong. */ ctx->tmp_flush_bb = apr_brigade_create(c->pool, c->bucket_alloc); } /* remain compatible with legacy MPMs that passed NULL to this filter */ if (bb == NULL) { if (ctx->empty_bb == NULL) { ctx->empty_bb = apr_brigade_create(c->pool, c->bucket_alloc); } bb = ctx->empty_bb; } /* Prepend buckets set aside, if any. */ ap_filter_reinstate_brigade(f, bb, NULL); if (APR_BRIGADE_EMPTY(bb)) { return APR_SUCCESS; } /* Non-blocking writes on the socket in any case. */ apr_socket_timeout_get(sock, &sock_timeout); apr_socket_timeout_set(sock, 0); do { rv = send_brigade_nonblocking(sock, bb, ctx, c); if (APR_STATUS_IS_EAGAIN(rv)) { /* Scan through the brigade and decide whether we must absolutely * flush the remaining data, based on ap_filter_reinstate_brigade() * rules. If so, wait for writability and retry, otherwise we did * our best already and can wait for the next call. */ apr_bucket *flush_upto; ap_filter_reinstate_brigade(f, bb, &flush_upto); if (flush_upto) { apr_int32_t nfd; apr_pollfd_t pfd; memset(&pfd, 0, sizeof(pfd)); pfd.reqevents = APR_POLLOUT; pfd.desc_type = APR_POLL_SOCKET; pfd.desc.s = sock; pfd.p = c->pool; do { rv = apr_poll(&pfd, 1, &nfd, sock_timeout); } while (APR_STATUS_IS_EINTR(rv)); } } } while (rv == APR_SUCCESS && !APR_BRIGADE_EMPTY(bb)); /* Restore original socket timeout before leaving. */ apr_socket_timeout_set(sock, sock_timeout); if (rv != APR_SUCCESS && !APR_STATUS_IS_EAGAIN(rv)) { /* The client has aborted the connection */ ap_log_cerror( APLOG_MARK, APLOG_TRACE1, rv, c, "core_output_filter: writing data to the network"); apr_brigade_cleanup(bb); c->aborted = 1; return rv; } return ap_filter_setaside_brigade(f, bb); }
d2a_function_data_5848
int BN_bn2bin(const BIGNUM *a, unsigned char *to) { int n, i; BN_ULONG l; bn_check_top(a); n = i = BN_num_bytes(a); while (i--) { l = a->d[i / BN_BYTES]; *(to++) = (unsigned char)(l >> (8 * (i % BN_BYTES))) & 0xff; } return (n); }
d2a_function_data_5849
static int readSeparateTilesIntoBuffer (TIFF* in, uint8 *obuf, uint32 imagelength, uint32 imagewidth, uint32 tw, uint32 tl, uint16 spp, uint16 bps) { int i, status = 1, sample; int shift_width, bytes_per_pixel; uint16 bytes_per_sample; uint32 row, col; /* Current row and col of image */ uint32 nrow, ncol; /* Number of rows and cols in current tile */ uint32 row_offset, col_offset; /* Output buffer offsets */ tsize_t tbytes = 0, tilesize = TIFFTileSize(in); tsample_t s; uint8* bufp = (uint8*)obuf; unsigned char *srcbuffs[MAX_SAMPLES]; unsigned char *tbuff = NULL; bytes_per_sample = (bps + 7) / 8; for (sample = 0; (sample < spp) && (sample < MAX_SAMPLES); sample++) { srcbuffs[sample] = NULL; tbuff = (unsigned char *)_TIFFmalloc(tilesize + 8); if (!tbuff) { TIFFError ("readSeparateTilesIntoBuffer", "Unable to allocate tile read buffer for sample %d", sample); for (i = 0; i < sample; i++) _TIFFfree (srcbuffs[i]); return 0; } srcbuffs[sample] = tbuff; } /* Each tile contains only the data for a single plane * arranged in scanlines of tw * bytes_per_sample bytes. */ for (row = 0; row < imagelength; row += tl) { nrow = (row + tl > imagelength) ? imagelength - row : tl; for (col = 0; col < imagewidth; col += tw) { for (s = 0; s < spp && s < MAX_SAMPLES; s++) { /* Read each plane of a tile set into srcbuffs[s] */ tbytes = TIFFReadTile(in, srcbuffs[s], col, row, 0, s); if (tbytes < 0 && !ignore) { TIFFError(TIFFFileName(in), "Error, can't read tile for row %lu col %lu, " "sample %lu", (unsigned long) col, (unsigned long) row, (unsigned long) s); status = 0; for (sample = 0; (sample < spp) && (sample < MAX_SAMPLES); sample++) { tbuff = srcbuffs[sample]; if (tbuff != NULL) _TIFFfree(tbuff); } return status; } } /* Tiles on the right edge may be padded out to tw * which must be a multiple of 16. * Ncol represents the visible (non padding) portion. */ if (col + tw > imagewidth) ncol = imagewidth - col; else ncol = tw; row_offset = row * (((imagewidth * spp * bps) + 7) / 8); col_offset = ((col * spp * bps) + 7) / 8; bufp = obuf + row_offset + col_offset; if ((bps % 8) == 0) { if (combineSeparateTileSamplesBytes(srcbuffs, bufp, ncol, nrow, imagewidth, tw, spp, bps, NULL, 0, 0)) { status = 0; break; } } else { bytes_per_pixel = ((bps * spp) + 7) / 8; if (bytes_per_pixel < (bytes_per_sample + 1)) shift_width = bytes_per_pixel; else shift_width = bytes_per_sample + 1; switch (shift_width) { case 1: if (combineSeparateTileSamples8bits (srcbuffs, bufp, ncol, nrow, imagewidth, tw, spp, bps, NULL, 0, 0)) { status = 0; break; } break; case 2: if (combineSeparateTileSamples16bits (srcbuffs, bufp, ncol, nrow, imagewidth, tw, spp, bps, NULL, 0, 0)) { status = 0; break; } break; case 3: if (combineSeparateTileSamples24bits (srcbuffs, bufp, ncol, nrow, imagewidth, tw, spp, bps, NULL, 0, 0)) { status = 0; break; } break; case 4: case 5: case 6: case 7: case 8: if (combineSeparateTileSamples32bits (srcbuffs, bufp, ncol, nrow, imagewidth, tw, spp, bps, NULL, 0, 0)) { status = 0; break; } break; default: TIFFError ("readSeparateTilesIntoBuffer", "Unsupported bit depth: %d", bps); status = 0; break; } } } } for (sample = 0; (sample < spp) && (sample < MAX_SAMPLES); sample++) { tbuff = srcbuffs[sample]; if (tbuff != NULL) _TIFFfree(tbuff); } return status; }
d2a_function_data_5850
STACK_OF(SSL_CIPHER) *ssl_bytes_to_cipher_list(SSL *s, PACKET *cipher_suites, STACK_OF(SSL_CIPHER) **skp, int sslv2format, int *al) { const SSL_CIPHER *c; STACK_OF(SSL_CIPHER) *sk; int n; /* 3 = SSLV2_CIPHER_LEN > TLS_CIPHER_LEN = 2. */ unsigned char cipher[SSLV2_CIPHER_LEN]; s->s3->send_connection_binding = 0; n = sslv2format ? SSLV2_CIPHER_LEN : TLS_CIPHER_LEN; if (PACKET_remaining(cipher_suites) == 0) { SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, SSL_R_NO_CIPHERS_SPECIFIED); *al = SSL_AD_ILLEGAL_PARAMETER; return NULL; } if (PACKET_remaining(cipher_suites) % n != 0) { SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST); *al = SSL_AD_DECODE_ERROR; return NULL; } sk = sk_SSL_CIPHER_new_null(); if (sk == NULL) { SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, ERR_R_MALLOC_FAILURE); *al = SSL_AD_INTERNAL_ERROR; return NULL; } OPENSSL_free(s->s3->tmp.ciphers_raw); s->s3->tmp.ciphers_raw = NULL; s->s3->tmp.ciphers_rawlen = 0; if (sslv2format) { size_t numciphers = PACKET_remaining(cipher_suites) / n; PACKET sslv2ciphers = *cipher_suites; unsigned int leadbyte; unsigned char *raw; /* * We store the raw ciphers list in SSLv3+ format so we need to do some * preprocessing to convert the list first. If there are any SSLv2 only * ciphersuites with a non-zero leading byte then we are going to * slightly over allocate because we won't store those. But that isn't a * problem. */ raw = OPENSSL_malloc(numciphers * TLS_CIPHER_LEN); s->s3->tmp.ciphers_raw = raw; if (raw == NULL) { *al = SSL_AD_INTERNAL_ERROR; goto err; } for (s->s3->tmp.ciphers_rawlen = 0; PACKET_remaining(&sslv2ciphers) > 0; raw += TLS_CIPHER_LEN) { if (!PACKET_get_1(&sslv2ciphers, &leadbyte) || (leadbyte == 0 && !PACKET_copy_bytes(&sslv2ciphers, raw, TLS_CIPHER_LEN)) || (leadbyte != 0 && !PACKET_forward(&sslv2ciphers, TLS_CIPHER_LEN))) { *al = SSL_AD_INTERNAL_ERROR; OPENSSL_free(s->s3->tmp.ciphers_raw); s->s3->tmp.ciphers_raw = NULL; s->s3->tmp.ciphers_rawlen = 0; goto err; } if (leadbyte == 0) s->s3->tmp.ciphers_rawlen += TLS_CIPHER_LEN; } } else if (!PACKET_memdup(cipher_suites, &s->s3->tmp.ciphers_raw, &s->s3->tmp.ciphers_rawlen)) { *al = SSL_AD_INTERNAL_ERROR; goto err; } while (PACKET_copy_bytes(cipher_suites, cipher, n)) { /* * SSLv3 ciphers wrapped in an SSLv2-compatible ClientHello have the * first byte set to zero, while true SSLv2 ciphers have a non-zero * first byte. We don't support any true SSLv2 ciphers, so skip them. */ if (sslv2format && cipher[0] != '\0') continue; /* Check for TLS_EMPTY_RENEGOTIATION_INFO_SCSV */ if ((cipher[n - 2] == ((SSL3_CK_SCSV >> 8) & 0xff)) && (cipher[n - 1] == (SSL3_CK_SCSV & 0xff))) { /* SCSV fatal if renegotiating */ if (s->renegotiate) { SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, SSL_R_SCSV_RECEIVED_WHEN_RENEGOTIATING); *al = SSL_AD_HANDSHAKE_FAILURE; goto err; } s->s3->send_connection_binding = 1; continue; } /* Check for TLS_FALLBACK_SCSV */ if ((cipher[n - 2] == ((SSL3_CK_FALLBACK_SCSV >> 8) & 0xff)) && (cipher[n - 1] == (SSL3_CK_FALLBACK_SCSV & 0xff))) { /* * The SCSV indicates that the client previously tried a higher * version. Fail if the current version is an unexpected * downgrade. */ if (!ssl_check_version_downgrade(s)) { SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, SSL_R_INAPPROPRIATE_FALLBACK); *al = SSL_AD_INAPPROPRIATE_FALLBACK; goto err; } continue; } /* For SSLv2-compat, ignore leading 0-byte. */ c = ssl_get_cipher_by_char(s, sslv2format ? &cipher[1] : cipher, 0); if (c != NULL) { if (!sk_SSL_CIPHER_push(sk, c)) { SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, ERR_R_MALLOC_FAILURE); *al = SSL_AD_INTERNAL_ERROR; goto err; } } } if (PACKET_remaining(cipher_suites) > 0) { *al = SSL_AD_INTERNAL_ERROR; SSLerr(SSL_F_SSL_BYTES_TO_CIPHER_LIST, ERR_R_INTERNAL_ERROR); goto err; } *skp = sk; return sk; err: sk_SSL_CIPHER_free(sk); return NULL; }
d2a_function_data_5851
static int old_codec37(SANMVideoContext *ctx, int top, int left, int width, int height) { int stride = ctx->pitch; int i, j, k, t; int skip_run = 0; int compr, mvoff, seq, flags; uint32_t decoded_size; uint8_t *dst, *prev; compr = bytestream2_get_byte(&ctx->gb); mvoff = bytestream2_get_byte(&ctx->gb); seq = bytestream2_get_le16(&ctx->gb); decoded_size = bytestream2_get_le32(&ctx->gb); bytestream2_skip(&ctx->gb, 4); flags = bytestream2_get_byte(&ctx->gb); bytestream2_skip(&ctx->gb, 3); if (decoded_size > height * stride - left - top * stride) { decoded_size = height * stride - left - top * stride; av_log(ctx->avctx, AV_LOG_WARNING, "decoded size is too large\n"); } ctx->rotate_code = 0; if (((seq & 1) || !(flags & 1)) && (compr && compr != 2)) rotate_bufs(ctx, 1); dst = ((uint8_t*)ctx->frm0) + left + top * stride; prev = ((uint8_t*)ctx->frm2) + left + top * stride; if (mvoff > 2) { av_log(ctx->avctx, AV_LOG_ERROR, "invalid motion base value %d\n", mvoff); return AVERROR_INVALIDDATA; } av_dlog(ctx->avctx, "compression %d\n", compr); switch (compr) { case 0: for (i = 0; i < height; i++) { bytestream2_get_buffer(&ctx->gb, dst, width); dst += stride; } memset(ctx->frm1, 0, ctx->height * stride); memset(ctx->frm2, 0, ctx->height * stride); break; case 2: if (rle_decode(ctx, dst, decoded_size)) return AVERROR_INVALIDDATA; memset(ctx->frm1, 0, ctx->frm1_size); memset(ctx->frm2, 0, ctx->frm2_size); break; case 3: case 4: if (flags & 4) { for (j = 0; j < height; j += 4) { for (i = 0; i < width; i += 4) { int code; if (skip_run) { skip_run--; copy_block4(dst + i, prev + i, stride, stride, 4); continue; } if (bytestream2_get_bytes_left(&ctx->gb) < 1) return AVERROR_INVALIDDATA; code = bytestream2_get_byteu(&ctx->gb); switch (code) { case 0xFF: if (bytestream2_get_bytes_left(&ctx->gb) < 16) return AVERROR_INVALIDDATA; for (k = 0; k < 4; k++) bytestream2_get_bufferu(&ctx->gb, dst + i + k * stride, 4); break; case 0xFE: if (bytestream2_get_bytes_left(&ctx->gb) < 4) return AVERROR_INVALIDDATA; for (k = 0; k < 4; k++) memset(dst + i + k * stride, bytestream2_get_byteu(&ctx->gb), 4); break; case 0xFD: if (bytestream2_get_bytes_left(&ctx->gb) < 1) return AVERROR_INVALIDDATA; t = bytestream2_get_byteu(&ctx->gb); for (k = 0; k < 4; k++) memset(dst + i + k * stride, t, 4); break; default: if (compr == 4 && !code) { if (bytestream2_get_bytes_left(&ctx->gb) < 1) return AVERROR_INVALIDDATA; skip_run = bytestream2_get_byteu(&ctx->gb) + 1; i -= 4; } else { int mx, my; mx = c37_mv[(mvoff * 255 + code) * 2 ]; my = c37_mv[(mvoff * 255 + code) * 2 + 1]; codec37_mv(dst + i, prev + i + mx + my * stride, ctx->height, stride, i + mx, j + my); } } } dst += stride * 4; prev += stride * 4; } } else { for (j = 0; j < height; j += 4) { for (i = 0; i < width; i += 4) { int code; if (skip_run) { skip_run--; copy_block4(dst + i, prev + i, stride, stride, 4); continue; } code = bytestream2_get_byte(&ctx->gb); if (code == 0xFF) { if (bytestream2_get_bytes_left(&ctx->gb) < 16) return AVERROR_INVALIDDATA; for (k = 0; k < 4; k++) bytestream2_get_bufferu(&ctx->gb, dst + i + k * stride, 4); } else if (compr == 4 && !code) { if (bytestream2_get_bytes_left(&ctx->gb) < 1) return AVERROR_INVALIDDATA; skip_run = bytestream2_get_byteu(&ctx->gb) + 1; i -= 4; } else { int mx, my; mx = c37_mv[(mvoff * 255 + code) * 2]; my = c37_mv[(mvoff * 255 + code) * 2 + 1]; codec37_mv(dst + i, prev + i + mx + my * stride, ctx->height, stride, i + mx, j + my); } } dst += stride * 4; prev += stride * 4; } } break; default: av_log(ctx->avctx, AV_LOG_ERROR, "subcodec 37 compression %d not implemented\n", compr); return AVERROR_PATCHWELCOME; } return 0; }
d2a_function_data_5852
char *av_strdup(const char *s) { char *ptr = NULL; if (s) { int len = strlen(s) + 1; ptr = av_malloc(len); if (ptr) memcpy(ptr, s, len); } return ptr; }
d2a_function_data_5853
static void x509v3_cache_extensions(X509 *x) { BASIC_CONSTRAINTS *bs; PROXY_CERT_INFO_EXTENSION *pci; ASN1_BIT_STRING *usage; ASN1_BIT_STRING *ns; EXTENDED_KEY_USAGE *extusage; X509_EXTENSION *ex; int i; if(x->ex_flags & EXFLAG_SET) return; #ifndef OPENSSL_NO_SHA X509_digest(x, EVP_sha1(), x->sha1_hash, NULL); #endif /* Does subject name match issuer ? */ if(!X509_NAME_cmp(X509_get_subject_name(x), X509_get_issuer_name(x))) x->ex_flags |= EXFLAG_SI; /* V1 should mean no extensions ... */ if(!X509_get_version(x)) x->ex_flags |= EXFLAG_V1; /* Handle basic constraints */ if((bs=X509_get_ext_d2i(x, NID_basic_constraints, NULL, NULL))) { if(bs->ca) x->ex_flags |= EXFLAG_CA; if(bs->pathlen) { if((bs->pathlen->type == V_ASN1_NEG_INTEGER) || !bs->ca) { x->ex_flags |= EXFLAG_INVALID; x->ex_pathlen = 0; } else x->ex_pathlen = ASN1_INTEGER_get(bs->pathlen); } else x->ex_pathlen = -1; BASIC_CONSTRAINTS_free(bs); x->ex_flags |= EXFLAG_BCONS; } /* Handle proxy certificates */ if((pci=X509_get_ext_d2i(x, NID_proxyCertInfo, NULL, NULL))) { if (x->ex_flags & EXFLAG_CA || X509_get_ext_by_NID(x, NID_subject_alt_name, 0) >= 0 || X509_get_ext_by_NID(x, NID_issuer_alt_name, 0) >= 0) { x->ex_flags |= EXFLAG_INVALID; } if (pci->pcPathLengthConstraint) { x->ex_pcpathlen = ASN1_INTEGER_get(pci->pcPathLengthConstraint); } else x->ex_pcpathlen = -1; PROXY_CERT_INFO_EXTENSION_free(pci); x->ex_flags |= EXFLAG_PROXY; } /* Handle key usage */ if((usage=X509_get_ext_d2i(x, NID_key_usage, NULL, NULL))) { if(usage->length > 0) { x->ex_kusage = usage->data[0]; if(usage->length > 1) x->ex_kusage |= usage->data[1] << 8; } else x->ex_kusage = 0; x->ex_flags |= EXFLAG_KUSAGE; ASN1_BIT_STRING_free(usage); } x->ex_xkusage = 0; if((extusage=X509_get_ext_d2i(x, NID_ext_key_usage, NULL, NULL))) { x->ex_flags |= EXFLAG_XKUSAGE; for(i = 0; i < sk_ASN1_OBJECT_num(extusage); i++) { switch(OBJ_obj2nid(sk_ASN1_OBJECT_value(extusage,i))) { case NID_server_auth: x->ex_xkusage |= XKU_SSL_SERVER; break; case NID_client_auth: x->ex_xkusage |= XKU_SSL_CLIENT; break; case NID_email_protect: x->ex_xkusage |= XKU_SMIME; break; case NID_code_sign: x->ex_xkusage |= XKU_CODE_SIGN; break; case NID_ms_sgc: case NID_ns_sgc: x->ex_xkusage |= XKU_SGC; break; case NID_OCSP_sign: x->ex_xkusage |= XKU_OCSP_SIGN; break; case NID_time_stamp: x->ex_xkusage |= XKU_TIMESTAMP; break; case NID_dvcs: x->ex_xkusage |= XKU_DVCS; break; } } sk_ASN1_OBJECT_pop_free(extusage, ASN1_OBJECT_free); } if((ns=X509_get_ext_d2i(x, NID_netscape_cert_type, NULL, NULL))) { if(ns->length > 0) x->ex_nscert = ns->data[0]; else x->ex_nscert = 0; x->ex_flags |= EXFLAG_NSCERT; ASN1_BIT_STRING_free(ns); } x->skid =X509_get_ext_d2i(x, NID_subject_key_identifier, NULL, NULL); x->akid =X509_get_ext_d2i(x, NID_authority_key_identifier, NULL, NULL); x->crldp = X509_get_ext_d2i(x, NID_crl_distribution_points, NULL, NULL); #ifndef OPENSSL_NO_RFC3779 x->rfc3779_addr =X509_get_ext_d2i(x, NID_sbgp_ipAddrBlock, NULL, NULL); x->rfc3779_asid =X509_get_ext_d2i(x, NID_sbgp_autonomousSysNum, NULL, NULL); #endif for (i = 0; i < X509_get_ext_count(x); i++) { ex = X509_get_ext(x, i); if (!X509_EXTENSION_get_critical(ex)) continue; if (!X509_supported_extension(ex)) { x->ex_flags |= EXFLAG_CRITICAL; break; } } x->ex_flags |= EXFLAG_SET; }
d2a_function_data_5854
int avfilter_open(AVFilterContext **filter_ctx, AVFilter *filter, const char *inst_name) { AVFilterContext *ret; *filter_ctx = NULL; if (!filter) return AVERROR(EINVAL); ret = av_mallocz(sizeof(AVFilterContext)); if (!ret) return AVERROR(ENOMEM); ret->av_class = &avfilter_class; ret->filter = filter; ret->name = inst_name ? av_strdup(inst_name) : NULL; if (filter->priv_size) { ret->priv = av_mallocz(filter->priv_size); if (!ret->priv) goto err; } ret->input_count = pad_count(filter->inputs); if (ret->input_count) { ret->input_pads = av_malloc(sizeof(AVFilterPad) * ret->input_count); if (!ret->input_pads) goto err; memcpy(ret->input_pads, filter->inputs, sizeof(AVFilterPad) * ret->input_count); ret->inputs = av_mallocz(sizeof(AVFilterLink*) * ret->input_count); if (!ret->inputs) goto err; } ret->output_count = pad_count(filter->outputs); if (ret->output_count) { ret->output_pads = av_malloc(sizeof(AVFilterPad) * ret->output_count); if (!ret->output_pads) goto err; memcpy(ret->output_pads, filter->outputs, sizeof(AVFilterPad) * ret->output_count); ret->outputs = av_mallocz(sizeof(AVFilterLink*) * ret->output_count); if (!ret->outputs) goto err; } *filter_ctx = ret; return 0; err: av_freep(&ret->inputs); av_freep(&ret->input_pads); ret->input_count = 0; av_freep(&ret->outputs); av_freep(&ret->output_pads); ret->output_count = 0; av_freep(&ret->priv); av_free(ret); return AVERROR(ENOMEM); }
d2a_function_data_5855
static int resample(ResampleContext *c, void *dst, const void *src, int *consumed, int src_size, int dst_size, int update_ctx, int nearest_neighbour) { int dst_index; int index = c->index; int frac = c->frac; int dst_incr_frac = c->dst_incr % c->src_incr; int dst_incr = c->dst_incr / c->src_incr; int compensation_distance = c->compensation_distance; if (!dst != !src) return AVERROR(EINVAL); if (nearest_neighbour) { int64_t index2 = ((int64_t)index) << 32; int64_t incr = (1LL << 32) * c->dst_incr / c->src_incr; dst_size = FFMIN(dst_size, (src_size-1-index) * (int64_t)c->src_incr / c->dst_incr); if (dst) { for(dst_index = 0; dst_index < dst_size; dst_index++) { c->resample_nearest(dst, dst_index, src, index2 >> 32); index2 += incr; } } else { dst_index = dst_size; } index += dst_index * dst_incr; index += (frac + dst_index * (int64_t)dst_incr_frac) / c->src_incr; frac = (frac + dst_index * (int64_t)dst_incr_frac) % c->src_incr; } else { for (dst_index = 0; dst_index < dst_size; dst_index++) { int sample_index = index >> c->phase_shift; if (sample_index + c->filter_length > src_size || -sample_index >= src_size) break; if (dst) c->resample_one(c, dst, dst_index, src, src_size, index, frac); frac += dst_incr_frac; index += dst_incr; if (frac >= c->src_incr) { frac -= c->src_incr; index++; } if (dst_index + 1 == compensation_distance) { compensation_distance = 0; dst_incr_frac = c->ideal_dst_incr % c->src_incr; dst_incr = c->ideal_dst_incr / c->src_incr; } } } if (consumed) *consumed = FFMAX(index, 0) >> c->phase_shift; if (update_ctx) { if (index >= 0) index &= c->phase_mask; if (compensation_distance) { compensation_distance -= dst_index; if (compensation_distance <= 0) return AVERROR_BUG; } c->frac = frac; c->index = index; c->dst_incr = dst_incr_frac + c->src_incr*dst_incr; c->compensation_distance = compensation_distance; } return dst_index; }
d2a_function_data_5856
static int hls_mux_init(AVFormatContext *s) { HLSContext *hls = s->priv_data; AVFormatContext *oc; AVFormatContext *vtt_oc = NULL; int i, ret; ret = avformat_alloc_output_context2(&hls->avf, hls->oformat, NULL, NULL); if (ret < 0) return ret; oc = hls->avf; oc->oformat = hls->oformat; oc->interrupt_callback = s->interrupt_callback; oc->max_delay = s->max_delay; av_dict_copy(&oc->metadata, s->metadata, 0); if(hls->vtt_oformat) { ret = avformat_alloc_output_context2(&hls->vtt_avf, hls->vtt_oformat, NULL, NULL); if (ret < 0) return ret; vtt_oc = hls->vtt_avf; vtt_oc->oformat = hls->vtt_oformat; av_dict_copy(&vtt_oc->metadata, s->metadata, 0); } for (i = 0; i < s->nb_streams; i++) { AVStream *st; AVFormatContext *loc; if (s->streams[i]->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) loc = vtt_oc; else loc = oc; if (!(st = avformat_new_stream(loc, NULL))) return AVERROR(ENOMEM); avcodec_copy_context(st->codec, s->streams[i]->codec); st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio; st->time_base = s->streams[i]->time_base; } hls->start_pos = 0; return 0; }
d2a_function_data_5857
static int hls_read_packet(AVFormatContext *s, AVPacket *pkt) { HLSContext *c = s->priv_data; int ret, i, minvariant = -1; if (c->first_packet) { recheck_discard_flags(s, 1); c->first_packet = 0; } start: c->end_of_segment = 0; for (i = 0; i < c->n_variants; i++) { struct variant *var = c->variants[i]; /* Make sure we've got one buffered packet from each open variant * stream */ if (var->needed && !var->pkt.data) { while (1) { int64_t ts_diff; AVStream *st; ret = av_read_frame(var->ctx, &var->pkt); if (ret < 0) { if (!var->pb.eof_reached) return ret; reset_packet(&var->pkt); break; } else { if (c->first_timestamp == AV_NOPTS_VALUE) c->first_timestamp = var->pkt.dts; } if (c->seek_timestamp == AV_NOPTS_VALUE) break; if (var->pkt.dts == AV_NOPTS_VALUE) { c->seek_timestamp = AV_NOPTS_VALUE; break; } st = var->ctx->streams[var->pkt.stream_index]; ts_diff = av_rescale_rnd(var->pkt.dts, AV_TIME_BASE, st->time_base.den, AV_ROUND_DOWN) - c->seek_timestamp; if (ts_diff >= 0 && (c->seek_flags & AVSEEK_FLAG_ANY || var->pkt.flags & AV_PKT_FLAG_KEY)) { c->seek_timestamp = AV_NOPTS_VALUE; break; } } } /* Check if this stream has the packet with the lowest dts */ if (var->pkt.data) { if (minvariant < 0 || var->pkt.dts < c->variants[minvariant]->pkt.dts) minvariant = i; } } if (c->end_of_segment) { if (recheck_discard_flags(s, 0)) goto start; } /* If we got a packet, return it */ if (minvariant >= 0) { *pkt = c->variants[minvariant]->pkt; pkt->stream_index += c->variants[minvariant]->stream_offset; reset_packet(&c->variants[minvariant]->pkt); return 0; } return AVERROR_EOF; }