static int mov_read_trak(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) { AVStream *st; MOVStreamContext *sc; int ret; st = av_new_stream(c->fc, c->fc->nb_streams); if (!st) return AVERROR(ENOMEM); sc = av_mallocz(sizeof(MOVStreamContext)); if (!sc) return AVERROR(ENOMEM); st->priv_data = sc; st->codec->codec_type = CODEC_TYPE_DATA; st->start_time = 0; /* XXX: check */ if ((ret = mov_read_default(c, pb, atom)) < 0) return ret; /* sanity checks */ if(sc->chunk_count && (!sc->stts_count || !sc->sample_to_chunk_sz || (!sc->sample_size && !sc->sample_count))){ av_log(c->fc, AV_LOG_ERROR, "stream %d, missing mandatory atoms, broken header\n", st->index); sc->sample_count = 0; //ignore track return 0; } if(!sc->time_rate) sc->time_rate=1; if(!sc->time_scale) sc->time_scale= c->time_scale; av_set_pts_info(st, 64, sc->time_rate, sc->time_scale); if (st->codec->codec_type == CODEC_TYPE_AUDIO && !st->codec->frame_size && sc->stts_count == 1) st->codec->frame_size = av_rescale(sc->time_rate, st->codec->sample_rate, sc->time_scale); if(st->duration != AV_NOPTS_VALUE){ assert(st->duration % sc->time_rate == 0); st->duration /= sc->time_rate; } sc->ffindex = st->index; mov_build_index(c, st); if (sc->dref_id-1 < sc->drefs_count && sc->drefs[sc->dref_id-1].path) { if (url_fopen(&sc->pb, sc->drefs[sc->dref_id-1].path, URL_RDONLY) < 0) av_log(c->fc, AV_LOG_ERROR, "stream %d, error opening file %s: %s\n", st->index, sc->drefs[sc->dref_id-1].path, strerror(errno)); } else sc->pb = c->fc->pb; switch (st->codec->codec_id) { #ifdef CONFIG_H261_DECODER case CODEC_ID_H261: #endif #ifdef CONFIG_H263_DECODER case CODEC_ID_H263: #endif #ifdef CONFIG_MPEG4_DECODER case CODEC_ID_MPEG4: #endif st->codec->width= 0; /* let decoder init width/height */ st->codec->height= 0; break; #ifdef CONFIG_VORBIS_DECODER case CODEC_ID_VORBIS: #endif st->codec->sample_rate= 0; /* let decoder init parameters properly */ break; } /* Do not need those anymore. */ av_freep(&sc->chunk_offsets); av_freep(&sc->sample_to_chunk); av_freep(&sc->sample_sizes); av_freep(&sc->keyframes); av_freep(&sc->stts_data); return 0; }


static av_cold int libschroedinger_encode_init(AVCodecContext *avctx) { SchroEncoderParams *p_schro_params = avctx->priv_data; SchroVideoFormatEnum preset; /* Initialize the libraries that libschroedinger depends on. */ schro_init(); /* Create an encoder object. */ p_schro_params->encoder = schro_encoder_new(); if (!p_schro_params->encoder) { av_log(avctx, AV_LOG_ERROR, "Unrecoverable Error: schro_encoder_new failed. "); return -1; } /* Initialize the format. */ preset = ff_get_schro_video_format_preset(avctx); p_schro_params->format = schro_encoder_get_video_format(p_schro_params->encoder); schro_video_format_set_std_video_format(p_schro_params->format, preset); p_schro_params->format->width = avctx->width; p_schro_params->format->height = avctx->height; if (set_chroma_format(avctx) == -1) return -1; if (avctx->color_primaries == AVCOL_PRI_BT709) { p_schro_params->format->colour_primaries = SCHRO_COLOUR_PRIMARY_HDTV; } else if (avctx->color_primaries == AVCOL_PRI_BT470BG) { p_schro_params->format->colour_primaries = SCHRO_COLOUR_PRIMARY_SDTV_625; } else if (avctx->color_primaries == AVCOL_PRI_SMPTE170M) { p_schro_params->format->colour_primaries = SCHRO_COLOUR_PRIMARY_SDTV_525; } if (avctx->colorspace == AVCOL_SPC_BT709) { p_schro_params->format->colour_matrix = SCHRO_COLOUR_MATRIX_HDTV; } else if (avctx->colorspace == AVCOL_SPC_BT470BG) { p_schro_params->format->colour_matrix = SCHRO_COLOUR_MATRIX_SDTV; } if (avctx->color_trc == AVCOL_TRC_BT709) { p_schro_params->format->transfer_function = SCHRO_TRANSFER_CHAR_TV_GAMMA; } if (ff_get_schro_frame_format(p_schro_params->format->chroma_format, &p_schro_params->frame_format) == -1) { av_log(avctx, AV_LOG_ERROR, "This codec currently supports only planar YUV 4:2:0, 4:2:2" " and 4:4:4 formats.\n"); return -1; } p_schro_params->format->frame_rate_numerator = avctx->time_base.den; p_schro_params->format->frame_rate_denominator = avctx->time_base.num; p_schro_params->frame_size = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height); avctx->coded_frame = av_frame_alloc(); if (!avctx->coded_frame) return AVERROR(ENOMEM); if (!avctx->gop_size) { schro_encoder_setting_set_double(p_schro_params->encoder, "gop_structure", SCHRO_ENCODER_GOP_INTRA_ONLY); if (avctx->coder_type == FF_CODER_TYPE_VLC) schro_encoder_setting_set_double(p_schro_params->encoder, "enable_noarith", 1); } else { schro_encoder_setting_set_double(p_schro_params->encoder, "au_distance", avctx->gop_size); avctx->has_b_frames = 1; p_schro_params->dts = -1; } /* FIXME - Need to handle SCHRO_ENCODER_RATE_CONTROL_LOW_DELAY. */ if (avctx->flags & CODEC_FLAG_QSCALE) { if (!avctx->global_quality) { /* lossless coding */ schro_encoder_setting_set_double(p_schro_params->encoder, "rate_control", SCHRO_ENCODER_RATE_CONTROL_LOSSLESS); } else { int quality; schro_encoder_setting_set_double(p_schro_params->encoder, "rate_control", SCHRO_ENCODER_RATE_CONTROL_CONSTANT_QUALITY); quality = avctx->global_quality / FF_QP2LAMBDA; if (quality > 10) quality = 10; schro_encoder_setting_set_double(p_schro_params->encoder, "quality", quality); } } else { schro_encoder_setting_set_double(p_schro_params->encoder, "rate_control", SCHRO_ENCODER_RATE_CONTROL_CONSTANT_BITRATE); schro_encoder_setting_set_double(p_schro_params->encoder, "bitrate", avctx->bit_rate); } if (avctx->flags & CODEC_FLAG_INTERLACED_ME) /* All material can be coded as interlaced or progressive irrespective of the type of source material. */ schro_encoder_setting_set_double(p_schro_params->encoder, "interlaced_coding", 1); schro_encoder_setting_set_double(p_schro_params->encoder, "open_gop", !(avctx->flags & CODEC_FLAG_CLOSED_GOP)); /* FIXME: Signal range hardcoded to 8-bit data until both libschroedinger * and libdirac support other bit-depth data. */ schro_video_format_set_std_signal_range(p_schro_params->format, SCHRO_SIGNAL_RANGE_8BIT_VIDEO); /* Set the encoder format. */ schro_encoder_set_video_format(p_schro_params->encoder, p_schro_params->format); /* Set the debug level. */ schro_debug_set_level(avctx->debug); schro_encoder_start(p_schro_params->encoder); /* Initialize the encoded frame queue. */ ff_schro_queue_init(&p_schro_params->enc_frame_queue); return 0; }


static struct omap_mcbsp_s *omap_mcbsp_init(MemoryRegion *system_memory, target_phys_addr_t base, qemu_irq txirq, qemu_irq rxirq, qemu_irq *dma, omap_clk clk) { struct omap_mcbsp_s *s = (struct omap_mcbsp_s *) g_malloc0(sizeof(struct omap_mcbsp_s)); s->txirq = txirq; s->rxirq = rxirq; s->txdrq = dma[0]; s->rxdrq = dma[1]; s->sink_timer = qemu_new_timer_ns(vm_clock, omap_mcbsp_sink_tick, s); s->source_timer = qemu_new_timer_ns(vm_clock, omap_mcbsp_source_tick, s); omap_mcbsp_reset(s); memory_region_init_io(&s->iomem, &omap_mcbsp_ops, s, "omap-mcbsp", 0x800); memory_region_add_subregion(system_memory, base, &s->iomem); return s; }


static void rv34_pred_mv(RV34DecContext *r, int block_type, int subblock_no, int dmv_no) { MpegEncContext *s = &r->s; int mv_pos = s->mb_x * 2 + s->mb_y * 2 * s->b8_stride; int A[2] = {0}, B[2], C[2]; int i, j; int mx, my; int avail_index = avail_indexes[subblock_no]; int c_off = part_sizes_w[block_type]; mv_pos += (subblock_no & 1) + (subblock_no >> 1)*s->b8_stride; if(subblock_no == 3) c_off = -1; if(r->avail_cache[avail_index - 1]){ A[0] = s->current_picture_ptr->f.motion_val[0][mv_pos-1][0]; A[1] = s->current_picture_ptr->f.motion_val[0][mv_pos-1][1]; } if(r->avail_cache[avail_index - 4]){ B[0] = s->current_picture_ptr->f.motion_val[0][mv_pos-s->b8_stride][0]; B[1] = s->current_picture_ptr->f.motion_val[0][mv_pos-s->b8_stride][1]; }else{ B[0] = A[0]; B[1] = A[1]; } if(!r->avail_cache[avail_index - 4 + c_off]){ if(r->avail_cache[avail_index - 4] && (r->avail_cache[avail_index - 1] || r->rv30)){ C[0] = s->current_picture_ptr->f.motion_val[0][mv_pos-s->b8_stride-1][0]; C[1] = s->current_picture_ptr->f.motion_val[0][mv_pos-s->b8_stride-1][1]; }else{ C[0] = A[0]; C[1] = A[1]; } }else{ C[0] = s->current_picture_ptr->f.motion_val[0][mv_pos-s->b8_stride+c_off][0]; C[1] = s->current_picture_ptr->f.motion_val[0][mv_pos-s->b8_stride+c_off][1]; } mx = mid_pred(A[0], B[0], C[0]); my = mid_pred(A[1], B[1], C[1]); mx += r->dmv[dmv_no][0]; my += r->dmv[dmv_no][1]; for(j = 0; j < part_sizes_h[block_type]; j++){ for(i = 0; i < part_sizes_w[block_type]; i++){ s->current_picture_ptr->f.motion_val[0][mv_pos + i + j*s->b8_stride][0] = mx; s->current_picture_ptr->f.motion_val[0][mv_pos + i + j*s->b8_stride][1] = my; } } }