id
stringlengths 22
22
| content
stringlengths 75
11.3k
|
|---|---|
d2a_function_data_5240
|
static int64_t wrap_timestamp(AVStream *st, int64_t timestamp)
{
if (st->pts_wrap_behavior != AV_PTS_WRAP_IGNORE && st->pts_wrap_bits < 64 &&
st->pts_wrap_reference != AV_NOPTS_VALUE && timestamp != AV_NOPTS_VALUE) {
if (st->pts_wrap_behavior == AV_PTS_WRAP_ADD_OFFSET &&
timestamp < st->pts_wrap_reference)
return timestamp + (1ULL<<st->pts_wrap_bits);
else if (st->pts_wrap_behavior == AV_PTS_WRAP_SUB_OFFSET &&
timestamp >= st->pts_wrap_reference)
return timestamp - (1ULL<<st->pts_wrap_bits);
}
return timestamp;
}
|
d2a_function_data_5241
|
void
ngx_rbtree_insert_timer_value(ngx_rbtree_node_t *temp, ngx_rbtree_node_t *node,
ngx_rbtree_node_t *sentinel)
{
ngx_rbtree_node_t **p;
for ( ;; ) {
/*
* Timer values
* 1) are spread in small range, usually several minutes,
* 2) and overflow each 49 days, if milliseconds are stored in 32 bits.
* The comparison takes into account that overflow.
*/
/* node->key < temp->key */
p = ((ngx_rbtree_key_int_t) node->key - (ngx_rbtree_key_int_t) temp->key
< 0)
? &temp->left : &temp->right;
if (*p == sentinel) {
break;
}
temp = *p;
}
*p = node;
node->parent = temp;
node->left = sentinel;
node->right = sentinel;
ngx_rbt_red(node);
}
|
d2a_function_data_5242
|
static int check_pkt(AVFormatContext *s, AVPacket *pkt)
{
MOVMuxContext *mov = s->priv_data;
MOVTrack *trk = &mov->tracks[pkt->stream_index];
int64_t ref;
uint64_t duration;
if (trk->entry) {
ref = trk->cluster[trk->entry - 1].dts;
} else if (trk->start_dts != AV_NOPTS_VALUE) {
ref = trk->start_dts + trk->track_duration;
} else
ref = pkt->dts; // Skip tests for the first packet
duration = pkt->dts - ref;
if (pkt->dts < ref || duration >= INT_MAX) {
av_log(s, AV_LOG_ERROR, "Application provided duration: %"PRId64" / timestamp: %"PRId64" is out of range for mov/mp4 format\n",
duration, pkt->dts
);
pkt->dts = ref + 1;
pkt->pts = AV_NOPTS_VALUE;
}
if (pkt->duration < 0 || pkt->duration > INT_MAX) {
av_log(s, AV_LOG_ERROR, "Application provided duration: %"PRId64" is invalid\n", pkt->duration);
return AVERROR(EINVAL);
}
return 0;
}
|
d2a_function_data_5243
|
int SSL_early_get1_extensions_present(SSL *s, int **out, size_t *outlen)
{
RAW_EXTENSION *ext;
int *present;
size_t num = 0, i;
if (s->clienthello == NULL || out == NULL || outlen == NULL)
return 0;
for (i = 0; i < s->clienthello->pre_proc_exts_len; i++) {
ext = s->clienthello->pre_proc_exts + i;
if (ext->present)
num++;
}
present = OPENSSL_malloc(sizeof(*present) * num);
if (present == NULL)
return 0;
for (i = 0; i < s->clienthello->pre_proc_exts_len; i++) {
ext = s->clienthello->pre_proc_exts + i;
if (ext->present) {
if (ext->received_order >= num)
goto err;
present[ext->received_order] = ext->type;
}
}
*out = present;
*outlen = num;
return 1;
err:
OPENSSL_free(present);
return 0;
}
|
d2a_function_data_5244
|
static int generate_codebook(RoqContext *enc, RoqTempdata *tempdata,
int *points, int inputCount, roq_cell *results,
int size, int cbsize)
{
int i, j, k, ret = 0;
int c_size = size*size/4;
int *buf;
int *codebook = av_malloc(6*c_size*cbsize*sizeof(int));
int *closest_cb;
if (!codebook)
return AVERROR(ENOMEM);
if (size == 4) {
closest_cb = av_malloc(6*c_size*inputCount*sizeof(int));
if (!closest_cb) {
ret = AVERROR(ENOMEM);
goto out;
}
} else
closest_cb = tempdata->closest_cb2;
ret = ff_init_elbg(points, 6 * c_size, inputCount, codebook,
cbsize, 1, closest_cb, &enc->randctx);
if (ret < 0)
goto out;
ret = ff_do_elbg(points, 6 * c_size, inputCount, codebook,
cbsize, 1, closest_cb, &enc->randctx);
if (ret < 0)
goto out;
buf = codebook;
for (i=0; i<cbsize; i++)
for (k=0; k<c_size; k++) {
for(j=0; j<4; j++)
results->y[j] = *buf++;
results->u = (*buf++ + CHROMA_BIAS/2)/CHROMA_BIAS;
results->v = (*buf++ + CHROMA_BIAS/2)/CHROMA_BIAS;
results++;
}
out:
if (size == 4)
av_free(closest_cb);
av_free(codebook);
return ret;
}
|
d2a_function_data_5245
|
static apr_status_t store_headers(cache_handle_t *h, request_rec *r,
cache_info *info)
{
cache_socache_dir_conf *dconf =
ap_get_module_config(r->per_dir_config, &cache_socache_module);
cache_socache_conf *conf = ap_get_module_config(r->server->module_config,
&cache_socache_module);
apr_size_t slider;
apr_status_t rv;
cache_object_t *obj = h->cache_obj;
cache_socache_object_t *sobj = (cache_socache_object_t*) obj->vobj;
cache_socache_info_t *socache_info;
memcpy(&h->cache_obj->info, info, sizeof(cache_info));
if (r->headers_out) {
sobj->headers_out = ap_cache_cacheable_headers_out(r);
}
if (r->headers_in) {
sobj->headers_in = ap_cache_cacheable_headers_in(r);
}
sobj->expire
= obj->info.expire > r->request_time + dconf->maxtime ? r->request_time
+ dconf->maxtime
: obj->info.expire + dconf->mintime;
apr_pool_create(&sobj->pool, r->pool);
sobj->buffer = apr_palloc(sobj->pool, dconf->max);
sobj->buffer_len = dconf->max;
socache_info = (cache_socache_info_t *) sobj->buffer;
if (sobj->headers_out) {
const char *vary;
vary = apr_table_get(sobj->headers_out, "Vary");
if (vary) {
apr_array_header_t* varray;
apr_uint32_t format = CACHE_SOCACHE_VARY_FORMAT_VERSION;
memcpy(sobj->buffer, &format, sizeof(format));
slider = sizeof(format);
memcpy(sobj->buffer + slider, &obj->info.expire,
sizeof(obj->info.expire));
slider += sizeof(obj->info.expire);
varray = apr_array_make(r->pool, 6, sizeof(char*));
tokens_to_array(r->pool, vary, varray);
if (APR_SUCCESS != (rv = store_array(varray, sobj->buffer,
sobj->buffer_len, &slider))) {
ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, APLOGNO(02370)
"buffer too small for Vary array, caching aborted: %s",
obj->key);
apr_pool_destroy(sobj->pool);
sobj->pool = NULL;
return rv;
}
if (socache_mutex) {
apr_status_t status = apr_global_mutex_lock(socache_mutex);
if (status != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, APLOGNO(02371)
"could not acquire lock, ignoring: %s", obj->key);
apr_pool_destroy(sobj->pool);
sobj->pool = NULL;
return status;
}
}
rv = conf->provider->socache_provider->store(
conf->provider->socache_instance, r->server,
(unsigned char *) obj->key, strlen(obj->key), sobj->expire,
(unsigned char *) sobj->buffer, (unsigned int) slider,
sobj->pool);
if (socache_mutex) {
apr_status_t status = apr_global_mutex_unlock(socache_mutex);
if (status != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, APLOGNO(02372)
"could not release lock, ignoring: %s", obj->key);
}
}
if (rv != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r, APLOGNO(02373)
"Vary not written to cache, ignoring: %s", obj->key);
apr_pool_destroy(sobj->pool);
sobj->pool = NULL;
return rv;
}
obj->key = sobj->key = regen_key(r->pool, sobj->headers_in, varray,
sobj->name);
}
}
socache_info->format = CACHE_SOCACHE_DISK_FORMAT_VERSION;
socache_info->date = obj->info.date;
socache_info->expire = obj->info.expire;
socache_info->entity_version = sobj->socache_info.entity_version++;
socache_info->request_time = obj->info.request_time;
socache_info->response_time = obj->info.response_time;
socache_info->status = obj->info.status;
if (r->header_only && r->status != HTTP_NOT_MODIFIED) {
socache_info->header_only = 1;
}
else {
socache_info->header_only = sobj->socache_info.header_only;
}
socache_info->name_len = strlen(sobj->name);
memcpy(&socache_info->control, &obj->info.control, sizeof(cache_control_t));
slider = sizeof(cache_socache_info_t);
if (slider + socache_info->name_len >= sobj->buffer_len) {
ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, APLOGNO(02374)
"cache buffer too small for name: %s",
sobj->name);
apr_pool_destroy(sobj->pool);
sobj->pool = NULL;
return APR_EGENERAL;
}
memcpy(sobj->buffer + slider, sobj->name, socache_info->name_len);
slider += socache_info->name_len;
if (sobj->headers_out) {
if (APR_SUCCESS != store_table(sobj->headers_out, sobj->buffer,
sobj->buffer_len, &slider)) {
ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, APLOGNO(02375)
"out-headers didn't fit in buffer: %s", sobj->name);
apr_pool_destroy(sobj->pool);
sobj->pool = NULL;
return APR_EGENERAL;
}
}
/* Parse the vary header and dump those fields from the headers_in. */
/* TODO: Make call to the same thing cache_select calls to crack Vary. */
if (sobj->headers_in) {
if (APR_SUCCESS != store_table(sobj->headers_in, sobj->buffer,
sobj->buffer_len, &slider)) {
ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, APLOGNO(02376)
"in-headers didn't fit in buffer %s",
sobj->key);
apr_pool_destroy(sobj->pool);
sobj->pool = NULL;
return APR_EGENERAL;
}
}
sobj->body_offset = slider;
return APR_SUCCESS;
}
|
d2a_function_data_5246
|
int cmdutils_read_file(const char *filename, char **bufptr, size_t *size)
{
int ret;
FILE *f = fopen(filename, "rb");
if (!f) {
av_log(NULL, AV_LOG_ERROR, "Cannot read file '%s': %s\n", filename,
strerror(errno));
return AVERROR(errno);
}
fseek(f, 0, SEEK_END);
*size = ftell(f);
fseek(f, 0, SEEK_SET);
*bufptr = av_malloc(*size + 1);
if (!*bufptr) {
av_log(NULL, AV_LOG_ERROR, "Could not allocate file buffer\n");
fclose(f);
return AVERROR(ENOMEM);
}
ret = fread(*bufptr, 1, *size, f);
if (ret < *size) {
av_free(*bufptr);
if (ferror(f)) {
av_log(NULL, AV_LOG_ERROR, "Error while reading file '%s': %s\n",
filename, strerror(errno));
ret = AVERROR(errno);
} else
ret = AVERROR_EOF;
} else {
ret = 0;
(*bufptr)[(*size)++] = '\0';
}
fclose(f);
return ret;
}
|
d2a_function_data_5247
|
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
{
void **p = ptr;
if (min_size < *size)
return;
min_size= FFMAX(17*min_size/16 + 32, min_size);
av_free(*p);
*p = av_malloc(min_size);
if (!*p) min_size = 0;
*size= min_size;
}
|
d2a_function_data_5248
|
static int decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
FourXContext * const f = avctx->priv_data;
AVFrame *picture = data;
AVFrame *p, temp;
int i, frame_4cc, frame_size;
frame_4cc= AV_RL32(buf);
if(buf_size != AV_RL32(buf+4)+8 || buf_size < 20){
av_log(f->avctx, AV_LOG_ERROR, "size mismatch %d %d\n", buf_size, AV_RL32(buf+4));
}
if(frame_4cc == AV_RL32("cfrm")){
int free_index=-1;
const int data_size= buf_size - 20;
const int id= AV_RL32(buf+12);
const int whole_size= AV_RL32(buf+16);
CFrameBuffer *cfrm;
for(i=0; i<CFRAME_BUFFER_COUNT; i++){
if(f->cfrm[i].id && f->cfrm[i].id < avctx->frame_number)
av_log(f->avctx, AV_LOG_ERROR, "lost c frame %d\n", f->cfrm[i].id);
}
for(i=0; i<CFRAME_BUFFER_COUNT; i++){
if(f->cfrm[i].id == id) break;
if(f->cfrm[i].size == 0 ) free_index= i;
}
if(i>=CFRAME_BUFFER_COUNT){
i= free_index;
f->cfrm[i].id= id;
}
cfrm= &f->cfrm[i];
cfrm->data= av_fast_realloc(cfrm->data, &cfrm->allocated_size, cfrm->size + data_size + FF_INPUT_BUFFER_PADDING_SIZE);
if(!cfrm->data){ //explicit check needed as memcpy below might not catch a NULL
av_log(f->avctx, AV_LOG_ERROR, "realloc falure");
return -1;
}
memcpy(cfrm->data + cfrm->size, buf+20, data_size);
cfrm->size += data_size;
if(cfrm->size >= whole_size){
buf= cfrm->data;
frame_size= cfrm->size;
if(id != avctx->frame_number){
av_log(f->avctx, AV_LOG_ERROR, "cframe id mismatch %d %d\n", id, avctx->frame_number);
}
cfrm->size= cfrm->id= 0;
frame_4cc= AV_RL32("pfrm");
}else
return buf_size;
}else{
buf= buf + 12;
frame_size= buf_size - 12;
}
temp= f->current_picture;
f->current_picture= f->last_picture;
f->last_picture= temp;
p= &f->current_picture;
avctx->coded_frame= p;
avctx->flags |= CODEC_FLAG_EMU_EDGE; // alternatively we would have to use our own buffer management
p->reference= 1;
if (avctx->reget_buffer(avctx, p) < 0) {
av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
return -1;
}
if(frame_4cc == AV_RL32("ifr2")){
p->pict_type= AV_PICTURE_TYPE_I;
if(decode_i2_frame(f, buf-4, frame_size) < 0)
return -1;
}else if(frame_4cc == AV_RL32("ifrm")){
p->pict_type= AV_PICTURE_TYPE_I;
if(decode_i_frame(f, buf, frame_size) < 0)
return -1;
}else if(frame_4cc == AV_RL32("pfrm") || frame_4cc == AV_RL32("pfr2")){
if(!f->last_picture.data[0]){
f->last_picture.reference= 1;
if(avctx->get_buffer(avctx, &f->last_picture) < 0){
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
}
p->pict_type= AV_PICTURE_TYPE_P;
if(decode_p_frame(f, buf, frame_size) < 0)
return -1;
}else if(frame_4cc == AV_RL32("snd_")){
av_log(avctx, AV_LOG_ERROR, "ignoring snd_ chunk length:%d\n", buf_size);
}else{
av_log(avctx, AV_LOG_ERROR, "ignoring unknown chunk length:%d\n", buf_size);
}
p->key_frame= p->pict_type == AV_PICTURE_TYPE_I;
*picture= *p;
*data_size = sizeof(AVPicture);
emms_c();
return buf_size;
}
|
d2a_function_data_5249
|
static int query_formats(AVFilterGraph *graph, AVClass *log_ctx)
{
int i, j, ret;
int scaler_count = 0, resampler_count = 0;
for (j = 0; j < 2; j++) {
/* ask all the sub-filters for their supported media formats */
for (i = 0; i < graph->nb_filters; i++) {
/* Call query_formats on sources first.
This is a temporary workaround for amerge,
until format renegociation is implemented. */
if (!graph->filters[i]->nb_inputs == j)
continue;
if (graph->filters[i]->filter->query_formats)
ret = filter_query_formats(graph->filters[i]);
else
ret = ff_default_query_formats(graph->filters[i]);
if (ret < 0)
return ret;
}
}
/* go through and merge as many format lists as possible */
for (i = 0; i < graph->nb_filters; i++) {
AVFilterContext *filter = graph->filters[i];
for (j = 0; j < filter->nb_inputs; j++) {
AVFilterLink *link = filter->inputs[j];
int convert_needed = 0;
if (!link)
continue;
if (link->in_formats != link->out_formats &&
!ff_merge_formats(link->in_formats, link->out_formats,
link->type))
convert_needed = 1;
if (link->type == AVMEDIA_TYPE_AUDIO) {
if (link->in_channel_layouts != link->out_channel_layouts &&
!ff_merge_channel_layouts(link->in_channel_layouts,
link->out_channel_layouts))
convert_needed = 1;
if (link->in_samplerates != link->out_samplerates &&
!ff_merge_samplerates(link->in_samplerates,
link->out_samplerates))
convert_needed = 1;
}
if (convert_needed) {
AVFilterContext *convert;
AVFilter *filter;
AVFilterLink *inlink, *outlink;
char scale_args[256];
char inst_name[30];
/* couldn't merge format lists. auto-insert conversion filter */
switch (link->type) {
case AVMEDIA_TYPE_VIDEO:
if (!(filter = avfilter_get_by_name("scale"))) {
av_log(log_ctx, AV_LOG_ERROR, "'scale' filter "
"not present, cannot convert pixel formats.\n");
return AVERROR(EINVAL);
}
snprintf(inst_name, sizeof(inst_name), "auto-inserted scaler %d",
scaler_count++);
if (graph->scale_sws_opts)
snprintf(scale_args, sizeof(scale_args), "0:0:%s", graph->scale_sws_opts);
else
snprintf(scale_args, sizeof(scale_args), "0:0");
if ((ret = avfilter_graph_create_filter(&convert, filter,
inst_name, scale_args, NULL,
graph)) < 0)
return ret;
break;
case AVMEDIA_TYPE_AUDIO:
if (!(filter = avfilter_get_by_name("aresample"))) {
av_log(log_ctx, AV_LOG_ERROR, "'aresample' filter "
"not present, cannot convert audio formats.\n");
return AVERROR(EINVAL);
}
snprintf(inst_name, sizeof(inst_name), "auto-inserted resampler %d",
resampler_count++);
scale_args[0] = '\0';
if (graph->aresample_swr_opts)
snprintf(scale_args, sizeof(scale_args), "%s",
graph->aresample_swr_opts);
if ((ret = avfilter_graph_create_filter(&convert, filter,
inst_name, graph->aresample_swr_opts,
NULL, graph)) < 0)
return ret;
break;
default:
return AVERROR(EINVAL);
}
if ((ret = avfilter_insert_filter(link, convert, 0, 0)) < 0)
return ret;
filter_query_formats(convert);
inlink = convert->inputs[0];
outlink = convert->outputs[0];
if (!ff_merge_formats( inlink->in_formats, inlink->out_formats, inlink->type) ||
!ff_merge_formats(outlink->in_formats, outlink->out_formats, outlink->type))
ret |= AVERROR(ENOSYS);
if (inlink->type == AVMEDIA_TYPE_AUDIO &&
(!ff_merge_samplerates(inlink->in_samplerates,
inlink->out_samplerates) ||
!ff_merge_channel_layouts(inlink->in_channel_layouts,
inlink->out_channel_layouts)))
ret |= AVERROR(ENOSYS);
if (outlink->type == AVMEDIA_TYPE_AUDIO &&
(!ff_merge_samplerates(outlink->in_samplerates,
outlink->out_samplerates) ||
!ff_merge_channel_layouts(outlink->in_channel_layouts,
outlink->out_channel_layouts)))
ret |= AVERROR(ENOSYS);
if (ret < 0) {
av_log(log_ctx, AV_LOG_ERROR,
"Impossible to convert between the formats supported by the filter "
"'%s' and the filter '%s'\n", link->src->name, link->dst->name);
return ret;
}
}
}
}
return 0;
}
|
d2a_function_data_5250
|
static ngx_inline uint32_t
ngx_crc32_short(u_char *p, size_t len)
{
u_char c;
uint32_t crc;
crc = 0xffffffff;
while (len--) {
c = *p++;
crc = ngx_crc32_table_short[(crc ^ (c & 0xf)) & 0xf] ^ (crc >> 4);
crc = ngx_crc32_table_short[(crc ^ (c >> 4)) & 0xf] ^ (crc >> 4);
}
return crc ^ 0xffffffff;
}
|
d2a_function_data_5251
|
void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
{
if (min_size < *size)
return ptr;
min_size = FFMAX(17 * min_size / 16 + 32, min_size);
ptr = av_realloc(ptr, min_size);
/* we could set this to the unmodified min_size but this is safer
* if the user lost the ptr and uses NULL now
*/
if (!ptr)
min_size = 0;
*size = min_size;
return ptr;
}
|
d2a_function_data_5252
|
unsigned char *next_protos_parse(unsigned short *outlen, const char *in)
{
size_t len;
unsigned char *out;
size_t i, start = 0;
len = strlen(in);
if (len >= 65535)
return NULL;
out = app_malloc(strlen(in) + 1, "NPN buffer");
for (i = 0; i <= len; ++i) {
if (i == len || in[i] == ',') {
if (i - start > 255) {
OPENSSL_free(out);
return NULL;
}
out[start] = i - start;
start = i + 1;
} else
out[i + 1] = in[i];
}
*outlen = len + 1;
return out;
}
|
d2a_function_data_5253
|
void
ngx_http_upstream_free_round_robin_peer(ngx_peer_connection_t *pc, void *data,
ngx_uint_t state)
{
ngx_http_upstream_rr_peer_data_t *rrp = data;
time_t now;
ngx_http_upstream_rr_peer_t *peer;
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, pc->log, 0,
"free rr peer %ui %ui", pc->tries, state);
/* TODO: NGX_PEER_KEEPALIVE */
peer = rrp->current;
if (rrp->peers->single) {
peer->conns--;
pc->tries = 0;
return;
}
ngx_http_upstream_rr_peers_rlock(rrp->peers);
ngx_http_upstream_rr_peer_lock(rrp->peers, peer);
if (state & NGX_PEER_FAILED) {
now = ngx_time();
peer->fails++;
peer->accessed = now;
peer->checked = now;
if (peer->max_fails) {
peer->effective_weight -= peer->weight / peer->max_fails;
}
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, pc->log, 0,
"free rr peer failed: %p %i",
peer, peer->effective_weight);
if (peer->effective_weight < 0) {
peer->effective_weight = 0;
}
} else {
/* mark peer live if check passed */
if (peer->accessed < peer->checked) {
peer->fails = 0;
}
}
peer->conns--;
ngx_http_upstream_rr_peer_unlock(rrp->peers, peer);
ngx_http_upstream_rr_peers_unlock(rrp->peers);
if (pc->tries) {
pc->tries--;
}
}
|
d2a_function_data_5254
|
static void vc1_inv_trans_4x8_dc_c(uint8_t *dest, int linesize, DCTELEM *block)
{
int i;
int dc = block[0];
dc = (17 * dc + 4) >> 3;
dc = (12 * dc + 64) >> 7;
for(i = 0; i < 8; i++){
dest[0] = av_clip_uint8(dest[0] + dc);
dest[1] = av_clip_uint8(dest[1] + dc);
dest[2] = av_clip_uint8(dest[2] + dc);
dest[3] = av_clip_uint8(dest[3] + dc);
dest += linesize;
}
}
|
d2a_function_data_5255
|
static int decode_frame(AVCodecContext *avctx,
void *data, int *data_size,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
ASV1Context * const a = avctx->priv_data;
AVFrame *picture = data;
AVFrame * const p= &a->picture;
int mb_x, mb_y;
if(p->data[0])
avctx->release_buffer(avctx, p);
p->reference= 0;
if(avctx->get_buffer(avctx, p) < 0){
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1;
}
p->pict_type= AV_PICTURE_TYPE_I;
p->key_frame= 1;
av_fast_malloc(&a->bitstream_buffer, &a->bitstream_buffer_size, buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!a->bitstream_buffer)
return AVERROR(ENOMEM);
memset(a->bitstream_buffer + buf_size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
if(avctx->codec_id == CODEC_ID_ASV1)
a->dsp.bswap_buf((uint32_t*)a->bitstream_buffer, (const uint32_t*)buf, buf_size/4);
else{
int i;
for(i=0; i<buf_size; i++)
a->bitstream_buffer[i]= av_reverse[ buf[i] ];
}
init_get_bits(&a->gb, a->bitstream_buffer, buf_size*8);
for(mb_y=0; mb_y<a->mb_height2; mb_y++){
for(mb_x=0; mb_x<a->mb_width2; mb_x++){
if( decode_mb(a, a->block) <0)
return -1;
idct_put(a, mb_x, mb_y);
}
}
if(a->mb_width2 != a->mb_width){
mb_x= a->mb_width2;
for(mb_y=0; mb_y<a->mb_height2; mb_y++){
if( decode_mb(a, a->block) <0)
return -1;
idct_put(a, mb_x, mb_y);
}
}
if(a->mb_height2 != a->mb_height){
mb_y= a->mb_height2;
for(mb_x=0; mb_x<a->mb_width; mb_x++){
if( decode_mb(a, a->block) <0)
return -1;
idct_put(a, mb_x, mb_y);
}
}
*picture= *(AVFrame*)&a->picture;
*data_size = sizeof(AVPicture);
emms_c();
return (get_bits_count(&a->gb)+31)/32*4;
}
|
d2a_function_data_5256
|
static av_always_inline
int vp78_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
AVPacket *avpkt, int is_vp7)
{
VP8Context *s = avctx->priv_data;
int ret, i, referenced, num_jobs;
enum AVDiscard skip_thresh;
VP8Frame *av_uninit(curframe), *prev_frame;
if (is_vp7)
ret = vp7_decode_frame_header(s, avpkt->data, avpkt->size);
else
ret = vp8_decode_frame_header(s, avpkt->data, avpkt->size);
if (ret < 0)
goto err;
prev_frame = s->framep[VP56_FRAME_CURRENT];
referenced = s->update_last || s->update_golden == VP56_FRAME_CURRENT ||
s->update_altref == VP56_FRAME_CURRENT;
skip_thresh = !referenced ? AVDISCARD_NONREF
: !s->keyframe ? AVDISCARD_NONKEY
: AVDISCARD_ALL;
if (avctx->skip_frame >= skip_thresh) {
s->invisible = 1;
memcpy(&s->next_framep[0], &s->framep[0], sizeof(s->framep[0]) * 4);
goto skip_decode;
}
s->deblock_filter = s->filter.level && avctx->skip_loop_filter < skip_thresh;
// release no longer referenced frames
for (i = 0; i < 5; i++)
if (s->frames[i].tf.f->data[0] &&
&s->frames[i] != prev_frame &&
&s->frames[i] != s->framep[VP56_FRAME_PREVIOUS] &&
&s->frames[i] != s->framep[VP56_FRAME_GOLDEN] &&
&s->frames[i] != s->framep[VP56_FRAME_GOLDEN2])
vp8_release_frame(s, &s->frames[i]);
curframe = s->framep[VP56_FRAME_CURRENT] = vp8_find_free_buffer(s);
/* Given that arithmetic probabilities are updated every frame, it's quite
* likely that the values we have on a random interframe are complete
* junk if we didn't start decode on a keyframe. So just don't display
* anything rather than junk. */
if (!s->keyframe && (!s->framep[VP56_FRAME_PREVIOUS] ||
!s->framep[VP56_FRAME_GOLDEN] ||
!s->framep[VP56_FRAME_GOLDEN2])) {
av_log(avctx, AV_LOG_WARNING,
"Discarding interframe without a prior keyframe!\n");
ret = AVERROR_INVALIDDATA;
goto err;
}
curframe->tf.f->key_frame = s->keyframe;
curframe->tf.f->pict_type = s->keyframe ? AV_PICTURE_TYPE_I
: AV_PICTURE_TYPE_P;
if ((ret = vp8_alloc_frame(s, curframe, referenced))) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed!\n");
goto err;
}
// check if golden and altref are swapped
if (s->update_altref != VP56_FRAME_NONE)
s->next_framep[VP56_FRAME_GOLDEN2] = s->framep[s->update_altref];
else
s->next_framep[VP56_FRAME_GOLDEN2] = s->framep[VP56_FRAME_GOLDEN2];
if (s->update_golden != VP56_FRAME_NONE)
s->next_framep[VP56_FRAME_GOLDEN] = s->framep[s->update_golden];
else
s->next_framep[VP56_FRAME_GOLDEN] = s->framep[VP56_FRAME_GOLDEN];
if (s->update_last)
s->next_framep[VP56_FRAME_PREVIOUS] = curframe;
else
s->next_framep[VP56_FRAME_PREVIOUS] = s->framep[VP56_FRAME_PREVIOUS];
s->next_framep[VP56_FRAME_CURRENT] = curframe;
ff_thread_finish_setup(avctx);
s->linesize = curframe->tf.f->linesize[0];
s->uvlinesize = curframe->tf.f->linesize[1];
memset(s->top_nnz, 0, s->mb_width * sizeof(*s->top_nnz));
/* Zero macroblock structures for top/top-left prediction
* from outside the frame. */
if (!s->mb_layout)
memset(s->macroblocks + s->mb_height * 2 - 1, 0,
(s->mb_width + 1) * sizeof(*s->macroblocks));
if (!s->mb_layout && s->keyframe)
memset(s->intra4x4_pred_mode_top, DC_PRED, s->mb_width * 4);
memset(s->ref_count, 0, sizeof(s->ref_count));
if (s->mb_layout == 1) {
// Make sure the previous frame has read its segmentation map,
// if we re-use the same map.
if (prev_frame && s->segmentation.enabled &&
!s->segmentation.update_map)
ff_thread_await_progress(&prev_frame->tf, 1, 0);
if (is_vp7)
vp7_decode_mv_mb_modes(avctx, curframe, prev_frame);
else
vp8_decode_mv_mb_modes(avctx, curframe, prev_frame);
}
if (avctx->active_thread_type == FF_THREAD_FRAME)
num_jobs = 1;
else
num_jobs = FFMIN(s->num_coeff_partitions, avctx->thread_count);
s->num_jobs = num_jobs;
s->curframe = curframe;
s->prev_frame = prev_frame;
s->mv_min.y = -MARGIN;
s->mv_max.y = ((s->mb_height - 1) << 6) + MARGIN;
for (i = 0; i < MAX_THREADS; i++) {
s->thread_data[i].thread_mb_pos = 0;
s->thread_data[i].wait_mb_pos = INT_MAX;
}
if (is_vp7)
avctx->execute2(avctx, vp7_decode_mb_row_sliced, s->thread_data, NULL,
num_jobs);
else
avctx->execute2(avctx, vp8_decode_mb_row_sliced, s->thread_data, NULL,
num_jobs);
ff_thread_report_progress(&curframe->tf, INT_MAX, 0);
memcpy(&s->framep[0], &s->next_framep[0], sizeof(s->framep[0]) * 4);
skip_decode:
// if future frames don't use the updated probabilities,
// reset them to the values we saved
if (!s->update_probabilities)
s->prob[0] = s->prob[1];
if (!s->invisible) {
if ((ret = av_frame_ref(data, curframe->tf.f)) < 0)
return ret;
*got_frame = 1;
}
return avpkt->size;
err:
memcpy(&s->next_framep[0], &s->framep[0], sizeof(s->framep[0]) * 4);
return ret;
}
|
d2a_function_data_5257
|
char *make_revocation_str(int rev_type, char *rev_arg)
{
char *reason = NULL, *other = NULL, *str;
ASN1_OBJECT *otmp;
ASN1_UTCTIME *revtm = NULL;
int i;
switch (rev_type)
{
case REV_NONE:
break;
case REV_CRL_REASON:
for (i = 0; i < 8; i++)
{
if (!strcasecmp(rev_arg, crl_reasons[i]))
{
reason = crl_reasons[i];
break;
}
}
if (reason == NULL)
{
BIO_printf(bio_err, "Unknown CRL reason %s\n", rev_arg);
return NULL;
}
break;
case REV_HOLD:
/* Argument is an OID */
otmp = OBJ_txt2obj(rev_arg, 0);
ASN1_OBJECT_free(otmp);
if (otmp == NULL)
{
BIO_printf(bio_err, "Invalid object identifier %s\n", rev_arg);
return NULL;
}
reason = "holdInstruction";
other = rev_arg;
break;
case REV_KEY_COMPROMISE:
case REV_CA_COMPROMISE:
/* Argument is the key compromise time */
if (!ASN1_GENERALIZEDTIME_set_string(NULL, rev_arg))
{
BIO_printf(bio_err, "Invalid time format %s. Need YYYYMMDDHHMMSSZ\n", rev_arg);
return NULL;
}
other = rev_arg;
if (rev_type == REV_KEY_COMPROMISE)
reason = "keyTime";
else
reason = "CAkeyTime";
break;
}
revtm = X509_gmtime_adj(NULL, 0);
i = revtm->length + 1;
if (reason) i += strlen(reason) + 1;
if (other) i += strlen(other) + 1;
str = OPENSSL_malloc(i);
if (!str) return NULL;
strcpy(str, (char *)revtm->data);
if (reason)
{
strcat(str, ",");
strcat(str, reason);
}
if (other)
{
strcat(str, ",");
strcat(str, other);
}
ASN1_UTCTIME_free(revtm);
return str;
}
|
d2a_function_data_5258
|
static int check_image_pointers(uint8_t *data[4], enum AVPixelFormat pix_fmt,
const int linesizes[4])
{
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);
int i;
for (i = 0; i < 4; i++) {
int plane = desc->comp[i].plane;
if (!data[plane] || !linesizes[plane])
return 0;
}
return 1;
}
|
d2a_function_data_5259
|
static int hls_window(AVFormatContext *s, int last)
{
HLSContext *hls = s->priv_data;
ListEntry *en;
int64_t target_duration = 0;
int ret = 0;
AVIOContext *out = NULL;
char temp_filename[1024];
int64_t sequence = FFMAX(hls->start_sequence, hls->sequence - hls->size);
snprintf(temp_filename, sizeof(temp_filename), "%s.tmp", s->filename);
if ((ret = s->io_open(s, &out, temp_filename, AVIO_FLAG_WRITE, NULL)) < 0)
goto fail;
for (en = hls->list; en; en = en->next) {
if (target_duration < en->duration)
target_duration = en->duration;
}
avio_printf(out, "#EXTM3U\n");
avio_printf(out, "#EXT-X-VERSION:%d\n", hls->version);
if (hls->allowcache == 0 || hls->allowcache == 1) {
avio_printf(out, "#EXT-X-ALLOW-CACHE:%s\n", hls->allowcache == 0 ? "NO" : "YES");
}
avio_printf(out, "#EXT-X-TARGETDURATION:%"PRId64"\n",
av_rescale_rnd(target_duration, 1, AV_TIME_BASE,
AV_ROUND_UP));
avio_printf(out, "#EXT-X-MEDIA-SEQUENCE:%"PRId64"\n", sequence);
av_log(s, AV_LOG_VERBOSE, "EXT-X-MEDIA-SEQUENCE:%"PRId64"\n",
sequence);
for (en = hls->list; en; en = en->next) {
if (hls->version > 2)
avio_printf(out, "#EXTINF:%f\n",
(double)en->duration / AV_TIME_BASE);
else
avio_printf(out, "#EXTINF:%"PRId64",\n",
av_rescale(en->duration, 1, AV_TIME_BASE));
if (hls->baseurl)
avio_printf(out, "%s", hls->baseurl);
avio_printf(out, "%s\n", en->name);
}
if (last)
avio_printf(out, "#EXT-X-ENDLIST\n");
fail:
ff_format_io_close(s, &out);
if (ret >= 0)
ff_rename(temp_filename, s->filename);
return ret;
}
|
d2a_function_data_5260
|
static inline void mc_part_weighted(H264Context *h, int n, int square, int chroma_height, int delta,
uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
int x_offset, int y_offset,
qpel_mc_func *qpix_put, h264_chroma_mc_func chroma_put,
h264_weight_func luma_weight_op, h264_weight_func chroma_weight_op,
h264_biweight_func luma_weight_avg, h264_biweight_func chroma_weight_avg,
int list0, int list1){
MpegEncContext * const s = &h->s;
dest_y += 2*x_offset + 2*y_offset*h-> mb_linesize;
dest_cb += x_offset + y_offset*h->mb_uvlinesize;
dest_cr += x_offset + y_offset*h->mb_uvlinesize;
x_offset += 8*s->mb_x;
y_offset += 8*(s->mb_y >> MB_FIELD);
if(list0 && list1){
/* don't optimize for luma-only case, since B-frames usually
* use implicit weights => chroma too. */
uint8_t *tmp_cb = s->obmc_scratchpad;
uint8_t *tmp_cr = s->obmc_scratchpad + 8;
uint8_t *tmp_y = s->obmc_scratchpad + 8*h->mb_uvlinesize;
int refn0 = h->ref_cache[0][ scan8[n] ];
int refn1 = h->ref_cache[1][ scan8[n] ];
mc_dir_part(h, &h->ref_list[0][refn0], n, square, chroma_height, delta, 0,
dest_y, dest_cb, dest_cr,
x_offset, y_offset, qpix_put, chroma_put);
mc_dir_part(h, &h->ref_list[1][refn1], n, square, chroma_height, delta, 1,
tmp_y, tmp_cb, tmp_cr,
x_offset, y_offset, qpix_put, chroma_put);
if(h->use_weight == 2){
int weight0 = h->implicit_weight[refn0][refn1];
int weight1 = 64 - weight0;
luma_weight_avg( dest_y, tmp_y, h-> mb_linesize, 5, weight0, weight1, 0);
chroma_weight_avg(dest_cb, tmp_cb, h->mb_uvlinesize, 5, weight0, weight1, 0);
chroma_weight_avg(dest_cr, tmp_cr, h->mb_uvlinesize, 5, weight0, weight1, 0);
}else{
luma_weight_avg(dest_y, tmp_y, h->mb_linesize, h->luma_log2_weight_denom,
h->luma_weight[0][refn0], h->luma_weight[1][refn1],
h->luma_offset[0][refn0] + h->luma_offset[1][refn1]);
chroma_weight_avg(dest_cb, tmp_cb, h->mb_uvlinesize, h->chroma_log2_weight_denom,
h->chroma_weight[0][refn0][0], h->chroma_weight[1][refn1][0],
h->chroma_offset[0][refn0][0] + h->chroma_offset[1][refn1][0]);
chroma_weight_avg(dest_cr, tmp_cr, h->mb_uvlinesize, h->chroma_log2_weight_denom,
h->chroma_weight[0][refn0][1], h->chroma_weight[1][refn1][1],
h->chroma_offset[0][refn0][1] + h->chroma_offset[1][refn1][1]);
}
}else{
int list = list1 ? 1 : 0;
int refn = h->ref_cache[list][ scan8[n] ];
Picture *ref= &h->ref_list[list][refn];
mc_dir_part(h, ref, n, square, chroma_height, delta, list,
dest_y, dest_cb, dest_cr, x_offset, y_offset,
qpix_put, chroma_put);
luma_weight_op(dest_y, h->mb_linesize, h->luma_log2_weight_denom,
h->luma_weight[list][refn], h->luma_offset[list][refn]);
if(h->use_weight_chroma){
chroma_weight_op(dest_cb, h->mb_uvlinesize, h->chroma_log2_weight_denom,
h->chroma_weight[list][refn][0], h->chroma_offset[list][refn][0]);
chroma_weight_op(dest_cr, h->mb_uvlinesize, h->chroma_log2_weight_denom,
h->chroma_weight[list][refn][1], h->chroma_offset[list][refn][1]);
}
}
}
|
d2a_function_data_5261
|
static int sami_paragraph_to_ass(AVCodecContext *avctx, const char *src)
{
SAMIContext *sami = avctx->priv_data;
int ret = 0;
char *tag = NULL;
char *dupsrc = av_strdup(src);
char *p = dupsrc;
AVBPrint *dst_content = &sami->encoded_content;
AVBPrint *dst_source = &sami->encoded_source;
if (!dupsrc)
return AVERROR(ENOMEM);
av_bprint_clear(&sami->encoded_content);
av_bprint_clear(&sami->content);
av_bprint_clear(&sami->encoded_source);
for (;;) {
char *saveptr = NULL;
int prev_chr_is_space = 0;
AVBPrint *dst = &sami->content;
/* parse & extract paragraph tag */
p = av_stristr(p, "<P");
if (!p)
break;
if (p[2] != '>' && !av_isspace(p[2])) { // avoid confusion with tags such as <PRE>
p++;
continue;
}
if (dst->len) // add a separator with the previous paragraph if there was one
av_bprintf(dst, "\\N");
tag = av_strtok(p, ">", &saveptr);
if (!tag || !saveptr)
break;
p = saveptr;
/* check if the current paragraph is the "source" (speaker name) */
if (av_stristr(tag, "ID=Source") || av_stristr(tag, "ID=\"Source\"")) {
dst = &sami->source;
av_bprint_clear(dst);
}
/* if empty event -> skip subtitle */
while (av_isspace(*p))
p++;
if (!strncmp(p, " ", 6)) {
ret = -1;
goto end;
}
/* extract the text, stripping most of the tags */
while (*p) {
if (*p == '<') {
if (!av_strncasecmp(p, "<P", 2) && (p[2] == '>' || av_isspace(p[2])))
break;
}
if (!av_strncasecmp(p, "<BR", 3)) {
av_bprintf(dst, "\\N");
p++;
while (*p && *p != '>')
p++;
if (!*p)
break;
if (*p == '>')
p++;
continue;
}
if (!av_isspace(*p))
av_bprint_chars(dst, *p, 1);
else if (!prev_chr_is_space)
av_bprint_chars(dst, ' ', 1);
prev_chr_is_space = av_isspace(*p);
p++;
}
}
av_bprint_clear(&sami->full);
if (sami->source.len) {
ret = ff_htmlmarkup_to_ass(avctx, dst_source, sami->source.str);
if (ret < 0)
goto end;
av_bprintf(&sami->full, "{\\i1}%s{\\i0}\\N", sami->encoded_source.str);
}
ret = ff_htmlmarkup_to_ass(avctx, dst_content, sami->content.str);
if (ret < 0)
goto end;
av_bprintf(&sami->full, "%s", sami->encoded_content.str);
end:
av_free(dupsrc);
return ret;
}
|
d2a_function_data_5262
|
int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
{
int max,min,dif;
register BN_ULONG t1,t2,*ap,*bp,*rp;
int i,carry;
#if defined(IRIX_CC_BUG) && !defined(LINT)
int dummy;
#endif
bn_check_top(a);
bn_check_top(b);
max = a->top;
min = b->top;
dif = max - min;
if (dif < 0) /* hmm... should not be happening */
{
BNerr(BN_F_BN_USUB,BN_R_ARG2_LT_ARG3);
return(0);
}
if (bn_wexpand(r,max) == NULL) return(0);
ap=a->d;
bp=b->d;
rp=r->d;
#if 1
carry=0;
for (i = min; i != 0; i--)
{
t1= *(ap++);
t2= *(bp++);
if (carry)
{
carry=(t1 <= t2);
t1=(t1-t2-1)&BN_MASK2;
}
else
{
carry=(t1 < t2);
t1=(t1-t2)&BN_MASK2;
}
#if defined(IRIX_CC_BUG) && !defined(LINT)
dummy=t1;
#endif
*(rp++)=t1&BN_MASK2;
}
#else
carry=bn_sub_words(rp,ap,bp,min);
ap+=min;
bp+=min;
rp+=min;
#endif
if (carry) /* subtracted */
{
if (!dif)
/* error: a < b */
return 0;
while (dif)
{
dif--;
t1 = *(ap++);
t2 = (t1-1)&BN_MASK2;
*(rp++) = t2;
if (t1)
break;
}
}
#if 0
memcpy(rp,ap,sizeof(*rp)*(max-i));
#else
if (rp != ap)
{
for (;;)
{
if (!dif--) break;
rp[0]=ap[0];
if (!dif--) break;
rp[1]=ap[1];
if (!dif--) break;
rp[2]=ap[2];
if (!dif--) break;
rp[3]=ap[3];
rp+=4;
ap+=4;
}
}
#endif
r->top=max;
r->neg=0;
bn_correct_top(r);
return(1);
}
|
d2a_function_data_5263
|
static void encode_window_bands_info(AACEncContext *s, SingleChannelElement *sce,
int win, int group_len, const float lambda)
{
BandCodingPath path[120][CB_TOT];
int w, swb, cb, start, size;
int i, j;
const int max_sfb = sce->ics.max_sfb;
const int run_bits = sce->ics.num_windows == 1 ? 5 : 3;
const int run_esc = (1 << run_bits) - 1;
int idx, ppos, count;
int stackrun[120], stackcb[120], stack_len;
float next_minrd = INFINITY;
int next_mincb = 0;
abs_pow34_v(s->scoefs, sce->coeffs, 1024);
start = win*128;
for (cb = 0; cb < CB_TOT; cb++) {
path[0][cb].cost = 0.0f;
path[0][cb].prev_idx = -1;
path[0][cb].run = 0;
}
for (swb = 0; swb < max_sfb; swb++) {
size = sce->ics.swb_sizes[swb];
if (sce->zeroes[win*16 + swb]) {
for (cb = 0; cb < CB_TOT; cb++) {
path[swb+1][cb].prev_idx = cb;
path[swb+1][cb].cost = path[swb][cb].cost;
path[swb+1][cb].run = path[swb][cb].run + 1;
}
} else {
float minrd = next_minrd;
int mincb = next_mincb;
next_minrd = INFINITY;
next_mincb = 0;
for (cb = 0; cb < CB_TOT; cb++) {
float cost_stay_here, cost_get_here;
float rd = 0.0f;
for (w = 0; w < group_len; w++) {
FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(win+w)*16+swb];
rd += quantize_band_cost(s, sce->coeffs + start + w*128,
s->scoefs + start + w*128, size,
sce->sf_idx[(win+w)*16+swb], aac_cb_out_map[cb],
lambda / band->threshold, INFINITY, NULL);
}
cost_stay_here = path[swb][cb].cost + rd;
cost_get_here = minrd + rd + run_bits + 4;
if ( run_value_bits[sce->ics.num_windows == 8][path[swb][cb].run]
!= run_value_bits[sce->ics.num_windows == 8][path[swb][cb].run+1])
cost_stay_here += run_bits;
if (cost_get_here < cost_stay_here) {
path[swb+1][cb].prev_idx = mincb;
path[swb+1][cb].cost = cost_get_here;
path[swb+1][cb].run = 1;
} else {
path[swb+1][cb].prev_idx = cb;
path[swb+1][cb].cost = cost_stay_here;
path[swb+1][cb].run = path[swb][cb].run + 1;
}
if (path[swb+1][cb].cost < next_minrd) {
next_minrd = path[swb+1][cb].cost;
next_mincb = cb;
}
}
}
start += sce->ics.swb_sizes[swb];
}
//convert resulting path from backward-linked list
stack_len = 0;
idx = 0;
for (cb = 1; cb < CB_TOT; cb++)
if (path[max_sfb][cb].cost < path[max_sfb][idx].cost)
idx = cb;
ppos = max_sfb;
while (ppos > 0) {
cb = idx;
stackrun[stack_len] = path[ppos][cb].run;
stackcb [stack_len] = cb;
idx = path[ppos-path[ppos][cb].run+1][cb].prev_idx;
ppos -= path[ppos][cb].run;
stack_len++;
}
//perform actual band info encoding
start = 0;
for (i = stack_len - 1; i >= 0; i--) {
cb = aac_cb_out_map[stackcb[i]];
put_bits(&s->pb, 4, cb);
count = stackrun[i];
memset(sce->zeroes + win*16 + start, !cb, count);
//XXX: memset when band_type is also uint8_t
for (j = 0; j < count; j++) {
sce->band_type[win*16 + start] = cb;
start++;
}
while (count >= run_esc) {
put_bits(&s->pb, run_bits, run_esc);
count -= run_esc;
}
put_bits(&s->pb, run_bits, count);
}
}
|
d2a_function_data_5264
|
static int build_filter(ResampleContext *c, void *filter, double factor, int tap_count, int alloc, int phase_count, int scale,
int filter_type, int kaiser_beta){
int ph, i;
double x, y, w;
double *tab = av_malloc_array(tap_count, sizeof(*tab));
const int center= (tap_count-1)/2;
if (!tab)
return AVERROR(ENOMEM);
/* if upsampling, only need to interpolate, no filter */
if (factor > 1.0)
factor = 1.0;
for(ph=0;ph<phase_count;ph++) {
double norm = 0;
for(i=0;i<tap_count;i++) {
x = M_PI * ((double)(i - center) - (double)ph / phase_count) * factor;
if (x == 0) y = 1.0;
else y = sin(x) / x;
switch(filter_type){
case SWR_FILTER_TYPE_CUBIC:{
const float d= -0.5; //first order derivative = -0.5
x = fabs(((double)(i - center) - (double)ph / phase_count) * factor);
if(x<1.0) y= 1 - 3*x*x + 2*x*x*x + d*( -x*x + x*x*x);
else y= d*(-4 + 8*x - 5*x*x + x*x*x);
break;}
case SWR_FILTER_TYPE_BLACKMAN_NUTTALL:
w = 2.0*x / (factor*tap_count) + M_PI;
y *= 0.3635819 - 0.4891775 * cos(w) + 0.1365995 * cos(2*w) - 0.0106411 * cos(3*w);
break;
case SWR_FILTER_TYPE_KAISER:
w = 2.0*x / (factor*tap_count*M_PI);
y *= bessel(kaiser_beta*sqrt(FFMAX(1-w*w, 0)));
break;
default:
av_assert0(0);
}
tab[i] = y;
norm += y;
}
/* normalize so that an uniform color remains the same */
switch(c->format){
case AV_SAMPLE_FMT_S16P:
for(i=0;i<tap_count;i++)
((int16_t*)filter)[ph * alloc + i] = av_clip(lrintf(tab[i] * scale / norm), INT16_MIN, INT16_MAX);
break;
case AV_SAMPLE_FMT_S32P:
for(i=0;i<tap_count;i++)
((int32_t*)filter)[ph * alloc + i] = av_clipl_int32(llrint(tab[i] * scale / norm));
break;
case AV_SAMPLE_FMT_FLTP:
for(i=0;i<tap_count;i++)
((float*)filter)[ph * alloc + i] = tab[i] * scale / norm;
break;
case AV_SAMPLE_FMT_DBLP:
for(i=0;i<tap_count;i++)
((double*)filter)[ph * alloc + i] = tab[i] * scale / norm;
break;
}
}
#if 0
{
#define LEN 1024
int j,k;
double sine[LEN + tap_count];
double filtered[LEN];
double maxff=-2, minff=2, maxsf=-2, minsf=2;
for(i=0; i<LEN; i++){
double ss=0, sf=0, ff=0;
for(j=0; j<LEN+tap_count; j++)
sine[j]= cos(i*j*M_PI/LEN);
for(j=0; j<LEN; j++){
double sum=0;
ph=0;
for(k=0; k<tap_count; k++)
sum += filter[ph * tap_count + k] * sine[k+j];
filtered[j]= sum / (1<<FILTER_SHIFT);
ss+= sine[j + center] * sine[j + center];
ff+= filtered[j] * filtered[j];
sf+= sine[j + center] * filtered[j];
}
ss= sqrt(2*ss/LEN);
ff= sqrt(2*ff/LEN);
sf= 2*sf/LEN;
maxff= FFMAX(maxff, ff);
minff= FFMIN(minff, ff);
maxsf= FFMAX(maxsf, sf);
minsf= FFMIN(minsf, sf);
if(i%11==0){
av_log(NULL, AV_LOG_ERROR, "i:%4d ss:%f ff:%13.6e-%13.6e sf:%13.6e-%13.6e\n", i, ss, maxff, minff, maxsf, minsf);
minff=minsf= 2;
maxff=maxsf= -2;
}
}
}
#endif
av_free(tab);
return 0;
}
|
d2a_function_data_5265
|
static char *make_config_name()
{
const char *t;
size_t len;
char *p;
if ((t = getenv("OPENSSL_CONF")) != NULL)
return BUF_strdup(t);
t = X509_get_default_cert_area();
len = strlen(t) + 1 + strlen(OPENSSL_CONF) + 1;
p = app_malloc(len, "config filename buffer");
strcpy(p, t);
#ifndef OPENSSL_SYS_VMS
strcat(p, "/");
#endif
strcat(p, OPENSSL_CONF);
return p;
}
|
d2a_function_data_5266
|
void ff_mspel_motion(MpegEncContext *s,
uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
uint8_t **ref_picture, op_pixels_func (*pix_op)[4],
int motion_x, int motion_y, int h)
{
Wmv2Context * const w= (Wmv2Context*)s;
uint8_t *ptr;
int dxy, mx, my, src_x, src_y, v_edge_pos;
ptrdiff_t offset, linesize, uvlinesize;
int emu=0;
dxy = ((motion_y & 1) << 1) | (motion_x & 1);
dxy = 2*dxy + w->hshift;
src_x = s->mb_x * 16 + (motion_x >> 1);
src_y = s->mb_y * 16 + (motion_y >> 1);
/* WARNING: do no forget half pels */
v_edge_pos = s->v_edge_pos;
src_x = av_clip(src_x, -16, s->width);
src_y = av_clip(src_y, -16, s->height);
if(src_x<=-16 || src_x >= s->width)
dxy &= ~3;
if(src_y<=-16 || src_y >= s->height)
dxy &= ~4;
linesize = s->linesize;
uvlinesize = s->uvlinesize;
ptr = ref_picture[0] + (src_y * linesize) + src_x;
if(src_x<1 || src_y<1 || src_x + 17 >= s->h_edge_pos
|| src_y + h+1 >= v_edge_pos){
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr - 1 - s->linesize, s->linesize, 19, 19,
src_x-1, src_y-1, s->h_edge_pos, s->v_edge_pos);
ptr= s->edge_emu_buffer + 1 + s->linesize;
emu=1;
}
s->dsp.put_mspel_pixels_tab[dxy](dest_y , ptr , linesize);
s->dsp.put_mspel_pixels_tab[dxy](dest_y+8 , ptr+8 , linesize);
s->dsp.put_mspel_pixels_tab[dxy](dest_y +8*linesize, ptr +8*linesize, linesize);
s->dsp.put_mspel_pixels_tab[dxy](dest_y+8+8*linesize, ptr+8+8*linesize, linesize);
if(s->flags&CODEC_FLAG_GRAY) return;
if (s->out_format == FMT_H263) {
dxy = 0;
if ((motion_x & 3) != 0)
dxy |= 1;
if ((motion_y & 3) != 0)
dxy |= 2;
mx = motion_x >> 2;
my = motion_y >> 2;
} else {
mx = motion_x / 2;
my = motion_y / 2;
dxy = ((my & 1) << 1) | (mx & 1);
mx >>= 1;
my >>= 1;
}
src_x = s->mb_x * 8 + mx;
src_y = s->mb_y * 8 + my;
src_x = av_clip(src_x, -8, s->width >> 1);
if (src_x == (s->width >> 1))
dxy &= ~1;
src_y = av_clip(src_y, -8, s->height >> 1);
if (src_y == (s->height >> 1))
dxy &= ~2;
offset = (src_y * uvlinesize) + src_x;
ptr = ref_picture[1] + offset;
if(emu){
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9,
src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
ptr= s->edge_emu_buffer;
}
pix_op[1][dxy](dest_cb, ptr, uvlinesize, h >> 1);
ptr = ref_picture[2] + offset;
if(emu){
s->vdsp.emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9,
src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
ptr= s->edge_emu_buffer;
}
pix_op[1][dxy](dest_cr, ptr, uvlinesize, h >> 1);
}
|
d2a_function_data_5267
|
static int test_client_hello(int currtest)
{
SSL_CTX *ctx;
SSL *con = NULL;
BIO *rbio;
BIO *wbio;
long len;
unsigned char *data;
PACKET pkt = {0}, pkt2 = {0}, pkt3 = {0};
char *dummytick = "Hello World!";
unsigned int type = 0;
int testresult = 0;
size_t msglen;
BIO *sessbio = NULL;
SSL_SESSION *sess = NULL;
#ifdef OPENSSL_NO_TLS1_3
if (currtest == TEST_ADD_PADDING_AND_PSK)
return 1;
#endif
/*
* For each test set up an SSL_CTX and SSL and see what ClientHello gets
* produced when we try to connect
*/
ctx = SSL_CTX_new(TLS_method());
if (!TEST_ptr(ctx))
goto end;
switch(currtest) {
case TEST_SET_SESSION_TICK_DATA_VER_NEG:
/* Testing for session tickets <= TLS1.2; not relevant for 1.3 */
if (!TEST_true(SSL_CTX_set_max_proto_version(ctx, TLS1_2_VERSION)))
goto end;
break;
case TEST_ADD_PADDING_AND_PSK:
case TEST_ADD_PADDING:
case TEST_PADDING_NOT_NEEDED:
SSL_CTX_set_options(ctx, SSL_OP_TLSEXT_PADDING);
/*
* Add some dummy ALPN protocols so that the ClientHello is at least
* F5_WORKAROUND_MIN_MSG_LEN bytes long - meaning padding will be
* needed.
*/
if (currtest == TEST_ADD_PADDING
&& (!TEST_false(SSL_CTX_set_alpn_protos(ctx,
(unsigned char *)alpn_prots,
sizeof(alpn_prots) - 1))))
goto end;
break;
default:
goto end;
}
con = SSL_new(ctx);
if (!TEST_ptr(con))
goto end;
if (currtest == TEST_ADD_PADDING_AND_PSK) {
sessbio = BIO_new_file(sessionfile, "r");
if (!TEST_ptr(sessbio)) {
TEST_info("Unable to open session.pem");
goto end;
}
sess = PEM_read_bio_SSL_SESSION(sessbio, NULL, NULL, NULL);
if (!TEST_ptr(sess)) {
TEST_info("Unable to load SSL_SESSION");
goto end;
}
/*
* We reset the creation time so that we don't discard the session as
* too old.
*/
if (!TEST_true(SSL_SESSION_set_time(sess, time(NULL)))
|| !TEST_true(SSL_set_session(con, sess)))
goto end;
}
rbio = BIO_new(BIO_s_mem());
wbio = BIO_new(BIO_s_mem());
if (!TEST_ptr(rbio)|| !TEST_ptr(wbio)) {
BIO_free(rbio);
BIO_free(wbio);
goto end;
}
SSL_set_bio(con, rbio, wbio);
SSL_set_connect_state(con);
if (currtest == TEST_SET_SESSION_TICK_DATA_VER_NEG) {
if (!TEST_true(SSL_set_session_ticket_ext(con, dummytick,
strlen(dummytick))))
goto end;
}
if (!TEST_int_le(SSL_connect(con), 0)) {
/* This shouldn't succeed because we don't have a server! */
goto end;
}
len = BIO_get_mem_data(wbio, (char **)&data);
if (!TEST_true(PACKET_buf_init(&pkt, data, len))
/* Skip the record header */
|| !PACKET_forward(&pkt, SSL3_RT_HEADER_LENGTH))
goto end;
msglen = PACKET_remaining(&pkt);
/* Skip the handshake message header */
if (!TEST_true(PACKET_forward(&pkt, SSL3_HM_HEADER_LENGTH))
/* Skip client version and random */
|| !TEST_true(PACKET_forward(&pkt, CLIENT_VERSION_LEN
+ SSL3_RANDOM_SIZE))
/* Skip session id */
|| !TEST_true(PACKET_get_length_prefixed_1(&pkt, &pkt2))
/* Skip ciphers */
|| !TEST_true(PACKET_get_length_prefixed_2(&pkt, &pkt2))
/* Skip compression */
|| !TEST_true(PACKET_get_length_prefixed_1(&pkt, &pkt2))
/* Extensions len */
|| !TEST_true(PACKET_as_length_prefixed_2(&pkt, &pkt2)))
goto end;
/* Loop through all extensions */
while (PACKET_remaining(&pkt2)) {
if (!TEST_true(PACKET_get_net_2(&pkt2, &type))
|| !TEST_true(PACKET_get_length_prefixed_2(&pkt2, &pkt3)))
goto end;
if (type == TLSEXT_TYPE_session_ticket) {
if (currtest == TEST_SET_SESSION_TICK_DATA_VER_NEG) {
if (TEST_true(PACKET_equal(&pkt3, dummytick,
strlen(dummytick)))) {
/* Ticket data is as we expected */
testresult = 1;
}
goto end;
}
}
if (type == TLSEXT_TYPE_padding) {
if (!TEST_false(currtest == TEST_PADDING_NOT_NEEDED))
goto end;
else if (TEST_true(currtest == TEST_ADD_PADDING
|| currtest == TEST_ADD_PADDING_AND_PSK))
testresult = TEST_true(msglen == F5_WORKAROUND_MAX_MSG_LEN);
}
}
if (currtest == TEST_PADDING_NOT_NEEDED)
testresult = 1;
end:
SSL_free(con);
SSL_CTX_free(ctx);
SSL_SESSION_free(sess);
BIO_free(sessbio);
return testresult;
}
|
d2a_function_data_5268
|
void av_dynarray_add(void *tab_ptr, int *nb_ptr, void *elem)
{
void **tab;
memcpy(&tab, tab_ptr, sizeof(tab));
FF_DYNARRAY_ADD(INT_MAX, sizeof(*tab), tab, *nb_ptr, {
tab[*nb_ptr] = elem;
memcpy(tab_ptr, &tab, sizeof(tab));
}, {
*nb_ptr = 0;
av_freep(tab_ptr);
});
}
|
d2a_function_data_5269
|
int BN_mod_exp_mont(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont)
{
int i,j,bits,ret=0,wstart,wend,window,wvalue;
int start=1;
BIGNUM *d,*r;
const BIGNUM *aa;
/* Table of variables obtained from 'ctx' */
BIGNUM *val[TABLE_SIZE];
BN_MONT_CTX *mont=NULL;
bn_check_top(a);
bn_check_top(p);
bn_check_top(m);
if (!BN_is_odd(m))
{
BNerr(BN_F_BN_MOD_EXP_MONT,BN_R_CALLED_WITH_EVEN_MODULUS);
return(0);
}
bits=BN_num_bits(p);
if (bits == 0)
{
ret = BN_one(rr);
return ret;
}
BN_CTX_start(ctx);
d = BN_CTX_get(ctx);
r = BN_CTX_get(ctx);
val[0] = BN_CTX_get(ctx);
if (!d || !r || !val[0]) goto err;
/* If this is not done, things will break in the montgomery
* part */
if (in_mont != NULL)
mont=in_mont;
else
{
if ((mont=BN_MONT_CTX_new()) == NULL) goto err;
if (!BN_MONT_CTX_set(mont,m,ctx)) goto err;
}
if (a->neg || BN_ucmp(a,m) >= 0)
{
if (!BN_nnmod(val[0],a,m,ctx))
goto err;
aa= val[0];
}
else
aa=a;
if (BN_is_zero(aa))
{
BN_zero(rr);
ret = 1;
goto err;
}
if (!BN_to_montgomery(val[0],aa,mont,ctx)) goto err; /* 1 */
window = BN_window_bits_for_exponent_size(bits);
if (window > 1)
{
if (!BN_mod_mul_montgomery(d,val[0],val[0],mont,ctx)) goto err; /* 2 */
j=1<<(window-1);
for (i=1; i<j; i++)
{
if(((val[i] = BN_CTX_get(ctx)) == NULL) ||
!BN_mod_mul_montgomery(val[i],val[i-1],
d,mont,ctx))
goto err;
}
}
start=1; /* This is used to avoid multiplication etc
* when there is only the value '1' in the
* buffer. */
wvalue=0; /* The 'value' of the window */
wstart=bits-1; /* The top bit of the window */
wend=0; /* The bottom bit of the window */
if (!BN_to_montgomery(r,BN_value_one(),mont,ctx)) goto err;
for (;;)
{
if (BN_is_bit_set(p,wstart) == 0)
{
if (!start)
{
if (!BN_mod_mul_montgomery(r,r,r,mont,ctx))
goto err;
}
if (wstart == 0) break;
wstart--;
continue;
}
/* We now have wstart on a 'set' bit, we now need to work out
* how bit a window to do. To do this we need to scan
* forward until the last set bit before the end of the
* window */
j=wstart;
wvalue=1;
wend=0;
for (i=1; i<window; i++)
{
if (wstart-i < 0) break;
if (BN_is_bit_set(p,wstart-i))
{
wvalue<<=(i-wend);
wvalue|=1;
wend=i;
}
}
/* wend is the size of the current window */
j=wend+1;
/* add the 'bytes above' */
if (!start)
for (i=0; i<j; i++)
{
if (!BN_mod_mul_montgomery(r,r,r,mont,ctx))
goto err;
}
/* wvalue will be an odd number < 2^window */
if (!BN_mod_mul_montgomery(r,r,val[wvalue>>1],mont,ctx))
goto err;
/* move the 'window' down further */
wstart-=wend+1;
wvalue=0;
start=0;
if (wstart < 0) break;
}
if (!BN_from_montgomery(rr,r,mont,ctx)) goto err;
ret=1;
err:
if ((in_mont == NULL) && (mont != NULL)) BN_MONT_CTX_free(mont);
BN_CTX_end(ctx);
bn_check_top(rr);
return(ret);
}
|
d2a_function_data_5270
|
int dtls1_do_write(SSL *s, int type)
{
int ret;
unsigned int curr_mtu;
int retry = 1;
unsigned int len, frag_off, mac_size, blocksize, used_len;
if (!dtls1_query_mtu(s))
return -1;
OPENSSL_assert(s->d1->mtu >= dtls1_min_mtu(s)); /* should have something
* reasonable now */
if (s->init_off == 0 && type == SSL3_RT_HANDSHAKE)
OPENSSL_assert(s->init_num ==
(int)s->d1->w_msg_hdr.msg_len +
DTLS1_HM_HEADER_LENGTH);
if (s->write_hash) {
if (s->enc_write_ctx
&& ((EVP_CIPHER_CTX_mode(s->enc_write_ctx) == EVP_CIPH_GCM_MODE) ||
(EVP_CIPHER_CTX_mode(s->enc_write_ctx) == EVP_CIPH_CCM_MODE)))
mac_size = 0;
else
mac_size = EVP_MD_CTX_size(s->write_hash);
} else
mac_size = 0;
if (s->enc_write_ctx &&
(EVP_CIPHER_CTX_mode(s->enc_write_ctx) == EVP_CIPH_CBC_MODE))
blocksize = 2 * EVP_CIPHER_block_size(s->enc_write_ctx->cipher);
else
blocksize = 0;
frag_off = 0;
/* s->init_num shouldn't ever be < 0...but just in case */
while (s->init_num > 0) {
if (type == SSL3_RT_HANDSHAKE && s->init_off != 0) {
/* We must be writing a fragment other than the first one */
if (frag_off > 0) {
/* This is the first attempt at writing out this fragment */
if (s->init_off <= DTLS1_HM_HEADER_LENGTH) {
/*
* Each fragment that was already sent must at least have
* contained the message header plus one other byte.
* Therefore |init_off| must have progressed by at least
* |DTLS1_HM_HEADER_LENGTH + 1| bytes. If not something went
* wrong.
*/
return -1;
}
/*
* Adjust |init_off| and |init_num| to allow room for a new
* message header for this fragment.
*/
s->init_off -= DTLS1_HM_HEADER_LENGTH;
s->init_num += DTLS1_HM_HEADER_LENGTH;
} else {
/*
* We must have been called again after a retry so use the
* fragment offset from our last attempt. We do not need
* to adjust |init_off| and |init_num| as above, because
* that should already have been done before the retry.
*/
frag_off = s->d1->w_msg_hdr.frag_off;
}
}
used_len = BIO_wpending(SSL_get_wbio(s)) + DTLS1_RT_HEADER_LENGTH
+ mac_size + blocksize;
if (s->d1->mtu > used_len)
curr_mtu = s->d1->mtu - used_len;
else
curr_mtu = 0;
if (curr_mtu <= DTLS1_HM_HEADER_LENGTH) {
/*
* grr.. we could get an error if MTU picked was wrong
*/
ret = BIO_flush(SSL_get_wbio(s));
if (ret <= 0)
return ret;
used_len = DTLS1_RT_HEADER_LENGTH + mac_size + blocksize;
if (s->d1->mtu > used_len + DTLS1_HM_HEADER_LENGTH) {
curr_mtu = s->d1->mtu - used_len;
} else {
/* Shouldn't happen */
return -1;
}
}
/*
* We just checked that s->init_num > 0 so this cast should be safe
*/
if (((unsigned int)s->init_num) > curr_mtu)
len = curr_mtu;
else
len = s->init_num;
/* Shouldn't ever happen */
if (len > INT_MAX)
len = INT_MAX;
/*
* XDTLS: this function is too long. split out the CCS part
*/
if (type == SSL3_RT_HANDSHAKE) {
if (len < DTLS1_HM_HEADER_LENGTH) {
/*
* len is so small that we really can't do anything sensible
* so fail
*/
return -1;
}
dtls1_fix_message_header(s, frag_off,
len - DTLS1_HM_HEADER_LENGTH);
dtls1_write_message_header(s,
(unsigned char *)&s->init_buf->
data[s->init_off]);
}
ret = dtls1_write_bytes(s, type, &s->init_buf->data[s->init_off],
len);
if (ret < 0) {
/*
* might need to update MTU here, but we don't know which
* previous packet caused the failure -- so can't really
* retransmit anything. continue as if everything is fine and
* wait for an alert to handle the retransmit
*/
if (retry && BIO_ctrl(SSL_get_wbio(s),
BIO_CTRL_DGRAM_MTU_EXCEEDED, 0, NULL) > 0) {
if (!(SSL_get_options(s) & SSL_OP_NO_QUERY_MTU)) {
if (!dtls1_query_mtu(s))
return -1;
/* Have one more go */
retry = 0;
} else
return -1;
} else {
return (-1);
}
} else {
/*
* bad if this assert fails, only part of the handshake message
* got sent. but why would this happen?
*/
OPENSSL_assert(len == (unsigned int)ret);
if (type == SSL3_RT_HANDSHAKE && !s->d1->retransmitting) {
/*
* should not be done for 'Hello Request's, but in that case
* we'll ignore the result anyway
*/
unsigned char *p =
(unsigned char *)&s->init_buf->data[s->init_off];
const struct hm_header_st *msg_hdr = &s->d1->w_msg_hdr;
int xlen;
if (frag_off == 0 && s->version != DTLS1_BAD_VER) {
/*
* reconstruct message header is if it is being sent in
* single fragment
*/
*p++ = msg_hdr->type;
l2n3(msg_hdr->msg_len, p);
s2n(msg_hdr->seq, p);
l2n3(0, p);
l2n3(msg_hdr->msg_len, p);
p -= DTLS1_HM_HEADER_LENGTH;
xlen = ret;
} else {
p += DTLS1_HM_HEADER_LENGTH;
xlen = ret - DTLS1_HM_HEADER_LENGTH;
}
ssl3_finish_mac(s, p, xlen);
}
if (ret == s->init_num) {
if (s->msg_callback)
s->msg_callback(1, s->version, type, s->init_buf->data,
(size_t)(s->init_off + s->init_num), s,
s->msg_callback_arg);
s->init_off = 0; /* done writing this message */
s->init_num = 0;
return (1);
}
s->init_off += ret;
s->init_num -= ret;
ret -= DTLS1_HM_HEADER_LENGTH;
frag_off += ret;
/*
* We save the fragment offset for the next fragment so we have it
* available in case of an IO retry. We don't know the length of the
* next fragment yet so just set that to 0 for now. It will be
* updated again later.
*/
dtls1_fix_message_header(s, frag_off, 0);
}
}
return (0);
}
|
d2a_function_data_5271
|
static inline void writer_print_string(WriterContext *wctx,
const char *key, const char *val, int opt)
{
if (opt && !(wctx->writer->flags & WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS))
return;
wctx->writer->print_string(wctx, key, val);
wctx->nb_item++;
}
|
d2a_function_data_5272
|
static int oma_read_header(AVFormatContext *s)
{
int ret, framesize, jsflag, samplerate;
uint32_t codec_params, channel_id;
int16_t eid;
uint8_t buf[EA3_HEADER_SIZE];
uint8_t *edata;
AVStream *st;
ID3v2ExtraMeta *extra_meta = NULL;
OMAContext *oc = s->priv_data;
ff_id3v2_read(s, ID3v2_EA3_MAGIC, &extra_meta, 0);
if ((ret = ff_id3v2_parse_chapters(s, &extra_meta)) < 0) {
ff_id3v2_free_extra_meta(&extra_meta);
return ret;
}
ret = avio_read(s->pb, buf, EA3_HEADER_SIZE);
if (ret < EA3_HEADER_SIZE)
return -1;
if (memcmp(buf, ((const uint8_t[]){'E', 'A', '3'}), 3) ||
buf[4] != 0 || buf[5] != EA3_HEADER_SIZE) {
av_log(s, AV_LOG_ERROR, "Couldn't find the EA3 header !\n");
return AVERROR_INVALIDDATA;
}
oc->content_start = avio_tell(s->pb);
/* encrypted file */
eid = AV_RB16(&buf[6]);
if (eid != -1 && eid != -128 && decrypt_init(s, extra_meta, buf) < 0) {
ff_id3v2_free_extra_meta(&extra_meta);
return -1;
}
ff_id3v2_free_extra_meta(&extra_meta);
codec_params = AV_RB24(&buf[33]);
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
st->start_time = 0;
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_tag = buf[32];
st->codecpar->codec_id = ff_codec_get_id(ff_oma_codec_tags,
st->codecpar->codec_tag);
oc->read_packet = read_packet;
switch (buf[32]) {
case OMA_CODECID_ATRAC3:
samplerate = ff_oma_srate_tab[(codec_params >> 13) & 7] * 100;
if (!samplerate) {
av_log(s, AV_LOG_ERROR, "Unsupported sample rate\n");
return AVERROR_INVALIDDATA;
}
if (samplerate != 44100)
avpriv_request_sample(s, "Sample rate %d", samplerate);
framesize = (codec_params & 0x3FF) * 8;
/* get stereo coding mode, 1 for joint-stereo */
jsflag = (codec_params >> 17) & 1;
st->codecpar->channels = 2;
st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
st->codecpar->sample_rate = samplerate;
st->codecpar->bit_rate = st->codecpar->sample_rate * framesize / (1024 / 8);
/* fake the ATRAC3 extradata
* (wav format, makes stream copy to wav work) */
if (ff_alloc_extradata(st->codecpar, 14))
return AVERROR(ENOMEM);
edata = st->codecpar->extradata;
AV_WL16(&edata[0], 1); // always 1
AV_WL32(&edata[2], samplerate); // samples rate
AV_WL16(&edata[6], jsflag); // coding mode
AV_WL16(&edata[8], jsflag); // coding mode
AV_WL16(&edata[10], 1); // always 1
// AV_WL16(&edata[12], 0); // always 0
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
break;
case OMA_CODECID_ATRAC3P:
channel_id = (codec_params >> 10) & 7;
if (!channel_id) {
av_log(s, AV_LOG_ERROR,
"Invalid ATRAC-X channel id: %"PRIu32"\n", channel_id);
return AVERROR_INVALIDDATA;
}
st->codecpar->channel_layout = ff_oma_chid_to_native_layout[channel_id - 1];
st->codecpar->channels = ff_oma_chid_to_num_channels[channel_id - 1];
framesize = ((codec_params & 0x3FF) * 8) + 8;
samplerate = ff_oma_srate_tab[(codec_params >> 13) & 7] * 100;
if (!samplerate) {
av_log(s, AV_LOG_ERROR, "Unsupported sample rate\n");
return AVERROR_INVALIDDATA;
}
st->codecpar->sample_rate = samplerate;
st->codecpar->bit_rate = samplerate * framesize / (2048 / 8);
avpriv_set_pts_info(st, 64, 1, samplerate);
break;
case OMA_CODECID_MP3:
st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
framesize = 1024;
break;
case OMA_CODECID_LPCM:
/* PCM 44.1 kHz 16 bit stereo big-endian */
st->codecpar->channels = 2;
st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
st->codecpar->sample_rate = 44100;
framesize = 1024;
/* bit rate = sample rate x PCM block align (= 4) x 8 */
st->codecpar->bit_rate = st->codecpar->sample_rate * 32;
st->codecpar->bits_per_coded_sample =
av_get_bits_per_sample(st->codecpar->codec_id);
avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
break;
case OMA_CODECID_ATRAC3AL:
st->codecpar->channels = 2;
st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
st->codecpar->sample_rate = 44100;
avpriv_set_pts_info(st, 64, 1, 44100);
oc->read_packet = aal_read_packet;
framesize = 4096;
break;
case OMA_CODECID_ATRAC3PAL:
st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
st->codecpar->channels = 2;
st->codecpar->sample_rate = 44100;
avpriv_set_pts_info(st, 64, 1, 44100);
oc->read_packet = aal_read_packet;
framesize = 4096;
break;
default:
av_log(s, AV_LOG_ERROR, "Unsupported codec %d!\n", buf[32]);
return AVERROR(ENOSYS);
}
st->codecpar->block_align = framesize;
return 0;
}
|
d2a_function_data_5273
|
static av_always_inline int setup_classifs(vorbis_context *vc,
vorbis_residue *vr,
uint8_t *do_not_decode,
unsigned ch_used,
int partition_count)
{
int p, j, i;
unsigned c_p_c = vc->codebooks[vr->classbook].dimensions;
unsigned inverse_class = ff_inverse[vr->classifications];
unsigned temp, temp2;
for (p = 0, j = 0; j < ch_used; ++j) {
if (!do_not_decode[j]) {
temp = get_vlc2(&vc->gb, vc->codebooks[vr->classbook].vlc.table,
vc->codebooks[vr->classbook].nb_bits, 3);
av_dlog(NULL, "Classword: %u\n", temp);
if ((int)temp < 0)
return temp;
av_assert0(vr->classifications > 1); //needed for inverse[]
if (temp <= 65536) {
for (i = partition_count + c_p_c - 1; i >= partition_count; i--) {
temp2 = (((uint64_t)temp) * inverse_class) >> 32;
if (i < vr->ptns_to_read)
vr->classifs[p + i] = temp - temp2 * vr->classifications;
temp = temp2;
}
} else {
for (i = partition_count + c_p_c - 1; i >= partition_count; i--) {
temp2 = temp / vr->classifications;
if (i < vr->ptns_to_read)
vr->classifs[p + i] = temp - temp2 * vr->classifications;
temp = temp2;
}
}
}
p += vr->ptns_to_read;
}
return 0;
}
|
d2a_function_data_5274
|
AVBitStreamFilterContext *av_bitstream_filter_init(const char *name)
{
AVBitStreamFilter *bsf = first_bitstream_filter;
while (bsf) {
if (!strcmp(name, bsf->name)) {
AVBitStreamFilterContext *bsfc =
av_mallocz(sizeof(AVBitStreamFilterContext));
if (!bsfc)
return NULL;
bsfc->filter = bsf;
bsfc->priv_data = NULL;
if (bsf->priv_data_size) {
bsfc->priv_data = av_mallocz(bsf->priv_data_size);
if (!bsfc->priv_data) {
av_freep(&bsfc);
return NULL;
}
}
return bsfc;
}
bsf = bsf->next;
}
return NULL;
}
|
d2a_function_data_5275
|
static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
{
int i, ret = 0;
s->ref = NULL;
s->last_eos = s->eos;
s->eos = 0;
/* split the input packet into NAL units, so we know the upper bound on the
* number of slices in the frame */
ret = ff_h2645_packet_split(&s->pkt, buf, length, s->avctx, s->is_nalff,
s->nal_length_size, s->avctx->codec_id, 1);
if (ret < 0) {
av_log(s->avctx, AV_LOG_ERROR,
"Error splitting the input into NAL units.\n");
return ret;
}
for (i = 0; i < s->pkt.nb_nals; i++) {
if (s->pkt.nals[i].type == NAL_EOB_NUT ||
s->pkt.nals[i].type == NAL_EOS_NUT)
s->eos = 1;
}
/* decode the NAL units */
for (i = 0; i < s->pkt.nb_nals; i++) {
ret = decode_nal_unit(s, &s->pkt.nals[i]);
if (ret < 0) {
av_log(s->avctx, AV_LOG_WARNING,
"Error parsing NAL unit #%d.\n", i);
goto fail;
}
}
fail:
if (s->ref && s->threads_type == FF_THREAD_FRAME)
ff_thread_report_progress(&s->ref->tf, INT_MAX, 0);
return ret;
}
|
d2a_function_data_5276
|
static void
ngx_conf_flush_files(ngx_cycle_t *cycle)
{
ngx_uint_t i;
ngx_list_part_t *part;
ngx_open_file_t *file;
ngx_log_debug0(NGX_LOG_DEBUG_CORE, cycle->log, 0, "flush files");
part = &cycle->open_files.part;
file = part->elts;
for (i = 0; /* void */ ; i++) {
if (i >= part->nelts) {
if (part->next == NULL) {
break;
}
part = part->next;
file = part->elts;
i = 0;
}
if (file[i].flush) {
file[i].flush(&file[i], cycle->log);
}
}
}
|
d2a_function_data_5277
|
int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,
int (*compare)(AVFormatContext *, AVPacket *, AVPacket *))
{
AVPacketList **next_point, *this_pktl;
AVStream *st = s->streams[pkt->stream_index];
int chunked = s->max_chunk_size || s->max_chunk_duration;
this_pktl = av_mallocz(sizeof(AVPacketList));
if (!this_pktl)
return AVERROR(ENOMEM);
this_pktl->pkt = *pkt;
pkt->destruct = NULL; // do not free original but only the copy
av_dup_packet(&this_pktl->pkt); // duplicate the packet if it uses non-allocated memory
if (s->streams[pkt->stream_index]->last_in_packet_buffer) {
next_point = &(st->last_in_packet_buffer->next);
} else {
next_point = &s->packet_buffer;
}
if (chunked) {
uint64_t max= av_rescale_q_rnd(s->max_chunk_duration, AV_TIME_BASE_Q, st->time_base, AV_ROUND_UP);
st->interleaver_chunk_size += pkt->size;
st->interleaver_chunk_duration += pkt->duration;
if ( (s->max_chunk_size && st->interleaver_chunk_size > s->max_chunk_size)
|| (max && st->interleaver_chunk_duration > max)) {
st->interleaver_chunk_size =
st->interleaver_chunk_duration = 0;
this_pktl->pkt.flags |= CHUNK_START;
}
}
if (*next_point) {
if (chunked && !(this_pktl->pkt.flags & CHUNK_START))
goto next_non_null;
if (compare(s, &s->packet_buffer_end->pkt, pkt)) {
while ( *next_point
&& ((chunked && !((*next_point)->pkt.flags&CHUNK_START))
|| !compare(s, &(*next_point)->pkt, pkt)))
next_point = &(*next_point)->next;
if (*next_point)
goto next_non_null;
} else {
next_point = &(s->packet_buffer_end->next);
}
}
av_assert1(!*next_point);
s->packet_buffer_end = this_pktl;
next_non_null:
this_pktl->next = *next_point;
s->streams[pkt->stream_index]->last_in_packet_buffer =
*next_point = this_pktl;
return 0;
}
|
d2a_function_data_5278
|
static int pkey_set_type(EVP_PKEY *pkey, int type, const char *str, int len)
{
const EVP_PKEY_ASN1_METHOD *ameth;
ENGINE *e = NULL;
if (pkey) {
if (pkey->pkey.ptr)
EVP_PKEY_free_it(pkey);
/*
* If key type matches and a method exists then this lookup has
* succeeded once so just indicate success.
*/
if ((type == pkey->save_type) && pkey->ameth)
return 1;
#ifndef OPENSSL_NO_ENGINE
/* If we have an ENGINE release it */
ENGINE_finish(pkey->engine);
pkey->engine = NULL;
#endif
}
if (str)
ameth = EVP_PKEY_asn1_find_str(&e, str, len);
else
ameth = EVP_PKEY_asn1_find(&e, type);
#ifndef OPENSSL_NO_ENGINE
if (pkey == NULL)
ENGINE_finish(e);
#endif
if (ameth == NULL) {
EVPerr(EVP_F_PKEY_SET_TYPE, EVP_R_UNSUPPORTED_ALGORITHM);
return 0;
}
if (pkey) {
pkey->ameth = ameth;
pkey->engine = e;
pkey->type = pkey->ameth->pkey_id;
pkey->save_type = type;
}
return 1;
}
|
d2a_function_data_5279
|
static int64_t pva_read_timestamp(struct AVFormatContext *s, int stream_index,
int64_t *pos, int64_t pos_limit) {
ByteIOContext *pb = s->pb;
PVAContext *pvactx = s->priv_data;
int length, streamid;
int64_t res = AV_NOPTS_VALUE;
pos_limit = FFMIN(*pos+PVA_MAX_PAYLOAD_LENGTH*8, (uint64_t)*pos+pos_limit);
while (*pos < pos_limit) {
res = AV_NOPTS_VALUE;
url_fseek(pb, *pos, SEEK_SET);
pvactx->continue_pes = 0;
if (read_part_of_packet(s, &res, &length, &streamid, 0)) {
(*pos)++;
continue;
}
if (streamid - 1 != stream_index || res == AV_NOPTS_VALUE) {
*pos = url_ftell(pb) + length;
continue;
}
break;
}
pvactx->continue_pes = 0;
return res;
}
|
d2a_function_data_5280
|
static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t flags)
{
int isv34, tlen, unsync;
char tag[5];
int64_t next, end = avio_tell(s->pb) + len;
int taghdrlen;
const char *reason = NULL;
AVIOContext pb;
unsigned char *buffer = NULL;
int buffer_size = 0;
switch (version) {
case 2:
if (flags & 0x40) {
reason = "compression";
goto error;
}
isv34 = 0;
taghdrlen = 6;
break;
case 3:
case 4:
isv34 = 1;
taghdrlen = 10;
break;
default:
reason = "version";
goto error;
}
unsync = flags & 0x80;
if (isv34 && flags & 0x40) /* Extended header present, just skip over it */
avio_skip(s->pb, get_size(s->pb, 4));
while (len >= taghdrlen) {
unsigned int tflags;
int tunsync = 0;
if (isv34) {
avio_read(s->pb, tag, 4);
tag[4] = 0;
if(version==3){
tlen = avio_rb32(s->pb);
}else
tlen = get_size(s->pb, 4);
tflags = avio_rb16(s->pb);
tunsync = tflags & ID3v2_FLAG_UNSYNCH;
} else {
avio_read(s->pb, tag, 3);
tag[3] = 0;
tlen = avio_rb24(s->pb);
}
if (tlen < 0 || tlen > len - taghdrlen) {
av_log(s, AV_LOG_WARNING, "Invalid size in frame %s, skipping the rest of tag.\n", tag);
break;
}
len -= taghdrlen + tlen;
next = avio_tell(s->pb) + tlen;
if (tflags & ID3v2_FLAG_DATALEN) {
avio_rb32(s->pb);
tlen -= 4;
}
if (tflags & (ID3v2_FLAG_ENCRYPTION | ID3v2_FLAG_COMPRESSION)) {
av_log(s, AV_LOG_WARNING, "Skipping encrypted/compressed ID3v2 frame %s.\n", tag);
avio_skip(s->pb, tlen);
} else if (tag[0] == 'T') {
if (unsync || tunsync) {
int i, j;
av_fast_malloc(&buffer, &buffer_size, tlen);
for (i = 0, j = 0; i < tlen; i++, j++) {
buffer[j] = avio_r8(s->pb);
if (j > 0 && !buffer[j] && buffer[j - 1] == 0xff) {
/* Unsynchronised byte, skip it */
j--;
}
}
ffio_init_context(&pb, buffer, j, 0, NULL, NULL, NULL, NULL);
read_ttag(s, &pb, j, tag);
} else {
read_ttag(s, s->pb, tlen, tag);
}
}
else if (!tag[0]) {
if (tag[1])
av_log(s, AV_LOG_WARNING, "invalid frame id, assuming padding");
avio_skip(s->pb, tlen);
break;
}
/* Skip to end of tag */
avio_seek(s->pb, next, SEEK_SET);
}
if (version == 4 && flags & 0x10) /* Footer preset, always 10 bytes, skip over it */
end += 10;
error:
if (reason)
av_log(s, AV_LOG_INFO, "ID3v2.%d tag skipped, cannot handle %s\n", version, reason);
avio_seek(s->pb, end, SEEK_SET);
av_free(buffer);
return;
}
|
d2a_function_data_5281
|
int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
enum AVPixelFormat pix_fmt, int width, int height)
{
int i, ret;
if (pix_fmt != AV_PIX_FMT_YUV420P &&
pix_fmt != AV_PIX_FMT_YUVJ420P &&
pix_fmt != AV_PIX_FMT_YUV422P &&
pix_fmt != AV_PIX_FMT_YUVJ422P &&
pix_fmt != AV_PIX_FMT_YUV444P &&
pix_fmt != AV_PIX_FMT_YUV411P &&
pix_fmt != AV_PIX_FMT_GRAY8)
return -1;
if ((width & 3) != 0 || (height & 3) != 0)
return -1;
for(i=0;i<3;i++) {
if (i == 1) {
switch(pix_fmt) {
case AV_PIX_FMT_YUVJ420P:
case AV_PIX_FMT_YUV420P:
width >>= 1;
height >>= 1;
break;
case AV_PIX_FMT_YUV422P:
case AV_PIX_FMT_YUVJ422P:
width >>= 1;
break;
case AV_PIX_FMT_YUV411P:
width >>= 2;
break;
default:
break;
}
if (pix_fmt == AV_PIX_FMT_GRAY8) {
break;
}
}
if (src == dst) {
ret = deinterlace_bottom_field_inplace(dst->data[i],
dst->linesize[i],
width, height);
if (ret < 0)
return ret;
} else {
deinterlace_bottom_field(dst->data[i],dst->linesize[i],
src->data[i], src->linesize[i],
width, height);
}
}
emms_c();
return 0;
}
|
d2a_function_data_5282
|
static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
{
BN_ULONG *a = NULL;
bn_check_top(b);
if (words > (INT_MAX / (4 * BN_BITS2))) {
BNerr(BN_F_BN_EXPAND_INTERNAL, BN_R_BIGNUM_TOO_LONG);
return NULL;
}
if (BN_get_flags(b, BN_FLG_STATIC_DATA)) {
BNerr(BN_F_BN_EXPAND_INTERNAL, BN_R_EXPAND_ON_STATIC_BIGNUM_DATA);
return (NULL);
}
if (BN_get_flags(b, BN_FLG_SECURE))
a = OPENSSL_secure_zalloc(words * sizeof(*a));
else
a = OPENSSL_zalloc(words * sizeof(*a));
if (a == NULL) {
BNerr(BN_F_BN_EXPAND_INTERNAL, ERR_R_MALLOC_FAILURE);
return (NULL);
}
assert(b->top <= words);
if (b->top > 0)
memcpy(a, b->d, sizeof(*a) * b->top);
return a;
}
|
d2a_function_data_5283
|
static void proxy_wstunnel_callback(void *b) {
int status;
apr_socket_t *sockets[3] = {NULL, NULL, NULL};
ws_baton_t *baton = (ws_baton_t*)b;
proxyws_dir_conf *dconf = ap_get_module_config(baton->r->per_dir_config, &proxy_wstunnel_module);
apr_pool_clear(baton->subpool);
status = proxy_wstunnel_pump(baton, dconf->async_delay, dconf->is_async);
if (status == SUSPENDED) {
sockets[0] = baton->client_soc;
sockets[1] = baton->server_soc;
ap_mpm_register_socket_callback_timeout(sockets, baton->subpool, 1,
proxy_wstunnel_callback,
proxy_wstunnel_cancel_callback,
baton,
dconf->idle_timeout);
ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, baton->r, "proxy_wstunnel_callback suspend");
}
else {
proxy_wstunnel_finish(baton);
}
}
|
d2a_function_data_5284
|
static int ff_asf_get_packet(AVFormatContext *s, AVIOContext *pb)
{
ASFContext *asf = s->priv_data;
uint32_t packet_length, padsize;
int rsize = 8;
int c, d, e, off;
// if we do not know packet size, allow skipping up to 32 kB
off= 32768;
if (s->packet_size > 0)
off= (avio_tell(pb) - s->data_offset) % s->packet_size + 3;
c=d=e=-1;
while(off-- > 0){
c=d; d=e;
e= avio_r8(pb);
if(c == 0x82 && !d && !e)
break;
}
if (c != 0x82) {
/**
* This code allows handling of -EAGAIN at packet boundaries (i.e.
* if the packet sync code above triggers -EAGAIN). This does not
* imply complete -EAGAIN handling support at random positions in
* the stream.
*/
if (pb->error == AVERROR(EAGAIN))
return AVERROR(EAGAIN);
if (!pb->eof_reached)
av_log(s, AV_LOG_ERROR, "ff asf bad header %x at:%"PRId64"\n", c, avio_tell(pb));
}
if ((c & 0x8f) == 0x82) {
if (d || e) {
if (!pb->eof_reached)
av_log(s, AV_LOG_ERROR, "ff asf bad non zero\n");
return -1;
}
c= avio_r8(pb);
d= avio_r8(pb);
rsize+=3;
}else{
avio_seek(pb, -1, SEEK_CUR); //FIXME
}
asf->packet_flags = c;
asf->packet_property = d;
DO_2BITS(asf->packet_flags >> 5, packet_length, s->packet_size);
DO_2BITS(asf->packet_flags >> 1, padsize, 0); // sequence ignored
DO_2BITS(asf->packet_flags >> 3, padsize, 0); // padding length
//the following checks prevent overflows and infinite loops
if(!packet_length || packet_length >= (1U<<29)){
av_log(s, AV_LOG_ERROR, "invalid packet_length %d at:%"PRId64"\n", packet_length, avio_tell(pb));
return -1;
}
if(padsize >= packet_length){
av_log(s, AV_LOG_ERROR, "invalid padsize %d at:%"PRId64"\n", padsize, avio_tell(pb));
return -1;
}
asf->packet_timestamp = avio_rl32(pb);
avio_rl16(pb); /* duration */
// rsize has at least 11 bytes which have to be present
if (asf->packet_flags & 0x01) {
asf->packet_segsizetype = avio_r8(pb); rsize++;
asf->packet_segments = asf->packet_segsizetype & 0x3f;
} else {
asf->packet_segments = 1;
asf->packet_segsizetype = 0x80;
}
asf->packet_size_left = packet_length - padsize - rsize;
if (packet_length < asf->hdr.min_pktsize)
padsize += asf->hdr.min_pktsize - packet_length;
asf->packet_padsize = padsize;
av_dlog(s, "packet: size=%d padsize=%d left=%d\n", s->packet_size, asf->packet_padsize, asf->packet_size_left);
return 0;
}
|
d2a_function_data_5285
|
static const unsigned char *authz_find_data(const unsigned char *authz,
size_t authz_length,
unsigned char data_type,
size_t *data_length)
{
if (authz == NULL) return NULL;
if (!authz_validate(authz, authz_length))
{
SSLerr(SSL_F_AUTHZ_FIND_DATA,SSL_R_INVALID_AUTHZ_DATA);
return NULL;
}
for (;;)
{
unsigned char type;
unsigned short len;
if (!authz_length)
return NULL;
type = *(authz++);
authz_length--;
/* We've validated the authz data, so we don't have to
* check again that we have enough bytes left. */
len = ((unsigned short) authz[0]) << 8 |
((unsigned short) authz[1]);
authz += 2;
authz_length -= 2;
if (type == data_type)
{
*data_length = len;
return authz;
}
authz += len;
authz_length -= len;
}
/* No match */
return NULL;
}
|
d2a_function_data_5286
|
static int64_t scene_sad16(FrameRateContext *s, const uint16_t *p1, int p1_linesize, const uint16_t* p2, int p2_linesize, const int width, const int height)
{
int64_t sad;
int x, y;
for (sad = y = 0; y < height - 7; y += 8) {
for (x = 0; x < width - 7; x += 8) {
sad += sad_8x8_16(p1 + y * p1_linesize + x,
p1_linesize,
p2 + y * p2_linesize + x,
p2_linesize);
}
}
return sad;
}
|
d2a_function_data_5287
|
static apr_status_t event_register_socket_callback(apr_socket_t **s,
apr_pool_t *p,
int for_read,
ap_mpm_callback_fn_t *cbfn,
void *baton)
{
apr_status_t rc, final_rc= APR_SUCCESS;
int i = 0, nsock;
socket_callback_baton_t *scb = apr_pcalloc(p, sizeof(*scb));
listener_poll_type *pt = apr_palloc(p, sizeof(*pt));
apr_pollfd_t **pfds = NULL;
while(s[i] != NULL) {
i++;
}
nsock = i;
pfds = apr_palloc(p, nsock * sizeof(apr_pollfd_t*));
pt->type = PT_USER;
pt->baton = scb;
scb->cbfunc = cbfn;
scb->user_baton = baton;
scb->nsock = nsock;
scb->pfds = pfds;
for (i = 0; i<nsock; i++) {
pfds[i] = apr_palloc(p, sizeof(apr_pollfd_t));
pfds[i]->desc_type = APR_POLL_SOCKET;
pfds[i]->reqevents = (for_read ? APR_POLLIN : APR_POLLOUT) | APR_POLLERR | APR_POLLHUP;
pfds[i]->desc.s = s[i];
pfds[i]->client_data = pt;
rc = apr_pollset_add(event_pollset, pfds[i]);
if (rc != APR_SUCCESS) final_rc = rc;
}
return final_rc;
}
|
d2a_function_data_5288
|
static int tgv_decode_inter(TgvContext * s, const uint8_t *buf, const uint8_t *buf_end){
int num_mvs;
int num_blocks_raw;
int num_blocks_packed;
int vector_bits;
int i,j,x,y;
GetBitContext gb;
int mvbits;
const unsigned char *blocks_raw;
if(buf+12>buf_end)
return -1;
num_mvs = AV_RL16(&buf[0]);
num_blocks_raw = AV_RL16(&buf[2]);
num_blocks_packed = AV_RL16(&buf[4]);
vector_bits = AV_RL16(&buf[6]);
buf += 12;
/* allocate codebook buffers as necessary */
if (num_mvs > s->num_mvs) {
s->mv_codebook = av_realloc(s->mv_codebook, num_mvs*2*sizeof(int));
s->num_mvs = num_mvs;
}
if (num_blocks_packed > s->num_blocks_packed) {
s->block_codebook = av_realloc(s->block_codebook, num_blocks_packed*16*sizeof(unsigned char));
s->num_blocks_packed = num_blocks_packed;
}
/* read motion vectors */
mvbits = (num_mvs*2*10+31) & ~31;
if (buf+(mvbits>>3)+16*num_blocks_raw+8*num_blocks_packed>buf_end)
return -1;
init_get_bits(&gb, buf, mvbits);
for (i=0; i<num_mvs; i++) {
s->mv_codebook[i][0] = get_sbits(&gb, 10);
s->mv_codebook[i][1] = get_sbits(&gb, 10);
}
buf += mvbits>>3;
/* note ptr to uncompressed blocks */
blocks_raw = buf;
buf += num_blocks_raw*16;
/* read compressed blocks */
init_get_bits(&gb, buf, (buf_end-buf)<<3);
for (i=0; i<num_blocks_packed; i++) {
int tmp[4];
for(j=0; j<4; j++)
tmp[j] = get_bits(&gb, 8);
for(j=0; j<16; j++)
s->block_codebook[i][15-j] = tmp[get_bits(&gb, 2)];
}
if (get_bits_left(&gb) < vector_bits *
(s->avctx->height/4) * (s->avctx->width/4))
return -1;
/* read vectors and build frame */
for(y=0; y<s->avctx->height/4; y++)
for(x=0; x<s->avctx->width/4; x++) {
unsigned int vector = get_bits(&gb, vector_bits);
const unsigned char *src;
int src_stride;
if (vector < num_mvs) {
int mx = x * 4 + s->mv_codebook[vector][0];
int my = y * 4 + s->mv_codebook[vector][1];
if ( mx < 0 || mx + 4 > s->avctx->width
|| my < 0 || my + 4 > s->avctx->height)
continue;
src = s->last_frame.data[0] + mx + my * s->last_frame.linesize[0];
src_stride = s->last_frame.linesize[0];
}else{
int offset = vector - num_mvs;
if (offset<num_blocks_raw)
src = blocks_raw + 16*offset;
else if (offset-num_blocks_raw<num_blocks_packed)
src = s->block_codebook[offset-num_blocks_raw];
else
continue;
src_stride = 4;
}
for(j=0; j<4; j++)
for(i=0; i<4; i++)
s->frame.data[0][ (y*4+j)*s->frame.linesize[0] + (x*4+i) ] =
src[j*src_stride + i];
}
return 0;
}
|
d2a_function_data_5289
|
static void stereo_processing(PSContext *ps, float (*l)[32][2], float (*r)[32][2], int is34)
{
int e, b, k;
float (*H11)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H11;
float (*H12)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H12;
float (*H21)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H21;
float (*H22)[PS_MAX_NUM_ENV+1][PS_MAX_NR_IIDICC] = ps->H22;
int8_t *opd_hist = ps->opd_hist;
int8_t *ipd_hist = ps->ipd_hist;
int8_t iid_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC];
int8_t icc_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC];
int8_t ipd_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC];
int8_t opd_mapped_buf[PS_MAX_NUM_ENV][PS_MAX_NR_IIDICC];
int8_t (*iid_mapped)[PS_MAX_NR_IIDICC] = iid_mapped_buf;
int8_t (*icc_mapped)[PS_MAX_NR_IIDICC] = icc_mapped_buf;
int8_t (*ipd_mapped)[PS_MAX_NR_IIDICC] = ipd_mapped_buf;
int8_t (*opd_mapped)[PS_MAX_NR_IIDICC] = opd_mapped_buf;
const int8_t *k_to_i = is34 ? k_to_i_34 : k_to_i_20;
TABLE_CONST float (*H_LUT)[8][4] = (PS_BASELINE || ps->icc_mode < 3) ? HA : HB;
//Remapping
if (ps->num_env_old) {
memcpy(H11[0][0], H11[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[0][0][0]));
memcpy(H11[1][0], H11[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H11[1][0][0]));
memcpy(H12[0][0], H12[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[0][0][0]));
memcpy(H12[1][0], H12[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H12[1][0][0]));
memcpy(H21[0][0], H21[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[0][0][0]));
memcpy(H21[1][0], H21[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H21[1][0][0]));
memcpy(H22[0][0], H22[0][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[0][0][0]));
memcpy(H22[1][0], H22[1][ps->num_env_old], PS_MAX_NR_IIDICC*sizeof(H22[1][0][0]));
}
if (is34) {
remap34(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1);
remap34(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1);
if (ps->enable_ipdopd) {
remap34(&ipd_mapped, ps->ipd_par, ps->nr_ipdopd_par, ps->num_env, 0);
remap34(&opd_mapped, ps->opd_par, ps->nr_ipdopd_par, ps->num_env, 0);
}
if (!ps->is34bands_old) {
map_val_20_to_34(H11[0][0]);
map_val_20_to_34(H11[1][0]);
map_val_20_to_34(H12[0][0]);
map_val_20_to_34(H12[1][0]);
map_val_20_to_34(H21[0][0]);
map_val_20_to_34(H21[1][0]);
map_val_20_to_34(H22[0][0]);
map_val_20_to_34(H22[1][0]);
ipdopd_reset(ipd_hist, opd_hist);
}
} else {
remap20(&iid_mapped, ps->iid_par, ps->nr_iid_par, ps->num_env, 1);
remap20(&icc_mapped, ps->icc_par, ps->nr_icc_par, ps->num_env, 1);
if (ps->enable_ipdopd) {
remap20(&ipd_mapped, ps->ipd_par, ps->nr_ipdopd_par, ps->num_env, 0);
remap20(&opd_mapped, ps->opd_par, ps->nr_ipdopd_par, ps->num_env, 0);
}
if (ps->is34bands_old) {
map_val_34_to_20(H11[0][0]);
map_val_34_to_20(H11[1][0]);
map_val_34_to_20(H12[0][0]);
map_val_34_to_20(H12[1][0]);
map_val_34_to_20(H21[0][0]);
map_val_34_to_20(H21[1][0]);
map_val_34_to_20(H22[0][0]);
map_val_34_to_20(H22[1][0]);
ipdopd_reset(ipd_hist, opd_hist);
}
}
//Mixing
for (e = 0; e < ps->num_env; e++) {
for (b = 0; b < NR_PAR_BANDS[is34]; b++) {
float h11, h12, h21, h22;
h11 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][0];
h12 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][1];
h21 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][2];
h22 = H_LUT[iid_mapped[e][b] + 7 + 23 * ps->iid_quant][icc_mapped[e][b]][3];
if (!PS_BASELINE && ps->enable_ipdopd && b < NR_IPDOPD_BANDS[is34]) {
//The spec say says to only run this smoother when enable_ipdopd
//is set but the reference decoder appears to run it constantly
float h11i, h12i, h21i, h22i;
float ipd_adj_re, ipd_adj_im;
int opd_idx = opd_hist[b] * 8 + opd_mapped[e][b];
int ipd_idx = ipd_hist[b] * 8 + ipd_mapped[e][b];
float opd_re = pd_re_smooth[opd_idx];
float opd_im = pd_im_smooth[opd_idx];
float ipd_re = pd_re_smooth[ipd_idx];
float ipd_im = pd_im_smooth[ipd_idx];
opd_hist[b] = opd_idx & 0x3F;
ipd_hist[b] = ipd_idx & 0x3F;
ipd_adj_re = opd_re*ipd_re + opd_im*ipd_im;
ipd_adj_im = opd_im*ipd_re - opd_re*ipd_im;
h11i = h11 * opd_im;
h11 = h11 * opd_re;
h12i = h12 * ipd_adj_im;
h12 = h12 * ipd_adj_re;
h21i = h21 * opd_im;
h21 = h21 * opd_re;
h22i = h22 * ipd_adj_im;
h22 = h22 * ipd_adj_re;
H11[1][e+1][b] = h11i;
H12[1][e+1][b] = h12i;
H21[1][e+1][b] = h21i;
H22[1][e+1][b] = h22i;
}
H11[0][e+1][b] = h11;
H12[0][e+1][b] = h12;
H21[0][e+1][b] = h21;
H22[0][e+1][b] = h22;
}
for (k = 0; k < NR_BANDS[is34]; k++) {
float h[2][4];
float h_step[2][4];
int start = ps->border_position[e];
int stop = ps->border_position[e+1];
float width = 1.f / (stop - start);
b = k_to_i[k];
h[0][0] = H11[0][e][b];
h[0][1] = H12[0][e][b];
h[0][2] = H21[0][e][b];
h[0][3] = H22[0][e][b];
if (!PS_BASELINE && ps->enable_ipdopd) {
//Is this necessary? ps_04_new seems unchanged
if ((is34 && k <= 13 && k >= 9) || (!is34 && k <= 1)) {
h[1][0] = -H11[1][e][b];
h[1][1] = -H12[1][e][b];
h[1][2] = -H21[1][e][b];
h[1][3] = -H22[1][e][b];
} else {
h[1][0] = H11[1][e][b];
h[1][1] = H12[1][e][b];
h[1][2] = H21[1][e][b];
h[1][3] = H22[1][e][b];
}
}
//Interpolation
h_step[0][0] = (H11[0][e+1][b] - h[0][0]) * width;
h_step[0][1] = (H12[0][e+1][b] - h[0][1]) * width;
h_step[0][2] = (H21[0][e+1][b] - h[0][2]) * width;
h_step[0][3] = (H22[0][e+1][b] - h[0][3]) * width;
if (!PS_BASELINE && ps->enable_ipdopd) {
h_step[1][0] = (H11[1][e+1][b] - h[1][0]) * width;
h_step[1][1] = (H12[1][e+1][b] - h[1][1]) * width;
h_step[1][2] = (H21[1][e+1][b] - h[1][2]) * width;
h_step[1][3] = (H22[1][e+1][b] - h[1][3]) * width;
}
ps->dsp.stereo_interpolate[!PS_BASELINE && ps->enable_ipdopd](
l[k] + start + 1, r[k] + start + 1,
h, h_step, stop - start);
}
}
}
|
d2a_function_data_5290
|
static inline int get_egolomb(GetBitContext *gb)
{
int v = 4;
while (get_bits1(gb)) v++;
return (1 << v) + get_bits(gb, v);
}
|
d2a_function_data_5291
|
static void vc1_decode_b_blocks(VC1Context *v)
{
MpegEncContext *s = &v->s;
/* select codingmode used for VLC tables selection */
switch(v->c_ac_table_index){
case 0:
v->codingset = (v->pqindex <= 8) ? CS_HIGH_RATE_INTRA : CS_LOW_MOT_INTRA;
break;
case 1:
v->codingset = CS_HIGH_MOT_INTRA;
break;
case 2:
v->codingset = CS_MID_RATE_INTRA;
break;
}
switch(v->c_ac_table_index){
case 0:
v->codingset2 = (v->pqindex <= 8) ? CS_HIGH_RATE_INTER : CS_LOW_MOT_INTER;
break;
case 1:
v->codingset2 = CS_HIGH_MOT_INTER;
break;
case 2:
v->codingset2 = CS_MID_RATE_INTER;
break;
}
s->first_slice_line = 1;
for(s->mb_y = 0; s->mb_y < s->mb_height; s->mb_y++) {
for(s->mb_x = 0; s->mb_x < s->mb_width; s->mb_x++) {
ff_init_block_index(s);
ff_update_block_index(s);
s->dsp.clear_blocks(s->block[0]);
vc1_decode_b_mb(v);
if(get_bits_count(&s->gb) > v->bits || get_bits_count(&s->gb) < 0) {
ff_er_add_slice(s, 0, 0, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END));
av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i at %ix%i\n", get_bits_count(&s->gb), v->bits,s->mb_x,s->mb_y);
return;
}
if(v->s.loop_filter) vc1_loop_filter_iblk(s, s->current_picture.qscale_table[s->mb_x + s->mb_y *s->mb_stride]);
}
ff_draw_horiz_band(s, s->mb_y * 16, 16);
s->first_slice_line = 0;
}
ff_er_add_slice(s, 0, 0, s->mb_width - 1, s->mb_height - 1, (AC_END|DC_END|MV_END));
}
|
d2a_function_data_5292
|
static int instantiate(RAND_DRBG *drbg, DRBG_SELFTEST_DATA *td,
TEST_CTX *t)
{
if (!TEST_true(init(drbg, td, t))
|| !TEST_true(RAND_DRBG_instantiate(drbg, td->pers, td->perslen)))
return 0;
return 1;
}
|
d2a_function_data_5293
|
void BN_CTX_end(BN_CTX *ctx)
{
CTXDBG_ENTRY("BN_CTX_end", ctx);
if(ctx->err_stack)
ctx->err_stack--;
else
{
unsigned int fp = BN_STACK_pop(&ctx->stack);
/* Does this stack frame have anything to release? */
if(fp < ctx->used)
BN_POOL_release(&ctx->pool, ctx->used - fp);
ctx->used = fp;
/* Unjam "too_many" in case "get" had failed */
ctx->too_many = 0;
}
CTXDBG_EXIT(ctx);
}
|
d2a_function_data_5294
|
static void put_ebml_uint(ByteIOContext *pb, unsigned int elementid, uint64_t val)
{
int i, bytes = 1;
while (val >> bytes*8) bytes++;
put_ebml_id(pb, elementid);
put_ebml_num(pb, bytes, 0);
for (i = bytes - 1; i >= 0; i--)
put_byte(pb, val >> i*8);
}
|
d2a_function_data_5295
|
char *lh_insert(LHASH *lh, char *data)
{
unsigned long hash;
LHASH_NODE *nn,**rn;
char *ret;
lh->error=0;
if (lh->up_load <= (lh->num_items*LH_LOAD_MULT/lh->num_nodes))
expand(lh);
rn=getrn(lh,data,&hash);
if (*rn == NULL)
{
if ((nn=(LHASH_NODE *)Malloc(sizeof(LHASH_NODE))) == NULL)
{
lh->error++;
return(NULL);
}
nn->data=data;
nn->next=NULL;
#ifndef NO_HASH_COMP
nn->hash=hash;
#endif
*rn=nn;
ret=NULL;
lh->num_insert++;
lh->num_items++;
}
else /* replace same key */
{
ret= (*rn)->data;
(*rn)->data=data;
lh->num_replace++;
}
return(ret);
}
|
d2a_function_data_5296
|
int ossl_namemap_add(OSSL_NAMEMAP *namemap, int number, const char *name)
{
NAMENUM_ENTRY *namenum = NULL;
int tmp_number;
#ifndef FIPS_MODE
if (namemap == NULL)
namemap = ossl_namemap_stored(NULL);
#endif
if (name == NULL || namemap == NULL)
return 0;
if ((tmp_number = ossl_namemap_name2num(namemap, name)) != 0)
return tmp_number; /* Pretend success */
CRYPTO_THREAD_write_lock(namemap->lock);
if ((namenum = OPENSSL_zalloc(sizeof(*namenum))) == NULL
|| (namenum->name = OPENSSL_strdup(name)) == NULL)
goto err;
namenum->number = tmp_number =
number != 0 ? number : ++namemap->max_number;
(void)lh_NAMENUM_ENTRY_insert(namemap->namenum, namenum);
if (lh_NAMENUM_ENTRY_error(namemap->namenum))
goto err;
CRYPTO_THREAD_unlock(namemap->lock);
return tmp_number;
err:
namenum_free(namenum);
CRYPTO_THREAD_unlock(namemap->lock);
return 0;
}
|
d2a_function_data_5297
|
int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len,
const EVP_MD *md, ENGINE *impl)
{
int rv = 0;
int i, j, reset = 0;
unsigned char pad[HMAC_MAX_MD_CBLOCK_SIZE];
/* If we are changing MD then we must have a key */
if (md != NULL && md != ctx->md && (key == NULL || len < 0))
return 0;
if (md != NULL) {
reset = 1;
ctx->md = md;
} else if (ctx->md) {
md = ctx->md;
} else {
return 0;
}
if (key != NULL) {
reset = 1;
j = EVP_MD_block_size(md);
if (!ossl_assert(j <= (int)sizeof(ctx->key)))
return 0;
if (j < len) {
if (!EVP_DigestInit_ex(ctx->md_ctx, md, impl)
|| !EVP_DigestUpdate(ctx->md_ctx, key, len)
|| !EVP_DigestFinal_ex(ctx->md_ctx, ctx->key,
&ctx->key_length))
return 0;
} else {
if (len < 0 || len > (int)sizeof(ctx->key))
return 0;
memcpy(ctx->key, key, len);
ctx->key_length = len;
}
if (ctx->key_length != HMAC_MAX_MD_CBLOCK_SIZE)
memset(&ctx->key[ctx->key_length], 0,
HMAC_MAX_MD_CBLOCK_SIZE - ctx->key_length);
}
if (reset) {
for (i = 0; i < HMAC_MAX_MD_CBLOCK_SIZE; i++)
pad[i] = 0x36 ^ ctx->key[i];
if (!EVP_DigestInit_ex(ctx->i_ctx, md, impl)
|| !EVP_DigestUpdate(ctx->i_ctx, pad, EVP_MD_block_size(md)))
goto err;
for (i = 0; i < HMAC_MAX_MD_CBLOCK_SIZE; i++)
pad[i] = 0x5c ^ ctx->key[i];
if (!EVP_DigestInit_ex(ctx->o_ctx, md, impl)
|| !EVP_DigestUpdate(ctx->o_ctx, pad, EVP_MD_block_size(md)))
goto err;
}
if (!EVP_MD_CTX_copy_ex(ctx->md_ctx, ctx->i_ctx))
goto err;
rv = 1;
err:
if (reset)
OPENSSL_cleanse(pad, sizeof(pad));
return rv;
}
|
d2a_function_data_5298
|
static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
AVPacket *avpkt) {
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
PCXContext * const s = avctx->priv_data;
AVFrame *picture = data;
AVFrame * const p = &s->picture;
int compressed, xmin, ymin, xmax, ymax;
unsigned int w, h, bits_per_pixel, bytes_per_line, nplanes, stride, y, x,
bytes_per_scanline;
uint8_t *ptr;
uint8_t const *bufstart = buf;
uint8_t *scanline;
int ret = -1;
if (buf[0] != 0x0a || buf[1] > 5) {
av_log(avctx, AV_LOG_ERROR, "this is not PCX encoded data\n");
return AVERROR_INVALIDDATA;
}
compressed = buf[2];
xmin = AV_RL16(buf+ 4);
ymin = AV_RL16(buf+ 6);
xmax = AV_RL16(buf+ 8);
ymax = AV_RL16(buf+10);
if (xmax < xmin || ymax < ymin) {
av_log(avctx, AV_LOG_ERROR, "invalid image dimensions\n");
return AVERROR_INVALIDDATA;
}
w = xmax - xmin + 1;
h = ymax - ymin + 1;
bits_per_pixel = buf[3];
bytes_per_line = AV_RL16(buf+66);
nplanes = buf[65];
bytes_per_scanline = nplanes * bytes_per_line;
if (bytes_per_scanline < w * bits_per_pixel * nplanes / 8) {
av_log(avctx, AV_LOG_ERROR, "PCX data is corrupted\n");
return AVERROR_INVALIDDATA;
}
switch ((nplanes<<8) + bits_per_pixel) {
case 0x0308:
avctx->pix_fmt = AV_PIX_FMT_RGB24;
break;
case 0x0108:
case 0x0104:
case 0x0102:
case 0x0101:
case 0x0401:
case 0x0301:
case 0x0201:
avctx->pix_fmt = AV_PIX_FMT_PAL8;
break;
default:
av_log(avctx, AV_LOG_ERROR, "invalid PCX file\n");
return AVERROR_INVALIDDATA;
}
buf += 128;
if (p->data[0])
avctx->release_buffer(avctx, p);
if (av_image_check_size(w, h, 0, avctx))
return AVERROR_INVALIDDATA;
if (w != avctx->width || h != avctx->height)
avcodec_set_dimensions(avctx, w, h);
if ((ret = avctx->get_buffer(avctx, p)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
p->pict_type = AV_PICTURE_TYPE_I;
ptr = p->data[0];
stride = p->linesize[0];
scanline = av_malloc(bytes_per_scanline);
if (!scanline)
return AVERROR(ENOMEM);
if (nplanes == 3 && bits_per_pixel == 8) {
for (y=0; y<h; y++) {
buf = pcx_rle_decode(buf, scanline, bytes_per_scanline, compressed);
for (x=0; x<w; x++) {
ptr[3*x ] = scanline[x ];
ptr[3*x+1] = scanline[x+ bytes_per_line ];
ptr[3*x+2] = scanline[x+(bytes_per_line<<1)];
}
ptr += stride;
}
} else if (nplanes == 1 && bits_per_pixel == 8) {
const uint8_t *palstart = bufstart + buf_size - 769;
for (y=0; y<h; y++, ptr+=stride) {
buf = pcx_rle_decode(buf, scanline, bytes_per_scanline, compressed);
memcpy(ptr, scanline, w);
}
if (buf != palstart) {
av_log(avctx, AV_LOG_WARNING, "image data possibly corrupted\n");
buf = palstart;
}
if (*buf++ != 12) {
av_log(avctx, AV_LOG_ERROR, "expected palette after image data\n");
ret = AVERROR_INVALIDDATA;
goto end;
}
} else if (nplanes == 1) { /* all packed formats, max. 16 colors */
GetBitContext s;
for (y=0; y<h; y++) {
init_get_bits(&s, scanline, bytes_per_scanline<<3);
buf = pcx_rle_decode(buf, scanline, bytes_per_scanline, compressed);
for (x=0; x<w; x++)
ptr[x] = get_bits(&s, bits_per_pixel);
ptr += stride;
}
} else { /* planar, 4, 8 or 16 colors */
int i;
for (y=0; y<h; y++) {
buf = pcx_rle_decode(buf, scanline, bytes_per_scanline, compressed);
for (x=0; x<w; x++) {
int m = 0x80 >> (x&7), v = 0;
for (i=nplanes - 1; i>=0; i--) {
v <<= 1;
v += !!(scanline[i*bytes_per_line + (x>>3)] & m);
}
ptr[x] = v;
}
ptr += stride;
}
}
if (nplanes == 1 && bits_per_pixel == 8) {
pcx_palette(&buf, (uint32_t *) p->data[1], 256);
} else if (bits_per_pixel * nplanes == 1) {
AV_WN32A(p->data[1] , 0xFF000000);
AV_WN32A(p->data[1]+4, 0xFFFFFFFF);
} else if (bits_per_pixel < 8) {
const uint8_t *palette = bufstart+16;
pcx_palette(&palette, (uint32_t *) p->data[1], 16);
}
*picture = s->picture;
*data_size = sizeof(AVFrame);
ret = buf - bufstart;
end:
av_free(scanline);
return ret;
}
|
d2a_function_data_5299
|
int ff_mpv_common_frame_size_change(MpegEncContext *s)
{
int i, err = 0;
if (!s->context_initialized)
return AVERROR(EINVAL);
if (s->slice_context_count > 1) {
for (i = 0; i < s->slice_context_count; i++) {
free_duplicate_context(s->thread_context[i]);
}
for (i = 1; i < s->slice_context_count; i++) {
av_freep(&s->thread_context[i]);
}
} else
free_duplicate_context(s);
free_context_frame(s);
if (s->picture)
for (i = 0; i < MAX_PICTURE_COUNT; i++) {
s->picture[i].needs_realloc = 1;
}
s->last_picture_ptr =
s->next_picture_ptr =
s->current_picture_ptr = NULL;
// init
if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO && !s->progressive_sequence)
s->mb_height = (s->height + 31) / 32 * 2;
else
s->mb_height = (s->height + 15) / 16;
if ((s->width || s->height) &&
(err = av_image_check_size(s->width, s->height, 0, s->avctx)) < 0)
goto fail;
if ((err = init_context_frame(s)))
goto fail;
memset(s->thread_context, 0, sizeof(s->thread_context));
s->thread_context[0] = s;
if (s->width && s->height) {
int nb_slices = s->slice_context_count;
if (nb_slices > 1) {
for (i = 0; i < nb_slices; i++) {
if (i) {
s->thread_context[i] = av_memdup(s, sizeof(MpegEncContext));
if (!s->thread_context[i]) {
err = AVERROR(ENOMEM);
goto fail;
}
}
if ((err = init_duplicate_context(s->thread_context[i])) < 0)
goto fail;
s->thread_context[i]->start_mb_y =
(s->mb_height * (i) + nb_slices / 2) / nb_slices;
s->thread_context[i]->end_mb_y =
(s->mb_height * (i + 1) + nb_slices / 2) / nb_slices;
}
} else {
err = init_duplicate_context(s);
if (err < 0)
goto fail;
s->start_mb_y = 0;
s->end_mb_y = s->mb_height;
}
s->slice_context_count = nb_slices;
}
return 0;
fail:
ff_mpv_common_end(s);
return err;
}
|
d2a_function_data_5300
|
static int parse_picture_segment(AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
PGSSubContext *ctx = avctx->priv_data;
uint8_t sequence_desc;
unsigned int rle_bitmap_len, width, height;
if (buf_size <= 4)
return -1;
buf_size -= 4;
/* skip 3 unknown bytes: Object ID (2 bytes), Version Number */
buf += 3;
/* Read the Sequence Description to determine if start of RLE data or appended to previous RLE */
sequence_desc = bytestream_get_byte(&buf);
if (!(sequence_desc & 0x80)) {
/* Additional RLE data */
if (buf_size > ctx->picture.rle_remaining_len)
return -1;
memcpy(ctx->picture.rle + ctx->picture.rle_data_len, buf, buf_size);
ctx->picture.rle_data_len += buf_size;
ctx->picture.rle_remaining_len -= buf_size;
return 0;
}
if (buf_size <= 7)
return -1;
buf_size -= 7;
/* Decode rle bitmap length, stored size includes width/height data */
rle_bitmap_len = bytestream_get_be24(&buf) - 2*2;
/* Get bitmap dimensions from data */
width = bytestream_get_be16(&buf);
height = bytestream_get_be16(&buf);
/* Make sure the bitmap is not too large */
if (avctx->width < width || avctx->height < height) {
av_log(avctx, AV_LOG_ERROR, "Bitmap dimensions larger than video.\n");
return -1;
}
ctx->picture.w = width;
ctx->picture.h = height;
av_fast_malloc(&ctx->picture.rle, &ctx->picture.rle_buffer_size, rle_bitmap_len);
if (!ctx->picture.rle)
return -1;
memcpy(ctx->picture.rle, buf, buf_size);
ctx->picture.rle_data_len = buf_size;
ctx->picture.rle_remaining_len = rle_bitmap_len - buf_size;
return 0;
}
|
d2a_function_data_5301
|
void av_frame_unref(AVFrame *frame)
{
int i;
if (!frame)
return;
wipe_side_data(frame);
for (i = 0; i < FF_ARRAY_ELEMS(frame->buf); i++)
av_buffer_unref(&frame->buf[i]);
for (i = 0; i < frame->nb_extended_buf; i++)
av_buffer_unref(&frame->extended_buf[i]);
av_freep(&frame->extended_buf);
av_dict_free(&frame->metadata);
#if FF_API_FRAME_QP
av_buffer_unref(&frame->qp_table_buf);
#endif
av_buffer_unref(&frame->hw_frames_ctx);
av_buffer_unref(&frame->opaque_ref);
get_frame_defaults(frame);
}
|
d2a_function_data_5302
|
void rgb24toyv12_c(const uint8_t *src, uint8_t *ydst, uint8_t *udst,
uint8_t *vdst, int width, int height, int lumStride,
int chromStride, int srcStride)
{
int y;
const int chromWidth = width >> 1;
for (y = 0; y < height; y += 2) {
int i;
for (i = 0; i < chromWidth; i++) {
unsigned int b = src[6 * i + 0];
unsigned int g = src[6 * i + 1];
unsigned int r = src[6 * i + 2];
unsigned int Y = ((RY * r + GY * g + BY * b) >> RGB2YUV_SHIFT) + 16;
unsigned int V = ((RV * r + GV * g + BV * b) >> RGB2YUV_SHIFT) + 128;
unsigned int U = ((RU * r + GU * g + BU * b) >> RGB2YUV_SHIFT) + 128;
udst[i] = U;
vdst[i] = V;
ydst[2 * i] = Y;
b = src[6 * i + 3];
g = src[6 * i + 4];
r = src[6 * i + 5];
Y = ((RY * r + GY * g + BY * b) >> RGB2YUV_SHIFT) + 16;
ydst[2 * i + 1] = Y;
}
ydst += lumStride;
src += srcStride;
if (y+1 == height)
break;
for (i = 0; i < chromWidth; i++) {
unsigned int b = src[6 * i + 0];
unsigned int g = src[6 * i + 1];
unsigned int r = src[6 * i + 2];
unsigned int Y = ((RY * r + GY * g + BY * b) >> RGB2YUV_SHIFT) + 16;
ydst[2 * i] = Y;
b = src[6 * i + 3];
g = src[6 * i + 4];
r = src[6 * i + 5];
Y = ((RY * r + GY * g + BY * b) >> RGB2YUV_SHIFT) + 16;
ydst[2 * i + 1] = Y;
}
udst += chromStride;
vdst += chromStride;
ydst += lumStride;
src += srcStride;
}
}
|
d2a_function_data_5303
|
int av_samples_fill_arrays(uint8_t **audio_data, int *linesize,
const uint8_t *buf, int nb_channels, int nb_samples,
enum AVSampleFormat sample_fmt, int align)
{
int ch, planar, buf_size, line_size;
planar = av_sample_fmt_is_planar(sample_fmt);
buf_size = av_samples_get_buffer_size(&line_size, nb_channels, nb_samples,
sample_fmt, align);
if (buf_size < 0)
return buf_size;
audio_data[0] = (uint8_t *)buf;
for (ch = 1; planar && ch < nb_channels; ch++)
audio_data[ch] = audio_data[ch-1] + line_size;
if (linesize)
*linesize = line_size;
#if FF_API_SAMPLES_UTILS_RETURN_ZERO
return 0;
#else
return buf_size;
#endif
}
|
d2a_function_data_5304
|
int av_fifo_realloc2(AVFifoBuffer *f, unsigned int new_size)
{
unsigned int old_size = f->end - f->buffer;
if (old_size < new_size) {
int len = av_fifo_size(f);
AVFifoBuffer *f2 = av_fifo_alloc(new_size);
if (!f2)
return AVERROR(ENOMEM);
av_fifo_generic_read(f, f2->buffer, len, NULL);
f2->wptr += len;
f2->wndx += len;
av_free(f->buffer);
*f = *f2;
av_free(f2);
}
return 0;
}
|
d2a_function_data_5305
|
static inline void flush_put_bits(PutBitContext *s)
{
#ifdef ALT_BITSTREAM_WRITER
align_put_bits(s);
#else
#ifndef BITSTREAM_WRITER_LE
s->bit_buf<<= s->bit_left;
#endif
while (s->bit_left < 32) {
/* XXX: should test end of buffer */
#ifdef BITSTREAM_WRITER_LE
*s->buf_ptr++=s->bit_buf;
s->bit_buf>>=8;
#else
*s->buf_ptr++=s->bit_buf >> 24;
s->bit_buf<<=8;
#endif
s->bit_left+=8;
}
s->bit_left=32;
s->bit_buf=0;
#endif
}
|
d2a_function_data_5306
|
static inline void expand_category(COOKContext *q, int *category,
int *category_index)
{
int i;
for (i = 0; i < q->num_vectors; i++)
++category[category_index[i]];
}
|
d2a_function_data_5307
|
static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc,
AVCodecContext *avctx, const char *args,
uint8_t **poutbuf, int *poutbuf_size,
const uint8_t *buf, int buf_size,
int keyframe) {
H264BSFContext *ctx = bsfc->priv_data;
uint8_t unit_type;
int32_t nal_size;
uint32_t cumul_size = 0;
const uint8_t *buf_end = buf + buf_size;
/* nothing to filter */
if (!avctx->extradata || avctx->extradata_size < 6) {
*poutbuf = (uint8_t*) buf;
*poutbuf_size = buf_size;
return 0;
}
/* retrieve sps and pps NAL units from extradata */
if (!ctx->sps_pps_data) {
uint16_t unit_size;
uint32_t total_size = 0;
uint8_t *out = NULL, unit_nb, sps_done = 0;
const uint8_t *extradata = avctx->extradata+4;
static const uint8_t nalu_header[4] = {0, 0, 0, 1};
/* retrieve length coded size */
ctx->length_size = (*extradata++ & 0x3) + 1;
if (ctx->length_size == 3)
return AVERROR(EINVAL);
/* retrieve sps and pps unit(s) */
unit_nb = *extradata++ & 0x1f; /* number of sps unit(s) */
if (!unit_nb) {
unit_nb = *extradata++; /* number of pps unit(s) */
sps_done++;
}
while (unit_nb--) {
unit_size = AV_RB16(extradata);
total_size += unit_size+4;
if (extradata+2+unit_size > avctx->extradata+avctx->extradata_size) {
av_free(out);
return AVERROR(EINVAL);
}
out = av_realloc(out, total_size);
if (!out)
return AVERROR(ENOMEM);
memcpy(out+total_size-unit_size-4, nalu_header, 4);
memcpy(out+total_size-unit_size, extradata+2, unit_size);
extradata += 2+unit_size;
if (!unit_nb && !sps_done++)
unit_nb = *extradata++; /* number of pps unit(s) */
}
ctx->sps_pps_data = out;
ctx->size = total_size;
ctx->first_idr = 1;
}
*poutbuf_size = 0;
*poutbuf = NULL;
do {
if (buf + ctx->length_size > buf_end)
goto fail;
if (ctx->length_size == 1)
nal_size = buf[0];
else if (ctx->length_size == 2)
nal_size = AV_RB16(buf);
else
nal_size = AV_RB32(buf);
buf += ctx->length_size;
unit_type = *buf & 0x1f;
if (buf + nal_size > buf_end || nal_size < 0)
goto fail;
/* prepend only to the first type 5 NAL unit of an IDR picture */
if (ctx->first_idr && unit_type == 5) {
alloc_and_copy(poutbuf, poutbuf_size,
ctx->sps_pps_data, ctx->size,
buf, nal_size);
ctx->first_idr = 0;
}
else {
alloc_and_copy(poutbuf, poutbuf_size,
NULL, 0,
buf, nal_size);
if (!ctx->first_idr && unit_type == 1)
ctx->first_idr = 1;
}
buf += nal_size;
cumul_size += nal_size + ctx->length_size;
} while (cumul_size < buf_size);
return 1;
fail:
av_freep(poutbuf);
*poutbuf_size = 0;
return AVERROR(EINVAL);
}
|
d2a_function_data_5308
|
static void sr_1d97_int(int32_t *p, int i0, int i1)
{
int i;
if (i1 <= i0 + 1) {
if (i0 == 1)
p[1] = (p[1] * I_LFTG_K + (1<<16)) >> 17;
else
p[0] = (p[0] * I_LFTG_X + (1<<15)) >> 16;
return;
}
extend97_int(p, i0, i1);
for (i = i0 / 2 - 1; i < i1 / 2 + 2; i++)
p[2 * i] -= (I_LFTG_DELTA * (p[2 * i - 1] + p[2 * i + 1]) + (1 << 15)) >> 16;
/* step 4 */
for (i = i0 / 2 - 1; i < i1 / 2 + 1; i++)
p[2 * i + 1] -= (I_LFTG_GAMMA * (p[2 * i] + p[2 * i + 2]) + (1 << 15)) >> 16;
/*step 5*/
for (i = i0 / 2; i < i1 / 2 + 1; i++)
p[2 * i] += (I_LFTG_BETA * (p[2 * i - 1] + p[2 * i + 1]) + (1 << 15)) >> 16;
/* step 6 */
for (i = i0 / 2; i < i1 / 2; i++)
p[2 * i + 1] += (I_LFTG_ALPHA * (p[2 * i] + p[2 * i + 2]) + (1 << 15)) >> 16;
}
|
d2a_function_data_5309
|
static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce,
int win, int group_len, const float lambda)
{
BandCodingPath path[120][12];
int w, swb, cb, start, size;
int i, j;
const int max_sfb = sce->ics.max_sfb;
const int run_bits = sce->ics.num_windows == 1 ? 5 : 3;
const int run_esc = (1 << run_bits) - 1;
int idx, ppos, count;
int stackrun[120], stackcb[120], stack_len;
float next_minbits = INFINITY;
int next_mincb = 0;
abs_pow34_v(s->scoefs, sce->coeffs, 1024);
start = win*128;
for (cb = 0; cb < 12; cb++) {
path[0][cb].cost = run_bits+4;
path[0][cb].prev_idx = -1;
path[0][cb].run = 0;
}
for (swb = 0; swb < max_sfb; swb++) {
size = sce->ics.swb_sizes[swb];
if (sce->zeroes[win*16 + swb]) {
float cost_stay_here = path[swb][0].cost;
float cost_get_here = next_minbits + run_bits + 4;
if ( run_value_bits[sce->ics.num_windows == 8][path[swb][0].run]
!= run_value_bits[sce->ics.num_windows == 8][path[swb][0].run+1])
cost_stay_here += run_bits;
if (cost_get_here < cost_stay_here) {
path[swb+1][0].prev_idx = next_mincb;
path[swb+1][0].cost = cost_get_here;
path[swb+1][0].run = 1;
} else {
path[swb+1][0].prev_idx = 0;
path[swb+1][0].cost = cost_stay_here;
path[swb+1][0].run = path[swb][0].run + 1;
}
next_minbits = path[swb+1][0].cost;
next_mincb = 0;
for (cb = 1; cb < 12; cb++) {
path[swb+1][cb].cost = 61450;
path[swb+1][cb].prev_idx = -1;
path[swb+1][cb].run = 0;
}
} else {
float minbits = next_minbits;
int mincb = next_mincb;
int startcb = sce->band_type[win*16+swb];
next_minbits = INFINITY;
next_mincb = 0;
for (cb = 0; cb < startcb; cb++) {
path[swb+1][cb].cost = 61450;
path[swb+1][cb].prev_idx = -1;
path[swb+1][cb].run = 0;
}
for (cb = startcb; cb < 12; cb++) {
float cost_stay_here, cost_get_here;
float bits = 0.0f;
for (w = 0; w < group_len; w++) {
bits += quantize_band_cost(s, sce->coeffs + start + w*128,
s->scoefs + start + w*128, size,
sce->sf_idx[(win+w)*16+swb], cb,
0, INFINITY, NULL);
}
cost_stay_here = path[swb][cb].cost + bits;
cost_get_here = minbits + bits + run_bits + 4;
if ( run_value_bits[sce->ics.num_windows == 8][path[swb][cb].run]
!= run_value_bits[sce->ics.num_windows == 8][path[swb][cb].run+1])
cost_stay_here += run_bits;
if (cost_get_here < cost_stay_here) {
path[swb+1][cb].prev_idx = mincb;
path[swb+1][cb].cost = cost_get_here;
path[swb+1][cb].run = 1;
} else {
path[swb+1][cb].prev_idx = cb;
path[swb+1][cb].cost = cost_stay_here;
path[swb+1][cb].run = path[swb][cb].run + 1;
}
if (path[swb+1][cb].cost < next_minbits) {
next_minbits = path[swb+1][cb].cost;
next_mincb = cb;
}
}
}
start += sce->ics.swb_sizes[swb];
}
//convert resulting path from backward-linked list
stack_len = 0;
idx = 0;
for (cb = 1; cb < 12; cb++)
if (path[max_sfb][cb].cost < path[max_sfb][idx].cost)
idx = cb;
ppos = max_sfb;
while (ppos > 0) {
av_assert1(idx >= 0);
cb = idx;
stackrun[stack_len] = path[ppos][cb].run;
stackcb [stack_len] = cb;
idx = path[ppos-path[ppos][cb].run+1][cb].prev_idx;
ppos -= path[ppos][cb].run;
stack_len++;
}
//perform actual band info encoding
start = 0;
for (i = stack_len - 1; i >= 0; i--) {
put_bits(&s->pb, 4, stackcb[i]);
count = stackrun[i];
memset(sce->zeroes + win*16 + start, !stackcb[i], count);
//XXX: memset when band_type is also uint8_t
for (j = 0; j < count; j++) {
sce->band_type[win*16 + start] = stackcb[i];
start++;
}
while (count >= run_esc) {
put_bits(&s->pb, run_bits, run_esc);
count -= run_esc;
}
put_bits(&s->pb, run_bits, count);
}
}
|
d2a_function_data_5310
|
static void bastardized_rice_decompress(ALACContext *alac,
int32_t *output_buffer,
int output_size,
int readsamplesize, /* arg_10 */
int rice_initialhistory, /* arg424->b */
int rice_kmodifier, /* arg424->d */
int rice_historymult, /* arg424->c */
int rice_kmodifier_mask /* arg424->e */
)
{
int output_count;
unsigned int history = rice_initialhistory;
int sign_modifier = 0;
for (output_count = 0; output_count < output_size; output_count++) {
int32_t x;
int32_t x_modified;
int32_t final_val;
/* read x - number of 1s before 0 represent the rice */
x = get_unary_0_9(&alac->gb);
if (x > 8) { /* RICE THRESHOLD */
/* use alternative encoding */
x = get_bits(&alac->gb, readsamplesize);
} else {
/* standard rice encoding */
int extrabits;
int k; /* size of extra bits */
/* read k, that is bits as is */
k = 31 - count_leading_zeros((history >> 9) + 3);
if (k >= rice_kmodifier)
k = rice_kmodifier;
if (k != 1) {
extrabits = show_bits(&alac->gb, k);
/* multiply x by 2^k - 1, as part of their strange algorithm */
x = (x << k) - x;
if (extrabits > 1) {
x += extrabits - 1;
skip_bits(&alac->gb, k);
} else
skip_bits(&alac->gb, k - 1);
}
}
x_modified = sign_modifier + x;
final_val = (x_modified + 1) / 2;
if (x_modified & 1) final_val *= -1;
output_buffer[output_count] = final_val;
sign_modifier = 0;
/* now update the history */
history += x_modified * rice_historymult
- ((history * rice_historymult) >> 9);
if (x_modified > 0xffff)
history = 0xffff;
/* special case: there may be compressed blocks of 0 */
if ((history < 128) && (output_count+1 < output_size)) {
int block_size;
sign_modifier = 1;
x = get_unary_0_9(&alac->gb);
if (x > 8) {
block_size = get_bits(&alac->gb, 16);
} else {
int k;
int extrabits;
k = count_leading_zeros(history) + ((history + 16) >> 6 /* / 64 */) - 24;
if (k >= rice_kmodifier)
k = rice_kmodifier;
x = (x << k) - x;
extrabits = show_bits(&alac->gb, k);
if (extrabits < 2) {
skip_bits(&alac->gb, k - 1);
} else {
x += extrabits - 1;
skip_bits(&alac->gb, k);
}
block_size = x;
}
if (block_size > 0) {
memset(&output_buffer[output_count+1], 0, block_size * 4);
output_count += block_size;
}
if (block_size > 0xffff)
sign_modifier = 0;
history = 0;
}
}
}
|
d2a_function_data_5311
|
static void sbr_hf_inverse_filter(SBRDSPContext *dsp,
int (*alpha0)[2], int (*alpha1)[2],
const int X_low[32][40][2], int k0)
{
int k;
int shift, round;
for (k = 0; k < k0; k++) {
SoftFloat phi[3][2][2];
SoftFloat a00, a01, a10, a11;
SoftFloat dk;
dsp->autocorrelate(X_low[k], phi);
dk = av_sub_sf(av_mul_sf(phi[2][1][0], phi[1][0][0]),
av_mul_sf(av_add_sf(av_mul_sf(phi[1][1][0], phi[1][1][0]),
av_mul_sf(phi[1][1][1], phi[1][1][1])), FLOAT_0999999));
if (!dk.mant) {
a10 = FLOAT_0;
a11 = FLOAT_0;
} else {
SoftFloat temp_real, temp_im;
temp_real = av_sub_sf(av_sub_sf(av_mul_sf(phi[0][0][0], phi[1][1][0]),
av_mul_sf(phi[0][0][1], phi[1][1][1])),
av_mul_sf(phi[0][1][0], phi[1][0][0]));
temp_im = av_sub_sf(av_add_sf(av_mul_sf(phi[0][0][0], phi[1][1][1]),
av_mul_sf(phi[0][0][1], phi[1][1][0])),
av_mul_sf(phi[0][1][1], phi[1][0][0]));
a10 = av_div_sf(temp_real, dk);
a11 = av_div_sf(temp_im, dk);
}
if (!phi[1][0][0].mant) {
a00 = FLOAT_0;
a01 = FLOAT_0;
} else {
SoftFloat temp_real, temp_im;
temp_real = av_add_sf(phi[0][0][0],
av_add_sf(av_mul_sf(a10, phi[1][1][0]),
av_mul_sf(a11, phi[1][1][1])));
temp_im = av_add_sf(phi[0][0][1],
av_sub_sf(av_mul_sf(a11, phi[1][1][0]),
av_mul_sf(a10, phi[1][1][1])));
temp_real.mant = -temp_real.mant;
temp_im.mant = -temp_im.mant;
a00 = av_div_sf(temp_real, phi[1][0][0]);
a01 = av_div_sf(temp_im, phi[1][0][0]);
}
shift = a00.exp;
if (shift >= 3)
alpha0[k][0] = 0x7fffffff;
else if (shift <= -30)
alpha0[k][0] = 0;
else {
a00.mant *= 2;
shift = 2-shift;
if (shift == 0)
alpha0[k][0] = a00.mant;
else {
round = 1 << (shift-1);
alpha0[k][0] = (a00.mant + round) >> shift;
}
}
shift = a01.exp;
if (shift >= 3)
alpha0[k][1] = 0x7fffffff;
else if (shift <= -30)
alpha0[k][1] = 0;
else {
a01.mant *= 2;
shift = 2-shift;
if (shift == 0)
alpha0[k][1] = a01.mant;
else {
round = 1 << (shift-1);
alpha0[k][1] = (a01.mant + round) >> shift;
}
}
shift = a10.exp;
if (shift >= 3)
alpha1[k][0] = 0x7fffffff;
else if (shift <= -30)
alpha1[k][0] = 0;
else {
a10.mant *= 2;
shift = 2-shift;
if (shift == 0)
alpha1[k][0] = a10.mant;
else {
round = 1 << (shift-1);
alpha1[k][0] = (a10.mant + round) >> shift;
}
}
shift = a11.exp;
if (shift >= 3)
alpha1[k][1] = 0x7fffffff;
else if (shift <= -30)
alpha1[k][1] = 0;
else {
a11.mant *= 2;
shift = 2-shift;
if (shift == 0)
alpha1[k][1] = a11.mant;
else {
round = 1 << (shift-1);
alpha1[k][1] = (a11.mant + round) >> shift;
}
}
shift = (int)(((int64_t)(alpha1[k][0]>>1) * (alpha1[k][0]>>1) + \
(int64_t)(alpha1[k][1]>>1) * (alpha1[k][1]>>1) + \
0x40000000) >> 31);
if (shift >= 0x20000000){
alpha1[k][0] = 0;
alpha1[k][1] = 0;
alpha0[k][0] = 0;
alpha0[k][1] = 0;
}
shift = (int)(((int64_t)(alpha0[k][0]>>1) * (alpha0[k][0]>>1) + \
(int64_t)(alpha0[k][1]>>1) * (alpha0[k][1]>>1) + \
0x40000000) >> 31);
if (shift >= 0x20000000){
alpha1[k][0] = 0;
alpha1[k][1] = 0;
alpha0[k][0] = 0;
alpha0[k][1] = 0;
}
}
}
|
d2a_function_data_5312
|
BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b)
{
int i;
BN_ULONG *A;
const BN_ULONG *B;
bn_check_top(b);
if (a == b)
return (a);
if (bn_wexpand(a, b->top) == NULL)
return (NULL);
#if 1
A = a->d;
B = b->d;
for (i = b->top >> 2; i > 0; i--, A += 4, B += 4) {
BN_ULONG a0, a1, a2, a3;
a0 = B[0];
a1 = B[1];
a2 = B[2];
a3 = B[3];
A[0] = a0;
A[1] = a1;
A[2] = a2;
A[3] = a3;
}
/* ultrix cc workaround, see comments in bn_expand_internal */
switch (b->top & 3) {
case 3:
A[2] = B[2];
case 2:
A[1] = B[1];
case 1:
A[0] = B[0];
case 0:;
}
#else
memcpy(a->d, b->d, sizeof(b->d[0]) * b->top);
#endif
a->top = b->top;
a->neg = b->neg;
bn_check_top(a);
return (a);
}
|
d2a_function_data_5313
|
void ff_mpc_dequantize_and_synth(MPCContext * c, int maxband, void *data, int channels)
{
int i, j, ch;
Band *bands = c->bands;
int off;
float mul;
/* dequantize */
memset(c->sb_samples, 0, sizeof(c->sb_samples));
off = 0;
for(i = 0; i <= maxband; i++, off += SAMPLES_PER_BAND){
for(ch = 0; ch < 2; ch++){
if(bands[i].res[ch]){
j = 0;
mul = mpc_CC[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][0]];
for(; j < 12; j++)
c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off];
mul = mpc_CC[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][1]];
for(; j < 24; j++)
c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off];
mul = mpc_CC[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][2]];
for(; j < 36; j++)
c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off];
}
}
if(bands[i].msf){
int t1, t2;
for(j = 0; j < SAMPLES_PER_BAND; j++){
t1 = c->sb_samples[0][j][i];
t2 = c->sb_samples[1][j][i];
c->sb_samples[0][j][i] = t1 + t2;
c->sb_samples[1][j][i] = t1 - t2;
}
}
}
mpc_synth(c, data, channels);
}
|
d2a_function_data_5314
|
static inline
void compute_images_mse(PSNRContext *s,
const uint8_t *main_data[4], const int main_linesizes[4],
const uint8_t *ref_data[4], const int ref_linesizes[4],
int w, int h, double mse[4])
{
int i, c;
for (c = 0; c < s->nb_components; c++) {
const int outw = s->planewidth[c];
const int outh = s->planeheight[c];
const uint8_t *main_line = main_data[c];
const uint8_t *ref_line = ref_data[c];
const int ref_linesize = ref_linesizes[c];
const int main_linesize = main_linesizes[c];
uint64_t m = 0;
for (i = 0; i < outh; i++) {
m += s->dsp.sse_line(main_line, ref_line, outw);
ref_line += ref_linesize;
main_line += main_linesize;
}
mse[c] = m / (double)(outw * outh);
}
}
|
d2a_function_data_5315
|
static int decode_i_frame(FourXContext *f, const uint8_t *buf, int length){
int x, y;
const int width= f->avctx->width;
const int height= f->avctx->height;
uint16_t *dst= (uint16_t*)f->current_picture.data[0];
const int stride= f->current_picture.linesize[0]>>1;
const unsigned int bitstream_size= AV_RL32(buf);
unsigned int prestream_size;
const uint8_t *prestream;
if (bitstream_size > (1<<26) || length < bitstream_size + 12)
return -1;
prestream_size = 4*AV_RL32(buf + bitstream_size + 4);
prestream = buf + bitstream_size + 12;
if (prestream_size > (1<<26) ||
prestream_size != length - (bitstream_size + 12)){
av_log(f->avctx, AV_LOG_ERROR, "size mismatch %d %d %d\n", prestream_size, bitstream_size, length);
return -1;
}
prestream= read_huffman_tables(f, prestream, buf + length - prestream);
if (!prestream)
return -1;
init_get_bits(&f->gb, buf + 4, 8*bitstream_size);
prestream_size= length + buf - prestream;
av_fast_malloc(&f->bitstream_buffer, &f->bitstream_buffer_size, prestream_size + FF_INPUT_BUFFER_PADDING_SIZE);
if (!f->bitstream_buffer)
return AVERROR(ENOMEM);
f->dsp.bswap_buf(f->bitstream_buffer, (const uint32_t*)prestream, prestream_size/4);
memset((uint8_t*)f->bitstream_buffer + prestream_size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
init_get_bits(&f->pre_gb, f->bitstream_buffer, 8*prestream_size);
f->last_dc= 0*128*8*8;
for(y=0; y<height; y+=16){
for(x=0; x<width; x+=16){
if(decode_i_mb(f) < 0)
return -1;
idct_put(f, x, y);
}
dst += 16*stride;
}
if(get_vlc2(&f->pre_gb, f->pre_vlc.table, ACDC_VLC_BITS, 3) != 256)
av_log(f->avctx, AV_LOG_ERROR, "end mismatch\n");
return 0;
}
|
d2a_function_data_5316
|
int ff_MPV_common_frame_size_change(MpegEncContext *s)
{
int i, err = 0;
if (s->slice_context_count > 1) {
for (i = 0; i < s->slice_context_count; i++) {
free_duplicate_context(s->thread_context[i]);
}
for (i = 1; i < s->slice_context_count; i++) {
av_freep(&s->thread_context[i]);
}
} else
free_duplicate_context(s);
if ((err = free_context_frame(s)) < 0)
return err;
if (s->picture)
for (i = 0; i < MAX_PICTURE_COUNT; i++) {
s->picture[i].needs_realloc = 1;
}
s->last_picture_ptr =
s->next_picture_ptr =
s->current_picture_ptr = NULL;
// init
if (s->codec_id == AV_CODEC_ID_MPEG2VIDEO && !s->progressive_sequence)
s->mb_height = (s->height + 31) / 32 * 2;
else
s->mb_height = (s->height + 15) / 16;
if ((s->width || s->height) &&
av_image_check_size(s->width, s->height, 0, s->avctx))
return AVERROR_INVALIDDATA;
if ((err = init_context_frame(s)))
goto fail;
s->thread_context[0] = s;
if (s->width && s->height) {
int nb_slices = s->slice_context_count;
if (nb_slices > 1) {
for (i = 1; i < nb_slices; i++) {
s->thread_context[i] = av_malloc(sizeof(MpegEncContext));
memcpy(s->thread_context[i], s, sizeof(MpegEncContext));
}
for (i = 0; i < nb_slices; i++) {
if (init_duplicate_context(s->thread_context[i]) < 0)
goto fail;
s->thread_context[i]->start_mb_y =
(s->mb_height * (i) + nb_slices / 2) / nb_slices;
s->thread_context[i]->end_mb_y =
(s->mb_height * (i + 1) + nb_slices / 2) / nb_slices;
}
} else {
err = init_duplicate_context(s);
if (err < 0)
goto fail;
s->start_mb_y = 0;
s->end_mb_y = s->mb_height;
}
s->slice_context_count = nb_slices;
}
return 0;
fail:
ff_MPV_common_end(s);
return err;
}
|
d2a_function_data_5317
|
int WPACKET_reserve_bytes(WPACKET *pkt, size_t len, unsigned char **allocbytes)
{
/* Internal API, so should not fail */
assert(pkt->subs != NULL && len != 0);
if (pkt->subs == NULL || len == 0)
return 0;
if (pkt->maxsize - pkt->written < len)
return 0;
if (pkt->staticbuf == NULL && (pkt->buf->length - pkt->written < len)) {
size_t newlen;
size_t reflen;
reflen = (len > pkt->buf->length) ? len : pkt->buf->length;
if (reflen > SIZE_MAX / 2) {
newlen = SIZE_MAX;
} else {
newlen = reflen * 2;
if (newlen < DEFAULT_BUF_SIZE)
newlen = DEFAULT_BUF_SIZE;
}
if (BUF_MEM_grow(pkt->buf, newlen) == 0)
return 0;
}
if (allocbytes != NULL)
*allocbytes = WPACKET_get_curr(pkt);
return 1;
}
|
d2a_function_data_5318
|
static inline void skip_bits_long(GetBitContext *s, int n){
s->index += n;
}
|
d2a_function_data_5319
|
static void filter_mb_row_simple(VP8Context *s, int mb_y)
{
uint8_t *dst = s->framep[VP56_FRAME_CURRENT]->data[0] + 16*mb_y*s->linesize;
VP8Macroblock *mb = s->macroblocks + mb_y*s->mb_stride;
int mb_x;
for (mb_x = 0; mb_x < s->mb_width; mb_x++) {
backup_mb_border(s->top_border[mb_x+1], dst, NULL, NULL, s->linesize, 0, 1);
filter_mb_simple(s, dst, mb++, mb_x, mb_y);
dst += 16;
}
}
|
d2a_function_data_5320
|
int ff_init_poc(H264Context *h, int pic_field_poc[2], int *pic_poc)
{
const SPS *sps = h->ps.sps;
const int max_frame_num = 1 << sps->log2_max_frame_num;
int field_poc[2];
h->frame_num_offset = h->prev_frame_num_offset;
if (h->frame_num < h->prev_frame_num)
h->frame_num_offset += max_frame_num;
if (sps->poc_type == 0) {
const int max_poc_lsb = 1 << sps->log2_max_poc_lsb;
if (h->poc_lsb < h->prev_poc_lsb &&
h->prev_poc_lsb - h->poc_lsb >= max_poc_lsb / 2)
h->poc_msb = h->prev_poc_msb + max_poc_lsb;
else if (h->poc_lsb > h->prev_poc_lsb &&
h->prev_poc_lsb - h->poc_lsb < -max_poc_lsb / 2)
h->poc_msb = h->prev_poc_msb - max_poc_lsb;
else
h->poc_msb = h->prev_poc_msb;
field_poc[0] =
field_poc[1] = h->poc_msb + h->poc_lsb;
if (h->picture_structure == PICT_FRAME)
field_poc[1] += h->delta_poc_bottom;
} else if (sps->poc_type == 1) {
int abs_frame_num, expected_delta_per_poc_cycle, expectedpoc;
int i;
if (sps->poc_cycle_length != 0)
abs_frame_num = h->frame_num_offset + h->frame_num;
else
abs_frame_num = 0;
if (h->nal_ref_idc == 0 && abs_frame_num > 0)
abs_frame_num--;
expected_delta_per_poc_cycle = 0;
for (i = 0; i < sps->poc_cycle_length; i++)
// FIXME integrate during sps parse
expected_delta_per_poc_cycle += sps->offset_for_ref_frame[i];
if (abs_frame_num > 0) {
int poc_cycle_cnt = (abs_frame_num - 1) / sps->poc_cycle_length;
int frame_num_in_poc_cycle = (abs_frame_num - 1) % sps->poc_cycle_length;
expectedpoc = poc_cycle_cnt * expected_delta_per_poc_cycle;
for (i = 0; i <= frame_num_in_poc_cycle; i++)
expectedpoc = expectedpoc + sps->offset_for_ref_frame[i];
} else
expectedpoc = 0;
if (h->nal_ref_idc == 0)
expectedpoc = expectedpoc + sps->offset_for_non_ref_pic;
field_poc[0] = expectedpoc + h->delta_poc[0];
field_poc[1] = field_poc[0] + sps->offset_for_top_to_bottom_field;
if (h->picture_structure == PICT_FRAME)
field_poc[1] += h->delta_poc[1];
} else {
int poc = 2 * (h->frame_num_offset + h->frame_num);
if (!h->nal_ref_idc)
poc--;
field_poc[0] = poc;
field_poc[1] = poc;
}
if (h->picture_structure != PICT_BOTTOM_FIELD)
pic_field_poc[0] = field_poc[0];
if (h->picture_structure != PICT_TOP_FIELD)
pic_field_poc[1] = field_poc[1];
*pic_poc = FFMIN(pic_field_poc[0], pic_field_poc[1]);
return 0;
}
|
d2a_function_data_5321
|
BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod)
{
BN_BLINDING *ret=NULL;
bn_check_top(mod);
if ((ret=(BN_BLINDING *)OPENSSL_malloc(sizeof(BN_BLINDING))) == NULL)
{
BNerr(BN_F_BN_BLINDING_NEW,ERR_R_MALLOC_FAILURE);
return(NULL);
}
memset(ret,0,sizeof(BN_BLINDING));
if (A != NULL)
{
if ((ret->A = BN_dup(A)) == NULL) goto err;
}
if (Ai != NULL)
{
if ((ret->Ai = BN_dup(Ai)) == NULL) goto err;
}
/* save a copy of mod in the BN_BLINDING structure */
if ((ret->mod = BN_dup(mod)) == NULL) goto err;
if (BN_get_flags(mod, BN_FLG_CONSTTIME) != 0)
BN_set_flags(ret->mod, BN_FLG_CONSTTIME);
ret->counter = BN_BLINDING_COUNTER;
CRYPTO_THREADID_current(&ret->tid);
return(ret);
err:
if (ret != NULL) BN_BLINDING_free(ret);
return(NULL);
}
|
d2a_function_data_5322
|
static void generate_new_codebooks(RoqContext *enc, RoqTempdata *tempData)
{
int i,j;
RoqCodebooks *codebooks = &tempData->codebooks;
int max = enc->width*enc->height/16;
uint8_t mb2[3*4];
roq_cell *results4 = av_malloc(sizeof(roq_cell)*MAX_CBS_4x4*4);
uint8_t *yuvClusters=av_malloc(sizeof(int)*max*6*4);
int *points = av_malloc(max*6*4*sizeof(int));
int bias;
/* Subsample YUV data */
create_clusters(enc->frame_to_enc, enc->width, enc->height, yuvClusters);
/* Cast to integer and apply chroma bias */
for (i=0; i<max*24; i++) {
bias = ((i%6)<4) ? 1 : CHROMA_BIAS;
points[i] = bias*yuvClusters[i];
}
/* Create 4x4 codebooks */
generate_codebook(enc, tempData, points, max, results4, 4, MAX_CBS_4x4);
codebooks->numCB4 = MAX_CBS_4x4;
tempData->closest_cb2 = av_malloc(max*4*sizeof(int));
/* Create 2x2 codebooks */
generate_codebook(enc, tempData, points, max*4, enc->cb2x2, 2, MAX_CBS_2x2);
codebooks->numCB2 = MAX_CBS_2x2;
/* Unpack 2x2 codebook clusters */
for (i=0; i<codebooks->numCB2; i++)
unpack_roq_cell(enc->cb2x2 + i, codebooks->unpacked_cb2 + i*2*2*3);
/* Index all 4x4 entries to the 2x2 entries, unpack, and enlarge */
for (i=0; i<codebooks->numCB4; i++) {
for (j=0; j<4; j++) {
unpack_roq_cell(&results4[4*i + j], mb2);
index_mb(mb2, codebooks->unpacked_cb2, codebooks->numCB2,
&enc->cb4x4[i].idx[j], 2);
}
unpack_roq_qcell(codebooks->unpacked_cb2, enc->cb4x4 + i,
codebooks->unpacked_cb4 + i*4*4*3);
enlarge_roq_mb4(codebooks->unpacked_cb4 + i*4*4*3,
codebooks->unpacked_cb4_enlarged + i*8*8*3);
}
av_free(yuvClusters);
av_free(points);
av_free(results4);
}
|
d2a_function_data_5323
|
static int kmvc_decode_inter_8x8(KmvcContext * ctx, int w, int h)
{
BitBuf bb;
int res, val;
int i, j;
int bx, by;
int l0x, l1x, l0y, l1y;
int mx, my;
kmvc_init_getbits(bb, &ctx->g);
for (by = 0; by < h; by += 8)
for (bx = 0; bx < w; bx += 8) {
kmvc_getbit(bb, &ctx->g, res);
if (!res) {
kmvc_getbit(bb, &ctx->g, res);
if (!res) { // fill whole 8x8 block
if (!bytestream2_get_bytes_left(&ctx->g)) {
av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
return AVERROR_INVALIDDATA;
}
val = bytestream2_get_byte(&ctx->g);
for (i = 0; i < 64; i++)
BLK(ctx->cur, bx + (i & 0x7), by + (i >> 3)) = val;
} else { // copy block from previous frame
for (i = 0; i < 64; i++)
BLK(ctx->cur, bx + (i & 0x7), by + (i >> 3)) =
BLK(ctx->prev, bx + (i & 0x7), by + (i >> 3));
}
} else { // handle four 4x4 subblocks
if (!bytestream2_get_bytes_left(&ctx->g)) {
av_log(ctx->avctx, AV_LOG_ERROR, "Data overrun\n");
return AVERROR_INVALIDDATA;
}
for (i = 0; i < 4; i++) {
l0x = bx + (i & 1) * 4;
l0y = by + (i & 2) * 2;
kmvc_getbit(bb, &ctx->g, res);
if (!res) {
kmvc_getbit(bb, &ctx->g, res);
if (!res) { // fill whole 4x4 block
val = bytestream2_get_byte(&ctx->g);
for (j = 0; j < 16; j++)
BLK(ctx->cur, l0x + (j & 3), l0y + (j >> 2)) = val;
} else { // copy block
val = bytestream2_get_byte(&ctx->g);
mx = (val & 0xF) - 8;
my = (val >> 4) - 8;
if ((l0x+mx) + 320*(l0y+my) < 0 || (l0x+mx) + 320*(l0y+my) > 320*197 - 4) {
av_log(ctx->avctx, AV_LOG_ERROR, "Invalid MV\n");
return AVERROR_INVALIDDATA;
}
for (j = 0; j < 16; j++)
BLK(ctx->cur, l0x + (j & 3), l0y + (j >> 2)) =
BLK(ctx->prev, l0x + (j & 3) + mx, l0y + (j >> 2) + my);
}
} else { // descend to 2x2 sub-sub-blocks
for (j = 0; j < 4; j++) {
l1x = l0x + (j & 1) * 2;
l1y = l0y + (j & 2);
kmvc_getbit(bb, &ctx->g, res);
if (!res) {
kmvc_getbit(bb, &ctx->g, res);
if (!res) { // fill whole 2x2 block
val = bytestream2_get_byte(&ctx->g);
BLK(ctx->cur, l1x, l1y) = val;
BLK(ctx->cur, l1x + 1, l1y) = val;
BLK(ctx->cur, l1x, l1y + 1) = val;
BLK(ctx->cur, l1x + 1, l1y + 1) = val;
} else { // copy block
val = bytestream2_get_byte(&ctx->g);
mx = (val & 0xF) - 8;
my = (val >> 4) - 8;
if ((l1x+mx) + 320*(l1y+my) < 0 || (l1x+mx) + 320*(l1y+my) > 320*199 - 2) {
av_log(ctx->avctx, AV_LOG_ERROR, "Invalid MV\n");
return AVERROR_INVALIDDATA;
}
BLK(ctx->cur, l1x, l1y) = BLK(ctx->prev, l1x + mx, l1y + my);
BLK(ctx->cur, l1x + 1, l1y) =
BLK(ctx->prev, l1x + 1 + mx, l1y + my);
BLK(ctx->cur, l1x, l1y + 1) =
BLK(ctx->prev, l1x + mx, l1y + 1 + my);
BLK(ctx->cur, l1x + 1, l1y + 1) =
BLK(ctx->prev, l1x + 1 + mx, l1y + 1 + my);
}
} else { // read values for block
BLK(ctx->cur, l1x, l1y) = bytestream2_get_byte(&ctx->g);
BLK(ctx->cur, l1x + 1, l1y) = bytestream2_get_byte(&ctx->g);
BLK(ctx->cur, l1x, l1y + 1) = bytestream2_get_byte(&ctx->g);
BLK(ctx->cur, l1x + 1, l1y + 1) = bytestream2_get_byte(&ctx->g);
}
}
}
}
}
}
return 0;
}
|
d2a_function_data_5324
|
int asn1_ex_i2c(ASN1_VALUE **pval, unsigned char *cout, int *putype,
const ASN1_ITEM *it)
{
ASN1_BOOLEAN *tbool = NULL;
ASN1_STRING *strtmp;
ASN1_OBJECT *otmp;
int utype;
const unsigned char *cont;
unsigned char c;
int len;
const ASN1_PRIMITIVE_FUNCS *pf;
pf = it->funcs;
if (pf && pf->prim_i2c)
return pf->prim_i2c(pval, cout, putype, it);
/* Should type be omitted? */
if ((it->itype != ASN1_ITYPE_PRIMITIVE)
|| (it->utype != V_ASN1_BOOLEAN))
{
if (!*pval) return -1;
}
if (it->itype == ASN1_ITYPE_MSTRING)
{
/* If MSTRING type set the underlying type */
strtmp = (ASN1_STRING *)*pval;
utype = strtmp->type;
*putype = utype;
}
else if (it->utype == V_ASN1_ANY)
{
/* If ANY set type and pointer to value */
ASN1_TYPE *typ;
typ = (ASN1_TYPE *)*pval;
utype = typ->type;
*putype = utype;
pval = &typ->value.asn1_value;
}
else utype = *putype;
switch(utype)
{
case V_ASN1_OBJECT:
otmp = (ASN1_OBJECT *)*pval;
cont = otmp->data;
len = otmp->length;
break;
case V_ASN1_NULL:
cont = NULL;
len = 0;
break;
case V_ASN1_BOOLEAN:
tbool = (ASN1_BOOLEAN *)pval;
if (*tbool == -1)
return -1;
if (it->utype != V_ASN1_ANY)
{
/* Default handling if value == size field then omit */
if (*tbool && (it->size > 0))
return -1;
if (!*tbool && !it->size)
return -1;
}
c = (unsigned char)*tbool;
cont = &c;
len = 1;
break;
case V_ASN1_BIT_STRING:
return i2c_ASN1_BIT_STRING((ASN1_BIT_STRING *)*pval,
cout ? &cout : NULL);
break;
case V_ASN1_INTEGER:
case V_ASN1_NEG_INTEGER:
case V_ASN1_ENUMERATED:
case V_ASN1_NEG_ENUMERATED:
/* These are all have the same content format
* as ASN1_INTEGER
*/
return i2c_ASN1_INTEGER((ASN1_INTEGER *)*pval,
cout ? &cout : NULL);
break;
case V_ASN1_OCTET_STRING:
case V_ASN1_NUMERICSTRING:
case V_ASN1_PRINTABLESTRING:
case V_ASN1_T61STRING:
case V_ASN1_VIDEOTEXSTRING:
case V_ASN1_IA5STRING:
case V_ASN1_UTCTIME:
case V_ASN1_GENERALIZEDTIME:
case V_ASN1_GRAPHICSTRING:
case V_ASN1_VISIBLESTRING:
case V_ASN1_GENERALSTRING:
case V_ASN1_UNIVERSALSTRING:
case V_ASN1_BMPSTRING:
case V_ASN1_UTF8STRING:
case V_ASN1_SEQUENCE:
case V_ASN1_SET:
default:
/* All based on ASN1_STRING and handled the same */
strtmp = (ASN1_STRING *)*pval;
/* Special handling for NDEF */
if ((it->size == ASN1_TFLG_NDEF)
&& (strtmp->flags & ASN1_STRING_FLAG_NDEF))
{
if (cout)
{
strtmp->data = cout;
strtmp->length = 0;
}
/* Special return code */
return -2;
}
cont = strtmp->data;
len = strtmp->length;
break;
}
if (cout && len)
memcpy(cout, cont, len);
return len;
}
|
d2a_function_data_5325
|
static int sk_reserve(OPENSSL_STACK *st, int n, int exact)
{
const void **tmpdata;
int num_alloc;
/* Check to see the reservation isn't exceeding the hard limit */
if (n > max_nodes - st->num)
return 0;
/* Figure out the new size */
num_alloc = st->num + n;
if (num_alloc < min_nodes)
num_alloc = min_nodes;
/* If |st->data| allocation was postponed */
if (st->data == NULL) {
/*
* At this point, |st->num_alloc| and |st->num| are 0;
* so |num_alloc| value is |n| or |min_nodes| if greater than |n|.
*/
st->data = OPENSSL_zalloc(sizeof(void *) * num_alloc);
if (st->data == NULL)
return 0;
st->num_alloc = num_alloc;
return 1;
}
if (!exact) {
if (num_alloc <= st->num_alloc)
return 1;
num_alloc = compute_growth(num_alloc, st->num_alloc);
if (num_alloc == 0)
return 0;
} else if (num_alloc == st->num_alloc) {
return 1;
}
tmpdata = OPENSSL_realloc((void *)st->data, sizeof(void *) * num_alloc);
if (tmpdata == NULL)
return 0;
st->data = tmpdata;
st->num_alloc = num_alloc;
return 1;
}
|
d2a_function_data_5326
|
AVFilterBufferRef *avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask)
{
AVFilterBufferRef *ret = av_malloc(sizeof(AVFilterBufferRef));
if (!ret)
return NULL;
*ret = *ref;
if (ref->type == AVMEDIA_TYPE_VIDEO) {
ret->video = av_malloc(sizeof(AVFilterBufferRefVideoProps));
if (!ret->video) {
av_free(ret);
return NULL;
}
*ret->video = *ref->video;
} else if (ref->type == AVMEDIA_TYPE_AUDIO) {
ret->audio = av_malloc(sizeof(AVFilterBufferRefAudioProps));
if (!ret->audio) {
av_free(ret);
return NULL;
}
*ret->audio = *ref->audio;
}
ret->perms &= pmask;
ret->buf->refcount ++;
return ret;
}
|
d2a_function_data_5327
|
static int get_siz(Jpeg2000DecoderContext *s)
{
int i;
if (bytestream2_get_bytes_left(&s->g) < 36)
return AVERROR(EINVAL);
s->avctx->profile = bytestream2_get_be16u(&s->g); // Rsiz
s->width = bytestream2_get_be32u(&s->g); // Width
s->height = bytestream2_get_be32u(&s->g); // Height
s->image_offset_x = bytestream2_get_be32u(&s->g); // X0Siz
s->image_offset_y = bytestream2_get_be32u(&s->g); // Y0Siz
s->tile_width = bytestream2_get_be32u(&s->g); // XTSiz
s->tile_height = bytestream2_get_be32u(&s->g); // YTSiz
s->tile_offset_x = bytestream2_get_be32u(&s->g); // XT0Siz
s->tile_offset_y = bytestream2_get_be32u(&s->g); // YT0Siz
s->ncomponents = bytestream2_get_be16u(&s->g); // CSiz
if(s->ncomponents <= 0 || s->ncomponents > 4) {
av_log(s->avctx, AV_LOG_ERROR, "unsupported/invalid ncomponents: %d\n", s->ncomponents);
return AVERROR(EINVAL);
}
if(s->tile_width<=0 || s->tile_height<=0)
return AVERROR(EINVAL);
if (bytestream2_get_bytes_left(&s->g) < 3 * s->ncomponents)
return AVERROR(EINVAL);
for (i = 0; i < s->ncomponents; i++) { // Ssiz_i XRsiz_i, YRsiz_i
uint8_t x = bytestream2_get_byteu(&s->g);
s->cbps[i] = (x & 0x7f) + 1;
s->precision = FFMAX(s->cbps[i], s->precision);
s->sgnd[i] = (x & 0x80) == 1;
s->cdx[i] = bytestream2_get_byteu(&s->g);
s->cdy[i] = bytestream2_get_byteu(&s->g);
}
s->numXtiles = ff_jpeg2000_ceildiv(s->width - s->tile_offset_x, s->tile_width);
s->numYtiles = ff_jpeg2000_ceildiv(s->height - s->tile_offset_y, s->tile_height);
s->tile = av_mallocz(s->numXtiles * s->numYtiles * sizeof(*s->tile));
if (!s->tile)
return AVERROR(ENOMEM);
for (i = 0; i < s->numXtiles * s->numYtiles; i++) {
Jpeg2000Tile *tile = s->tile + i;
tile->comp = av_mallocz(s->ncomponents * sizeof(*tile->comp));
if (!tile->comp)
return AVERROR(ENOMEM);
}
/* compute image size with reduction factor */
s->avctx->width = ff_jpeg2000_ceildivpow2(s->width - s->image_offset_x,
s->reduction_factor);
s->avctx->height = ff_jpeg2000_ceildivpow2(s->height - s->image_offset_y,
s->reduction_factor);
switch (s->avctx->profile) {
case FF_PROFILE_JPEG2000_DCINEMA_2K:
case FF_PROFILE_JPEG2000_DCINEMA_4K:
/* XYZ color-space for digital cinema profiles */
s->avctx->pix_fmt = AV_PIX_FMT_XYZ12;
break;
default:
/* For other profiles selects color-space according number of
* components and bit depth precision. */
switch (s->ncomponents) {
case 1:
if (s->precision > 8)
s->avctx->pix_fmt = AV_PIX_FMT_GRAY16;
else
s->avctx->pix_fmt = AV_PIX_FMT_GRAY8;
break;
case 3:
if (s->precision > 8)
s->avctx->pix_fmt = AV_PIX_FMT_RGB48;
else
s->avctx->pix_fmt = AV_PIX_FMT_RGB24;
break;
case 4:
s->avctx->pix_fmt = AV_PIX_FMT_BGRA;
break;
default:
/* pixel format can not be identified */
s->avctx->pix_fmt = AV_PIX_FMT_NONE;
break;
}
break;
}
return 0;
}
|
d2a_function_data_5328
|
static void encode_block(NellyMoserEncodeContext *s, unsigned char *output, int output_size)
{
PutBitContext pb;
int i, j, band, block, best_idx, power_idx = 0;
float power_val, coeff, coeff_sum;
float pows[NELLY_FILL_LEN];
int bits[NELLY_BUF_LEN], idx_table[NELLY_BANDS];
float cand[NELLY_BANDS];
apply_mdct(s);
init_put_bits(&pb, output, output_size * 8);
i = 0;
for (band = 0; band < NELLY_BANDS; band++) {
coeff_sum = 0;
for (j = 0; j < ff_nelly_band_sizes_table[band]; i++, j++) {
coeff_sum += s->mdct_out[i ] * s->mdct_out[i ]
+ s->mdct_out[i + NELLY_BUF_LEN] * s->mdct_out[i + NELLY_BUF_LEN];
}
cand[band] =
log(FFMAX(1.0, coeff_sum / (ff_nelly_band_sizes_table[band] << 7))) * 1024.0 / M_LN2;
}
if (s->avctx->trellis) {
get_exponent_dynamic(s, cand, idx_table);
} else {
get_exponent_greedy(s, cand, idx_table);
}
i = 0;
for (band = 0; band < NELLY_BANDS; band++) {
if (band) {
power_idx += ff_nelly_delta_table[idx_table[band]];
put_bits(&pb, 5, idx_table[band]);
} else {
power_idx = ff_nelly_init_table[idx_table[0]];
put_bits(&pb, 6, idx_table[0]);
}
power_val = pow_table[power_idx & 0x7FF] / (1 << ((power_idx >> 11) + POW_TABLE_OFFSET));
for (j = 0; j < ff_nelly_band_sizes_table[band]; i++, j++) {
s->mdct_out[i] *= power_val;
s->mdct_out[i + NELLY_BUF_LEN] *= power_val;
pows[i] = power_idx;
}
}
ff_nelly_get_sample_bits(pows, bits);
for (block = 0; block < 2; block++) {
for (i = 0; i < NELLY_FILL_LEN; i++) {
if (bits[i] > 0) {
const float *table = ff_nelly_dequantization_table + (1 << bits[i]) - 1;
coeff = s->mdct_out[block * NELLY_BUF_LEN + i];
best_idx =
quant_lut[av_clip (
coeff * quant_lut_mul[bits[i]] + quant_lut_add[bits[i]],
quant_lut_offset[bits[i]],
quant_lut_offset[bits[i]+1] - 1
)];
if (fabs(coeff - table[best_idx]) > fabs(coeff - table[best_idx + 1]))
best_idx++;
put_bits(&pb, bits[i], best_idx);
}
}
if (!block)
put_bits(&pb, NELLY_HEADER_BITS + NELLY_DETAIL_BITS - put_bits_count(&pb), 0);
}
flush_put_bits(&pb);
memset(put_bits_ptr(&pb), 0, output + output_size - put_bits_ptr(&pb));
}
|
d2a_function_data_5329
|
int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq,
enum AVRounding rnd)
{
int64_t b= bq.num * (int64_t)cq.den;
int64_t c= cq.num * (int64_t)bq.den;
return av_rescale_rnd(a, b, c, rnd);
}
|
d2a_function_data_5330
|
static int pcm_read_packet(AVFormatContext *s, AVPacket *pkt)
{
int ret, size, bps;
// AVStream *st = s->streams[0];
size= RAW_SAMPLES*s->streams[0]->codec->block_align;
ret= av_get_packet(s->pb, pkt, size);
pkt->stream_index = 0;
if (ret < 0)
return ret;
bps= av_get_bits_per_sample(s->streams[0]->codec->codec_id);
assert(bps); // if false there IS a bug elsewhere (NOT in this function)
pkt->dts=
pkt->pts= pkt->pos*8 / (bps * s->streams[0]->codec->channels);
return ret;
}
|
d2a_function_data_5331
|
static char *mk_file_path(const char *dir, const char *file)
{
char *full_file = NULL;
size_t full_file_l = 0;
const char *sep = "";
#ifndef OPENSSL_SYS_VMS
sep = "/";
#endif
full_file_l = strlen(dir) + strlen(sep) + strlen(file) + 1;
full_file = OPENSSL_zalloc(full_file_l);
if (full_file != NULL) {
OPENSSL_strlcpy(full_file, dir, full_file_l);
OPENSSL_strlcat(full_file, sep, full_file_l);
OPENSSL_strlcat(full_file, file, full_file_l);
}
return full_file;
}
|
d2a_function_data_5332
|
static int opt_streamid(const char *opt, const char *arg)
{
int idx;
char *p;
char idx_str[16];
av_strlcpy(idx_str, arg, sizeof(idx_str));
p = strchr(idx_str, ':');
if (!p) {
fprintf(stderr,
"Invalid value '%s' for option '%s', required syntax is 'index:value'\n",
arg, opt);
ffmpeg_exit(1);
}
*p++ = '\0';
idx = parse_number_or_die(opt, idx_str, OPT_INT, 0, INT_MAX);
streamid_map = grow_array(streamid_map, sizeof(*streamid_map), &nb_streamid_map, idx+1);
streamid_map[idx] = parse_number_or_die(opt, p, OPT_INT, 0, INT_MAX);
return 0;
}
|
d2a_function_data_5333
|
static void fix_hostname(request_rec *r, const char *host_header)
{
const char *src;
char *host, *scope_id;
apr_port_t port;
apr_status_t rv;
const char *c;
src = host_header ? host_header : r->hostname;
/* According to RFC 2616, Host header field CAN be blank.
* XXX But only 'if the requested URI does not include an Internet host
* XXX name'. Can this happen?
*/
if (!*src) {
return;
}
/* apr_parse_addr_port will interpret a bare integer as a port
* which is incorrect in this context. So treat it separately.
*/
for (c = src; apr_isdigit(*c); ++c);
if (!*c) {
/* pure integer */
r->hostname = src;
return;
}
if (host_header) {
rv = apr_parse_addr_port(&host, &scope_id, &port, src, r->pool);
if (rv != APR_SUCCESS || scope_id)
goto bad;
if (port) {
/* Don't throw the Host: header's port number away:
save it in parsed_uri -- ap_get_server_port() needs it! */
/* @@@ XXX there should be a better way to pass the port.
* Like r->hostname, there should be a r->portno
*/
r->parsed_uri.port = port;
r->parsed_uri.port_str = apr_itoa(r->pool, (int)port);
}
if (host_header[0] == '[')
rv = fix_hostname_v6_literal(r, host);
else
rv = fix_hostname_non_v6(r, host);
}
else {
/*
* Already parsed, surrounding [ ] (if IPv6 literal) and :port have
* already been removed.
*/
host = apr_pstrdup(r->pool, r->hostname);
if (ap_strchr(host, ':') != NULL)
rv = fix_hostname_v6_literal(r, host);
else
rv = fix_hostname_non_v6(r, host);
}
if (rv != APR_SUCCESS)
goto bad;
r->hostname = host;
return;
bad:
r->status = HTTP_BAD_REQUEST;
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(00550)
"Client sent malformed Host header: %s",
r->hostname);
return;
}
|
d2a_function_data_5334
|
static int mxf_read_index_entry_array(AVIOContext *pb, MXFIndexTableSegment *segment)
{
int i, length;
segment->nb_index_entries = avio_rb32(pb);
length = avio_rb32(pb);
if(segment->nb_index_entries && length < 11)
return AVERROR_INVALIDDATA;
if (!(segment->temporal_offset_entries=av_calloc(segment->nb_index_entries, sizeof(*segment->temporal_offset_entries))) ||
!(segment->flag_entries = av_calloc(segment->nb_index_entries, sizeof(*segment->flag_entries))) ||
!(segment->stream_offset_entries = av_calloc(segment->nb_index_entries, sizeof(*segment->stream_offset_entries)))) {
av_freep(&segment->temporal_offset_entries);
av_freep(&segment->flag_entries);
return AVERROR(ENOMEM);
}
for (i = 0; i < segment->nb_index_entries; i++) {
if(avio_feof(pb))
return AVERROR_INVALIDDATA;
segment->temporal_offset_entries[i] = avio_r8(pb);
avio_r8(pb); /* KeyFrameOffset */
segment->flag_entries[i] = avio_r8(pb);
segment->stream_offset_entries[i] = avio_rb64(pb);
avio_skip(pb, length - 11);
}
return 0;
}
|
d2a_function_data_5335
|
static void print_report(OutputFile *output_files,
OutputStream *ost_table, int nb_ostreams,
int is_last_report, int64_t timer_start, int64_t cur_time)
{
char buf[1024];
OutputStream *ost;
AVFormatContext *oc;
int64_t total_size;
AVCodecContext *enc;
int frame_number, vid, i;
double bitrate;
int64_t pts = INT64_MAX;
static int64_t last_time = -1;
static int qp_histogram[52];
int hours, mins, secs, us;
if (!is_last_report) {
if (last_time == -1) {
last_time = cur_time;
return;
}
if ((cur_time - last_time) < 500000)
return;
last_time = cur_time;
}
oc = output_files[0].ctx;
total_size = avio_size(oc->pb);
if(total_size<0) // FIXME improve avio_size() so it works with non seekable output too
total_size= avio_tell(oc->pb);
buf[0] = '\0';
vid = 0;
for(i=0;i<nb_ostreams;i++) {
float q = -1;
ost = &ost_table[i];
enc = ost->st->codec;
if (!ost->st->stream_copy && enc->coded_frame)
q = enc->coded_frame->quality/(float)FF_QP2LAMBDA;
if (vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "q=%2.1f ", q);
}
if (!vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) {
float t = (cur_time-timer_start) / 1000000.0;
frame_number = ost->frame_number;
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "frame=%5d fps=%3d q=%3.1f ",
frame_number, (t>1)?(int)(frame_number/t+0.5) : 0, q);
if(is_last_report)
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "L");
if(qp_hist){
int j;
int qp = lrintf(q);
if(qp>=0 && qp<FF_ARRAY_ELEMS(qp_histogram))
qp_histogram[qp]++;
for(j=0; j<32; j++)
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%X", (int)lrintf(log(qp_histogram[j]+1)/log(2)));
}
if (enc->flags&CODEC_FLAG_PSNR){
int j;
double error, error_sum=0;
double scale, scale_sum=0;
char type[3]= {'Y','U','V'};
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "PSNR=");
for(j=0; j<3; j++){
if(is_last_report){
error= enc->error[j];
scale= enc->width*enc->height*255.0*255.0*frame_number;
}else{
error= enc->coded_frame->error[j];
scale= enc->width*enc->height*255.0*255.0;
}
if(j) scale/=4;
error_sum += error;
scale_sum += scale;
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%c:%2.2f ", type[j], psnr(error/scale));
}
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "*:%2.2f ", psnr(error_sum/scale_sum));
}
vid = 1;
}
/* compute min output value */
pts = FFMIN(pts, av_rescale_q(ost->st->pts.val,
ost->st->time_base, AV_TIME_BASE_Q));
}
secs = pts / AV_TIME_BASE;
us = pts % AV_TIME_BASE;
mins = secs / 60;
secs %= 60;
hours = mins / 60;
mins %= 60;
bitrate = pts ? total_size * 8 / (pts / 1000.0) : 0;
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
"size=%8.0fkB time=", total_size / 1024.0);
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
"%02d:%02d:%02d.%02d ", hours, mins, secs,
(100 * us) / AV_TIME_BASE);
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
"bitrate=%6.1fkbits/s", bitrate);
if (nb_frames_dup || nb_frames_drop)
snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " dup=%d drop=%d",
nb_frames_dup, nb_frames_drop);
av_log(NULL, is_last_report ? AV_LOG_WARNING : AV_LOG_INFO, "%s \r", buf);
fflush(stderr);
if (is_last_report) {
int64_t raw= audio_size + video_size + extra_size;
av_log(NULL, AV_LOG_INFO, "\n");
av_log(NULL, AV_LOG_INFO, "video:%1.0fkB audio:%1.0fkB global headers:%1.0fkB muxing overhead %f%%\n",
video_size/1024.0,
audio_size/1024.0,
extra_size/1024.0,
100.0*(total_size - raw)/raw
);
}
}
|
End of preview. Expand
in Data Studio
README.md exists but content is empty.
- Downloads last month
- 2