diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/build_ffmpeg.sh ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/build_ffmpeg.sh --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/build_ffmpeg.sh 2011-10-07 14:01:07.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/build_ffmpeg.sh 2011-11-04 12:34:39.000000000 +0000 @@ -2,7 +2,7 @@ . ./ffmpegrev -common="--enable-version2 --enable-gpl --enable-postproc --disable-muxers --disable-encoders --enable-libvorbis" +common="--enable-gpl --enable-postproc --disable-muxers --disable-encoders --enable-libvorbis" common="$common --disable-avconv --disable-ffmpeg --disable-ffplay --disable-ffserver --disable-ffprobe --disable-doc" #optional, if you have those libs installed(requires GPL3): diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/debian/bzr-builder.manifest ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/debian/bzr-builder.manifest --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/debian/bzr-builder.manifest 2011-10-07 14:04:27.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/debian/bzr-builder.manifest 2011-11-04 12:38:29.000000000 +0000 @@ -1,4 +1,4 @@ -# bzr-builder format 0.3 deb-version {debupstream}+503+30387+3 -lp:ffmpeg2theora revid:j-20111007130753-vvohpfu7tdra1acv -nest ffmpeg lp:ffmpeg ffmpeg revid:git-v1:f22bc68dc0de214ba893c15e2a5e80731ab19959 +# bzr-builder format 0.3 deb-version {debupstream}+506+30862+3 +lp:ffmpeg2theora revid:j-20111025111533-gjrk2bwuawrjow9g +nest ffmpeg lp:ffmpeg ffmpeg revid:git-v1:259a960f1b74339626f8da890cc261a4043097fe nest packaging lp:~j/ffmpeg2theora/debian debian revid:j-20111007135402-pgses1vk9agyilvn diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/debian/changelog ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/debian/changelog --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/debian/changelog 2011-10-07 14:04:27.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/debian/changelog 2011-11-04 12:38:29.000000000 +0000 @@ -1,8 +1,8 @@ -ffmpeg2theora (0.28~ppa2+503+30387+3~oneiric1) natty; urgency=low +ffmpeg2theora (0.28~ppa2+506+30862+3~oneiric1) natty; urgency=low * Auto build. - -- j^ Fri, 07 Oct 2011 14:04:27 +0000 + -- j^ Fri, 04 Nov 2011 12:38:29 +0000 ffmpeg2theora (0.28~ppa2) natty; urgency=low diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/avconv.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/avconv.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/avconv.c 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/avconv.c 2011-11-04 12:38:26.000000000 +0000 @@ -149,6 +149,8 @@ static float dts_delta_threshold = 10; +static int print_stats = 1; + static uint8_t *audio_buf; static uint8_t *audio_out; static unsigned int allocated_audio_out_size, allocated_audio_buf_size; @@ -238,9 +240,11 @@ AVFilterGraph *graph; #endif - int sws_flags; + int64_t sws_flags; AVDictionary *opts; int is_past_recording_time; + int stream_copy; + const char *attachment_filename; } OutputStream; #if HAVE_TERMIOS_H @@ -292,6 +296,8 @@ SpecifierOpt *ts_scale; int nb_ts_scale; + SpecifierOpt *dump_attachment; + int nb_dump_attachment; /* output options */ StreamMap *stream_maps; @@ -302,6 +308,8 @@ int metadata_global_manual; int metadata_streams_manual; int metadata_chapters_manual; + const char **attachments; + int nb_attachments; int chapters_input_file; @@ -345,6 +353,8 @@ int nb_inter_matrices; SpecifierOpt *top_field_first; int nb_top_field_first; + SpecifierOpt *presets; + int nb_presets; #if CONFIG_AVFILTER SpecifierOpt *filters; int nb_filters; @@ -392,7 +402,6 @@ memset(o, 0, sizeof(*o)); - o->mux_preload = 0.5; o->mux_max_delay = 0.7; o->recording_time = INT64_MAX; o->limit_filesize = UINT64_MAX; @@ -448,7 +457,7 @@ snprintf(args, 255, "%d:%d:flags=0x%X", codec->width, codec->height, - ost->sws_flags); + (unsigned)ost->sws_flags); if ((ret = avfilter_graph_create_filter(&filter, avfilter_get_by_name("scale"), NULL, args, NULL, ost->graph)) < 0) return ret; @@ -457,7 +466,7 @@ last_filter = filter; } - snprintf(args, sizeof(args), "flags=0x%X", ost->sws_flags); + snprintf(args, sizeof(args), "flags=0x%X", (unsigned)ost->sws_flags); ost->graph->scale_sws_opts = av_strdup(args); if (ost->avfilter) { @@ -1374,6 +1383,9 @@ static int qp_histogram[52]; int hours, mins, secs, us; + if (!print_stats && !is_last_report) + return; + if (!is_last_report) { int64_t cur_time; /* display the report every 0.5 seconds */ @@ -1400,7 +1412,7 @@ float q = -1; ost = &ost_table[i]; enc = ost->st->codec; - if (!ost->st->stream_copy && enc->coded_frame) + if (!ost->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); @@ -1470,7 +1482,7 @@ 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); + av_log(NULL, AV_LOG_INFO, "%s \r", buf); fflush(stderr); @@ -1668,7 +1680,6 @@ (ist->st->codec->sample_rate * ist->st->codec->channels); break;} case AVMEDIA_TYPE_VIDEO: - decoded_data_size = (ist->st->codec->width * ist->st->codec->height * 3) / 2; if (!(decoded_frame = avcodec_alloc_frame())) return AVERROR(ENOMEM); avpkt.pts = pkt_pts; @@ -2041,6 +2052,9 @@ os = output_files[ost->file_index].ctx; ist = &input_streams[ost->source_index]; + if (ost->attachment_filename) + continue; + codec = ost->st->codec; icodec = ist->st->codec; @@ -2048,7 +2062,7 @@ codec->bits_per_raw_sample= icodec->bits_per_raw_sample; codec->chroma_sample_location = icodec->chroma_sample_location; - if (ost->st->stream_copy) { + if (ost->stream_copy) { uint64_t extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE; if (extra_size > INT_MAX) { @@ -2135,6 +2149,8 @@ } else { if (!ost->enc) ost->enc = avcodec_find_encoder(ost->st->codec->codec_id); + ist->decoding_needed = 1; + ost->encoding_needed = 1; switch(codec->codec_type) { case AVMEDIA_TYPE_AUDIO: ost->fifo= av_fifo_alloc(1024); @@ -2142,9 +2158,8 @@ return AVERROR(ENOMEM); } ost->reformat_pair = MAKE_SFMT_PAIR(AV_SAMPLE_FMT_NONE,AV_SAMPLE_FMT_NONE); - if (!codec->sample_rate) { + if (!codec->sample_rate) codec->sample_rate = icodec->sample_rate; - } choose_sample_rate(ost->st, ost->enc); codec->time_base = (AVRational){1, codec->sample_rate}; if (codec->sample_fmt == AV_SAMPLE_FMT_NONE) @@ -2158,8 +2173,6 @@ codec->channel_layout = 0; ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1; icodec->request_channels = codec->channels; - ist->decoding_needed = 1; - ost->encoding_needed = 1; ost->resample_sample_fmt = icodec->sample_fmt; ost->resample_sample_rate = icodec->sample_rate; ost->resample_channels = icodec->channels; @@ -2189,8 +2202,6 @@ ost->resample_height = icodec->height; ost->resample_width = icodec->width; ost->resample_pix_fmt= icodec->pix_fmt; - ost->encoding_needed = 1; - ist->decoding_needed = 1; if (!ost->frame_rate.num) ost->frame_rate = ist->st->r_frame_rate.num ? ist->st->r_frame_rate : (AVRational){25,1}; @@ -2213,15 +2224,13 @@ #endif break; case AVMEDIA_TYPE_SUBTITLE: - ost->encoding_needed = 1; - ist->decoding_needed = 1; break; default: abort(); break; } /* two pass mode */ - if (ost->encoding_needed && codec->codec_id != CODEC_ID_H264 && + if (codec->codec_id != CODEC_ID_H264 && (codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) { char logfilename[1024]; FILE *f; @@ -2240,7 +2249,7 @@ } else { char *logbuffer; size_t logbuffer_size; - if (read_file(logfilename, &logbuffer, &logbuffer_size) < 0) { + if (cmdutils_read_file(logfilename, &logbuffer, &logbuffer_size) < 0) { av_log(NULL, AV_LOG_FATAL, "Error reading log file '%s' for pass-2 encoding\n", logfilename); exit_program(1); @@ -2349,6 +2358,13 @@ av_log(NULL, AV_LOG_INFO, "Stream mapping:\n"); for (i = 0; i < nb_output_streams; i++) { ost = &output_streams[i]; + + if (ost->attachment_filename) { + /* an attached file */ + av_log(NULL, AV_LOG_INFO, " File %s -> Stream #%d:%d\n", + ost->attachment_filename, ost->file_index, ost->index); + continue; + } av_log(NULL, AV_LOG_INFO, " Stream #%d.%d -> #%d.%d", input_streams[ost->source_index].file_index, input_streams[ost->source_index].st->index, @@ -2358,7 +2374,7 @@ av_log(NULL, AV_LOG_INFO, " [sync #%d.%d]", ost->sync_ist->file_index, ost->sync_ist->st->index); - if (ost->st->stream_copy) + if (ost->stream_copy) av_log(NULL, AV_LOG_INFO, " (copy)"); else av_log(NULL, AV_LOG_INFO, " (%s -> %s)", input_streams[ost->source_index].dec ? @@ -2641,7 +2657,7 @@ for (i = 0; i < nb_output_streams; i++) { ost = &output_streams[i]; if (ost) { - if (ost->st->stream_copy) + if (ost->stream_copy) av_freep(&ost->st->codec->extradata); if (ost->logfile) { fclose(ost->logfile); @@ -2665,12 +2681,6 @@ return ret; } -static int opt_verbose(const char *opt, const char *arg) -{ - av_log(NULL, AV_LOG_WARNING, "-%s is deprecated, use -loglevel\n", opt); - return 0; -} - static double parse_frame_aspect_ratio(const char *arg) { int x = 0, y = 0; @@ -2762,7 +2772,8 @@ /* disable some already defined maps */ for (i = 0; i < o->nb_stream_maps; i++) { m = &o->stream_maps[i]; - if (check_stream_specifier(input_files[m->file_index].ctx, + if (file_idx == m->file_index && + check_stream_specifier(input_files[m->file_index].ctx, input_files[m->file_index].ctx->streams[m->stream_index], *p == ':' ? p + 1 : p) > 0) m->disabled = 1; @@ -2797,6 +2808,14 @@ return 0; } +static int opt_attach(OptionsContext *o, const char *opt, const char *arg) +{ + o->attachments = grow_array(o->attachments, sizeof(*o->attachments), + &o->nb_attachments, o->nb_attachments + 1); + o->attachments[o->nb_attachments - 1] = arg; + return 0; +} + static void parse_meta_type(char *arg, char *type, int *index) { if (*arg) { @@ -2846,13 +2865,11 @@ return 0; } -static enum CodecID find_codec_or_die(const char *name, enum AVMediaType type, int encoder) +static AVCodec *find_codec_or_die(const char *name, enum AVMediaType type, int encoder) { const char *codec_string = encoder ? "encoder" : "decoder"; AVCodec *codec; - if(!name) - return CODEC_ID_NONE; codec = encoder ? avcodec_find_encoder_by_name(name) : avcodec_find_decoder_by_name(name); @@ -2864,29 +2881,20 @@ av_log(NULL, AV_LOG_FATAL, "Invalid %s type '%s'\n", codec_string, name); exit_program(1); } - return codec->id; + return codec; } -static AVCodec *choose_codec(OptionsContext *o, AVFormatContext *s, AVStream *st, enum AVMediaType type) +static AVCodec *choose_decoder(OptionsContext *o, AVFormatContext *s, AVStream *st) { char *codec_name = NULL; MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, st); - - if (!codec_name) { - if (s->oformat) { - st->codec->codec_id = av_guess_codec(s->oformat, NULL, s->filename, NULL, type); - return avcodec_find_encoder(st->codec->codec_id); - } - } else if (!strcmp(codec_name, "copy")) - st->stream_copy = 1; - else { - st->codec->codec_id = find_codec_or_die(codec_name, type, s->iformat == NULL); - return s->oformat ? avcodec_find_encoder_by_name(codec_name) : - avcodec_find_decoder_by_name(codec_name); - } - - return NULL; + if (codec_name) { + AVCodec *codec = find_codec_or_die(codec_name, st->codec->codec_type, 0); + st->codec->codec_id = codec->id; + return codec; + } else + return avcodec_find_decoder(st->codec->codec_id); } /** @@ -2913,9 +2921,7 @@ MATCH_PER_STREAM_OPT(ts_scale, dbl, scale, ic, st); ist->ts_scale = scale; - ist->dec = choose_codec(o, ic, st, dec->codec_type); - if (!ist->dec) - ist->dec = avcodec_find_decoder(dec->codec_id); + ist->dec = choose_decoder(o, ic, st); switch (dec->codec_type) { case AVMEDIA_TYPE_AUDIO: @@ -2962,6 +2968,60 @@ } } +static void assert_file_overwrite(const char *filename) +{ + if (!file_overwrite && + (strchr(filename, ':') == NULL || filename[1] == ':' || + av_strstart(filename, "file:", NULL))) { + if (avio_check(filename, 0) == 0) { + if (!using_stdin) { + fprintf(stderr,"File '%s' already exists. Overwrite ? [y/N] ", filename); + fflush(stderr); + if (!read_yesno()) { + fprintf(stderr, "Not overwriting - exiting\n"); + exit_program(1); + } + } + else { + fprintf(stderr,"File '%s' already exists. Exiting.\n", filename); + exit_program(1); + } + } + } +} + +static void dump_attachment(AVStream *st, const char *filename) +{ + int ret; + AVIOContext *out = NULL; + AVDictionaryEntry *e; + + if (!st->codec->extradata_size) { + av_log(NULL, AV_LOG_WARNING, "No extradata to dump in stream #%d:%d.\n", + nb_input_files - 1, st->index); + return; + } + if (!*filename && (e = av_dict_get(st->metadata, "filename", NULL, 0))) + filename = e->value; + if (!*filename) { + av_log(NULL, AV_LOG_FATAL, "No filename specified and no 'filename' tag" + "in stream #%d:%d.\n", nb_input_files - 1, st->index); + exit_program(1); + } + + assert_file_overwrite(filename); + + if ((ret = avio_open (&out, filename, AVIO_FLAG_WRITE)) < 0) { + av_log(NULL, AV_LOG_FATAL, "Could not open file %s for writing.\n", + filename); + exit_program(1); + } + + avio_write(out, st->codec->extradata, st->codec->extradata_size); + avio_flush(out); + avio_close(out); +} + static int opt_input_file(OptionsContext *o, const char *opt, const char *filename) { AVFormatContext *ic; @@ -3020,7 +3080,7 @@ /* apply forced codec ids */ for (i = 0; i < ic->nb_streams; i++) - choose_codec(o, ic, ic->streams[i], ic->streams[i]->codec->codec_type); + choose_decoder(o, ic, ic->streams[i]); /* Set AVCodecContext options for avformat_find_stream_info */ opts = setup_find_stream_info_opts(ic, codec_opts); @@ -3062,6 +3122,17 @@ input_files[nb_input_files - 1].nb_streams = ic->nb_streams; input_files[nb_input_files - 1].rate_emu = o->rate_emu; + for (i = 0; i < o->nb_dump_attachment; i++) { + int j; + + for (j = 0; j < ic->nb_streams; j++) { + AVStream *st = ic->streams[j]; + + if (check_stream_specifier(ic, st, o->dump_attachment[i].specifier) == 1) + dump_attachment(st, o->dump_attachment[i].u.str); + } + } + for (i = 0; i < orig_nb_streams; i++) av_dict_free(&opts[i]); av_freep(&opts); @@ -3093,21 +3164,88 @@ } } +static uint8_t *get_line(AVIOContext *s) +{ + AVIOContext *line; + uint8_t *buf; + char c; + + if (avio_open_dyn_buf(&line) < 0) { + av_log(NULL, AV_LOG_FATAL, "Could not alloc buffer for reading preset.\n"); + exit_program(1); + } + + while ((c = avio_r8(s)) && c != '\n') + avio_w8(line, c); + avio_w8(line, 0); + avio_close_dyn_buf(line, &buf); + + return buf; +} + +static int get_preset_file_2(const char *preset_name, const char *codec_name, AVIOContext **s) +{ + int i, ret = 1; + char filename[1000]; + const char *base[3] = { getenv("AVCONV_DATADIR"), + getenv("HOME"), + AVCONV_DATADIR, + }; + + for (i = 0; i < FF_ARRAY_ELEMS(base) && ret; i++) { + if (!base[i]) + continue; + if (codec_name) { + snprintf(filename, sizeof(filename), "%s%s/%s-%s.avpreset", base[i], + i != 1 ? "" : "/.avconv", codec_name, preset_name); + ret = avio_open(s, filename, AVIO_FLAG_READ); + } + if (ret) { + snprintf(filename, sizeof(filename), "%s%s/%s.avpreset", base[i], + i != 1 ? "" : "/.avconv", preset_name); + ret = avio_open(s, filename, AVIO_FLAG_READ); + } + } + return ret; +} + +static void choose_encoder(OptionsContext *o, AVFormatContext *s, OutputStream *ost) +{ + char *codec_name = NULL; + + MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, ost->st); + if (!codec_name) { + ost->st->codec->codec_id = av_guess_codec(s->oformat, NULL, s->filename, + NULL, ost->st->codec->codec_type); + ost->enc = avcodec_find_encoder(ost->st->codec->codec_id); + } else if (!strcmp(codec_name, "copy")) + ost->stream_copy = 1; + else { + ost->enc = find_codec_or_die(codec_name, ost->st->codec->codec_type, 1); + ost->st->codec->codec_id = ost->enc->id; + } +} + static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type) { OutputStream *ost; - AVStream *st = av_new_stream(oc, oc->nb_streams < o->nb_streamid_map ? o->streamid_map[oc->nb_streams] : 0); - int idx = oc->nb_streams - 1; + AVStream *st = avformat_new_stream(oc, NULL); + int idx = oc->nb_streams - 1, ret = 0; int64_t max_frames = INT64_MAX; char *bsf = NULL, *next, *codec_tag = NULL; AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL; double qscale = -1; + char *buf = NULL, *arg = NULL, *preset = NULL; + AVIOContext *s = NULL; if (!st) { av_log(NULL, AV_LOG_FATAL, "Could not alloc stream.\n"); exit_program(1); } + if (oc->nb_streams - 1 < o->nb_streamid_map) + st->id = o->streamid_map[oc->nb_streams - 1]; + output_streams = grow_array(output_streams, sizeof(*output_streams), &nb_output_streams, nb_output_streams + 1); ost = &output_streams[nb_output_streams - 1]; @@ -3115,7 +3253,7 @@ ost->index = idx; ost->st = st; st->codec->codec_type = type; - ost->enc = choose_codec(o, oc, st, type); + choose_encoder(o, oc, ost); if (ost->enc) { ost->opts = filter_codec_opts(codec_opts, ost->enc->id, oc, st); } @@ -3123,6 +3261,31 @@ avcodec_get_context_defaults3(st->codec, ost->enc); st->codec->codec_type = type; // XXX hack, avcodec_get_context_defaults2() sets type to unknown for stream copy + MATCH_PER_STREAM_OPT(presets, str, preset, oc, st); + if (preset && (!(ret = get_preset_file_2(preset, ost->enc->name, &s)))) { + do { + buf = get_line(s); + if (!buf[0] || buf[0] == '#') { + av_free(buf); + continue; + } + if (!(arg = strchr(buf, '='))) { + av_log(NULL, AV_LOG_FATAL, "Invalid line found in the preset file.\n"); + exit_program(1); + } + *arg++ = 0; + av_dict_set(&ost->opts, buf, arg, AV_DICT_DONT_OVERWRITE); + av_free(buf); + } while (!s->eof_reached); + avio_close(s); + } + if (ret) { + av_log(NULL, AV_LOG_FATAL, + "Preset %s specified for stream %d:%d, but could not be opened.\n", + preset, ost->file_index, ost->index); + exit_program(1); + } + MATCH_PER_STREAM_OPT(max_frames, i64, max_frames, oc, st); ost->max_frames = max_frames; @@ -3160,7 +3323,7 @@ if (oc->oformat->flags & AVFMT_GLOBALHEADER) st->codec->flags |= CODEC_FLAG_GLOBAL_HEADER; - ost->sws_flags = av_get_int(sws_opts, "sws_flags", NULL); + av_opt_get_int(sws_opts, "sws_flags", 0, &ost->sws_flags); return ost; } @@ -3191,7 +3354,7 @@ st = ost->st; video_enc = st->codec; - if (!st->stream_copy) { + if (!ost->stream_copy) { const char *p = NULL; char *forced_key_frames = NULL, *frame_rate = NULL, *frame_size = NULL; char *frame_aspect_ratio = NULL, *frame_pix_fmt = NULL; @@ -3308,7 +3471,7 @@ audio_enc = st->codec; audio_enc->codec_type = AVMEDIA_TYPE_AUDIO; - if (!st->stream_copy) { + if (!ost->stream_copy) { char *sample_fmt = NULL; MATCH_PER_STREAM_OPT(audio_channels, i, audio_enc->channels, oc, st); @@ -3328,12 +3491,10 @@ static OutputStream *new_data_stream(OptionsContext *o, AVFormatContext *oc) { - AVStream *st; OutputStream *ost; ost = new_output_stream(o, oc, AVMEDIA_TYPE_DATA); - st = ost->st; - if (!st->stream_copy) { + if (!ost->stream_copy) { av_log(NULL, AV_LOG_FATAL, "Data stream encoding not supported yet (only streamcopy)\n"); exit_program(1); } @@ -3344,7 +3505,7 @@ static OutputStream *new_attachment_stream(OptionsContext *o, AVFormatContext *oc) { OutputStream *ost = new_output_stream(o, oc, AVMEDIA_TYPE_ATTACHMENT); - ost->st->stream_copy = 1; + ost->stream_copy = 1; return ost; } @@ -3449,9 +3610,9 @@ memcpy(st->info, ic->streams[i]->info, sizeof(*st->info)); avcodec_copy_context(st->codec, ic->streams[i]->codec); - if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && !st->stream_copy) + if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && !ost->stream_copy) choose_sample_fmt(st, codec); - else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && !st->stream_copy) + else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && !ost->stream_copy) choose_pixel_fmt(st, codec); } @@ -3562,6 +3723,42 @@ } } + /* handle attached files */ + for (i = 0; i < o->nb_attachments; i++) { + AVIOContext *pb; + uint8_t *attachment; + const char *p; + int64_t len; + + if ((err = avio_open(&pb, o->attachments[i], AVIO_FLAG_READ)) < 0) { + av_log(NULL, AV_LOG_FATAL, "Could not open attachment file %s.\n", + o->attachments[i]); + exit_program(1); + } + if ((len = avio_size(pb)) <= 0) { + av_log(NULL, AV_LOG_FATAL, "Could not get size of the attachment %s.\n", + o->attachments[i]); + exit_program(1); + } + if (!(attachment = av_malloc(len))) { + av_log(NULL, AV_LOG_FATAL, "Attachment %s too large to fit into memory.\n", + o->attachments[i]); + exit_program(1); + } + avio_read(pb, attachment, len); + + ost = new_attachment_stream(o, oc); + ost->stream_copy = 0; + ost->source_index = -1; + ost->attachment_filename = o->attachments[i]; + ost->st->codec->extradata = attachment; + ost->st->codec->extradata_size = len; + + p = strrchr(o->attachments[i], '/'); + av_dict_set(&ost->st->metadata, "filename", (p && *p) ? p + 1 : o->attachments[i], AV_DICT_DONT_OVERWRITE); + avio_close(pb); + } + output_files = grow_array(output_files, sizeof(*output_files), &nb_output_files, nb_output_files + 1); output_files[nb_output_files - 1].ctx = oc; output_files[nb_output_files - 1].ost_index = nb_output_streams - oc->nb_streams; @@ -3580,25 +3777,7 @@ if (!(oc->oformat->flags & AVFMT_NOFILE)) { /* test if it already exists to avoid loosing precious files */ - if (!file_overwrite && - (strchr(filename, ':') == NULL || - filename[1] == ':' || - av_strstart(filename, "file:", NULL))) { - if (avio_check(filename, 0) == 0) { - if (!using_stdin) { - fprintf(stderr,"File '%s' already exists. Overwrite ? [y/N] ", filename); - fflush(stderr); - if (!read_yesno()) { - fprintf(stderr, "Not overwriting - exiting\n"); - exit_program(1); - } - } - else { - fprintf(stderr,"File '%s' already exists. Exiting.\n", filename); - exit_program(1); - } - } - } + assert_file_overwrite(filename); /* open the file */ if ((err = avio_open(&oc->pb, filename, AVIO_FLAG_WRITE)) < 0) { @@ -3607,7 +3786,11 @@ } } - oc->preload = (int)(o->mux_preload * AV_TIME_BASE); + if (o->mux_preload) { + uint8_t buf[64]; + snprintf(buf, sizeof(buf), "%d", (int)(o->mux_preload*AV_TIME_BASE)); + av_dict_set(&output_files[nb_output_files - 1].opts, "preload", buf, 0); + } oc->max_delay = (int)(o->mux_max_delay * AV_TIME_BASE); /* copy chapters */ @@ -3682,7 +3865,10 @@ AV_DICT_DONT_OVERWRITE); if (!o->metadata_streams_manual) for (i = output_files[nb_output_files - 1].ost_index; i < nb_output_streams; i++) { - InputStream *ist = &input_streams[output_streams[i].source_index]; + InputStream *ist; + if (output_streams[i].source_index < 0) /* this is true e.g. for attached files */ + continue; + ist = &input_streams[output_streams[i].source_index]; av_dict_copy(&output_streams[i].st->metadata, ist->st->metadata, AV_DICT_DONT_OVERWRITE); } @@ -3787,11 +3973,7 @@ static int opt_help(const char *opt, const char *arg) { - AVCodec *c; - AVOutputFormat *oformat = NULL; - AVInputFormat *iformat = NULL; - const AVClass *class; - + int flags = AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM; av_log_set_callback(log_callback_help); show_usage(); show_help_options(options, "Main options:\n", @@ -3818,41 +4000,10 @@ OPT_GRAB, OPT_GRAB); printf("\n"); - class = avcodec_get_class(); - av_opt_show2(&class, NULL, AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM, 0); - printf("\n"); - - /* individual codec options */ - c = NULL; - while ((c = av_codec_next(c))) { - if (c->priv_class) { - av_opt_show2(&c->priv_class, NULL, AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM, 0); - printf("\n"); - } - } - - class = avformat_get_class(); - av_opt_show2(&class, NULL, AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM, 0); - printf("\n"); - - /* individual muxer options */ - while ((oformat = av_oformat_next(oformat))) { - if (oformat->priv_class) { - av_opt_show2(&oformat->priv_class, NULL, AV_OPT_FLAG_ENCODING_PARAM, 0); - printf("\n"); - } - } - - /* individual demuxer options */ - while ((iformat = av_iformat_next(iformat))) { - if (iformat->priv_class) { - av_opt_show2(&iformat->priv_class, NULL, AV_OPT_FLAG_DECODING_PARAM, 0); - printf("\n"); - } - } + show_help_children(avcodec_get_class(), flags); + show_help_children(avformat_get_class(), flags); + show_help_children(sws_get_class(), flags); - class = sws_get_class(); - av_opt_show2(&class, NULL, AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM, 0); return 0; } @@ -4068,6 +4219,7 @@ { "y", OPT_BOOL, {(void*)&file_overwrite}, "overwrite output files" }, { "c", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(codec_names)}, "codec name", "codec" }, { "codec", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(codec_names)}, "codec name", "codec" }, + { "pre", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(presets)}, "preset name", "preset" }, { "map", HAS_ARG | OPT_EXPERT | OPT_FUNC2, {(void*)opt_map}, "set input stream mapping", "file.stream[:syncfile.syncstream]" }, { "map_metadata", HAS_ARG | OPT_EXPERT | OPT_FUNC2, {(void*)opt_map_metadata}, "set metadata information of outfile from infile", "outfile[,metadata]:infile[,metadata]" }, @@ -4087,7 +4239,6 @@ { "hex", OPT_BOOL | OPT_EXPERT, {(void*)&do_hex_dump}, "when dumping packets, also dump the payload" }, { "re", OPT_BOOL | OPT_EXPERT | OPT_OFFSET, {.off = OFFSET(rate_emu)}, "read input at native frame rate", "" }, - { "v", HAS_ARG, {(void*)opt_verbose}, "deprecated, use -loglevel instead", "number" }, { "target", HAS_ARG | OPT_FUNC2, {(void*)opt_target}, "specify target file type (\"vcd\", \"svcd\", \"dvd\", \"dv\", \"dv50\", \"pal-vcd\", \"ntsc-svcd\", ...)", "type" }, { "vsync", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&video_sync_method}, "video sync method", "" }, { "async", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&audio_sync_method}, "audio sync method", "" }, @@ -4105,6 +4256,9 @@ #if CONFIG_AVFILTER { "filter", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(filters)}, "set stream filterchain", "filter_list" }, #endif + { "stats", OPT_BOOL, {&print_stats}, "print progress report during encoding", }, + { "attach", HAS_ARG | OPT_FUNC2, {(void*)opt_attach}, "add an attachment to the output file", "filename" }, + { "dump_attachment", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(dump_attachment)}, "extract an attachment into a file", "filename" }, /* video options */ { "vframes", HAS_ARG | OPT_VIDEO | OPT_FUNC2, {(void*)opt_video_frames}, "set the number of video frames to record", "number" }, diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/Changelog ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/Changelog --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/Changelog 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/Changelog 2011-11-04 12:38:26.000000000 +0000 @@ -62,7 +62,16 @@ - CELT in Ogg demuxing - G.723.1 demuxer and decoder - libmodplug support (--enable-libmodplug) - +- VC-1 interlaced decoding +- libutvideo wrapper (--enable-libutvideo) +- aevalsrc audio source added +- Ut Video decoder +- Speex encoding via libspeex +- 4:2:2 H.264 decoding support +- Pulseaudio input device +- Prores encoder +- Video Decoder Acceleration (VDA) HWAccel module. +- replacement Indeo 3 decoder version 0.8: diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/cmdutils.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/cmdutils.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/cmdutils.c 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/cmdutils.c 2011-11-04 12:38:26.000000000 +0000 @@ -130,6 +130,16 @@ } } +void show_help_children(const AVClass *class, int flags) +{ + const AVClass *child = NULL; + av_opt_show2(&class, NULL, flags, 0); + printf("\n"); + + while (child = av_opt_child_class_next(class, child)) + show_help_children(child, flags); +} + static const OptionDef* find_option(const OptionDef *po, const char *name){ const char *p = strchr(name, ':'); int len = p ? p - name : strlen(name); @@ -336,11 +346,13 @@ void parse_loglevel(int argc, char **argv, const OptionDef *options) { int idx = locate_option(argc, argv, options, "loglevel"); + if (!idx) + idx = locate_option(argc, argv, options, "v"); if (idx && argv[idx + 1]) opt_loglevel("loglevel", argv[idx + 1]); } -#define FLAGS(o) ((o)->type == FF_OPT_TYPE_FLAGS) ? AV_DICT_APPEND : 0 +#define FLAGS(o) ((o)->type == AV_OPT_TYPE_FLAGS) ? AV_DICT_APPEND : 0 int opt_default(const char *opt, const char *arg) { const AVOption *oc, *of, *os; @@ -362,7 +374,7 @@ sc = sws_get_class(); if ((os = av_opt_find(&sc, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) { // XXX we only support sws_flags, not arbitrary sws options - int ret = av_set_string3(sws_opts, opt, arg, 1, NULL); + int ret = av_opt_set(sws_opts, opt, arg, 0); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt); return ret; @@ -411,6 +423,12 @@ return 0; } +int opt_codec_debug(const char *opt, const char *arg) +{ + av_log_set_level(AV_LOG_DEBUG); + return opt_default(opt, arg); +} + int opt_timelimit(const char *opt, const char *arg) { #if HAVE_SETRLIMIT @@ -789,8 +807,9 @@ return yesno; } -int read_file(const char *filename, char **bufptr, size_t *size) +int cmdutils_read_file(const char *filename, char **bufptr, size_t *size) { + int ret; FILE *f = fopen(filename, "rb"); if (!f) { @@ -806,11 +825,22 @@ fclose(f); return AVERROR(ENOMEM); } - fread(*bufptr, 1, *size, f); - (*bufptr)[*size++] = '\0'; + 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 0; + return ret; } FILE *get_preset_file(char *filename, size_t filename_size, diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/cmdutils_common_opts.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/cmdutils_common_opts.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/cmdutils_common_opts.h 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/cmdutils_common_opts.h 2011-11-04 12:38:26.000000000 +0000 @@ -12,3 +12,5 @@ { "pix_fmts" , OPT_EXIT, {(void*)opt_pix_fmts }, "show available pixel formats" }, { "sample_fmts", OPT_EXIT, {.func_arg = show_sample_fmts }, "show available audio sample formats" }, { "loglevel", HAS_ARG, {(void*)opt_loglevel}, "set libav* logging level", "loglevel" }, + { "v", HAS_ARG, {(void*)opt_loglevel}, "set libav* logging level", "loglevel" }, + { "debug", HAS_ARG, {(void*)opt_codec_debug}, "set debug flags", "flags" }, diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/cmdutils.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/cmdutils.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/cmdutils.h 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/cmdutils.h 2011-11-04 12:38:26.000000000 +0000 @@ -76,6 +76,8 @@ */ int opt_loglevel(const char *opt, const char *arg); +int opt_codec_debug(const char *opt, const char *arg); + /** * Limit the execution time. */ @@ -159,6 +161,12 @@ void show_help_options(const OptionDef *options, const char *msg, int mask, int value); /** + * Show help for all options with given flags in class and all its + * children. + */ +void show_help_children(const AVClass *class, int flags); + +/** * Parse the command line arguments. * * @param optctx an opaque options context @@ -315,7 +323,7 @@ * @return 0 in case of success, a negative value corresponding to an * AVERROR error code in case of failure. */ -int read_file(const char *filename, char **bufptr, size_t *size); +int cmdutils_read_file(const char *filename, char **bufptr, size_t *size); /** * Get a file corresponding to a preset file. @@ -354,4 +362,4 @@ */ void *grow_array(void *array, int elem_size, int *size, int new_size); -#endif /* LIBAV_CMDUTILS_H */ +#endif /* CMDUTILS_H */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/common.mak ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/common.mak --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/common.mak 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/common.mak 2011-11-04 12:38:26.000000000 +0000 @@ -47,6 +47,9 @@ %.o: %.cpp $(COMPILE_CXX) +%.s: %.c + $(CC) $(CPPFLAGS) $(CFLAGS) -S -o $@ $< + %.o: %.S $(COMPILE_S) diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/configure ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/configure --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/configure 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/configure 2011-11-04 12:38:26.000000000 +0000 @@ -76,7 +76,6 @@ --enable-shared build shared libraries [no] --enable-gpl allow use of GPL code, the resulting libs and binaries will be under GPL [no] - --enable-version2 force GPL version 2 [no] --enable-version3 upgrade (L)GPL to version 3 [no] --enable-nonfree allow use of nonfree code, the resulting libs and binaries will be unredistributable [no] @@ -94,7 +93,7 @@ --disable-postproc disable libpostproc build --disable-avfilter disable video filter support [no] --disable-pthreads disable pthreads [auto] - --enable-w32threads use Win32 threads [no] + --disable-w32threads disable Win32 threads [auto] --enable-x11grab enable X11 grabbing [no] --disable-network disable network support [no] --enable-gray enable full grayscale support (slower color) @@ -112,6 +111,7 @@ --enable-vaapi enable VAAPI code [autodetect] --enable-vdpau enable VDPAU code [autodetect] --disable-dxva2 disable DXVA2 code + --disable-vda disable VDA code --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary) --enable-hardcoded-tables use hardcoded tables instead of runtime generation --enable-memalign-hack emulate memalign, interferes with memory debuggers @@ -163,7 +163,7 @@ External library support: --enable-avisynth enable reading of AVISynth script files [no] --enable-bzlib enable bzlib [autodetect] - --enable-libcelt enable CELT/Opus decoding via libcelt [no] + --enable-libcelt enable CELT decoding via libcelt [no] --enable-frei0r enable frei0r video filtering --enable-libaacplus enable AAC+ encoding via libaacplus [no] --enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb [no] @@ -183,9 +183,10 @@ --enable-libopenjpeg enable JPEG 2000 decoding via OpenJPEG [no] --enable-librtmp enable RTMP[E] support via librtmp [no] --enable-libschroedinger enable Dirac support via libschroedinger [no] - --enable-libspeex enable Speex encoding and decoding via libspeex [no] + --enable-libspeex enable Speex support via libspeex [no] --enable-libstagefright-h264 enable H.264 decoding via libstagefright [no] --enable-libtheora enable Theora encoding via libtheora [no] + --enable-libutvideo enable Ut Video decoding via libutvideo [no] --enable-libvo-aacenc enable AAC encoding via libvo-aacenc [no] --enable-libvo-amrwbenc enable AMR-WB encoding via libvo-amrwbenc [no] --enable-libvorbis enable Vorbis encoding via libvorbis, @@ -845,6 +846,9 @@ static void sighandler(int sig){ raise(SIGTERM); } +int func(void){ + $code +} int main(void){ signal(SIGILL, sighandler); signal(SIGFPE, sighandler); @@ -852,7 +856,7 @@ #ifdef SIGBUS signal(SIGBUS, sighandler); #endif - { $code } + return func(); } EOF } @@ -1011,11 +1015,13 @@ libopencore_amrwb libopencv libopenjpeg + libpulse librtmp libschroedinger libspeex libstagefright_h264 libtheora + libutvideo libvo_aacenc libvo_amrwbenc libvorbis @@ -1047,8 +1053,8 @@ swscale_alpha thumb vaapi + vda vdpau - version2 version3 x11grab zlib @@ -1121,6 +1127,7 @@ attribute_may_alias attribute_packed bswap + cbrtf closesocket cmov dcbzl @@ -1186,7 +1193,6 @@ setrlimit strerror_r strptime - strtok_r struct_addrinfo struct_ipv6_mreq struct_sockaddr_in6 @@ -1216,7 +1222,6 @@ CONFIG_EXTRA=" avutil gplv3 - gplv2 lgplv3 " @@ -1374,6 +1379,8 @@ h264_dxva2_hwaccel_deps="dxva2api_h" h264_dxva2_hwaccel_select="dxva2 h264_decoder" h264_vaapi_hwaccel_select="vaapi" +h264_vda_hwaccel_deps="VideoDecodeAcceleration_VDADecoder_h" +h264_vda_hwaccel_select="vda" h264_vdpau_decoder_select="vdpau h264_decoder" imc_decoder_select="fft mdct sinewin" jpegls_decoder_select="golomb" @@ -1420,7 +1427,6 @@ nellymoser_encoder_select="mdct sinewin" png_decoder_select="zlib" png_encoder_select="zlib" -prores_gpl_decoder_deps="version2 gpl" qcelp_decoder_select="lsp" qdm2_decoder_select="mdct rdft mpegaudiodsp" ra_144_encoder_select="lpc" @@ -1517,6 +1523,7 @@ libx264_encoder_deps="libx264" libxavs_encoder_deps="libxavs" libxvid_encoder_deps="libxvid" +libutvideo_decoder_deps="libutvideo gpl" # demuxers / muxers ac3_demuxer_select="ac3_parser" @@ -1564,6 +1571,7 @@ openal_indev_deps="openal" oss_indev_deps_any="soundcard_h sys_soundcard_h" oss_outdev_deps_any="soundcard_h sys_soundcard_h" +pulse_indev_deps="libpulse" sdl_outdev_deps="sdl" sndio_indev_deps="sndio_h" sndio_outdev_deps="sndio_h" @@ -1586,17 +1594,14 @@ udp_protocol_deps="network" # filters -abuffer_filter_deps="strtok_r" -aconvert_filter_deps="strtok_r" -aformat_filter_deps="strtok_r" amovie_filter_deps="avcodec avformat" blackframe_filter_deps="gpl" boxblur_filter_deps="gpl" cropdetect_filter_deps="gpl" delogo_filter_deps="gpl" drawtext_filter_deps="libfreetype" -frei0r_filter_deps="frei0r dlopen strtok_r" -frei0r_src_filter_deps="frei0r dlopen strtok_r" +frei0r_filter_deps="frei0r dlopen" +frei0r_src_filter_deps="frei0r dlopen" hqdn3d_filter_deps="gpl" movie_filter_deps="avcodec avformat" mp_filter_deps="gpl avcodec" @@ -2293,7 +2298,7 @@ arch="sparc" subarch="sparc64" ;; - i[3-6]86|i86pc|BePC|x86pc|x86_64|amd64) + i[3-6]86|i86pc|BePC|x86pc|x86_64|x86_32|amd64) arch="x86" ;; esac @@ -2563,6 +2568,7 @@ disable network else target_os=mingw32 + enable_weak w32threads fi LIBTARGET=i386 if enabled x86_64; then @@ -2705,11 +2711,7 @@ die_license_disabled version3 libvo_aacenc die_license_disabled version3 libvo_amrwbenc -! enabled gpl && enabled version2 && die "LGPLv2 mode is unsupported" -enabled version3 && enabled version2 && ! enabled nonfree && die "GPLv2 (not v2+) and GPLv3 without --enable-nonfree" - enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; } -enabled version2 && enabled gpl && enable gplv2 disabled optimizations || check_cflags -fomit-frame-pointer @@ -2947,7 +2949,6 @@ check_func setrlimit check_func strerror_r check_func strptime -check_func strtok_r check_func_headers conio.h kbhit check_func_headers windows.h PeekNamedPipe check_func_headers io.h setmode @@ -2958,6 +2959,7 @@ check_func_headers windows.h VirtualAlloc check_header dlfcn.h +check_header VideoDecodeAcceleration/VDADecoder.h check_header dxva2api.h -D_WIN32_WINNT=0x0600 check_header libcrystalhd/libcrystalhd_if.h check_header malloc.h @@ -2973,6 +2975,11 @@ disabled zlib || check_lib zlib.h zlibVersion -lz || disable zlib disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib +# adds ldflags for VDA module +if enabled vda; then + add_ldflags -framework CoreFoundation -framework VideoDecodeAcceleration -framework QuartzCore +fi + # check for some common methods of building with pthread support # do this before the optional library checks as some of them require pthreads if ! disabled pthreads && ! enabled w32threads; then @@ -3004,6 +3011,7 @@ disabled crystalhd || check_lib libcrystalhd/libcrystalhd_if.h DtsCrystalHDVersion -lcrystalhd || disable crystalhd enabled vaapi && require vaapi va/va.h vaInitialize -lva +check_mathfunc cbrtf check_mathfunc exp2 check_mathfunc exp2f check_mathfunc llrint @@ -3036,6 +3044,7 @@ enabled libopencore_amrwb && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb enabled libopencv && require_pkg_config opencv opencv/cxcore.h cvCreateImageHeader enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg +enabled libpulse && require_pkg_config libpulse-simple pulse/simple.h pa_simple_new enabled librtmp && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket enabled libschroedinger && require_pkg_config schroedinger-1.0 schroedinger/schro.h schro_init enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex @@ -3043,6 +3052,7 @@ media/stagefright/MediaBufferGroup.h media/stagefright/MediaDebug.h media/stagefright/MediaDefs.h media/stagefright/OMXClient.h media/stagefright/OMXCodec.h" android::OMXClient -lstagefright -lmedia -lutils -lbinder enabled libtheora && require libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg +enabled libutvideo && require_cpp utvideo "stdint.h stdlib.h utvideo/utvideo.h utvideo/Codec.h" 'CCodec*' -lutvideo -lstdc++ enabled libvo_aacenc && require libvo_aacenc vo-aacenc/voAAC.h voGetAACEncAPI -lvo-aacenc enabled libvo_amrwbenc && require libvo_amrwbenc vo-amrwbenc/enc_if.h E_IF_init -lvo-amrwbenc enabled libvorbis && require libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg @@ -3052,8 +3062,8 @@ enabled libvpx_encoder && { check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" "vpx_codec_enc_init_ver VPX_CQ" -lvpx || die "ERROR: libvpx encoder version must be >=0.9.6"; } } enabled libx264 && require libx264 x264.h x264_encoder_encode -lx264 && - { check_cpp_condition x264.h "X264_BUILD >= 115" || - die "ERROR: libx264 version must be >= 0.115."; } + { check_cpp_condition x264.h "X264_BUILD >= 118" || + die "ERROR: libx264 version must be >= 0.118."; } enabled libxavs && require libxavs xavs.h xavs_encoder_encode -lxavs enabled libxvid && require libxvid xvid.h xvid_global -lxvidcore enabled openal && { { for al_libs in "${OPENAL_LIBS}" "-lopenal" "-lOpenAL32"; do @@ -3163,6 +3173,7 @@ check_cflags -Wundef check_cflags -Wmissing-prototypes check_cflags -Wno-pointer-to-int-cast +check_cflags -Wstrict-prototypes enabled extra_warnings && check_cflags -Winline # add some linker flags @@ -3363,11 +3374,13 @@ echo "libopencore-amrwb support ${libopencore_amrwb-no}" echo "libopencv support ${libopencv-no}" echo "libopenjpeg enabled ${libopenjpeg-no}" +echo "libpulse enabled ${libpulse-no}" echo "librtmp enabled ${librtmp-no}" echo "libschroedinger enabled ${libschroedinger-no}" echo "libspeex enabled ${libspeex-no}" echo "libstagefright-h264 enabled ${libstagefright_h264-no}" echo "libtheora enabled ${libtheora-no}" +echo "libutvideo enabled ${libutvideo-no}" echo "libvo-aacenc support ${libvo_aacenc-no}" echo "libvo-amrwbenc support ${libvo_amrwbenc-no}" echo "libvorbis enabled ${libvorbis-no}" @@ -3392,8 +3405,6 @@ license="nonfree and unredistributable" elif enabled gplv3; then license="GPL version 3 or later" -elif enabled gplv2; then - license="GPL version 2" elif enabled lgplv3; then license="LGPL version 3 or later" elif enabled gpl; then diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/APIchanges ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/APIchanges --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/APIchanges 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/APIchanges 2011-11-04 12:38:26.000000000 +0000 @@ -13,6 +13,41 @@ API changes, most recent first: +2011-11-03 - xxxxxxx - lavu 51.23.0 + Add av_strcasecmp() and av_strncasecmp() to avstring.h. + +2011-10-20 - b35e9e1 - lavu 51.22.0 + Add av_strtok() to avstring.h. + +2011-xx-xx - xxxxxxx - lavc 53.15.0 + Remove avcodec_parse_frame. + Deprecate AVCodecContext.parse_only and CODEC_CAP_PARSE_ONLY. + +2011-10-xx - xxxxxxx - lavf 53.10.0 + Add avformat_new_stream(). Deprecate av_new_stream(). + +2011-xx-xx - xxxxxxx - lavf 53.9.0 + Add AVFMT_NO_BYTE_SEEK AVInputFormat flag. + +2011-10-12 - lavu 51.12.0 + AVOptions API rewrite. + + - 145f741 FF_OPT_TYPE* renamed to AV_OPT_TYPE_* + - new setting/getting functions with slightly different semantics: + dac66da av_set_string3 -> av_opt_set + av_set_double -> av_opt_set_double + av_set_q -> av_opt_set_q + av_set_int -> av_opt_set_int + + 41d9d51 av_get_string -> av_opt_get + av_get_double -> av_opt_get_double + av_get_q -> av_opt_get_q + av_get_int -> av_opt_get_int + + - 8c5dcaa trivial rename av_next_option -> av_opt_next + - 641c7af new functions - av_opt_child_next, av_opt_child_class_next + and av_opt_find2() + 2011-09-22 - xxxxxxx - lavu 51.17.0 Add av_x_if_null(). diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/avconv.texi ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/avconv.texi --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/avconv.texi 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/avconv.texi 2011-11-04 12:38:26.000000000 +0000 @@ -154,10 +154,6 @@ avconv -i INPUT -metadata:s:1 language=eng OUTPUT @end example -@item -v @var{number} (@emph{global}) -This option is deprecated and has no effect, use -loglevel -to set verbosity level. - @item -target @var{type} (@emph{output}) Specify target file type (@code{vcd}, @code{svcd}, @code{dvd}, @code{dv}, @code{dv50}). @var{type} may be prefixed with @code{pal-}, @code{ntsc-} or @@ -186,10 +182,48 @@ Use fixed quality scale (VBR). The meaning of @var{q} is codec-dependent. -@item -filter[:@var{stream_specifier}] @var{filter_graph} +@item -filter[:@var{stream_specifier}] @var{filter_graph} (@emph{output,per-stream}) @var{filter_graph} is a description of the filter graph to apply to the stream. Use @code{-filters} to show all the available filters (including also sources and sinks). +@item -pre[:@var{stream_specifier}] @var{preset_name} (@emph{output,per-stream}) +Specify the preset for matching stream(s). + +@item -stats (@emph{global}) +Print encoding progress/statistics. On by default. + +@item -attach @var{filename} (@emph{output}) +Add an attachment to the output file. This is supported by a few formats +like Matroska for e.g. fonts used in rendering subtitles. Attachments +are implemented as a specific type of stream, so this option will add +a new stream to the file. It is then possible to use per-stream options +on this stream in the usual way. Attachment streams created with this +option will be created after all the other streams (i.e. those created +with @code{-map} or automatic mappings). + +Note that for Matroska you also have to set the mimetype metadata tag: +@example +avconv -i INPUT -attach DejaVuSans.ttf -metadata:s:2 mimetype=application/x-truetype-font out.mkv +@end example +(assuming that the attachment stream will be third in the output file). + +@item -dump_attachment[:@var{stream_specifier}] @var{filename} (@emph{input,per-stream}) +Extract the matching attachment stream into a file named @var{filename}. If +@var{filename} is empty, then the value of the @code{filename} metadata tag +will be used. + +E.g. to extract the first attachment to a file named 'out.ttf': +@example +avconv -dump_attachment:t:0 out.ttf INPUT +@end example +To extract all attachments to files determined by the @code{filename} tag: +@example +avconv -dump_attachment:t "" INPUT +@end example + +Technical note -- attachments are implemented as codec extradata, so this +option can actually be used to extract extradata from any stream, not just +attachments. @end table @@ -771,6 +805,21 @@ @chapter Examples @c man begin EXAMPLES +@section Preset files + +A preset file contains a sequence of @var{option=value} pairs, one for +each line, specifying a sequence of options which can be specified also on +the command line. Lines starting with the hash ('#') character are ignored and +are used to provide comments. Empty lines are also ignored. Check the +@file{presets} directory in the Libav source tree for examples. + +Preset files are specified with the @code{pre} option, this option takes a +preset name as input. Avconv searches for a file named @var{preset_name}.avpreset in +the directories @file{$AVCONV_DATADIR} (if set), and @file{$HOME/.avconv}, and in +the data directory defined at configuration time (usually @file{$PREFIX/share/avconv}) +in that order. For example, if the argument is @code{libx264-max}, it will +search for the file @file{libx264-max.avpreset}. + @section Video and Audio grabbing If you specify the input format and device then avconv can grab video diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/avtools-common-opts.texi ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/avtools-common-opts.texi --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/avtools-common-opts.texi 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/avtools-common-opts.texi 2011-11-04 12:38:26.000000000 +0000 @@ -37,7 +37,7 @@ 'd' for data and 't' for attachments. If @var{stream_index} is given, then matches stream number @var{stream_index} of this type. Otherwise matches all streams of this type. -@item @var{program_id}[:@var{stream_index}] +@item p:@var{program_id}[:@var{stream_index}] If @var{stream_index} is given, then matches stream number @var{stream_index} in program with id @var{program_id}. Otherwise matches all streams in this program. @end table @@ -101,7 +101,7 @@ @item -sample_fmts Show available sample formats. -@item -loglevel @var{loglevel} +@item -loglevel @var{loglevel} | -v @var{loglevel} Set the logging level used by the library. @var{loglevel} is a number or a string containing one of the following values: @table @samp diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/encoders.texi ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/encoders.texi --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/encoders.texi 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/encoders.texi 2011-11-04 12:38:26.000000000 +0000 @@ -320,10 +320,10 @@ Not Indicated (default) @item 1 @itemx on -Dolby Surround EX On +Dolby Surround EX Off @item 2 @itemx off -Dolby Surround EX Off +Dolby Surround EX On @end table @item -dheadphone_mode @var{mode} @@ -337,10 +337,10 @@ Not Indicated (default) @item 1 @itemx on -Dolby Headphone On +Dolby Headphone Off @item 2 @itemx off -Dolby Headphone Off +Dolby Headphone On @end table @item -ad_conv_type @var{type} @@ -551,15 +551,12 @@ @item tune @var{tune_name} Tune the encoding params. -Deprecated in favor of @var{x264opts} @item fastfirstpass @var{bool} Use fast settings when encoding first pass, default value is 1. -Deprecated in favor of @var{x264opts}. @item profile @var{profile_name} Set profile restrictions. -Deprecated in favor of @var{x264opts}. @item level @var{level} Specify level (as defined by Annex A). @@ -567,14 +564,14 @@ @item passlogfile @var{filename} Specify filename for 2 pass stats. -Deprecated in favor of @var{x264opts}. +Deprecated in favor of @var{x264opts} (see @var{stats} libx264 option). @item wpredp @var{wpred_type} Specify Weighted prediction for P-frames. -Deprecated in favor of @var{x264opts}. +Deprecated in favor of @var{x264opts} (see @var{weightp} libx264 option). @item x264opts @var{options} -Allow to set any x264 option, see x264 manual for a list. +Allow to set any x264 option, see x264 --fullhelp for a list. @var{options} is a list of @var{key}=@var{value} couples separated by ":". diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/eval.texi ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/eval.texi --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/eval.texi 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/eval.texi 2011-11-04 12:38:26.000000000 +0000 @@ -83,6 +83,30 @@ @item pow(x, y) Compute the power of @var{x} elevated @var{y}, it is equivalent to "(@var{x})^(@var{y})". + +@item random(x) +Return a pseudo random value between 0.0 and 1.0. @var{x} is the index of the +internal variable which will be used to save the seed/state. + +@item hypot(x, y) +This function is similar to the C function with the same name; it returns +"sqrt(@var{x}*@var{x} + @var{y}*@var{y})", the length of the hypotenuse of a +right triangle with sides of length @var{x} and @var{y}, or the distance of the +point (@var{x}, @var{y}) from the origin. + +@item gcd(x, y) +Return the greatest common divisor of @var{x} and @var{y}. If both @var{x} and +@var{y} are 0 or either or both are less than zero then behavior is undefined. +@end table + +The following constants are available: +@table @option +@item PI +area of the unit disc, approximatively 3.14 +@item E +exp(1) (Euler's number), approximatively 2.718 +@item PHI +golden ratio (1+sqrt(5))/2, approximatively 1.618 @end table Note that: diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/examples/decoding_encoding.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/examples/decoding_encoding.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/examples/decoding_encoding.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/examples/decoding_encoding.c 2011-11-04 12:38:26.000000000 +0000 @@ -0,0 +1,464 @@ +/* + * Copyright (c) 2001 Fabrice Bellard + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +/** + * @file + * libavcodec API use example. + * + * Note that libavcodec only handles codecs (mpeg, mpeg4, etc...), + * not file formats (avi, vob, mp4, mov, mkv, mxf, flv, mpegts, mpegps, etc...). See library 'libavformat' for the + * format handling + */ + +#include "libavutil/imgutils.h" +#include "libavutil/opt.h" +#include "libavcodec/avcodec.h" +#include "libavutil/mathematics.h" + +#define INBUF_SIZE 4096 +#define AUDIO_INBUF_SIZE 20480 +#define AUDIO_REFILL_THRESH 4096 + +/* + * Audio encoding example + */ +static void audio_encode_example(const char *filename) +{ + AVCodec *codec; + AVCodecContext *c= NULL; + int frame_size, i, j, out_size, outbuf_size; + FILE *f; + short *samples; + float t, tincr; + uint8_t *outbuf; + + printf("Audio encoding\n"); + + /* find the MP2 encoder */ + codec = avcodec_find_encoder(CODEC_ID_MP2); + if (!codec) { + fprintf(stderr, "codec not found\n"); + exit(1); + } + + c = avcodec_alloc_context3(codec); + + /* put sample parameters */ + c->bit_rate = 64000; + c->sample_rate = 44100; + c->channels = 2; + c->sample_fmt = AV_SAMPLE_FMT_S16; + + /* open it */ + if (avcodec_open(c, codec) < 0) { + fprintf(stderr, "could not open codec\n"); + exit(1); + } + + /* the codec gives us the frame size, in samples */ + frame_size = c->frame_size; + samples = malloc(frame_size * 2 * c->channels); + outbuf_size = 10000; + outbuf = malloc(outbuf_size); + + f = fopen(filename, "wb"); + if (!f) { + fprintf(stderr, "could not open %s\n", filename); + exit(1); + } + + /* encode a single tone sound */ + t = 0; + tincr = 2 * M_PI * 440.0 / c->sample_rate; + for(i=0;i<200;i++) { + for(j=0;j 0) { + out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE; + len = avcodec_decode_audio3(c, (short *)outbuf, &out_size, &avpkt); + if (len < 0) { + fprintf(stderr, "Error while decoding\n"); + exit(1); + } + if (out_size > 0) { + /* if a frame has been decoded, output it */ + fwrite(outbuf, 1, out_size, outfile); + } + avpkt.size -= len; + avpkt.data += len; + if (avpkt.size < AUDIO_REFILL_THRESH) { + /* Refill the input buffer, to avoid trying to decode + * incomplete frames. Instead of this, one could also use + * a parser, or use a proper container format through + * libavformat. */ + memmove(inbuf, avpkt.data, avpkt.size); + avpkt.data = inbuf; + len = fread(avpkt.data + avpkt.size, 1, + AUDIO_INBUF_SIZE - avpkt.size, f); + if (len > 0) + avpkt.size += len; + } + } + + fclose(outfile); + fclose(f); + free(outbuf); + + avcodec_close(c); + av_free(c); +} + +/* + * Video encoding example + */ +static void video_encode_example(const char *filename, int codec_id) +{ + AVCodec *codec; + AVCodecContext *c= NULL; + int i, out_size, size, x, y, outbuf_size; + FILE *f; + AVFrame *picture; + uint8_t *outbuf; + + printf("Video encoding\n"); + + /* find the mpeg1 video encoder */ + codec = avcodec_find_encoder(codec_id); + if (!codec) { + fprintf(stderr, "codec not found\n"); + exit(1); + } + + c = avcodec_alloc_context3(codec); + picture= avcodec_alloc_frame(); + + /* put sample parameters */ + c->bit_rate = 400000; + /* resolution must be a multiple of two */ + c->width = 352; + c->height = 288; + /* frames per second */ + c->time_base= (AVRational){1,25}; + c->gop_size = 10; /* emit one intra frame every ten frames */ + c->max_b_frames=1; + c->pix_fmt = PIX_FMT_YUV420P; + + if(codec_id == CODEC_ID_H264) + av_opt_set(c->priv_data, "preset", "slow", 0); + + /* open it */ + if (avcodec_open(c, codec) < 0) { + fprintf(stderr, "could not open codec\n"); + exit(1); + } + + f = fopen(filename, "wb"); + if (!f) { + fprintf(stderr, "could not open %s\n", filename); + exit(1); + } + + /* alloc image and output buffer */ + outbuf_size = 100000; + outbuf = malloc(outbuf_size); + + /* the image can be allocated by any means and av_image_alloc() is + * just the most convenient way if av_malloc() is to be used */ + av_image_alloc(picture->data, picture->linesize, + c->width, c->height, c->pix_fmt, 1); + + /* encode 1 second of video */ + for(i=0;i<25;i++) { + fflush(stdout); + /* prepare a dummy image */ + /* Y */ + for(y=0;yheight;y++) { + for(x=0;xwidth;x++) { + picture->data[0][y * picture->linesize[0] + x] = x + y + i * 3; + } + } + + /* Cb and Cr */ + for(y=0;yheight/2;y++) { + for(x=0;xwidth/2;x++) { + picture->data[1][y * picture->linesize[1] + x] = 128 + y + i * 2; + picture->data[2][y * picture->linesize[2] + x] = 64 + x + i * 5; + } + } + + /* encode the image */ + out_size = avcodec_encode_video(c, outbuf, outbuf_size, picture); + printf("encoding frame %3d (size=%5d)\n", i, out_size); + fwrite(outbuf, 1, out_size, f); + } + + /* get the delayed frames */ + for(; out_size; i++) { + fflush(stdout); + + out_size = avcodec_encode_video(c, outbuf, outbuf_size, NULL); + printf("write frame %3d (size=%5d)\n", i, out_size); + fwrite(outbuf, 1, out_size, f); + } + + /* add sequence end code to have a real mpeg file */ + outbuf[0] = 0x00; + outbuf[1] = 0x00; + outbuf[2] = 0x01; + outbuf[3] = 0xb7; + fwrite(outbuf, 1, 4, f); + fclose(f); + free(outbuf); + + avcodec_close(c); + av_free(c); + av_free(picture->data[0]); + av_free(picture); + printf("\n"); +} + +/* + * Video decoding example + */ + +static void pgm_save(unsigned char *buf, int wrap, int xsize, int ysize, + char *filename) +{ + FILE *f; + int i; + + f=fopen(filename,"w"); + fprintf(f,"P5\n%d %d\n%d\n",xsize,ysize,255); + for(i=0;icapabilities&CODEC_CAP_TRUNCATED) + c->flags|= CODEC_FLAG_TRUNCATED; /* we do not send complete frames */ + + /* For some codecs, such as msmpeg4 and mpeg4, width and height + MUST be initialized there because this information is not + available in the bitstream. */ + + /* open it */ + if (avcodec_open(c, codec) < 0) { + fprintf(stderr, "could not open codec\n"); + exit(1); + } + + /* the codec gives us the frame size, in samples */ + + f = fopen(filename, "rb"); + if (!f) { + fprintf(stderr, "could not open %s\n", filename); + exit(1); + } + + frame = 0; + for(;;) { + avpkt.size = fread(inbuf, 1, INBUF_SIZE, f); + if (avpkt.size == 0) + break; + + /* NOTE1: some codecs are stream based (mpegvideo, mpegaudio) + and this is the only method to use them because you cannot + know the compressed data size before analysing it. + + BUT some other codecs (msmpeg4, mpeg4) are inherently frame + based, so you must call them with all the data for one + frame exactly. You must also initialize 'width' and + 'height' before initializing them. */ + + /* NOTE2: some codecs allow the raw parameters (frame size, + sample rate) to be changed at any frame. We handle this, so + you should also take care of it */ + + /* here, we use a stream based decoder (mpeg1video), so we + feed decoder and see if it could decode a frame */ + avpkt.data = inbuf; + while (avpkt.size > 0) { + len = avcodec_decode_video2(c, picture, &got_picture, &avpkt); + if (len < 0) { + fprintf(stderr, "Error while decoding frame %d\n", frame); + exit(1); + } + if (got_picture) { + printf("saving frame %3d\n", frame); + fflush(stdout); + + /* the picture is allocated by the decoder. no need to + free it */ + snprintf(buf, sizeof(buf), outfilename, frame); + pgm_save(picture->data[0], picture->linesize[0], + c->width, c->height, buf); + frame++; + } + avpkt.size -= len; + avpkt.data += len; + } + } + + /* some codecs, such as MPEG, transmit the I and P frame with a + latency of one frame. You must do the following to have a + chance to get the last frame of the video */ + avpkt.data = NULL; + avpkt.size = 0; + len = avcodec_decode_video2(c, picture, &got_picture, &avpkt); + if (got_picture) { + printf("saving last frame %3d\n", frame); + fflush(stdout); + + /* the picture is allocated by the decoder. no need to + free it */ + snprintf(buf, sizeof(buf), outfilename, frame); + pgm_save(picture->data[0], picture->linesize[0], + c->width, c->height, buf); + frame++; + } + + fclose(f); + + avcodec_close(c); + av_free(c); + av_free(picture); + printf("\n"); +} + +int main(int argc, char **argv) +{ + const char *filename; + + /* must be called before using avcodec lib */ + avcodec_init(); + + /* register all the codecs */ + avcodec_register_all(); + + if (argc <= 1) { + audio_encode_example("/tmp/test.mp2"); + audio_decode_example("/tmp/test.sw", "/tmp/test.mp2"); + + video_encode_example("/tmp/test.h264", CODEC_ID_H264); + video_encode_example("/tmp/test.mpg", CODEC_ID_MPEG1VIDEO); + filename = "/tmp/test.mpg"; + } else { + filename = argv[1]; + } + + // audio_decode_example("/tmp/test.sw", filename); + video_decode_example("/tmp/test%d.pgm", filename); + + return 0; +} diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/examples/encoding.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/examples/encoding.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/examples/encoding.c 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/examples/encoding.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,458 +0,0 @@ -/* - * Copyright (c) 2001 Fabrice Bellard - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -/** - * @file - * libavcodec API use example. - * - * Note that libavcodec only handles codecs (mpeg, mpeg4, etc...), - * not file formats (avi, vob, etc...). See library 'libavformat' for the - * format handling - */ - -#include "libavcodec/avcodec.h" -#include "libavutil/mathematics.h" - -#define INBUF_SIZE 4096 -#define AUDIO_INBUF_SIZE 20480 -#define AUDIO_REFILL_THRESH 4096 - -/* - * Audio encoding example - */ -static void audio_encode_example(const char *filename) -{ - AVCodec *codec; - AVCodecContext *c= NULL; - int frame_size, i, j, out_size, outbuf_size; - FILE *f; - short *samples; - float t, tincr; - uint8_t *outbuf; - - printf("Audio encoding\n"); - - /* find the MP2 encoder */ - codec = avcodec_find_encoder(CODEC_ID_MP2); - if (!codec) { - fprintf(stderr, "codec not found\n"); - exit(1); - } - - c = avcodec_alloc_context3(codec); - - /* put sample parameters */ - c->bit_rate = 64000; - c->sample_rate = 44100; - c->channels = 2; - c->sample_fmt = AV_SAMPLE_FMT_S16; - - /* open it */ - if (avcodec_open(c, codec) < 0) { - fprintf(stderr, "could not open codec\n"); - exit(1); - } - - /* the codec gives us the frame size, in samples */ - frame_size = c->frame_size; - samples = malloc(frame_size * 2 * c->channels); - outbuf_size = 10000; - outbuf = malloc(outbuf_size); - - f = fopen(filename, "wb"); - if (!f) { - fprintf(stderr, "could not open %s\n", filename); - exit(1); - } - - /* encode a single tone sound */ - t = 0; - tincr = 2 * M_PI * 440.0 / c->sample_rate; - for(i=0;i<200;i++) { - for(j=0;j 0) { - out_size = AVCODEC_MAX_AUDIO_FRAME_SIZE; - len = avcodec_decode_audio3(c, (short *)outbuf, &out_size, &avpkt); - if (len < 0) { - fprintf(stderr, "Error while decoding\n"); - exit(1); - } - if (out_size > 0) { - /* if a frame has been decoded, output it */ - fwrite(outbuf, 1, out_size, outfile); - } - avpkt.size -= len; - avpkt.data += len; - if (avpkt.size < AUDIO_REFILL_THRESH) { - /* Refill the input buffer, to avoid trying to decode - * incomplete frames. Instead of this, one could also use - * a parser, or use a proper container format through - * libavformat. */ - memmove(inbuf, avpkt.data, avpkt.size); - avpkt.data = inbuf; - len = fread(avpkt.data + avpkt.size, 1, - AUDIO_INBUF_SIZE - avpkt.size, f); - if (len > 0) - avpkt.size += len; - } - } - - fclose(outfile); - fclose(f); - free(outbuf); - - avcodec_close(c); - av_free(c); -} - -/* - * Video encoding example - */ -static void video_encode_example(const char *filename) -{ - AVCodec *codec; - AVCodecContext *c= NULL; - int i, out_size, size, x, y, outbuf_size; - FILE *f; - AVFrame *picture; - uint8_t *outbuf; - - printf("Video encoding\n"); - - /* find the mpeg1 video encoder */ - codec = avcodec_find_encoder(CODEC_ID_MPEG1VIDEO); - if (!codec) { - fprintf(stderr, "codec not found\n"); - exit(1); - } - - c = avcodec_alloc_context3(codec); - picture= avcodec_alloc_frame(); - - /* put sample parameters */ - c->bit_rate = 400000; - /* resolution must be a multiple of two */ - c->width = 352; - c->height = 288; - /* frames per second */ - c->time_base= (AVRational){1,25}; - c->gop_size = 10; /* emit one intra frame every ten frames */ - c->max_b_frames=1; - c->pix_fmt = PIX_FMT_YUV420P; - - /* open it */ - if (avcodec_open(c, codec) < 0) { - fprintf(stderr, "could not open codec\n"); - exit(1); - } - - f = fopen(filename, "wb"); - if (!f) { - fprintf(stderr, "could not open %s\n", filename); - exit(1); - } - - /* alloc image and output buffer */ - outbuf_size = 100000; - outbuf = malloc(outbuf_size); - - /* the image can be allocated by any means and av_image_alloc() is - * just the most convenient way if av_malloc() is to be used */ - av_image_alloc(picture->data, picture->linesize, - c->width, c->height, c->pix_fmt, 1); - - /* encode 1 second of video */ - for(i=0;i<25;i++) { - fflush(stdout); - /* prepare a dummy image */ - /* Y */ - for(y=0;yheight;y++) { - for(x=0;xwidth;x++) { - picture->data[0][y * picture->linesize[0] + x] = x + y + i * 3; - } - } - - /* Cb and Cr */ - for(y=0;yheight/2;y++) { - for(x=0;xwidth/2;x++) { - picture->data[1][y * picture->linesize[1] + x] = 128 + y + i * 2; - picture->data[2][y * picture->linesize[2] + x] = 64 + x + i * 5; - } - } - - /* encode the image */ - out_size = avcodec_encode_video(c, outbuf, outbuf_size, picture); - printf("encoding frame %3d (size=%5d)\n", i, out_size); - fwrite(outbuf, 1, out_size, f); - } - - /* get the delayed frames */ - for(; out_size; i++) { - fflush(stdout); - - out_size = avcodec_encode_video(c, outbuf, outbuf_size, NULL); - printf("write frame %3d (size=%5d)\n", i, out_size); - fwrite(outbuf, 1, out_size, f); - } - - /* add sequence end code to have a real mpeg file */ - outbuf[0] = 0x00; - outbuf[1] = 0x00; - outbuf[2] = 0x01; - outbuf[3] = 0xb7; - fwrite(outbuf, 1, 4, f); - fclose(f); - free(outbuf); - - avcodec_close(c); - av_free(c); - av_free(picture->data[0]); - av_free(picture); - printf("\n"); -} - -/* - * Video decoding example - */ - -static void pgm_save(unsigned char *buf, int wrap, int xsize, int ysize, - char *filename) -{ - FILE *f; - int i; - - f=fopen(filename,"w"); - fprintf(f,"P5\n%d %d\n%d\n",xsize,ysize,255); - for(i=0;icapabilities&CODEC_CAP_TRUNCATED) - c->flags|= CODEC_FLAG_TRUNCATED; /* we do not send complete frames */ - - /* For some codecs, such as msmpeg4 and mpeg4, width and height - MUST be initialized there because this information is not - available in the bitstream. */ - - /* open it */ - if (avcodec_open(c, codec) < 0) { - fprintf(stderr, "could not open codec\n"); - exit(1); - } - - /* the codec gives us the frame size, in samples */ - - f = fopen(filename, "rb"); - if (!f) { - fprintf(stderr, "could not open %s\n", filename); - exit(1); - } - - frame = 0; - for(;;) { - avpkt.size = fread(inbuf, 1, INBUF_SIZE, f); - if (avpkt.size == 0) - break; - - /* NOTE1: some codecs are stream based (mpegvideo, mpegaudio) - and this is the only method to use them because you cannot - know the compressed data size before analysing it. - - BUT some other codecs (msmpeg4, mpeg4) are inherently frame - based, so you must call them with all the data for one - frame exactly. You must also initialize 'width' and - 'height' before initializing them. */ - - /* NOTE2: some codecs allow the raw parameters (frame size, - sample rate) to be changed at any frame. We handle this, so - you should also take care of it */ - - /* here, we use a stream based decoder (mpeg1video), so we - feed decoder and see if it could decode a frame */ - avpkt.data = inbuf; - while (avpkt.size > 0) { - len = avcodec_decode_video2(c, picture, &got_picture, &avpkt); - if (len < 0) { - fprintf(stderr, "Error while decoding frame %d\n", frame); - exit(1); - } - if (got_picture) { - printf("saving frame %3d\n", frame); - fflush(stdout); - - /* the picture is allocated by the decoder. no need to - free it */ - snprintf(buf, sizeof(buf), outfilename, frame); - pgm_save(picture->data[0], picture->linesize[0], - c->width, c->height, buf); - frame++; - } - avpkt.size -= len; - avpkt.data += len; - } - } - - /* some codecs, such as MPEG, transmit the I and P frame with a - latency of one frame. You must do the following to have a - chance to get the last frame of the video */ - avpkt.data = NULL; - avpkt.size = 0; - len = avcodec_decode_video2(c, picture, &got_picture, &avpkt); - if (got_picture) { - printf("saving last frame %3d\n", frame); - fflush(stdout); - - /* the picture is allocated by the decoder. no need to - free it */ - snprintf(buf, sizeof(buf), outfilename, frame); - pgm_save(picture->data[0], picture->linesize[0], - c->width, c->height, buf); - frame++; - } - - fclose(f); - - avcodec_close(c); - av_free(c); - av_free(picture); - printf("\n"); -} - -int main(int argc, char **argv) -{ - const char *filename; - - /* must be called before using avcodec lib */ - avcodec_init(); - - /* register all the codecs */ - avcodec_register_all(); - - if (argc <= 1) { - audio_encode_example("/tmp/test.mp2"); - audio_decode_example("/tmp/test.sw", "/tmp/test.mp2"); - - video_encode_example("/tmp/test.mpg"); - filename = "/tmp/test.mpg"; - } else { - filename = argv[1]; - } - - // audio_decode_example("/tmp/test.sw", filename); - video_decode_example("/tmp/test%d.pgm", filename); - - return 0; -} diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/examples/Makefile ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/examples/Makefile --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/examples/Makefile 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/examples/Makefile 2011-11-04 12:38:26.000000000 +0000 @@ -3,7 +3,7 @@ CFLAGS+=$(shell pkg-config --cflags $(FFMPEG_LIBS)) LDFLAGS+=$(shell pkg-config --libs $(FFMPEG_LIBS)) -EXAMPLES=encoding filtering metadata muxing +EXAMPLES=decoding_encoding filtering metadata muxing OBJS=$(addsuffix .o,$(EXAMPLES)) diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/examples/muxing.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/examples/muxing.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/examples/muxing.c 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/examples/muxing.c 2011-11-04 12:38:26.000000000 +0000 @@ -40,7 +40,7 @@ #undef exit /* 5 seconds stream duration */ -#define STREAM_DURATION 5.0 +#define STREAM_DURATION 200.0 #define STREAM_FRAME_RATE 25 /* 25 images/s */ #define STREAM_NB_FRAMES ((int)(STREAM_DURATION * STREAM_FRAME_RATE)) #define STREAM_PIX_FMT PIX_FMT_YUV420P /* default pix_fmt */ @@ -199,7 +199,7 @@ AVCodecContext *c; AVStream *st; - st = av_new_stream(oc, 0); + st = avformat_new_stream(oc, NULL); if (!st) { fprintf(stderr, "Could not alloc stream\n"); exit(1); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/ffmpeg.texi ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/ffmpeg.texi --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/ffmpeg.texi 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/ffmpeg.texi 2011-11-04 12:38:26.000000000 +0000 @@ -864,7 +864,7 @@ ffmpeg -i file.mov -an -vn -sbsf mov2textsub -c:s copy -f rawvideo sub.txt @end example -@item -tag[:@var{stream_specifier}] @var{codec_tag} (@emph{output,per-stream}) +@item -tag[:@var{stream_specifier}] @var{codec_tag} (@emph{per-stream}) Force a tag/fourcc for matching streams. @end table @@ -873,7 +873,7 @@ one for each line, specifying a sequence of options which would be awkward to specify on the command line. Lines starting with the hash ('#') character are ignored and are used to provide comments. Check -the @file{ffpresets} directory in the FFmpeg source tree for examples. +the @file{presets} directory in the FFmpeg source tree for examples. Preset files are specified with the @code{vpre}, @code{apre}, @code{spre}, and @code{fpre} options. The @code{fpre} option takes the @@ -955,6 +955,11 @@ ffmpeg -f oss -i /dev/dsp -f video4linux2 -i /dev/video0 /tmp/out.mpg @end example +Or with an ALSA audio source (mono input, card id 1) instead of OSS: +@example +ffmpeg -f alsa -ac 1 -i hw:1 -f video4linux2 -i /dev/video0 /tmp/out.mpg +@end example + Note that you must activate the right video source and channel before launching ffmpeg with any TV viewer such as @uref{http://linux.bytesex.org/xawtv/, xawtv} by Gerd Knorr. You also diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/ffmpeg.txt ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/ffmpeg.txt --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/ffmpeg.txt 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/ffmpeg.txt 2011-11-04 12:38:26.000000000 +0000 @@ -0,0 +1,47 @@ + : + ffmpeg.c : libav* + ======== : ====== + : + : + --------------------------------:---> AVStream... + InputStream input_streams[] / : + / : + InputFile input_files[] +==========================+ / ^ : + ------> 0 | : st ---:-----------:--/ : : + ^ +------+-----------+-----+ / +--------------------------+ : : + : | :ist_index--:-----:---------/ 1 | : st : | : : + : +------+-----------+-----+ +==========================+ : : + nb_input_files : | :ist_index--:-----:------------------> 2 | : st : | : : + : +------+-----------+-----+ +--------------------------+ : nb_input_streams : + : | :ist_index : | 3 | ... | : : + v +------+-----------+-----+ +--------------------------+ : : + --> 4 | | : : + | +--------------------------+ : : + | 5 | | : : + | +==========================+ v : + | : + | : + | : + | : + --------- --------------------------------:---> AVStream... + \ / : + OutputStream output_streams[] / : + \ / : + +======\======================/======+ ^ : + ------> 0 | : source_index : st-:--- | : : + OuputFile output_files[] / +------------------------------------+ : : + / 1 | : : : | : : + ^ +------+------------+-----+ / +------------------------------------+ : : + : | : ost_index -:-----:------/ 2 | : : : | : : + nb_output_files : +------+------------+-----+ +====================================+ : : + : | : ost_index -:-----|-----------------> 3 | : : : | : : + : +------+------------+-----+ +------------------------------------+ : nb_output_streams : + : | : : | 4 | | : : + : +------+------------+-----+ +------------------------------------+ : : + : | : : | 5 | | : : + v +------+------------+-----+ +------------------------------------+ : : + 6 | | : : + +------------------------------------+ : : + 7 | | : : + +====================================+ v : + : diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/ffprobe.texi ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/ffprobe.texi --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/ffprobe.texi 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/ffprobe.texi 2011-11-04 12:38:26.000000000 +0000 @@ -42,18 +42,11 @@ ffprobe will show it. ffprobe output is designed to be easily parsable by a textual filter, -and consists of one or more sections of the form: -@example -[SECTION] -key1=val1 -... -keyN=valN -[/SECTION] -@end example +and consists of one or more sections of a form defined by the selected +writer, which is specified by the @option{print_format} option. Metadata tags stored in the container or in the streams are recognized -and printed in the corresponding "FORMAT" or "STREAM" section, and -are prefixed by the string "TAG:". +and printed in the corresponding "FORMAT" or "STREAM" section. @c man end @@ -87,9 +80,19 @@ Prettify the format of the displayed values, it corresponds to the options "-unit -prefix -byte_binary_prefix -sexagesimal". -@item -print_format @var{format} +@item -print_format @var{writer_name}[=@var{writer_options}] Set the output printing format. -Current available formats are "default" and "json". + +@var{writer_name} specifies the name of the writer, and +@var{writer_options} specifies the options to be passed to the writer. + +For example for printing the output in JSON format, specify: +@example +-print_format json +@end example + +For more details on the available output printing formats, see the +Writers section below. @item -show_format Show information about the container format of the input multimedia @@ -118,6 +121,41 @@ @end table @c man end +@chapter Writers +@c man begin WRITERS + +A writer defines the output format adopted by @file{ffprobe}, and will be +used for printing all the parts of the output. + +A writer may accept one or more arguments, which specify the options to +adopt. + +A description of the currently available writers follows. + +@section default +Default format. + +Print each section in the form: +@example +[SECTION] +key1=val1 +... +keyN=valN +[/SECTION] +@end example + +Metadata tags are printed as a line in the corresponding FORMAT or +STREAM section, and are prefixed by the string "TAG:". + +@section json +JSON based format. + +Each section is printed using JSON notation. + +For more information about JSON, see @url{http://www.json.org/}. + +@c man end WRITERS + @include decoders.texi @include demuxers.texi @include protocols.texi diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/filters.texi ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/filters.texi --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/filters.texi 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/filters.texi 2011-11-04 12:38:26.000000000 +0000 @@ -216,11 +216,12 @@ if the packing format is planar, 0 if packed @item checksum -Adler-32 checksum of all the planes of the input frame +Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame @item plane_checksum -Adler-32 checksum for each input frame plane, expressed in the form -"[@var{c0} @var{c1} @var{c2} @var{c3} @var{c4} @var{c5} @var{c6} @var{c7}]" +Adler-32 checksum (printed in hexadecimal) for each input frame plane, +expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3} @var{c4} @var{c5} +@var{c6} @var{c7}]" @end table @c man end AUDIO FILTERS @@ -275,6 +276,86 @@ abuffer=44100:1:3:1 @end example +@section aevalsrc + +Generate an audio signal specified by an expression. + +This source accepts in input one or more expressions (one for each +channel), which are evaluated and used to generate a corresponding +audio signal. + +It accepts the syntax: @var{exprs}[::@var{options}]. +@var{exprs} is a list of expressions separated by ":", one for each +separate channel. The output channel layout depends on the number of +provided expressions, up to 8 channels are supported. + +@var{options} is an optional sequence of @var{key}=@var{value} pairs, +separated by ":". + +The description of the accepted options follows. + +@table @option + +@item nb_samples, n +Set the number of samples per channel per each output frame, +default to 1024. + +@item sample_rate, s +Specify the sample rate, default to 44100. +@end table + +Each expression in @var{exprs} can contain the following constants: + +@table @option +@item n +number of the evaluated sample, starting from 0 + +@item t +time of the evaluated sample expressed in seconds, starting from 0 + +@item s +sample rate + +@end table + +@subsection Examples + +@itemize + +@item +Generate silence: +@example +aevalsrc=0 +@end example + +@item + +Generate a sin signal with frequence of 440 Hz, set sample rate to +8000 Hz: +@example +aevalsrc="sin(440*2*PI*t)::s=8000" +@end example + +@item +Generate white noise: +@example +aevalsrc="-2+random(0)" +@end example + +@item +Generate an amplitude modulated signal: +@example +aevalsrc="sin(10*2*PI*t)*sin(880*2*PI*t)" +@end example + +@item +Generate 2.5 Hz binaural beats on a 360 Hz carrier: +@example +aevalsrc="0.1*sin(2*PI*(360-2.5/2)*t) : 0.1*sin(2*PI*(360+2.5/2)*t)" +@end example + +@end itemize + @section amovie Read an audio stream from a movie container. @@ -432,7 +513,7 @@ pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1. @end table -The radius must be a non-negative number, and must be not greater than +The radius must be a non-negative number, and must not be greater than the value of the expression @code{min(w,h)/2} for the luma and alpha planes, and of @code{min(cw,ch)/2} for the chroma planes. @@ -477,10 +558,6 @@ The parameters are expressions containing the following constants: @table @option -@item E, PI, PHI -the corresponding mathematical approximated values for e -(euler number), pi (greek PI), PHI (golden ratio) - @item x, y the computed values for @var{x} and @var{y}. They are evaluated for each new frame. @@ -668,6 +745,76 @@ @end itemize +@section deshake + +Attempt to fix small changes in horizontal and/or vertical shift. This +filter helps remove camera shake from hand-holding a camera, bumping a +tripod, moving on a vehicle, etc. + +The filter accepts parameters as a string of the form +"@var{x}:@var{y}:@var{w}:@var{h}:@var{rx}:@var{ry}:@var{edge}:@var{blocksize}:@var{contrast}:@var{search}:@var{filename}" + +A description of the accepted parameters follows. + +@table @option + +@item x, y, w, h +Specify a rectangular area where to limit the sarch for motion +vectors. +If desired the search for motion vectors can be limited to a +rectangular area of the frame defined by its top left corner, width +and height. These parameters have the same meaning as the drawbox +filter which can be used to visualise the position of the bounding +box. + +This is useful when simultaneous movement of subjects within the frame +might be confused for camera motion by the motion vector search. + +If any or all of @var{x}, @var{y}, @var{w} and @var{h} are set to -1 +then the full frame is used. This allows later options to be set +without specifying the bounding box for the motion vector search. + +Default - search the whole frame. + +@item rx, ry +Specify the maximum extent of movement in x and y directions in the +range 0-64 pixels. Default 16. + +@item edge +Specify how to generate pixels to fill blanks at the edge of the +frame. An integer from 0 to 3 as follows: +@table @option +@item 0 +Fill zeroes at blank locations +@item 1 +Original image at blank locations +@item 2 +Extruded edge value at blank locations +@item 3 +Mirrored edge at blank locations +@end table + +The default setting is mirror edge at blank locations. + +@item blocksize +Specify the blocksize to use for motion search. Range 4-128 pixels, +default 8. + +@item contrast +Specify the contrast threshold for blocks. Only blocks with more than +the specified contrast (difference between darkest and lightest +pixels) will be considered. Range 1-255, default 125. + +@item search +Specify the search strategy 0 = exhaustive search, 1 = less exhaustive +search. Default - exhaustive search. + +@item filename +If set then a detailed log of the motion search is written to the +specified file. + +@end table + @section drawbox Draw a colored box on the input image. @@ -816,10 +963,6 @@ following constants: @table @option -@item E, PI, PHI -the corresponding mathematical approximated values for e -(euler number), pi (greek PI), PHI (golden ratio) - @item w, h the input width and heigth @@ -1159,10 +1302,14 @@ The @var{lut} filter requires either YUV or RGB pixel formats in input, and accepts the options: @table @option -@var{c0} (first pixel component) -@var{c1} (second pixel component) -@var{c2} (third pixel component) -@var{c3} (fourth pixel component, corresponds to the alpha component) +@item c0 +first pixel component +@item c1 +second pixel component +@item c2 +third pixel component +@item c3 +fourth pixel component, corresponds to the alpha component @end table The exact component associated to each option depends on the format in @@ -1171,28 +1318,32 @@ The @var{lutrgb} filter requires RGB pixel formats in input, and accepts the options: @table @option -@var{r} (red component) -@var{g} (green component) -@var{b} (blue component) -@var{a} (alpha component) +@item r +red component +@item g +green component +@item b +blue component +@item a +alpha component @end table The @var{lutyuv} filter requires YUV pixel formats in input, and accepts the options: @table @option -@var{y} (Y/luminance component) -@var{u} (U/Cb component) -@var{v} (V/Cr component) -@var{a} (alpha component) +@item y +Y/luminance component +@item u +U/Cb component +@item v +V/Cr component +@item a +alpha component @end table The expressions can contain the following constants and functions: @table @option -@item E, PI, PHI -the corresponding mathematical approximated values for e -(euler number), pi (greek PI), PHI (golden ratio) - @item w, h the input width and heigth @@ -1480,10 +1631,10 @@ It takes two inputs and one output, the first input is the "main" video on which the second input is overlayed. -It accepts the parameters: @var{x}:@var{y}. +It accepts the parameters: @var{x}:@var{y}[:@var{options}]. @var{x} is the x coordinate of the overlayed video on the main video, -@var{y} is the y coordinate. The parameters are expressions containing +@var{y} is the y coordinate. @var{x} and @var{y} are expressions containing the following parameters: @table @option @@ -1500,6 +1651,17 @@ same as @var{overlay_w} and @var{overlay_h} @end table +@var{options} is an optional list of @var{key}=@var{value} pairs, +separated by ":". + +The description of the accepted options follows. + +@table @option +@item rgb +If set to 1, force the filter to accept inputs in the RGB +colorspace. Default value is 0. +@end table + Be aware that frames are taken from each input video in timestamp order, hence, if their initial timestamps differ, it is a a good idea to pass the two inputs through a @var{setpts=PTS-STARTPTS} filter to @@ -1543,10 +1705,6 @@ expressions containing the following constants: @table @option -@item E, PI, PHI -the corresponding mathematical approximated values for e -(euler number), pi (greek PI), phi (golden ratio) - @item in_w, in_h the input video width and height @@ -1656,16 +1814,12 @@ @section scale -Scale the input video to @var{width}:@var{height} and/or convert the image format. +Scale the input video to @var{width}:@var{height}[:@var{interl}=@{1|-1@}] and/or convert the image format. The parameters @var{width} and @var{height} are expressions containing the following constants: @table @option -@item E, PI, PHI -the corresponding mathematical approximated values for e -(euler number), pi (greek PI), phi (golden ratio) - @item in_w, in_h the input width and height @@ -1708,6 +1862,17 @@ The default value of @var{width} and @var{height} is 0. +Valid values for the optional parameter @var{interl} are: + +@table @option +@item 1 +force interlaced aware scaling + +@item -1 +select interlaced aware scaling depending on whether the source frames +are flagged as interlaced or not +@end table + Some examples follow: @example # scale the input video to a size of 200x100. @@ -1748,15 +1913,6 @@ The expression can contain the following constants: @table @option -@item PI -Greek PI - -@item PHI -golden ratio - -@item E -Euler number - @item n the sequential number of the filtered frame, starting from 0 @@ -1895,15 +2051,6 @@ @item PTS the presentation timestamp in input -@item PI -Greek PI - -@item PHI -golden ratio - -@item E -Euler number - @item N the count of the input frame, starting from 0. @@ -1976,7 +2123,7 @@ It is mainly useful for testing timebase configuration. It accepts in input an arithmetic expression representing a rational. -The expression can contain the constants "PI", "E", "PHI", "AVTB" (the +The expression can contain the constants "AVTB" (the default timebase), and "intb" (the input timebase). The default value for the input is "intb". @@ -2052,11 +2199,11 @@ @file{libavutil/avutil.h}. @item checksum -Adler-32 checksum of all the planes of the input frame +Adler-32 checksum (printed in hexadecimal) of all the planes of the input frame @item plane_checksum -Adler-32 checksum of each plane of the input frame, expressed in the form -"[@var{c0} @var{c1} @var{c2} @var{c3}]" +Adler-32 checksum (printed in hexadecimal) of each plane of the input frame, +expressed in the form "[@var{c0} @var{c1} @var{c2} @var{c3}]" @end table @section slicify @@ -2451,22 +2598,6 @@ will generate a "dc_luma" test pattern. -@section nullsrc - -Null video source, never return images. It is mainly useful as a -template and to be employed in analysis / debugging tools. - -It accepts as optional parameter a string of the form -@var{width}:@var{height}:@var{timebase}. - -@var{width} and @var{height} specify the size of the configured -source. The default values of @var{width} and @var{height} are -respectively 352 and 288 (corresponding to the CIF size format). - -@var{timebase} specifies an arithmetic expression representing a -timebase. The expression can contain the constants "PI", "E", "PHI", -"AVTB" (the default timebase), and defaults to the value "AVTB". - @section frei0r_src Provide a frei0r source. @@ -2494,7 +2625,11 @@ frei0r_src=200x200:10:partik0l=1234 [overlay]; [in][overlay] overlay @end example -@section rgbtestsrc, testsrc +@section nullsrc, rgbtestsrc, testsrc + +The @code{nullsrc} source returns unprocessed video frames. It is +mainly useful to be employed in analysis / debugging tools, or as the +source for filters which ignore the input data. The @code{rgbtestsrc} source generates an RGB test pattern useful for detecting RGB vs BGR issues. You should see a red, green and blue @@ -2504,7 +2639,7 @@ color pattern, a scrolling gradient and a timestamp. This is mainly intended for testing purposes. -Both sources accept an optional sequence of @var{key}=@var{value} pairs, +These sources accept an optional sequence of @var{key}=@var{value} pairs, separated by ":". The description of the accepted options follows. @table @option @@ -2544,6 +2679,13 @@ will generate a video with a duration of 5.3 seconds, with size 176x144 and a framerate of 10 frames per second. +If the input content is to be ignored, @code{nullsrc} can be used. The +following command generates noise in the luminance plane by employing +the @code{mp=geq} filter: +@example +nullsrc=s=256x256, mp=geq=random(1)*255:128:128 +@end example + @c man end VIDEO SOURCES @chapter Video Sinks diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/general.texi ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/general.texi --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/general.texi 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/general.texi 2011-11-04 12:38:26.000000000 +0000 @@ -106,8 +106,9 @@ @item framecrc testing format @tab X @tab @item FunCom ISS @tab @tab X @tab Audio format used in various games from FunCom like The Longest Journey. -@item G.723.1 @tab @tab X +@item G.723.1 @tab X @tab X @item G.729 BIT @tab X @tab X +@item G.729 raw @tab @tab X @item GIF Animation @tab X @tab @item GXF @tab X @tab X @tab General eXchange Format SMPTE 360M, used by Thomson Grass Valley @@ -350,7 +351,7 @@ @tab Used in Chinese MP3 players. @item ANSI/ASCII art @tab @tab X @item Apple MJPEG-B @tab @tab X -@item Apple ProRes @tab @tab X +@item Apple ProRes @tab X @tab X @item Apple QuickDraw @tab @tab X @tab fourcc: qdrw @item Asus v1 @tab X @tab X @@ -391,7 +392,7 @@ @item Creative YUV (CYUV) @tab @tab X @item DFA @tab @tab X @tab Codec used in Chronomaster game. -@item Dirac @tab E @tab E +@item Dirac @tab E @tab X @tab supported through external libdirac/libschroedinger libraries @item Deluxe Paint Animation @tab @tab X @item DNxHD @tab X @tab X @@ -467,7 +468,7 @@ @item MPEG-1/2 video (VDPAU acceleration) @tab @tab X @item MPEG-2 video @tab X @tab X @item MPEG-4 part 2 @tab X @tab X - @ libxvidcore can be used alternatively for encoding. + @tab libxvidcore can be used alternatively for encoding. @item MPEG-4 part 2 Microsoft variant version 1 @tab @tab X @item MPEG-4 part 2 Microsoft variant version 2 @tab X @tab X @item MPEG-4 part 2 Microsoft variant version 3 @tab X @tab X @@ -527,6 +528,7 @@ @tab encoding supported through external library libtheora @item Tiertex Limited SEQ video @tab @tab X @tab Codec used in DOS CD-ROM FlashBack game. +@item Ut Video @tab @tab X @item V210 Quicktime Uncompressed 4:2:2 10-bit @tab X @tab X @item VMware Screen Codec / VMware Video @tab @tab X @tab Codec used in videos captured by VMware. @@ -618,7 +620,7 @@ @item Atrac 3 @tab @tab X @item Bink Audio @tab @tab X @tab Used in Bink and Smacker files in many games. -@item CELT (Opus) @tab @tab E +@item CELT @tab @tab E @tab decoding supported through external library libcelt @item Delphine Software International CIN audio @tab @tab X @tab Codec used in Delphine Software International games. @@ -638,6 +640,7 @@ @item DV audio @tab @tab X @item Enhanced AC-3 @tab X @tab X @item FLAC (Free Lossless Audio Codec) @tab X @tab IX +@item G.723.1 @tab X @tab X @item G.729 @tab @tab X @item GSM @tab E @tab X @tab encoding supported through external library libgsm @@ -681,7 +684,7 @@ @item PCM unsigned 24-bit little-endian @tab X @tab X @item PCM unsigned 32-bit big-endian @tab X @tab X @item PCM unsigned 32-bit little-endian @tab X @tab X -@item PCM Zork @tab X @tab X +@item PCM Zork @tab @tab X @item QCELP / PureVoice @tab @tab X @item QDesign Music Codec 2 @tab @tab X @tab There are still some distortions. diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/indevs.texi ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/indevs.texi --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/indevs.texi 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/indevs.texi 2011-11-04 12:38:26.000000000 +0000 @@ -226,9 +226,6 @@ only video data is supported. The filtergraph is specified through the option @option{graph}. -To enable this input device, you need to configure your build with -@code{--enable-libavfilter}. - @subsection Options @table @option @@ -393,6 +390,89 @@ For more information about OSS see: @url{http://manuals.opensound.com/usersguide/dsp.html} +@section pulse + +pulseaudio input device. + +To enable this input device during configuration you need libpulse-simple +installed in your system. + +The filename to provide to the input device is a source device or the +string "default" + +To list the pulse source devices and their properties you can invoke +the command @file{pactl list sources}. + +@example +avconv -f pulse -i default /tmp/pulse.wav +@end example + +@subsection @var{server} AVOption + +The syntax is: +@example +-server @var{server name} +@end example + +Connects to a specific server. + +@subsection @var{name} AVOption + +The syntax is: +@example +-name @var{application name} +@end example + +Specify the application name pulse will use when showing active clients, +by default it is "libav" + +@subsection @var{stream_name} AVOption + +The syntax is: +@example +-stream_name @var{stream name} +@end example + +Specify the stream name pulse will use when showing active streams, +by default it is "record" + +@subsection @var{sample_rate} AVOption + +The syntax is: +@example +-sample_rate @var{samplerate} +@end example + +Specify the samplerate in Hz, by default 48kHz is used. + +@subsection @var{channels} AVOption + +The syntax is: +@example +-channels @var{N} +@end example + +Specify the channels in use, by default 2 (stereo) is set. + +@subsection @var{frame_size} AVOption + +The syntax is: +@example +-frame_size @var{bytes} +@end example + +Specify the number of byte per frame, by default it is set to 1024. + +@subsection @var{fragment_size} AVOption + +The syntax is: +@example +-fragment_size @var{bytes} +@end example + +Specify the minimal buffering fragment in pulseaudio, it will affect the +audio latency. By default it is unset. + @section sndio sndio input device. diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/muxers.texi ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/muxers.texi --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/muxers.texi 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/muxers.texi 2011-11-04 12:38:26.000000000 +0000 @@ -147,6 +147,18 @@ specify the name of the '.Y' file. The muxer will automatically open the '.U' and '.V' files as required. +@section mov + +MOV / MP4 muxer + +The muxer options are: + +@table @option +@item -moov_size @var{bytes} +Reserves space for the moov atom at the beginning of the file instead of placing the +moov atom at the end. If the space reserved is insufficient, muxing will fail. +@end table + @section mpegts MPEG transport stream muxer. diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/protocols.texi ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/protocols.texi --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/doc/protocols.texi 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/doc/protocols.texi 2011-11-04 12:38:26.000000000 +0000 @@ -246,12 +246,15 @@ The required syntax for a RTSP url is: @example -rtsp://@var{hostname}[:@var{port}]/@var{path}[?@var{options}] +rtsp://@var{hostname}[:@var{port}]/@var{path} @end example -@var{options} is a @code{&}-separated list. The following options +The following options (set on the @file{ffmpeg}/@file{ffplay} command +line, or set in code via @code{AVOption}s or in @code{avformat_open_input}), are supported: +Flags for @code{rtsp_transport}: + @table @option @item udp @@ -261,21 +264,25 @@ Use TCP (interleaving within the RTSP control channel) as lower transport protocol. -@item multicast +@item udp_multicast Use UDP multicast as lower transport protocol. @item http Use HTTP tunneling as lower transport protocol, which is useful for passing proxies. - -@item filter_src -Accept packets only from negotiated peer address and port. @end table Multiple lower transport protocols may be specified, in that case they are tried one at a time (if the setup of one fails, the next one is tried). For the muxer, only the @code{tcp} and @code{udp} options are supported. +Flags for @code{rtsp_flags}: + +@table @option +@item filter_src +Accept packets only from negotiated peer address and port. +@end table + When receiving data over UDP, the demuxer tries to reorder received packets (since they may arrive out of order, or packets may get lost totally). In order for this to be enabled, a maximum delay must be specified in the @@ -291,13 +298,13 @@ To watch a stream over UDP, with a max reordering delay of 0.5 seconds: @example -ffplay -max_delay 500000 rtsp://server/video.mp4?udp +ffplay -max_delay 500000 -rtsp_transport udp rtsp://server/video.mp4 @end example To watch a stream tunneled over HTTP: @example -ffplay rtsp://server/video.mp4?http +ffplay -rtsp_transport http rtsp://server/video.mp4 @end example To send a stream in realtime to a RTSP server, for others to watch: diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/ffmpeg.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/ffmpeg.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/ffmpeg.c 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/ffmpeg.c 2011-11-04 12:38:26.000000000 +0000 @@ -146,7 +146,7 @@ static int exit_on_error = 0; static int using_stdin = 0; static int run_as_daemon = 0; -static int q_pressed = 0; +static volatile int received_nb_signals = 0; static int64_t video_size = 0; static int64_t audio_size = 0; static int64_t extra_size = 0; @@ -156,6 +156,8 @@ static float dts_delta_threshold = 10; +static int print_stats = 1; + static uint8_t *audio_buf; static uint8_t *audio_out; static unsigned int allocated_audio_out_size, allocated_audio_buf_size; @@ -185,10 +187,10 @@ typedef struct InputFile { AVFormatContext *ctx; int eof_reached; /* true if eof reached */ - int ist_index; /* index of first stream in ist_table */ + int ist_index; /* index of first stream in input_streams */ int buffer_size; /* current total buffer size */ int64_t ts_offset; - int nb_streams; /* number of stream that avconv is aware of; may be different + int nb_streams; /* number of stream that ffmpeg is aware of; may be different from ctx.nb_streams if new streams appear during av_read_frame() */ int rate_emu; } InputFile; @@ -232,6 +234,7 @@ int resample_sample_fmt; int resample_channels; int resample_sample_rate; + float rematrix_volume; AVFifoBuffer *fifo; /* for compression: one audio fifo per codec */ FILE *logfile; @@ -245,9 +248,11 @@ AVFilterGraph *graph; #endif - int sws_flags; + int64_t sws_flags; AVDictionary *opts; int is_past_recording_time; + int stream_copy; + const char *attachment_filename; } OutputStream; @@ -287,6 +292,8 @@ int nb_audio_channels; SpecifierOpt *audio_sample_rate; int nb_audio_sample_rate; + SpecifierOpt *rematrix_volume; + int nb_rematrix_volume; SpecifierOpt *frame_rates; int nb_frame_rates; SpecifierOpt *frame_sizes; @@ -300,6 +307,8 @@ SpecifierOpt *ts_scale; int nb_ts_scale; + SpecifierOpt *dump_attachment; + int nb_dump_attachment; /* output options */ StreamMap *stream_maps; @@ -310,6 +319,8 @@ int metadata_global_manual; int metadata_streams_manual; int metadata_chapters_manual; + const char **attachments; + int nb_attachments; int chapters_input_file; @@ -353,6 +364,8 @@ int nb_inter_matrices; SpecifierOpt *top_field_first; int nb_top_field_first; + SpecifierOpt *presets; + int nb_presets; #if CONFIG_AVFILTER SpecifierOpt *filters; int nb_filters; @@ -403,7 +416,6 @@ if(is_input) o->recording_time = bak.recording_time; else o->recording_time = INT64_MAX; - o->mux_preload = 0.5; o->mux_max_delay = 0.7; o->limit_filesize = UINT64_MAX; o->chapters_input_file = INT_MAX; @@ -458,7 +470,7 @@ snprintf(args, 255, "%d:%d:flags=0x%X", codec->width, codec->height, - ost->sws_flags); + (unsigned)ost->sws_flags); if ((ret = avfilter_graph_create_filter(&filter, avfilter_get_by_name("scale"), NULL, args, NULL, ost->graph)) < 0) return ret; @@ -467,7 +479,7 @@ last_filter = filter; } - snprintf(args, sizeof(args), "flags=0x%X", ost->sws_flags); + snprintf(args, sizeof(args), "flags=0x%X", (unsigned)ost->sws_flags); ost->graph->scale_sws_opts = av_strdup(args); if (ost->avfilter) { @@ -520,7 +532,7 @@ static void sigterm_handler(int sig) { received_sigterm = sig; - q_pressed++; + received_nb_signals++; term_exit(); } @@ -564,9 +576,6 @@ struct timeval tv; fd_set rfds; - if(run_as_daemon) - return -1; - FD_ZERO(&rfds); FD_SET(0, &rfds); tv.tv_sec = 0; @@ -614,8 +623,7 @@ static int decode_interrupt_cb(void) { - q_pressed += read_key() == 'q'; - return q_pressed > 1; + return received_nb_signals > 1; } void exit_program(int ret) @@ -872,6 +880,7 @@ enc->channel_layout, enc->sample_fmt, enc->sample_rate, dec->channel_layout, dec->sample_fmt, dec->sample_rate, 0, NULL); + av_set_double(ost->swr, "rmvol", ost->rematrix_volume); av_set_int(ost->swr, "ich", dec->channels); av_set_int(ost->swr, "och", enc->channels); if(audio_sync_method>1) av_set_int(ost->swr, "flags", SWR_FLAG_RESAMPLE); @@ -1370,7 +1379,7 @@ static void print_report(OutputFile *output_files, OutputStream *ost_table, int nb_ostreams, - int is_last_report, int64_t timer_start) + int is_last_report, int64_t timer_start, int64_t cur_time) { char buf[1024]; OutputStream *ost; @@ -1384,10 +1393,10 @@ static int qp_histogram[52]; int hours, mins, secs, us; + if (!print_stats && !is_last_report) + return; + if (!is_last_report) { - int64_t cur_time; - /* display the report every 0.5 seconds */ - cur_time = av_gettime(); if (last_time == -1) { last_time = cur_time; return; @@ -1410,13 +1419,13 @@ float q = -1; ost = &ost_table[i]; enc = ost->st->codec; - if (!ost->st->stream_copy && enc->coded_frame) + if (!ost->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 = (av_gettime()-timer_start) / 1000000.0; + 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 ", @@ -1480,7 +1489,7 @@ 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); + av_log(NULL, AV_LOG_INFO, "%s \r", buf); fflush(stderr); @@ -1605,7 +1614,7 @@ #if CONFIG_AVFILTER int frame_available; #endif - float quality; + float quality = 0; AVPacket avpkt; int bps = av_get_bytes_per_sample(ist->st->codec->sample_fmt); @@ -1678,7 +1687,6 @@ (ist->st->codec->sample_rate * ist->st->codec->channels); break;} case AVMEDIA_TYPE_VIDEO: - decoded_data_size = (ist->st->codec->width * ist->st->codec->height * 3) / 2; if (!(decoded_frame = avcodec_alloc_frame())) return AVERROR(ENOMEM); avpkt.pts = pkt_pts; @@ -2056,6 +2064,9 @@ os = output_files[ost->file_index].ctx; ist = &input_streams[ost->source_index]; + if (ost->attachment_filename) + continue; + codec = ost->st->codec; icodec = ist->st->codec; @@ -2063,7 +2074,7 @@ codec->bits_per_raw_sample= icodec->bits_per_raw_sample; codec->chroma_sample_location = icodec->chroma_sample_location; - if (ost->st->stream_copy) { + if (ost->stream_copy) { uint64_t extra_size = (uint64_t)icodec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE; if (extra_size > INT_MAX) { @@ -2150,15 +2161,16 @@ } else { if (!ost->enc) ost->enc = avcodec_find_encoder(ost->st->codec->codec_id); + ist->decoding_needed = 1; + ost->encoding_needed = 1; switch(codec->codec_type) { case AVMEDIA_TYPE_AUDIO: ost->fifo= av_fifo_alloc(1024); if (!ost->fifo) { return AVERROR(ENOMEM); } - if (!codec->sample_rate) { + if (!codec->sample_rate) codec->sample_rate = icodec->sample_rate; - } choose_sample_rate(ost->st, ost->enc); codec->time_base = (AVRational){1, codec->sample_rate}; if (codec->sample_fmt == AV_SAMPLE_FMT_NONE) @@ -2174,8 +2186,6 @@ ost->audio_resample |= codec->sample_fmt != icodec->sample_fmt || codec->channel_layout != icodec->channel_layout; icodec->request_channels = codec->channels; - ist->decoding_needed = 1; - ost->encoding_needed = 1; ost->resample_sample_fmt = icodec->sample_fmt; ost->resample_sample_rate = icodec->sample_rate; ost->resample_channels = icodec->channels; @@ -2205,8 +2215,6 @@ ost->resample_height = icodec->height; ost->resample_width = icodec->width; ost->resample_pix_fmt= icodec->pix_fmt; - ost->encoding_needed = 1; - ist->decoding_needed = 1; if (!ost->frame_rate.num) ost->frame_rate = ist->st->r_frame_rate.num ? ist->st->r_frame_rate : (AVRational){25,1}; @@ -2233,15 +2241,13 @@ #endif break; case AVMEDIA_TYPE_SUBTITLE: - ost->encoding_needed = 1; - ist->decoding_needed = 1; break; default: abort(); break; } /* two pass mode */ - if (ost->encoding_needed && codec->codec_id != CODEC_ID_H264 && + if (codec->codec_id != CODEC_ID_H264 && (codec->flags & (CODEC_FLAG_PASS1 | CODEC_FLAG_PASS2))) { char logfilename[1024]; FILE *f; @@ -2249,6 +2255,16 @@ snprintf(logfilename, sizeof(logfilename), "%s-%d.log", pass_logfilename_prefix ? pass_logfilename_prefix : DEFAULT_PASS_LOGFILENAME_PREFIX, i); + if (codec->flags & CODEC_FLAG_PASS2) { + char *logbuffer; + size_t logbuffer_size; + if (cmdutils_read_file(logfilename, &logbuffer, &logbuffer_size) < 0) { + av_log(NULL, AV_LOG_FATAL, "Error reading log file '%s' for pass-2 encoding\n", + logfilename); + exit_program(1); + } + codec->stats_in = logbuffer; + } if (codec->flags & CODEC_FLAG_PASS1) { f = fopen(logfilename, "wb"); if (!f) { @@ -2257,15 +2273,6 @@ exit_program(1); } ost->logfile = f; - } else { - char *logbuffer; - size_t logbuffer_size; - if (read_file(logfilename, &logbuffer, &logbuffer_size) < 0) { - av_log(NULL, AV_LOG_FATAL, "Error reading log file '%s' for pass-2 encoding\n", - logfilename); - exit_program(1); - } - codec->stats_in = logbuffer; } } } @@ -2315,7 +2322,7 @@ assert_avoptions(ost->opts); if (ost->st->codec->bit_rate && ost->st->codec->bit_rate < 1000) av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low." - "It takes bits/s as argument, not kbits/s\n"); + " It takes bits/s as argument, not kbits/s\n"); extra_size += ost->st->codec->extradata_size; if (ost->st->codec->me_threshold) @@ -2369,6 +2376,13 @@ av_log(NULL, AV_LOG_INFO, "Stream mapping:\n"); for (i = 0; i < nb_output_streams; i++) { ost = &output_streams[i]; + + if (ost->attachment_filename) { + /* an attached file */ + av_log(NULL, AV_LOG_INFO, " File %s -> Stream #%d:%d\n", + ost->attachment_filename, ost->file_index, ost->index); + continue; + } av_log(NULL, AV_LOG_INFO, " Stream #%d.%d -> #%d.%d", input_streams[ost->source_index].file_index, input_streams[ost->source_index].st->index, @@ -2378,7 +2392,7 @@ av_log(NULL, AV_LOG_INFO, " [sync #%d.%d]", ost->sync_ist->file_index, ost->sync_ist->st->index); - if (ost->st->stream_copy) + if (ost->stream_copy) av_log(NULL, AV_LOG_INFO, " (copy)"); else av_log(NULL, AV_LOG_INFO, " (%s -> %s)", input_streams[ost->source_index].dec ? @@ -2425,7 +2439,6 @@ av_log(NULL, AV_LOG_INFO, "Press [q] to stop, [?] for help\n"); avio_set_interrupt_cb(decode_interrupt_cb); } - term_init(); timer_start = av_gettime(); @@ -2434,15 +2447,21 @@ AVPacket pkt; int64_t ipts_min; double opts_min; + int64_t cur_time= av_gettime(); ipts_min= INT64_MAX; opts_min= 1e100; /* if 'q' pressed, exits */ if (!using_stdin) { - if (q_pressed) + static int64_t last_time; + if (received_nb_signals) break; /* read_key() returns 0 on EOF */ - key = read_key(); + if(cur_time - last_time >= 100000 && !run_as_daemon){ + key = read_key(); + last_time = cur_time; + }else + key = -1; if (key == 'q') break; if (key == '+') av_log_set_level(av_log_get_level()+10); @@ -2643,7 +2662,7 @@ av_free_packet(&pkt); /* dump report by using the output first video and audio streams */ - print_report(output_files, output_streams, nb_output_streams, 0, timer_start); + print_report(output_files, output_streams, nb_output_streams, 0, timer_start, cur_time); } /* at the end of stream, we must flush the decoder buffers */ @@ -2664,7 +2683,7 @@ } /* dump report by using the first video and audio streams */ - print_report(output_files, output_streams, nb_output_streams, 1, timer_start); + print_report(output_files, output_streams, nb_output_streams, 1, timer_start, av_gettime()); /* close each encoder */ for (i = 0; i < nb_output_streams; i++) { @@ -2697,7 +2716,7 @@ for (i = 0; i < nb_output_streams; i++) { ost = &output_streams[i]; if (ost) { - if (ost->st->stream_copy) + if (ost->stream_copy) av_freep(&ost->st->codec->extradata); if (ost->logfile) { fclose(ost->logfile); @@ -2718,12 +2737,6 @@ return ret; } -static int opt_verbose(const char *opt, const char *arg) -{ - av_log(NULL, AV_LOG_WARNING, "-%s is deprecated, use -loglevel\n", opt); - return 0; -} - static int opt_frame_crop(const char *opt, const char *arg) { av_log(NULL, AV_LOG_FATAL, "Option '%s' has been removed, use the crop filter instead\n", opt); @@ -2842,7 +2855,8 @@ /* disable some already defined maps */ for (i = 0; i < o->nb_stream_maps; i++) { m = &o->stream_maps[i]; - if (check_stream_specifier(input_files[m->file_index].ctx, + if (file_idx == m->file_index && + check_stream_specifier(input_files[m->file_index].ctx, input_files[m->file_index].ctx->streams[m->stream_index], *p == ':' ? p + 1 : p) > 0) m->disabled = 1; @@ -2877,6 +2891,14 @@ return 0; } +static int opt_attach(OptionsContext *o, const char *opt, const char *arg) +{ + o->attachments = grow_array(o->attachments, sizeof(*o->attachments), + &o->nb_attachments, o->nb_attachments + 1); + o->attachments[o->nb_attachments - 1] = arg; + return 0; +} + static void parse_meta_type(char *arg, char *type, int *index) { if (*arg) { @@ -2946,13 +2968,11 @@ return 0; } -static enum CodecID find_codec_or_die(const char *name, enum AVMediaType type, int encoder) +static AVCodec *find_codec_or_die(const char *name, enum AVMediaType type, int encoder) { const char *codec_string = encoder ? "encoder" : "decoder"; AVCodec *codec; - if(!name) - return CODEC_ID_NONE; codec = encoder ? avcodec_find_encoder_by_name(name) : avcodec_find_decoder_by_name(name); @@ -2964,29 +2984,20 @@ av_log(NULL, AV_LOG_FATAL, "Invalid %s type '%s'\n", codec_string, name); exit_program(1); } - return codec->id; + return codec; } -static AVCodec *choose_codec(OptionsContext *o, AVFormatContext *s, AVStream *st, enum AVMediaType type) +static AVCodec *choose_decoder(OptionsContext *o, AVFormatContext *s, AVStream *st) { char *codec_name = NULL; MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, st); - - if (!codec_name) { - if (s->oformat) { - st->codec->codec_id = av_guess_codec(s->oformat, NULL, s->filename, NULL, type); - return avcodec_find_encoder(st->codec->codec_id); - } - } else if (!strcmp(codec_name, "copy")) - st->stream_copy = 1; - else { - st->codec->codec_id = find_codec_or_die(codec_name, type, s->iformat == NULL); - return s->oformat ? avcodec_find_encoder_by_name(codec_name) : - avcodec_find_decoder_by_name(codec_name); - } - - return NULL; + if (codec_name) { + AVCodec *codec = find_codec_or_die(codec_name, st->codec->codec_type, 0); + st->codec->codec_id = codec->id; + return codec; + } else + return avcodec_find_decoder(st->codec->codec_id); } /** @@ -2996,6 +3007,7 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) { int i, rfps, rfps_base; + char *next, *codec_tag = NULL; for (i = 0; i < ic->nb_streams; i++) { AVStream *st = ic->streams[i]; @@ -3013,9 +3025,15 @@ MATCH_PER_STREAM_OPT(ts_scale, dbl, scale, ic, st); ist->ts_scale = scale; - ist->dec = choose_codec(o, ic, st, dec->codec_type); - if (!ist->dec) - ist->dec = avcodec_find_decoder(dec->codec_id); + MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, ic, st); + if (codec_tag) { + uint32_t tag = strtol(codec_tag, &next, 0); + if (*next) + tag = AV_RL32(codec_tag); + st->codec->codec_tag = tag; + } + + ist->dec = choose_decoder(o, ic, st); switch (dec->codec_type) { case AVMEDIA_TYPE_AUDIO: @@ -3062,6 +3080,62 @@ } } +static void assert_file_overwrite(const char *filename) +{ + if (!file_overwrite && + (strchr(filename, ':') == NULL || filename[1] == ':' || + av_strstart(filename, "file:", NULL))) { + if (avio_check(filename, 0) == 0) { + if (!using_stdin) { + fprintf(stderr,"File '%s' already exists. Overwrite ? [y/N] ", filename); + fflush(stderr); + term_exit(); + if (!read_yesno()) { + av_log(0, AV_LOG_FATAL, "Not overwriting - exiting\n"); + exit_program(1); + } + term_init(); + } + else { + av_log(0, AV_LOG_FATAL, "File '%s' already exists. Exiting.\n", filename); + exit_program(1); + } + } + } +} + +static void dump_attachment(AVStream *st, const char *filename) +{ + int ret; + AVIOContext *out = NULL; + AVDictionaryEntry *e; + + if (!st->codec->extradata_size) { + av_log(NULL, AV_LOG_WARNING, "No extradata to dump in stream #%d:%d.\n", + nb_input_files - 1, st->index); + return; + } + if (!*filename && (e = av_dict_get(st->metadata, "filename", NULL, 0))) + filename = e->value; + if (!*filename) { + av_log(NULL, AV_LOG_FATAL, "No filename specified and no 'filename' tag" + "in stream #%d:%d.\n", nb_input_files - 1, st->index); + exit_program(1); + } + + assert_file_overwrite(filename); + + if ((ret = avio_open (&out, filename, AVIO_FLAG_WRITE)) < 0) { + av_log(NULL, AV_LOG_FATAL, "Could not open file %s for writing.\n", + filename); + exit_program(1); + } + + avio_write(out, st->codec->extradata, st->codec->extradata_size); + avio_flush(out); + avio_close(out); +} + static int opt_input_file(OptionsContext *o, const char *opt, const char *filename) { AVFormatContext *ic; @@ -3108,6 +3182,12 @@ if (o->nb_frame_pix_fmts) av_dict_set(&format_opts, "pixel_format", o->frame_pix_fmts[o->nb_frame_pix_fmts - 1].u.str, 0); + ic->video_codec_id = video_codec_name ? + find_codec_or_die(video_codec_name , AVMEDIA_TYPE_VIDEO , 0)->id : CODEC_ID_NONE; + ic->audio_codec_id = audio_codec_name ? + find_codec_or_die(audio_codec_name , AVMEDIA_TYPE_AUDIO , 0)->id : CODEC_ID_NONE; + ic->subtitle_codec_id= subtitle_codec_name ? + find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 0)->id : CODEC_ID_NONE; ic->flags |= AVFMT_FLAG_NONBLOCK; if (loop_input) { @@ -3125,7 +3205,7 @@ /* apply forced codec ids */ for (i = 0; i < ic->nb_streams; i++) - choose_codec(o, ic, ic->streams[i], ic->streams[i]->codec->codec_type); + choose_decoder(o, ic, ic->streams[i]); /* Set AVCodecContext options for avformat_find_stream_info */ opts = setup_find_stream_info_opts(ic, codec_opts); @@ -3167,6 +3247,17 @@ input_files[nb_input_files - 1].nb_streams = ic->nb_streams; input_files[nb_input_files - 1].rate_emu = o->rate_emu; + for (i = 0; i < o->nb_dump_attachment; i++) { + int j; + + for (j = 0; j < ic->nb_streams; j++) { + AVStream *st = ic->streams[j]; + + if (check_stream_specifier(ic, st, o->dump_attachment[i].specifier) == 1) + dump_attachment(st, o->dump_attachment[i].u.str); + } + } + for (i = 0; i < orig_nb_streams; i++) av_dict_free(&opts[i]); av_freep(&opts); @@ -3195,21 +3286,88 @@ } } +static uint8_t *get_line(AVIOContext *s) +{ + AVIOContext *line; + uint8_t *buf; + char c; + + if (avio_open_dyn_buf(&line) < 0) { + av_log(NULL, AV_LOG_FATAL, "Could not alloc buffer for reading preset.\n"); + exit_program(1); + } + + while ((c = avio_r8(s)) && c != '\n') + avio_w8(line, c); + avio_w8(line, 0); + avio_close_dyn_buf(line, &buf); + + return buf; +} + +static int get_preset_file_2(const char *preset_name, const char *codec_name, AVIOContext **s) +{ + int i, ret = 1; + char filename[1000]; + const char *base[3] = { getenv("AVCONV_DATADIR"), + getenv("HOME"), + AVCONV_DATADIR, + }; + + for (i = 0; i < FF_ARRAY_ELEMS(base) && ret; i++) { + if (!base[i]) + continue; + if (codec_name) { + snprintf(filename, sizeof(filename), "%s%s/%s-%s.avpreset", base[i], + i != 1 ? "" : "/.avconv", codec_name, preset_name); + ret = avio_open(s, filename, AVIO_FLAG_READ); + } + if (ret) { + snprintf(filename, sizeof(filename), "%s%s/%s.avpreset", base[i], + i != 1 ? "" : "/.avconv", preset_name); + ret = avio_open(s, filename, AVIO_FLAG_READ); + } + } + return ret; +} + +static void choose_encoder(OptionsContext *o, AVFormatContext *s, OutputStream *ost) +{ + char *codec_name = NULL; + + MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, ost->st); + if (!codec_name) { + ost->st->codec->codec_id = av_guess_codec(s->oformat, NULL, s->filename, + NULL, ost->st->codec->codec_type); + ost->enc = avcodec_find_encoder(ost->st->codec->codec_id); + } else if (!strcmp(codec_name, "copy")) + ost->stream_copy = 1; + else { + ost->enc = find_codec_or_die(codec_name, ost->st->codec->codec_type, 1); + ost->st->codec->codec_id = ost->enc->id; + } +} + static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type) { OutputStream *ost; - AVStream *st = av_new_stream(oc, oc->nb_streams < o->nb_streamid_map ? o->streamid_map[oc->nb_streams] : 0); - int idx = oc->nb_streams - 1; + AVStream *st = avformat_new_stream(oc, NULL); + int idx = oc->nb_streams - 1, ret = 0; int64_t max_frames = INT64_MAX; char *bsf = NULL, *next, *codec_tag = NULL; AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL; double qscale = -1; + char *buf = NULL, *arg = NULL, *preset = NULL; + AVIOContext *s = NULL; if (!st) { av_log(NULL, AV_LOG_FATAL, "Could not alloc stream.\n"); exit_program(1); } + if (oc->nb_streams - 1 < o->nb_streamid_map) + st->id = o->streamid_map[oc->nb_streams - 1]; + output_streams = grow_array(output_streams, sizeof(*output_streams), &nb_output_streams, nb_output_streams + 1); ost = &output_streams[nb_output_streams - 1]; @@ -3217,7 +3375,7 @@ ost->index = idx; ost->st = st; st->codec->codec_type = type; - ost->enc = choose_codec(o, oc, st, type); + choose_encoder(o, oc, ost); if (ost->enc) { ost->opts = filter_codec_opts(codec_opts, ost->enc->id, oc, st); } @@ -3225,6 +3383,31 @@ avcodec_get_context_defaults3(st->codec, ost->enc); st->codec->codec_type = type; // XXX hack, avcodec_get_context_defaults2() sets type to unknown for stream copy + MATCH_PER_STREAM_OPT(presets, str, preset, oc, st); + if (preset && (!(ret = get_preset_file_2(preset, ost->enc->name, &s)))) { + do { + buf = get_line(s); + if (!buf[0] || buf[0] == '#') { + av_free(buf); + continue; + } + if (!(arg = strchr(buf, '='))) { + av_log(NULL, AV_LOG_FATAL, "Invalid line found in the preset file.\n"); + exit_program(1); + } + *arg++ = 0; + av_dict_set(&ost->opts, buf, arg, AV_DICT_DONT_OVERWRITE); + av_free(buf); + } while (!s->eof_reached); + avio_close(s); + } + if (ret) { + av_log(NULL, AV_LOG_FATAL, + "Preset %s specified for stream %d:%d, but could not be opened.\n", + preset, ost->file_index, ost->index); + exit_program(1); + } + MATCH_PER_STREAM_OPT(max_frames, i64, max_frames, oc, st); ost->max_frames = max_frames; @@ -3262,7 +3445,7 @@ if (oc->oformat->flags & AVFMT_GLOBALHEADER) st->codec->flags |= CODEC_FLAG_GLOBAL_HEADER; - ost->sws_flags = av_get_int(sws_opts, "sws_flags", NULL); + av_opt_get_int(sws_opts, "sws_flags", 0, &ost->sws_flags); return ost; } @@ -3293,7 +3476,7 @@ st = ost->st; video_enc = st->codec; - if (!st->stream_copy) { + if (!ost->stream_copy) { const char *p = NULL; char *forced_key_frames = NULL, *frame_rate = NULL, *frame_size = NULL; char *frame_aspect_ratio = NULL, *frame_pix_fmt = NULL; @@ -3375,9 +3558,10 @@ /* two pass mode */ if (do_pass) { - if (do_pass == 1) { + if (do_pass & 1) { video_enc->flags |= CODEC_FLAG_PASS1; - } else { + } + if (do_pass & 2) { video_enc->flags |= CODEC_FLAG_PASS2; } } @@ -3414,7 +3598,7 @@ audio_enc = st->codec; audio_enc->codec_type = AVMEDIA_TYPE_AUDIO; - if (!st->stream_copy) { + if (!ost->stream_copy) { char *sample_fmt = NULL; MATCH_PER_STREAM_OPT(audio_channels, i, audio_enc->channels, oc, st); @@ -3427,6 +3611,9 @@ } MATCH_PER_STREAM_OPT(audio_sample_rate, i, audio_enc->sample_rate, oc, st); + + ost->rematrix_volume=1.0; + MATCH_PER_STREAM_OPT(rematrix_volume, f, ost->rematrix_volume, oc, st); } return ost; @@ -3434,12 +3621,10 @@ static OutputStream *new_data_stream(OptionsContext *o, AVFormatContext *oc) { - AVStream *st; OutputStream *ost; ost = new_output_stream(o, oc, AVMEDIA_TYPE_DATA); - st = ost->st; - if (!st->stream_copy) { + if (!ost->stream_copy) { av_log(NULL, AV_LOG_FATAL, "Data stream encoding not supported yet (only streamcopy)\n"); exit_program(1); } @@ -3450,7 +3635,7 @@ static OutputStream *new_attachment_stream(OptionsContext *o, AVFormatContext *oc) { OutputStream *ost = new_output_stream(o, oc, AVMEDIA_TYPE_ATTACHMENT); - ost->st->stream_copy = 1; + ost->stream_copy = 1; return ost; } @@ -3544,20 +3729,23 @@ AVStream *st; OutputStream *ost; AVCodec *codec; + AVCodecContext *avctx; codec = avcodec_find_encoder(ic->streams[i]->codec->codec_id); ost = new_output_stream(o, s, codec->type); st = ost->st; + avctx = st->codec; // FIXME: a more elegant solution is needed memcpy(st, ic->streams[i], sizeof(AVStream)); st->info = av_malloc(sizeof(*st->info)); memcpy(st->info, ic->streams[i]->info, sizeof(*st->info)); + st->codec= avctx; avcodec_copy_context(st->codec, ic->streams[i]->codec); - if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && !st->stream_copy) + if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && !ost->stream_copy) choose_sample_fmt(st, codec); - else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && !st->stream_copy) + else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && !ost->stream_copy) choose_pixel_fmt(st, codec); } @@ -3586,6 +3774,7 @@ if (!strcmp(file_oformat->name, "ffm") && av_strstart(filename, "http:", NULL)) { + int j; /* special case for files sent to ffserver: we get the stream parameters from ffserver */ int err = read_ffserver_streams(o, oc, filename); @@ -3593,6 +3782,18 @@ print_error(filename, err); exit_program(1); } + for(j = nb_output_streams - oc->nb_streams; j < nb_output_streams; j++) { + ost = &output_streams[j]; + for (i = 0; i < nb_input_streams; i++) { + ist = &input_streams[i]; + if(ist->st->codec->codec_type == ost->st->codec->codec_type){ + ost->sync_ist= ist; + ost->source_index= i; + ist->discard = 0; + break; + } + } + } } else if (!o->nb_stream_maps) { /* pick the "best" stream of each type */ #define NEW_STREAM(type, index)\ @@ -3674,6 +3875,42 @@ } } + /* handle attached files */ + for (i = 0; i < o->nb_attachments; i++) { + AVIOContext *pb; + uint8_t *attachment; + const char *p; + int64_t len; + + if ((err = avio_open(&pb, o->attachments[i], AVIO_FLAG_READ)) < 0) { + av_log(NULL, AV_LOG_FATAL, "Could not open attachment file %s.\n", + o->attachments[i]); + exit_program(1); + } + if ((len = avio_size(pb)) <= 0) { + av_log(NULL, AV_LOG_FATAL, "Could not get size of the attachment %s.\n", + o->attachments[i]); + exit_program(1); + } + if (!(attachment = av_malloc(len))) { + av_log(NULL, AV_LOG_FATAL, "Attachment %s too large to fit into memory.\n", + o->attachments[i]); + exit_program(1); + } + avio_read(pb, attachment, len); + + ost = new_attachment_stream(o, oc); + ost->stream_copy = 0; + ost->source_index = -1; + ost->attachment_filename = o->attachments[i]; + ost->st->codec->extradata = attachment; + ost->st->codec->extradata_size = len; + + p = strrchr(o->attachments[i], '/'); + av_dict_set(&ost->st->metadata, "filename", (p && *p) ? p + 1 : o->attachments[i], AV_DICT_DONT_OVERWRITE); + avio_close(pb); + } + output_files = grow_array(output_files, sizeof(*output_files), &nb_output_files, nb_output_files + 1); output_files[nb_output_files - 1].ctx = oc; output_files[nb_output_files - 1].ost_index = nb_output_streams - oc->nb_streams; @@ -3692,25 +3929,7 @@ if (!(oc->oformat->flags & AVFMT_NOFILE)) { /* test if it already exists to avoid loosing precious files */ - if (!file_overwrite && - (strchr(filename, ':') == NULL || - filename[1] == ':' || - av_strstart(filename, "file:", NULL))) { - if (avio_check(filename, 0) == 0) { - if (!using_stdin) { - fprintf(stderr,"File '%s' already exists. Overwrite ? [y/N] ", filename); - fflush(stderr); - if (!read_yesno()) { - av_log(0, AV_LOG_FATAL, "Not overwriting - exiting\n"); - exit_program(1); - } - } - else { - av_log(0, AV_LOG_FATAL,"File '%s' already exists. Exiting.\n", filename); - exit_program(1); - } - } - } + assert_file_overwrite(filename); /* open the file */ if ((err = avio_open(&oc->pb, filename, AVIO_FLAG_WRITE)) < 0) { @@ -3719,7 +3938,11 @@ } } - oc->preload = (int)(o->mux_preload * AV_TIME_BASE); + if (o->mux_preload) { + uint8_t buf[64]; + snprintf(buf, sizeof(buf), "%d", (int)(o->mux_preload*AV_TIME_BASE)); + av_dict_set(&output_files[nb_output_files - 1].opts, "preload", buf, 0); + } oc->max_delay = (int)(o->mux_max_delay * AV_TIME_BASE); if (loop_output >= 0) { @@ -3787,6 +4010,8 @@ METADATA_CHECK_INDEX(map->index, files[j]->nb_programs, "program") meta[j] = &files[j]->programs[map->index]->metadata; break; + default: + abort(); } } @@ -3802,7 +4027,10 @@ } if (!o->metadata_streams_manual) for (i = output_files[nb_output_files - 1].ost_index; i < nb_output_streams; i++) { - InputStream *ist = &input_streams[output_streams[i].source_index]; + InputStream *ist; + if (output_streams[i].source_index < 0) /* this is true e.g. for attached files */ + continue; + ist = &input_streams[output_streams[i].source_index]; av_dict_copy(&output_streams[i].st->metadata, ist->st->metadata, AV_DICT_DONT_OVERWRITE); } @@ -3853,7 +4081,7 @@ /* same option as mencoder */ static int opt_pass(const char *opt, const char *arg) { - do_pass = parse_number_or_die(opt, arg, OPT_INT, 1, 2); + do_pass = parse_number_or_die(opt, arg, OPT_INT, 1, 3); return 0; } @@ -3907,11 +4135,7 @@ static int opt_help(const char *opt, const char *arg) { - AVCodec *c; - AVOutputFormat *oformat = NULL; - AVInputFormat *iformat = NULL; - const AVClass *class; - + int flags = AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM; av_log_set_callback(log_callback_help); show_usage(); show_help_options(options, "Main options:\n", @@ -3938,41 +4162,10 @@ OPT_GRAB, OPT_GRAB); printf("\n"); - class = avcodec_get_class(); - av_opt_show2(&class, NULL, AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM, 0); - printf("\n"); + show_help_children(avcodec_get_class(), flags); + show_help_children(avformat_get_class(), flags); + show_help_children(sws_get_class(), flags); - /* individual codec options */ - c = NULL; - while ((c = av_codec_next(c))) { - if (c->priv_class) { - av_opt_show2(&c->priv_class, NULL, AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM, 0); - printf("\n"); - } - } - - class = avformat_get_class(); - av_opt_show2(&class, NULL, AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM, 0); - printf("\n"); - - /* individual muxer options */ - while ((oformat = av_oformat_next(oformat))) { - if (oformat->priv_class) { - av_opt_show2(&oformat->priv_class, NULL, AV_OPT_FLAG_ENCODING_PARAM, 0); - printf("\n"); - } - } - - /* individual demuxer options */ - while ((iformat = av_iformat_next(iformat))) { - if (iformat->priv_class) { - av_opt_show2(&iformat->priv_class, NULL, AV_OPT_FLAG_DECODING_PARAM, 0); - printf("\n"); - } - } - - class = sws_get_class(); - av_opt_show2(&class, NULL, AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM, 0); return 0; } @@ -4235,6 +4428,7 @@ { "y", OPT_BOOL, {(void*)&file_overwrite}, "overwrite output files" }, { "c", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(codec_names)}, "codec name", "codec" }, { "codec", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(codec_names)}, "codec name", "codec" }, + { "pre", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(presets)}, "preset name", "preset" }, { "map", HAS_ARG | OPT_EXPERT | OPT_FUNC2, {(void*)opt_map}, "set input stream mapping", "file.stream[:syncfile.syncstream]" }, { "map_meta_data", HAS_ARG | OPT_EXPERT | OPT_FUNC2, {(void*)opt_map_meta_data}, "DEPRECATED set meta data information of outfile from infile", "outfile[,metadata]:infile[,metadata]" }, @@ -4259,7 +4453,6 @@ { "re", OPT_BOOL | OPT_EXPERT | OPT_OFFSET, {.off = OFFSET(rate_emu)}, "read input at native frame rate", "" }, { "loop_input", OPT_BOOL | OPT_EXPERT, {(void*)&loop_input}, "deprecated, use -loop" }, { "loop_output", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&loop_output}, "deprecated, use -loop", "" }, - { "v", HAS_ARG, {(void*)opt_verbose}, "deprecated, use -loglevel instead", "number" }, { "target", HAS_ARG | OPT_FUNC2, {(void*)opt_target}, "specify target file type (\"vcd\", \"svcd\", \"dvd\", \"dv\", \"dv50\", \"pal-vcd\", \"ntsc-svcd\", ...)", "type" }, { "vsync", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&video_sync_method}, "video sync method", "" }, { "async", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&audio_sync_method}, "audio sync method", "" }, @@ -4277,6 +4470,9 @@ #if CONFIG_AVFILTER { "filter", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(filters)}, "set stream filterchain", "filter_list" }, #endif + { "stats", OPT_BOOL, {&print_stats}, "print progress report during encoding", }, + { "attach", HAS_ARG | OPT_FUNC2, {(void*)opt_attach}, "add an attachment to the output file", "filename" }, + { "dump_attachment", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(dump_attachment)}, "extract an attachment into a file", "filename" }, /* video options */ { "vframes", HAS_ARG | OPT_VIDEO | OPT_FUNC2, {(void*)opt_video_frames}, "set the number of video frames to record", "number" }, @@ -4332,6 +4528,7 @@ { "atag", HAS_ARG | OPT_EXPERT | OPT_AUDIO | OPT_FUNC2, {(void*)opt_old2new}, "force audio tag/fourcc", "fourcc/tag" }, { "vol", OPT_INT | HAS_ARG | OPT_AUDIO, {(void*)&audio_volume}, "change audio volume (256=normal)" , "volume" }, // { "sample_fmt", HAS_ARG | OPT_EXPERT | OPT_AUDIO | OPT_SPEC | OPT_STRING, {.off = OFFSET(sample_fmts)}, "set sample format", "format" }, + { "rmvol", HAS_ARG | OPT_AUDIO | OPT_FLOAT | OPT_SPEC, {.off = OFFSET(rematrix_volume)}, "rematrix volume (as factor)", "volume" }, /* subtitle options */ { "sn", OPT_BOOL | OPT_SUBTITLE | OPT_OFFSET, {.off = OFFSET(subtitle_disable)}, "disable subtitle" }, @@ -4395,6 +4592,8 @@ show_banner(); + term_init(); + /* parse options */ parse_options(&o, argc, argv, options, opt_output_file); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/ffplay.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/ffplay.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/ffplay.c 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/ffplay.c 2011-11-04 12:38:26.000000000 +0000 @@ -71,8 +71,6 @@ /* no AV correction is done if too big error */ #define AV_NOSYNC_THRESHOLD 10.0 -#define FRAME_SKIP_FACTOR 0.05 - /* maximum audio speed change to get correct sync */ #define SAMPLE_CORRECTION_PERCENT_MAX 10 @@ -98,12 +96,13 @@ typedef struct VideoPicture { double pts; ///width == screen->w && screen->w == w && is->height== screen->h && screen->h == h) return 0; - -#ifndef __APPLE__ screen = SDL_SetVideoMode(w, h, 0, flags); -#else - /* setting bits_per_pixel = 0 or 32 causes blank video on OS X */ - screen = SDL_SetVideoMode(w, h, 24, flags); -#endif if (!screen) { fprintf(stderr, "SDL: could not set video mode - exiting\n"); do_exit(is); @@ -1071,19 +1068,9 @@ is->paused = !is->paused; } -static double compute_target_time(double frame_current_pts, VideoState *is) +static double compute_target_delay(double delay, VideoState *is) { - double delay, sync_threshold, diff; - - /* compute nominal delay */ - delay = frame_current_pts - is->frame_last_pts; - if (delay <= 0 || delay >= 10.0) { - /* if incorrect delay, use previous one */ - delay = is->frame_last_delay; - } else { - is->frame_last_delay = delay; - } - is->frame_last_pts = frame_current_pts; + double sync_threshold, diff; /* update delay to follow master synchronisation source */ if (((is->av_sync_type == AV_SYNC_AUDIO_MASTER && is->audio_st) || @@ -1103,12 +1090,31 @@ delay = 2 * delay; } } - is->frame_timer += delay; - av_dlog(NULL, "video: delay=%0.3f pts=%0.3f A-V=%f\n", - delay, frame_current_pts, -diff); + av_dlog(NULL, "video: delay=%0.3f A-V=%f\n", + delay, -diff); - return is->frame_timer; + return delay; +} + +static void pictq_next_picture(VideoState *is) { + /* update queue size and signal for next picture */ + if (++is->pictq_rindex == VIDEO_PICTURE_QUEUE_SIZE) + is->pictq_rindex = 0; + + SDL_LockMutex(is->pictq_mutex); + is->pictq_size--; + SDL_CondSignal(is->pictq_cond); + SDL_UnlockMutex(is->pictq_mutex); +} + +static void update_video_pts(VideoState *is, double pts, int64_t pos) { + double time = av_gettime() / 1000000.0; + /* update current video pts */ + is->video_current_pts = pts; + is->video_current_pts_drift = is->video_current_pts - time; + is->video_current_pos = pos; + is->frame_last_pts = pts; } /* called to display each frame */ @@ -1116,43 +1122,60 @@ { VideoState *is = opaque; VideoPicture *vp; + double time; SubPicture *sp, *sp2; if (is->video_st) { retry: if (is->pictq_size == 0) { + SDL_LockMutex(is->pictq_mutex); + if (is->frame_last_dropped_pts != AV_NOPTS_VALUE && is->frame_last_dropped_pts > is->frame_last_pts) { + update_video_pts(is, is->frame_last_dropped_pts, is->frame_last_dropped_pos); + is->frame_last_dropped_pts = AV_NOPTS_VALUE; + } + SDL_UnlockMutex(is->pictq_mutex); //nothing to do, no picture to display in the que } else { - double time= av_gettime()/1000000.0; - double next_target; + double last_duration, duration, delay; /* dequeue the picture */ vp = &is->pictq[is->pictq_rindex]; - if(time < vp->target_clock) + if (vp->skip) { + pictq_next_picture(is); + goto retry; + } + + /* compute nominal last_duration */ + last_duration = vp->pts - is->frame_last_pts; + if (last_duration > 0 && last_duration < 10.0) { + /* if duration of the last frame was sane, update last_duration in video state */ + is->frame_last_duration = last_duration; + } + delay = compute_target_delay(is->frame_last_duration, is); + + time= av_gettime()/1000000.0; + if(time < is->frame_timer + delay) return; - /* update current video pts */ - is->video_current_pts = vp->pts; - is->video_current_pts_drift = is->video_current_pts - time; - is->video_current_pos = vp->pos; - if(is->pictq_size > 1){ - VideoPicture *nextvp= &is->pictq[(is->pictq_rindex+1)%VIDEO_PICTURE_QUEUE_SIZE]; - assert(nextvp->target_clock >= vp->target_clock); - next_target= nextvp->target_clock; - }else{ - next_target= vp->target_clock + vp->duration; + + if (delay > 0) + is->frame_timer += delay * FFMAX(1, floor((time-is->frame_timer) / delay)); + + SDL_LockMutex(is->pictq_mutex); + update_video_pts(is, vp->pts, vp->pos); + SDL_UnlockMutex(is->pictq_mutex); + + if(is->pictq_size > 1) { + VideoPicture *nextvp= &is->pictq[(is->pictq_rindex+1)%VIDEO_PICTURE_QUEUE_SIZE]; + duration = nextvp->pts - vp->pts; // More accurate this way, 1/time_base is often not reflecting FPS + } else { + duration = vp->duration; } - if((framedrop>0 || (framedrop && is->audio_st)) && time > next_target){ - is->skip_frames *= 1.0 + FRAME_SKIP_FACTOR; + + if((framedrop>0 || (framedrop && is->audio_st)) && time > is->frame_timer + duration){ if(is->pictq_size > 1){ - /* update queue size and signal for next picture */ - if (++is->pictq_rindex == VIDEO_PICTURE_QUEUE_SIZE) - is->pictq_rindex = 0; - - SDL_LockMutex(is->pictq_mutex); - is->pictq_size--; - SDL_CondSignal(is->pictq_cond); - SDL_UnlockMutex(is->pictq_mutex); + is->frame_drops_late++; + pictq_next_picture(is); goto retry; } } @@ -1205,14 +1228,7 @@ if (!display_disable) video_display(is); - /* update queue size and signal for next picture */ - if (++is->pictq_rindex == VIDEO_PICTURE_QUEUE_SIZE) - is->pictq_rindex = 0; - - SDL_LockMutex(is->pictq_mutex); - is->pictq_size--; - SDL_CondSignal(is->pictq_cond); - SDL_UnlockMutex(is->pictq_mutex); + pictq_next_picture(is); } } else if (is->audio_st) { /* draw the next audio frame */ @@ -1244,10 +1260,10 @@ av_diff = 0; if (is->audio_st && is->video_st) av_diff = get_audio_clock(is) - get_video_clock(is); - printf("%7.2f A-V:%7.3f s:%3.1f aq=%5dKB vq=%5dKB sq=%5dB f=%"PRId64"/%"PRId64" \r", + printf("%7.2f A-V:%7.3f fd=%4d aq=%5dKB vq=%5dKB sq=%5dB f=%"PRId64"/%"PRId64" \r", get_master_clock(is), av_diff, - FFMAX(is->skip_frames-1, 0), + is->frame_drops_early + is->frame_drops_late, aqsize / 1024, vqsize / 1024, sqsize, @@ -1331,9 +1347,6 @@ /* wait until we have space to put a new picture */ SDL_LockMutex(is->pictq_mutex); - if(is->pictq_size>=VIDEO_PICTURE_QUEUE_SIZE && !is->refresh) - is->skip_frames= FFMAX(1.0 - FRAME_SKIP_FACTOR, is->skip_frames * (1.0-FRAME_SKIP_FACTOR)); - while (is->pictq_size >= VIDEO_PICTURE_QUEUE_SIZE && !is->videoq.abort_request) { SDL_CondWait(is->pictq_cond, is->pictq_mutex); @@ -1348,7 +1361,7 @@ vp->duration = frame_delay; /* alloc or resize hardware picture buffer */ - if (!vp->bmp || + if (!vp->bmp || vp->reallocate || #if CONFIG_AVFILTER vp->width != is->out_video_filter->inputs[0]->w || vp->height != is->out_video_filter->inputs[0]->h) { @@ -1358,7 +1371,8 @@ #endif SDL_Event event; - vp->allocated = 0; + vp->allocated = 0; + vp->reallocate = 0; /* the allocation must be done in the main thread to avoid locking problems */ @@ -1425,13 +1439,12 @@ vp->pts = pts; vp->pos = pos; + vp->skip = 0; /* now we can update the picture count */ if (++is->pictq_windex == VIDEO_PICTURE_QUEUE_SIZE) is->pictq_windex = 0; SDL_LockMutex(is->pictq_mutex); - vp->target_clock= compute_target_time(vp->pts, is); - is->pictq_size++; SDL_UnlockMutex(is->pictq_mutex); } @@ -1451,25 +1464,26 @@ SDL_LockMutex(is->pictq_mutex); //Make sure there are no long delay timers (ideally we should just flush the que but thats harder) for (i = 0; i < VIDEO_PICTURE_QUEUE_SIZE; i++) { - is->pictq[i].target_clock= 0; + is->pictq[i].skip = 1; } while (is->pictq_size && !is->videoq.abort_request) { SDL_CondWait(is->pictq_cond, is->pictq_mutex); } is->video_current_pos = -1; - SDL_UnlockMutex(is->pictq_mutex); - is->frame_last_pts = AV_NOPTS_VALUE; - is->frame_last_delay = 0; + is->frame_last_duration = 0; is->frame_timer = (double)av_gettime() / 1000000.0; - is->skip_frames = 1; - is->skip_frames_index = 0; + is->frame_last_dropped_pts = AV_NOPTS_VALUE; + SDL_UnlockMutex(is->pictq_mutex); + return 0; } avcodec_decode_video2(is->video_st->codec, frame, &got_picture, pkt); if (got_picture) { + int ret = 1; + if (decoder_reorder_pts == -1) { *pts = frame->best_effort_timestamp; } else if (decoder_reorder_pts) { @@ -1482,12 +1496,29 @@ *pts = 0; } - is->skip_frames_index += 1; - if(is->skip_frames_index >= is->skip_frames){ - is->skip_frames_index -= FFMAX(is->skip_frames, 1.0); - return 1; + if (((is->av_sync_type == AV_SYNC_AUDIO_MASTER && is->audio_st) || is->av_sync_type == AV_SYNC_EXTERNAL_CLOCK) && + (framedrop>0 || (framedrop && is->audio_st))) { + SDL_LockMutex(is->pictq_mutex); + if (is->frame_last_pts != AV_NOPTS_VALUE && *pts) { + double clockdiff = get_video_clock(is) - get_master_clock(is); + double dpts = av_q2d(is->video_st->time_base) * *pts; + double ptsdiff = dpts - is->frame_last_pts; + if (fabs(clockdiff) < AV_NOSYNC_THRESHOLD && + ptsdiff > 0 && ptsdiff < AV_NOSYNC_THRESHOLD && + clockdiff + ptsdiff - is->frame_last_filter_delay < 0) { + is->frame_last_dropped_pos = pkt->pos; + is->frame_last_dropped_pts = dpts; + is->frame_drops_early++; + ret = 0; + } + } + SDL_UnlockMutex(is->pictq_mutex); } + if (ret) + is->frame_last_returned_time = av_gettime() / 1000000.0; + + return ret; } return 0; } @@ -1811,6 +1842,10 @@ if (ret < 0) goto the_end; + is->frame_last_filter_delay = av_gettime() / 1000000.0 - is->frame_last_returned_time; + if (fabs(is->frame_last_filter_delay) > AV_NOSYNC_THRESHOLD / 10.0) + is->frame_last_filter_delay = 0; + #if CONFIG_AVFILTER if (!picref) continue; @@ -2307,6 +2342,12 @@ packet_queue_end(&is->audioq); if (is->swr_ctx) swr_free(&is->swr_ctx); + av_free_packet(&is->audio_pkt); + + if (is->rdft) { + av_rdft_end(is->rdft); + av_freep(&is->rdft_data); + } break; case AVMEDIA_TYPE_VIDEO: packet_queue_abort(&is->videoq); @@ -2502,8 +2543,10 @@ else av_read_play(ic); } -#if CONFIG_RTSP_DEMUXER - if (is->paused && !strcmp(ic->iformat->name, "rtsp")) { +#if CONFIG_RTSP_DEMUXER || CONFIG_MMSH_PROTOCOL + if (is->paused && + (!strcmp(ic->iformat->name, "rtsp") || + (ic->pb && !strcmp(url_fileno(ic->pb)->prot->name, "mmsh")))) { /* wait 10 ms to avoid trying to get another packet */ /* XXX: horrible */ SDL_Delay(10); @@ -2714,6 +2757,12 @@ static void toggle_full_screen(VideoState *is) { is_full_screen = !is_full_screen; +#if defined(__APPLE__) && SDL_VERSION_ATLEAST(1, 2, 14) + /* OSX needs to reallocate the SDL overlays */ + for (int i = 0; i < VIDEO_PICTURE_QUEUE_SIZE; i++) { + is->pictq[i].reallocate = 1; + } +#endif video_open(is); } @@ -3029,7 +3078,6 @@ static int opt_help(const char *opt, const char *arg) { - const AVClass *class; av_log_set_callback(log_callback_help); show_usage(); show_help_options(options, "Main options:\n", @@ -3037,18 +3085,10 @@ show_help_options(options, "\nAdvanced options:\n", OPT_EXPERT, OPT_EXPERT); printf("\n"); - class = avcodec_get_class(); - av_opt_show2(&class, NULL, - AV_OPT_FLAG_DECODING_PARAM, 0); - printf("\n"); - class = avformat_get_class(); - av_opt_show2(&class, NULL, - AV_OPT_FLAG_DECODING_PARAM, 0); + show_help_children(avcodec_get_class(), AV_OPT_FLAG_DECODING_PARAM); + show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM); #if !CONFIG_AVFILTER - printf("\n"); - class = sws_get_class(); - av_opt_show2(&class, NULL, - AV_OPT_FLAG_ENCODING_PARAM, 0); + show_help_children(sws_get_class(), AV_OPT_FLAG_ENCODING_PARAM); #endif printf("\nWhile playing:\n" "q, ESC quit\n" diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/ffpresets/libx264-ipod320.ffpreset ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/ffpresets/libx264-ipod320.ffpreset --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/ffpresets/libx264-ipod320.ffpreset 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/ffpresets/libx264-ipod320.ffpreset 1970-01-01 00:00:00.000000000 +0000 @@ -1,8 +0,0 @@ -coder=0 -bf=0 -weightb=0 -8x8dct=0 -level=13 -maxrate=768000 -bufsize=3000000 -weightp=0 diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/ffpresets/libx264-ipod640.ffpreset ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/ffpresets/libx264-ipod640.ffpreset --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/ffpresets/libx264-ipod640.ffpreset 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/ffpresets/libx264-ipod640.ffpreset 1970-01-01 00:00:00.000000000 +0000 @@ -1,9 +0,0 @@ -coder=0 -bf=0 -refs=1 -weightb=0 -8x8dct=0 -level=30 -maxrate=10000000 -bufsize=10000000 -weightp=0 diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/ffprobe.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/ffprobe.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/ffprobe.c 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/ffprobe.c 2011-11-04 12:38:26.000000000 +0000 @@ -23,6 +23,7 @@ #include "libavformat/avformat.h" #include "libavcodec/avcodec.h" +#include "libavutil/avstring.h" #include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "libavutil/dict.h" @@ -121,123 +122,179 @@ return buf; } +/* WRITERS API */ -struct writer { +typedef struct WriterContext WriterContext; + +typedef struct Writer { + int priv_size; ///< private size for the writer context const char *name; - const char *item_sep; ///< separator between key/value couples - const char *items_sep; ///< separator between sets of key/value couples - const char *section_sep; ///< separator between sections (streams, packets, ...) - const char *header, *footer; - void (*print_section_start)(const char *, int); - void (*print_section_end) (const char *, int); - void (*print_header)(const char *); - void (*print_footer)(const char *); - void (*print_integer)(const char *, int); - void (*print_string)(const char *, const char *); - void (*show_tags)(struct writer *w, AVDictionary *dict); + + int (*init) (WriterContext *wctx, const char *args, void *opaque); + void (*uninit)(WriterContext *wctx); + + void (*print_header)(WriterContext *ctx); + void (*print_footer)(WriterContext *ctx); + + void (*print_chapter_header)(WriterContext *wctx, const char *); + void (*print_chapter_footer)(WriterContext *wctx, const char *); + void (*print_section_header)(WriterContext *wctx, const char *); + void (*print_section_footer)(WriterContext *wctx, const char *); + void (*print_integer) (WriterContext *wctx, const char *, int); + void (*print_string) (WriterContext *wctx, const char *, const char *); + void (*show_tags) (WriterContext *wctx, AVDictionary *dict); +} Writer; + +struct WriterContext { + const AVClass *class; ///< class of the writer + const Writer *writer; ///< the Writer of which this is an instance + char *name; ///< name of this writer instance + void *priv; ///< private data for use by the filter + unsigned int nb_item; ///< number of the item printed in the given section, starting at 0 + unsigned int nb_section; ///< number of the section printed in the given section sequence, starting at 0 + unsigned int nb_chapter; ///< number of the chapter, starting at 0 }; +static const char *writer_get_name(void *p) +{ + WriterContext *wctx = p; + return wctx->writer->name; +} -/* JSON output */ +static const AVClass writer_class = { + "Writer", + writer_get_name, + NULL, + LIBAVUTIL_VERSION_INT, +}; -static void json_print_header(const char *section) +static void writer_close(WriterContext **wctx) { - printf("{\n"); + if (*wctx && (*wctx)->writer->uninit) + (*wctx)->writer->uninit(*wctx); + + av_freep(&((*wctx)->priv)); + av_freep(wctx); } -static char *json_escape_str(const char *s) +static int writer_open(WriterContext **wctx, const Writer *writer, + const char *args, void *opaque) { - static const char json_escape[] = {'"', '\\', '\b', '\f', '\n', '\r', '\t', 0}; - static const char json_subst[] = {'"', '\\', 'b', 'f', 'n', 'r', 't', 0}; - char *ret, *p; - int i, len = 0; + int ret = 0; - // compute the length of the escaped string - for (i = 0; s[i]; i++) { - if (strchr(json_escape, s[i])) len += 2; // simple escape - else if ((unsigned char)s[i] < 32) len += 6; // handle non-printable chars - else len += 1; // char copy - } - - p = ret = av_malloc(len + 1); - if (!p) - return NULL; - for (i = 0; s[i]; i++) { - char *q = strchr(json_escape, s[i]); - if (q) { - *p++ = '\\'; - *p++ = json_subst[q - json_escape]; - } else if ((unsigned char)s[i] < 32) { - snprintf(p, 7, "\\u00%02x", s[i] & 0xff); - p += 6; - } else { - *p++ = s[i]; - } + if (!(*wctx = av_malloc(sizeof(WriterContext)))) { + ret = AVERROR(ENOMEM); + goto fail; + } + + if (!((*wctx)->priv = av_mallocz(writer->priv_size))) { + ret = AVERROR(ENOMEM); + goto fail; } - *p = 0; + + (*wctx)->class = &writer_class; + (*wctx)->writer = writer; + if ((*wctx)->writer->init) + ret = (*wctx)->writer->init(*wctx, args, opaque); + if (ret < 0) + goto fail; + + return 0; + +fail: + writer_close(wctx); return ret; } -static void json_print_str(const char *key, const char *value) +static inline void writer_print_header(WriterContext *wctx) { - char *key_esc = json_escape_str(key); - char *value_esc = json_escape_str(value); - printf(" \"%s\": \"%s\"", - key_esc ? key_esc : "", - value_esc ? value_esc : ""); - av_free(key_esc); - av_free(value_esc); + if (wctx->writer->print_header) + wctx->writer->print_header(wctx); + wctx->nb_chapter = 0; } -static void json_print_int(const char *key, int value) +static inline void writer_print_footer(WriterContext *wctx) { - char *key_esc = json_escape_str(key); - printf(" \"%s\": %d", key_esc ? key_esc : "", value); - av_free(key_esc); + if (wctx->writer->print_footer) + wctx->writer->print_footer(wctx); } -static void json_print_footer(const char *section) +static inline void writer_print_chapter_header(WriterContext *wctx, + const char *header) { - printf("\n }"); + if (wctx->writer->print_chapter_header) + wctx->writer->print_chapter_header(wctx, header); + wctx->nb_section = 0; } -static void json_print_section_start(const char *section, int multiple_entries) +static inline void writer_print_chapter_footer(WriterContext *wctx, + const char *footer) { - char *section_esc = json_escape_str(section); - printf("\n \"%s\":%s", section_esc ? section_esc : "", - multiple_entries ? " [" : " "); - av_free(section_esc); + if (wctx->writer->print_chapter_footer) + wctx->writer->print_chapter_footer(wctx, footer); + wctx->nb_chapter++; } -static void json_print_section_end(const char *section, int multiple_entries) +static inline void writer_print_section_header(WriterContext *wctx, + const char *header) { - if (multiple_entries) - printf("]"); + if (wctx->writer->print_section_header) + wctx->writer->print_section_header(wctx, header); + wctx->nb_item = 0; } +static inline void writer_print_section_footer(WriterContext *wctx, + const char *footer) +{ + if (wctx->writer->print_section_footer) + wctx->writer->print_section_footer(wctx, footer); + wctx->nb_section++; +} -/* Default output */ - -static void default_print_header(const char *section) +static inline void writer_print_integer(WriterContext *wctx, + const char *key, int val) { - printf("[%s]\n", section); + wctx->writer->print_integer(wctx, key, val); + wctx->nb_item++; } -static void default_print_str(const char *key, const char *value) +static inline void writer_print_string(WriterContext *wctx, + const char *key, const char *val) { - printf("%s=%s", key, value); + wctx->writer->print_string(wctx, key, val); + wctx->nb_item++; } -static void default_print_int(const char *key, int value) +static inline void writer_show_tags(WriterContext *wctx, AVDictionary *dict) { - printf("%s=%d", key, value); + wctx->writer->show_tags(wctx, dict); } -static void default_print_footer(const char *section) +#define MAX_REGISTERED_WRITERS_NB 64 + +static Writer *registered_writers[MAX_REGISTERED_WRITERS_NB + 1]; + +static int writer_register(Writer *writer) { - printf("\n[/%s]", section); + static int next_registered_writer_idx = 0; + + if (next_registered_writer_idx == MAX_REGISTERED_WRITERS_NB) + return AVERROR(ENOMEM); + + registered_writers[next_registered_writer_idx++] = writer; + return 0; } +static Writer *writer_get_by_name(const char *name) +{ + int i; + + for (i = 0; registered_writers[i]; i++) + if (!strcmp(registered_writers[i]->name, name)) + return registered_writers[i]; + + return NULL; +} /* Print helpers */ @@ -278,37 +335,292 @@ return NULL; } -#define print_fmt0(k, f, ...) do { \ - if (fast_asprintf(&pbuf, f, __VA_ARGS__)) \ - w->print_string(k, pbuf.s); \ -} while (0) -#define print_fmt( k, f, ...) do { \ - if (w->item_sep) \ - printf("%s", w->item_sep); \ - print_fmt0(k, f, __VA_ARGS__); \ -} while (0) +#define ESCAPE_INIT_BUF_SIZE 256 -#define print_int0(k, v) w->print_integer(k, v) -#define print_int( k, v) do { \ - if (w->item_sep) \ - printf("%s", w->item_sep); \ - print_int0(k, v); \ -} while (0) +#define ESCAPE_CHECK_SIZE(src, size, max_size) \ + if (size > max_size) { \ + char buf[64]; \ + snprintf(buf, sizeof(buf), "%s", src); \ + av_log(log_ctx, AV_LOG_WARNING, \ + "String '%s...' with is too big\n", buf); \ + return "FFPROBE_TOO_BIG_STRING"; \ + } + +#define ESCAPE_REALLOC_BUF(dst_size_p, dst_p, src, size) \ + if (*dst_size_p < size) { \ + char *q = av_realloc(*dst_p, size); \ + if (!q) { \ + char buf[64]; \ + snprintf(buf, sizeof(buf), "%s", src); \ + av_log(log_ctx, AV_LOG_WARNING, \ + "String '%s...' could not be escaped\n", buf); \ + return "FFPROBE_THIS_STRING_COULD_NOT_BE_ESCAPED"; \ + } \ + *dst_size_p = size; \ + *dst = q; \ + } -#define print_str0(k, v) print_fmt0(k, "%s", v) -#define print_str( k, v) print_fmt (k, "%s", v) +/* WRITERS */ +/* Default output */ -static void show_packet(struct writer *w, AVFormatContext *fmt_ctx, AVPacket *pkt, int packet_idx) +static void default_print_footer(WriterContext *wctx) +{ + printf("\n"); +} + +static void default_print_chapter_header(WriterContext *wctx, const char *chapter) +{ + if (wctx->nb_chapter) + printf("\n"); +} + +/* lame uppercasing routine, assumes the string is lower case ASCII */ +static inline char *upcase_string(char *dst, size_t dst_size, const char *src) +{ + int i; + for (i = 0; src[i] && i < dst_size-1; i++) + dst[i] = src[i]-32; + dst[i] = 0; + return dst; +} + +static void default_print_section_header(WriterContext *wctx, const char *section) +{ + char buf[32]; + + if (wctx->nb_section) + printf("\n"); + printf("[%s]\n", upcase_string(buf, sizeof(buf), section)); +} + +static void default_print_section_footer(WriterContext *wctx, const char *section) +{ + char buf[32]; + + printf("[/%s]", upcase_string(buf, sizeof(buf), section)); +} + +static void default_print_str(WriterContext *wctx, const char *key, const char *value) +{ + printf("%s=%s\n", key, value); +} + +static void default_print_int(WriterContext *wctx, const char *key, int value) +{ + printf("%s=%d\n", key, value); +} + +static void default_show_tags(WriterContext *wctx, AVDictionary *dict) +{ + AVDictionaryEntry *tag = NULL; + while ((tag = av_dict_get(dict, "", tag, AV_DICT_IGNORE_SUFFIX))) { + printf("TAG:"); + writer_print_string(wctx, tag->key, tag->value); + } +} + +static Writer default_writer = { + .name = "default", + .print_footer = default_print_footer, + .print_chapter_header = default_print_chapter_header, + .print_section_header = default_print_section_header, + .print_section_footer = default_print_section_footer, + .print_integer = default_print_int, + .print_string = default_print_str, + .show_tags = default_show_tags +}; + +/* JSON output */ + +typedef struct { + int multiple_entries; ///< tells if the given chapter requires multiple entries + char *buf; + size_t buf_size; +} JSONContext; + +static av_cold int json_init(WriterContext *wctx, const char *args, void *opaque) +{ + JSONContext *json = wctx->priv; + + json->buf_size = ESCAPE_INIT_BUF_SIZE; + if (!(json->buf = av_malloc(json->buf_size))) + return AVERROR(ENOMEM); + + return 0; +} + +static av_cold void json_uninit(WriterContext *wctx) +{ + JSONContext *json = wctx->priv; + av_freep(&json->buf); +} + +static const char *json_escape_str(char **dst, size_t *dst_size, const char *src, + void *log_ctx) +{ + static const char json_escape[] = {'"', '\\', '\b', '\f', '\n', '\r', '\t', 0}; + static const char json_subst[] = {'"', '\\', 'b', 'f', 'n', 'r', 't', 0}; + const char *p; + char *q; + size_t size = 1; + + // compute the length of the escaped string + for (p = src; *p; p++) { + ESCAPE_CHECK_SIZE(src, size, SIZE_MAX-6); + if (strchr(json_escape, *p)) size += 2; // simple escape + else if ((unsigned char)*p < 32) size += 6; // handle non-printable chars + else size += 1; // char copy + } + ESCAPE_REALLOC_BUF(dst_size, dst, src, size); + + q = *dst; + for (p = src; *p; p++) { + char *s = strchr(json_escape, *p); + if (s) { + *q++ = '\\'; + *q++ = json_subst[s - json_escape]; + } else if ((unsigned char)*p < 32) { + snprintf(q, 7, "\\u00%02x", *p & 0xff); + q += 6; + } else { + *q++ = *p; + } + } + *q = 0; + return *dst; +} + +static void json_print_header(WriterContext *wctx) +{ + printf("{"); +} + +static void json_print_footer(WriterContext *wctx) +{ + printf("\n}\n"); +} + +static void json_print_chapter_header(WriterContext *wctx, const char *chapter) +{ + JSONContext *json = wctx->priv; + + if (wctx->nb_chapter) + printf(","); + json->multiple_entries = !strcmp(chapter, "packets") || !strcmp(chapter, "streams"); + printf("\n \"%s\":%s", json_escape_str(&json->buf, &json->buf_size, chapter, wctx), + json->multiple_entries ? " [" : " "); +} + +static void json_print_chapter_footer(WriterContext *wctx, const char *chapter) +{ + JSONContext *json = wctx->priv; + + if (json->multiple_entries) + printf("]"); +} + +static void json_print_section_header(WriterContext *wctx, const char *section) +{ + if (wctx->nb_section) printf(","); + printf("{\n"); +} + +static void json_print_section_footer(WriterContext *wctx, const char *section) +{ + printf("\n }"); +} + +static inline void json_print_item_str(WriterContext *wctx, + const char *key, const char *value, + const char *indent) +{ + JSONContext *json = wctx->priv; + + printf("%s\"%s\":", indent, json_escape_str(&json->buf, &json->buf_size, key, wctx)); + printf(" \"%s\"", json_escape_str(&json->buf, &json->buf_size, value, wctx)); +} + +#define INDENT " " + +static void json_print_str(WriterContext *wctx, const char *key, const char *value) +{ + if (wctx->nb_item) printf(",\n"); + json_print_item_str(wctx, key, value, INDENT); +} + +static void json_print_int(WriterContext *wctx, const char *key, int value) +{ + JSONContext *json = wctx->priv; + + if (wctx->nb_item) printf(",\n"); + printf(INDENT "\"%s\": %d", + json_escape_str(&json->buf, &json->buf_size, key, wctx), value); +} + +static void json_show_tags(WriterContext *wctx, AVDictionary *dict) +{ + AVDictionaryEntry *tag = NULL; + int is_first = 1; + if (!dict) + return; + printf(",\n" INDENT "\"tags\": {\n"); + while ((tag = av_dict_get(dict, "", tag, AV_DICT_IGNORE_SUFFIX))) { + if (is_first) is_first = 0; + else printf(",\n"); + json_print_item_str(wctx, tag->key, tag->value, INDENT INDENT); + } + printf("\n }"); +} + +static Writer json_writer = { + .name = "json", + .priv_size = sizeof(JSONContext), + + .init = json_init, + .uninit = json_uninit, + .print_header = json_print_header, + .print_footer = json_print_footer, + .print_chapter_header = json_print_chapter_header, + .print_chapter_footer = json_print_chapter_footer, + .print_section_header = json_print_section_header, + .print_section_footer = json_print_section_footer, + .print_integer = json_print_int, + .print_string = json_print_str, + .show_tags = json_show_tags, +}; + +static void writer_register_all(void) +{ + static int initialized; + + if (initialized) + return; + initialized = 1; + + writer_register(&default_writer); + writer_register(&json_writer); +} + +#define print_fmt(k, f, ...) do { \ + if (fast_asprintf(&pbuf, f, __VA_ARGS__)) \ + writer_print_string(w, k, pbuf.s); \ +} while (0) + +#define print_int(k, v) writer_print_integer(w, k, v) +#define print_str(k, v) writer_print_string(w, k, v) +#define print_section_header(s) writer_print_section_header(w, s) +#define print_section_footer(s) writer_print_section_footer(w, s) +#define show_tags(metadata) writer_show_tags(w, metadata) + +static void show_packet(WriterContext *w, AVFormatContext *fmt_ctx, AVPacket *pkt, int packet_idx) { char val_str[128]; AVStream *st = fmt_ctx->streams[pkt->stream_index]; struct print_buf pbuf = {.s = NULL}; - if (packet_idx) - printf("%s", w->items_sep); - w->print_header("PACKET"); - print_str0("codec_type", av_x_if_null(av_get_media_type_string(st->codec->codec_type), "unknown")); + print_section_header("packet"); + print_str("codec_type", av_x_if_null(av_get_media_type_string(st->codec->codec_type), "unknown")); print_int("stream_index", pkt->stream_index); print_str("pts", ts_value_string (val_str, sizeof(val_str), pkt->pts)); print_str("pts_time", time_value_string(val_str, sizeof(val_str), pkt->pts, &st->time_base)); @@ -319,12 +631,13 @@ print_str("size", value_string (val_str, sizeof(val_str), pkt->size, unit_byte_str)); print_fmt("pos", "%"PRId64, pkt->pos); print_fmt("flags", "%c", pkt->flags & AV_PKT_FLAG_KEY ? 'K' : '_'); - w->print_footer("PACKET"); + print_section_footer("packet"); + av_free(pbuf.s); fflush(stdout); } -static void show_packets(struct writer *w, AVFormatContext *fmt_ctx) +static void show_packets(WriterContext *w, AVFormatContext *fmt_ctx) { AVPacket pkt; int i = 0; @@ -335,39 +648,7 @@ show_packet(w, fmt_ctx, &pkt, i++); } -static void json_show_tags(struct writer *w, AVDictionary *dict) -{ - AVDictionaryEntry *tag = NULL; - struct print_buf pbuf = {.s = NULL}; - int first = 1; - - if (!dict) - return; - printf(",\n \"tags\": {\n"); - while ((tag = av_dict_get(dict, "", tag, AV_DICT_IGNORE_SUFFIX))) { - if (first) { - print_str0(tag->key, tag->value); - first = 0; - } else { - print_str(tag->key, tag->value); - } - } - printf("\n }"); - av_free(pbuf.s); -} - -static void default_show_tags(struct writer *w, AVDictionary *dict) -{ - AVDictionaryEntry *tag = NULL; - struct print_buf pbuf = {.s = NULL}; - while ((tag = av_dict_get(dict, "", tag, AV_DICT_IGNORE_SUFFIX))) { - printf("\nTAG:"); - print_str0(tag->key, tag->value); - } - av_free(pbuf.s); -} - -static void show_stream(struct writer *w, AVFormatContext *fmt_ctx, int stream_idx) +static void show_stream(WriterContext *w, AVFormatContext *fmt_ctx, int stream_idx) { AVStream *stream = fmt_ctx->streams[stream_idx]; AVCodecContext *dec_ctx; @@ -376,11 +657,9 @@ AVRational display_aspect_ratio; struct print_buf pbuf = {.s = NULL}; - if (stream_idx) - printf("%s", w->items_sep); - w->print_header("STREAM"); + print_section_header("stream"); - print_int0("index", stream->index); + print_int("index", stream->index); if ((dec_ctx = stream->codec)) { if ((dec = dec_ctx->codec)) { @@ -420,6 +699,8 @@ break; case AVMEDIA_TYPE_AUDIO: + print_str("sample_fmt", + av_x_if_null(av_get_sample_fmt_name(dec_ctx->sample_fmt), "unknown")); print_str("sample_rate", value_string(val_str, sizeof(val_str), dec_ctx->sample_rate, unit_hertz_str)); print_int("channels", dec_ctx->channels); print_int("bits_per_sample", av_get_bits_per_sample(dec_ctx->codec_id)); @@ -439,27 +720,27 @@ if (stream->nb_frames) print_fmt("nb_frames", "%"PRId64, stream->nb_frames); - w->show_tags(w, stream->metadata); + show_tags(stream->metadata); - w->print_footer("STREAM"); + print_section_footer("stream"); av_free(pbuf.s); fflush(stdout); } -static void show_streams(struct writer *w, AVFormatContext *fmt_ctx) +static void show_streams(WriterContext *w, AVFormatContext *fmt_ctx) { int i; for (i = 0; i < fmt_ctx->nb_streams; i++) show_stream(w, fmt_ctx, i); } -static void show_format(struct writer *w, AVFormatContext *fmt_ctx) +static void show_format(WriterContext *w, AVFormatContext *fmt_ctx) { char val_str[128]; struct print_buf pbuf = {.s = NULL}; - w->print_header("FORMAT"); - print_str0("filename", fmt_ctx->filename); + print_section_header("format"); + print_str("filename", fmt_ctx->filename); print_int("nb_streams", fmt_ctx->nb_streams); print_str("format_name", fmt_ctx->iformat->name); print_str("format_long_name", fmt_ctx->iformat->long_name); @@ -467,8 +748,8 @@ print_str("duration", time_value_string(val_str, sizeof(val_str), fmt_ctx->duration, &AV_TIME_BASE_Q)); print_str("size", value_string(val_str, sizeof(val_str), fmt_ctx->file_size, unit_byte_str)); print_str("bit_rate", value_string(val_str, sizeof(val_str), fmt_ctx->bit_rate, unit_bit_per_second_str)); - w->show_tags(w, fmt_ctx->metadata); - w->print_footer("FORMAT"); + show_tags(fmt_ctx->metadata); + print_section_footer("format"); av_free(pbuf.s); fflush(stdout); } @@ -515,84 +796,55 @@ return 0; } -#define WRITER_FUNC(func) \ - .print_header = func ## _print_header, \ - .print_footer = func ## _print_footer, \ - .print_integer = func ## _print_int, \ - .print_string = func ## _print_str, \ - .show_tags = func ## _show_tags - -static struct writer writers[] = {{ - .name = "default", - .item_sep = "\n", - .items_sep = "\n", - .section_sep = "\n", - .footer = "\n", - WRITER_FUNC(default), - },{ - .name = "json", - .header = "{", - .item_sep = ",\n", - .items_sep = ",", - .section_sep = ",", - .footer = "\n}\n", - .print_section_start = json_print_section_start, - .print_section_end = json_print_section_end, - WRITER_FUNC(json), - } -}; - -static int get_writer(const char *name) -{ - int i; - if (!name) - return 0; - for (i = 0; i < FF_ARRAY_ELEMS(writers); i++) - if (!strcmp(writers[i].name, name)) - return i; - return -1; -} - -#define SECTION_PRINT(name, multiple_entries, left) do { \ - if (do_show_ ## name) { \ - if (w->print_section_start) \ - w->print_section_start(#name, multiple_entries); \ - show_ ## name (w, fmt_ctx); \ - if (w->print_section_end) \ - w->print_section_end(#name, multiple_entries); \ - if (left) \ - printf("%s", w->section_sep); \ - } \ +#define PRINT_CHAPTER(name) do { \ + if (do_show_ ## name) { \ + writer_print_chapter_header(wctx, #name); \ + show_ ## name (wctx, fmt_ctx); \ + writer_print_chapter_footer(wctx, #name); \ + } \ } while (0) static int probe_file(const char *filename) { AVFormatContext *fmt_ctx; - int ret, writer_id; - struct writer *w; - - writer_id = get_writer(print_format); - if (writer_id < 0) { - fprintf(stderr, "Invalid output format '%s'\n", print_format); - return AVERROR(EINVAL); + int ret; + Writer *w; + char *buf; + char *w_name = NULL, *w_args = NULL; + WriterContext *wctx; + + writer_register_all(); + + if (!print_format) + print_format = av_strdup("default"); + w_name = av_strtok(print_format, "=", &buf); + w_args = buf; + + w = writer_get_by_name(w_name); + if (!w) { + av_log(NULL, AV_LOG_ERROR, "Unknown output format with name '%s'\n", w_name); + ret = AVERROR(EINVAL); + goto end; } - w = &writers[writer_id]; + if ((ret = writer_open(&wctx, w, w_args, NULL)) < 0) + goto end; if ((ret = open_input_file(&fmt_ctx, filename))) - return ret; + goto end; - if (w->header) - printf("%s", w->header); + writer_print_header(wctx); + PRINT_CHAPTER(packets); + PRINT_CHAPTER(streams); + PRINT_CHAPTER(format); + writer_print_footer(wctx); - SECTION_PRINT(packets, 1, do_show_streams || do_show_format); - SECTION_PRINT(streams, 1, do_show_format); - SECTION_PRINT(format, 0, 0); + av_close_input_file(fmt_ctx); + writer_close(&wctx); - if (w->footer) - printf("%s", w->footer); +end: + av_freep(&print_format); - av_close_input_file(fmt_ctx); - return 0; + return ret; } static void show_usage(void) @@ -626,13 +878,13 @@ static int opt_help(const char *opt, const char *arg) { - const AVClass *class = avformat_get_class(); av_log_set_callback(log_callback_help); show_usage(); show_help_options(options, "Main options:\n", 0, 0); printf("\n"); - av_opt_show2(&class, NULL, - AV_OPT_FLAG_DECODING_PARAM, 0); + + show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM); + return 0; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/ffserver.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/ffserver.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/ffserver.c 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/ffserver.c 2011-11-04 12:38:26.000000000 +0000 @@ -3169,8 +3169,8 @@ switch(rtp_c->rtp_protocol) { case RTSP_LOWER_TRANSPORT_UDP: - rtp_port = rtp_get_local_rtp_port(rtp_c->rtp_handles[stream_index]); - rtcp_port = rtp_get_local_rtcp_port(rtp_c->rtp_handles[stream_index]); + rtp_port = ff_rtp_get_local_rtp_port(rtp_c->rtp_handles[stream_index]); + rtcp_port = ff_rtp_get_local_rtcp_port(rtp_c->rtp_handles[stream_index]); avio_printf(c->pb, "Transport: RTP/AVP/UDP;unicast;" "client_port=%d-%d;server_port=%d-%d", th->client_port_min, th->client_port_max, @@ -3938,7 +3938,7 @@ int ret = 0; const AVOption *o = av_opt_find(avctx, opt, NULL, type, 0); if(o) - ret = av_set_string3(avctx, opt, arg, 1, NULL); + ret = av_opt_set(avctx, opt, arg, 0); return ret; } @@ -4236,6 +4236,7 @@ stream->fmt = ffserver_guess_format(NULL, stream->filename, NULL); avcodec_get_context_defaults2(&video_enc, AVMEDIA_TYPE_VIDEO); avcodec_get_context_defaults2(&audio_enc, AVMEDIA_TYPE_AUDIO); + audio_id = CODEC_ID_NONE; video_id = CODEC_ID_NONE; if (stream->fmt) { diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/4xm.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/4xm.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/4xm.c 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/4xm.c 2011-11-04 12:38:26.000000000 +0000 @@ -279,7 +279,7 @@ } #endif -static inline void mcdc(uint16_t *dst, uint16_t *src, int log2w, int h, int stride, int scale, int dc){ +static inline void mcdc(uint16_t *dst, uint16_t *src, int log2w, int h, int stride, int scale, unsigned dc){ int i; dc*= 0x10001; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/aacadtsdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/aacadtsdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/aacadtsdec.c 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/aacadtsdec.c 2011-11-04 12:38:26.000000000 +0000 @@ -26,7 +26,7 @@ #include "get_bits.h" #include "mpeg4audio.h" -int ff_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr) +int avpriv_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr) { int size, rdb, ch, sr; int aot, crc_abs; @@ -39,7 +39,7 @@ crc_abs = get_bits1(gbc); /* protection_absent */ aot = get_bits(gbc, 2); /* profile_objecttype */ sr = get_bits(gbc, 4); /* sample_frequency_index */ - if(!ff_mpeg4audio_sample_rates[sr]) + if(!avpriv_mpeg4audio_sample_rates[sr]) return AAC_AC3_PARSE_ERROR_SAMPLE_RATE; skip_bits1(gbc); /* private_bit */ ch = get_bits(gbc, 3); /* channel_configuration */ @@ -62,7 +62,7 @@ hdr->crc_absent = crc_abs; hdr->num_aac_frames = rdb + 1; hdr->sampling_index = sr; - hdr->sample_rate = ff_mpeg4audio_sample_rates[sr]; + hdr->sample_rate = avpriv_mpeg4audio_sample_rates[sr]; hdr->samples = (rdb + 1) * 1024; hdr->bit_rate = size * 8 * hdr->sample_rate / hdr->samples; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/aacadtsdec.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/aacadtsdec.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/aacadtsdec.h 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/aacadtsdec.h 2011-11-04 12:38:26.000000000 +0000 @@ -49,6 +49,6 @@ * -2 if the version element is invalid, -3 if the sample rate * element is invalid, or -4 if the bit rate element is invalid. */ -int ff_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr); +int avpriv_aac_parse_header(GetBitContext *gbc, AACADTSHeaderInfo *hdr); #endif /* AVCODEC_AACADTSDEC_H */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/aac_adtstoasc_bsf.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/aac_adtstoasc_bsf.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/aac_adtstoasc_bsf.c 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/aac_adtstoasc_bsf.c 2011-11-04 12:38:26.000000000 +0000 @@ -55,7 +55,7 @@ if (show_bits(&gb, 12) != 0xfff) return 0; - if (ff_aac_parse_header(&gb, &hdr) < 0) { + if (avpriv_aac_parse_header(&gb, &hdr) < 0) { av_log(avctx, AV_LOG_ERROR, "Error parsing ADTS frame header!\n"); return -1; } @@ -78,7 +78,7 @@ return -1; } init_put_bits(&pb, pce_data, MAX_PCE_SIZE); - pce_size = ff_copy_pce_data(&pb, &gb)/8; + pce_size = avpriv_copy_pce_data(&pb, &gb)/8; flush_put_bits(&pb); buf_size -= get_bits_count(&gb)/8; buf += get_bits_count(&gb)/8; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/aacdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/aacdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/aacdec.c 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/aacdec.c 2011-11-04 12:38:26.000000000 +0000 @@ -184,9 +184,11 @@ int type, int id, int *channels) { if (che_pos[type][id]) { - if (!ac->che[type][id] && !(ac->che[type][id] = av_mallocz(sizeof(ChannelElement)))) - return AVERROR(ENOMEM); - ff_aac_sbr_ctx_init(ac, &ac->che[type][id]->sbr); + if (!ac->che[type][id]) { + if (!(ac->che[type][id] = av_mallocz(sizeof(ChannelElement)))) + return AVERROR(ENOMEM); + ff_aac_sbr_ctx_init(ac, &ac->che[type][id]->sbr); + } if (type != TYPE_CCE) { ac->output_data[(*channels)++] = ac->che[type][id]->ch[0].ret; if (type == TYPE_CPE || @@ -472,7 +474,7 @@ init_get_bits(&gb, data, data_size * 8); - if ((i = ff_mpeg4audio_get_config(m4ac, data, asclen/8)) < 0) + if ((i = avpriv_mpeg4audio_get_config(m4ac, data, asclen/8)) < 0) return -1; if (m4ac->sampling_index > 12) { av_log(avctx, AV_LOG_ERROR, "invalid sampling rate index %d\n", m4ac->sampling_index); @@ -596,7 +598,7 @@ int ret = set_default_channel_config(avctx, new_che_pos, ac->m4ac.chan_config); if (!ret) output_configure(ac, ac->che_pos, new_che_pos, ac->m4ac.chan_config, OC_GLOBAL_HDR); - else if (avctx->error_recognition >= FF_ER_EXPLODE) + else if (avctx->err_recognition & AV_EF_EXPLODE) return AVERROR_INVALIDDATA; } } @@ -1131,7 +1133,7 @@ GET_VLC(code, re, gb, vlc_tab, 8, 2); cb_idx = cb_vector_idx[code]; nnz = cb_idx >> 8 & 15; - bits = SHOW_UBITS(re, gb, nnz) << (32-nnz); + bits = nnz ? GET_CACHE(re, gb) : 0; LAST_SKIP_BITS(re, gb, nnz); cf = VMUL4S(cf, vq, cb_idx, bits, sf + idx); } while (len -= 4); @@ -1171,7 +1173,7 @@ GET_VLC(code, re, gb, vlc_tab, 8, 2); cb_idx = cb_vector_idx[code]; nnz = cb_idx >> 8 & 15; - sign = SHOW_UBITS(re, gb, nnz) << (cb_idx >> 12); + sign = nnz ? SHOW_UBITS(re, gb, nnz) << (cb_idx >> 12) : 0; LAST_SKIP_BITS(re, gb, nnz); cf = VMUL2S(cf, vq, cb_idx, sign, sf + idx); } while (len -= 2); @@ -2077,7 +2079,7 @@ int size; AACADTSHeaderInfo hdr_info; - size = ff_aac_parse_header(gb, &hdr_info); + size = avpriv_aac_parse_header(gb, &hdr_info); if (size > 0) { if (hdr_info.chan_config) { enum ChannelPosition new_che_pos[4][MAX_ELEM_ID]; @@ -2137,6 +2139,15 @@ elem_id = get_bits(gb, 4); if (elem_type < TYPE_DSE) { + if (!ac->tags_mapped && elem_type == TYPE_CPE && ac->m4ac.chan_config==1) { + enum ChannelPosition new_che_pos[4][MAX_ELEM_ID]= {0}; + ac->m4ac.chan_config=2; + + if (set_default_channel_config(ac->avctx, new_che_pos, 2)<0) + return -1; + if (output_configure(ac, ac->che_pos, new_che_pos, 2, OC_TRIAL_FRAME)<0) + return -1; + } if (!(che=get_che(ac, elem_type, elem_id))) { av_log(ac->avctx, AV_LOG_ERROR, "channel element %d.%d is not allocated\n", elem_type, elem_id); @@ -2312,8 +2323,8 @@ GetBitContext *gb, int asclen) { AVCodecContext *avctx = latmctx->aac_ctx.avctx; - MPEG4AudioConfig m4ac; AACContext *ac= &latmctx->aac_ctx; + MPEG4AudioConfig m4ac=ac->m4ac; int config_start_bit = get_bits_count(gb); int bits_consumed, esize; @@ -2329,7 +2340,8 @@ if (bits_consumed < 0) return AVERROR_INVALIDDATA; - ac->m4ac= m4ac; + if(ac->m4ac.sample_rate != m4ac.sample_rate || m4ac.chan_config != ac->m4ac.chan_config) + ac->m4ac= m4ac; esize = (bits_consumed+7) / 8; @@ -2489,9 +2501,6 @@ int muxlength, err; GetBitContext gb; - if (avpkt->size == 0) - return 0; - init_get_bits(&gb, avpkt->data, avpkt->size * 8); // check for LOAS sync word @@ -2511,8 +2520,9 @@ *out_size = 0; return avpkt->size; } else { - aac_decode_close(avctx); - if ((err = aac_decode_init(avctx)) < 0) + if ((err = decode_audio_specific_config( + &latmctx->aac_ctx, avctx, &latmctx->aac_ctx.m4ac, + avctx->extradata, avctx->extradata_size, 8*avctx->extradata_size)) < 0) return err; latmctx->initialized = 1; } @@ -2534,15 +2544,10 @@ av_cold static int latm_decode_init(AVCodecContext *avctx) { struct LATMContext *latmctx = avctx->priv_data; - int ret; - - ret = aac_decode_init(avctx); + int ret = aac_decode_init(avctx); - if (avctx->extradata_size > 0) { + if (avctx->extradata_size > 0) latmctx->initialized = !ret; - } else { - latmctx->initialized = 0; - } return ret; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/aacenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/aacenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/aacenc.c 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/aacenc.c 2011-11-04 12:38:26.000000000 +0000 @@ -180,7 +180,7 @@ avctx->frame_size = 1024; for (i = 0; i < 16; i++) - if (avctx->sample_rate == ff_mpeg4audio_sample_rates[i]) + if (avctx->sample_rate == avpriv_mpeg4audio_sample_rates[i]) break; if (i == 16) { av_log(avctx, AV_LOG_ERROR, "Unsupported sample rate %d\n", avctx->sample_rate); @@ -491,7 +491,7 @@ put_bits(&s->pb, 8, namelen - 16); put_bits(&s->pb, 4, 0); //extension type - filler padbits = 8 - (put_bits_count(&s->pb) & 7); - align_put_bits(&s->pb); + avpriv_align_put_bits(&s->pb); for (i = 0; i < namelen - 2; i++) put_bits(&s->pb, 8, name[i]); put_bits(&s->pb, 12 - padbits, 0); @@ -686,10 +686,10 @@ #define AACENC_FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM static const AVOption aacenc_options[] = { - {"stereo_mode", "Stereo coding method", offsetof(AACEncContext, options.stereo_mode), FF_OPT_TYPE_INT, {.dbl = 0}, -1, 1, AACENC_FLAGS, "stereo_mode"}, - {"auto", "Selected by the Encoder", 0, FF_OPT_TYPE_CONST, {.dbl = -1 }, INT_MIN, INT_MAX, AACENC_FLAGS, "stereo_mode"}, - {"ms_off", "Disable Mid/Side coding", 0, FF_OPT_TYPE_CONST, {.dbl = 0 }, INT_MIN, INT_MAX, AACENC_FLAGS, "stereo_mode"}, - {"ms_force", "Force Mid/Side for the whole frame if possible", 0, FF_OPT_TYPE_CONST, {.dbl = 1 }, INT_MIN, INT_MAX, AACENC_FLAGS, "stereo_mode"}, + {"stereo_mode", "Stereo coding method", offsetof(AACEncContext, options.stereo_mode), AV_OPT_TYPE_INT, {.dbl = 0}, -1, 1, AACENC_FLAGS, "stereo_mode"}, + {"auto", "Selected by the Encoder", 0, AV_OPT_TYPE_CONST, {.dbl = -1 }, INT_MIN, INT_MAX, AACENC_FLAGS, "stereo_mode"}, + {"ms_off", "Disable Mid/Side coding", 0, AV_OPT_TYPE_CONST, {.dbl = 0 }, INT_MIN, INT_MAX, AACENC_FLAGS, "stereo_mode"}, + {"ms_force", "Force Mid/Side for the whole frame if possible", 0, AV_OPT_TYPE_CONST, {.dbl = 1 }, INT_MIN, INT_MAX, AACENC_FLAGS, "stereo_mode"}, {NULL} }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/aac_parser.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/aac_parser.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/aac_parser.c 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/aac_parser.c 2011-11-04 12:38:26.000000000 +0000 @@ -40,7 +40,7 @@ tmp.u64 = av_be2ne64(state); init_get_bits(&bits, tmp.u8+8-AAC_ADTS_HEADER_SIZE, AAC_ADTS_HEADER_SIZE * 8); - if ((size = ff_aac_parse_header(&bits, &hdr)) < 0) + if ((size = avpriv_aac_parse_header(&bits, &hdr)) < 0) return 0; *need_next_header = 0; *new_frame_start = 1; @@ -61,9 +61,9 @@ AVCodecParser ff_aac_parser = { - { CODEC_ID_AAC }, - sizeof(AACAC3ParseContext), - aac_parse_init, - ff_aac_ac3_parse, - ff_parse_close, + .codec_ids = { CODEC_ID_AAC }, + .priv_data_size = sizeof(AACAC3ParseContext), + .parser_init = aac_parse_init, + .parser_parse = ff_aac_ac3_parse, + .parser_close = ff_parse_close, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ac3dec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ac3dec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ac3dec.c 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ac3dec.c 2011-11-04 12:38:26.000000000 +0000 @@ -261,7 +261,7 @@ AC3HeaderInfo hdr; int err; - err = ff_ac3_parse_header(&s->gbc, &hdr); + err = avpriv_ac3_parse_header(&s->gbc, &hdr); if(err) return err; @@ -505,9 +505,9 @@ mantissa = b5_mantissas[get_bits(gbc, 4)]; break; default: /* 6 to 15 */ - mantissa = get_bits(gbc, quantization_tab[bap]); /* Shift mantissa and sign-extend it. */ - mantissa = (mantissa << (32-quantization_tab[bap]))>>8; + mantissa = get_sbits(gbc, quantization_tab[bap]); + mantissa <<= 24 - quantization_tab[bap]; break; } coeffs[freq] = mantissa >> exps[freq]; @@ -1359,7 +1359,7 @@ if (s->frame_size > buf_size) { av_log(avctx, AV_LOG_ERROR, "incomplete frame\n"); err = AAC_AC3_PARSE_ERROR_FRAME_SIZE; - } else if (avctx->error_recognition >= FF_ER_CAREFUL) { + } else if (avctx->err_recognition & AV_EF_CRCCHECK) { /* check for crc mismatch */ if (av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, &buf[2], s->frame_size-2)) { av_log(avctx, AV_LOG_ERROR, "frame CRC mismatch\n"); @@ -1451,13 +1451,13 @@ #define OFFSET(x) offsetof(AC3DecodeContext, x) #define PAR (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM) static const AVOption options[] = { - { "drc_scale", "percentage of dynamic range compression to apply", OFFSET(drc_scale), FF_OPT_TYPE_FLOAT, {1.0}, 0.0, 1.0, PAR }, + { "drc_scale", "percentage of dynamic range compression to apply", OFFSET(drc_scale), AV_OPT_TYPE_FLOAT, {1.0}, 0.0, 1.0, PAR }, -{"dmix_mode", "Preferred Stereo Downmix Mode", OFFSET(preferred_stereo_downmix), FF_OPT_TYPE_INT, {.dbl = -1 }, -1, 2, 0, "dmix_mode"}, -{"ltrt_cmixlev", "Lt/Rt Center Mix Level", OFFSET(ltrt_center_mix_level), FF_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, 0}, -{"ltrt_surmixlev", "Lt/Rt Surround Mix Level", OFFSET(ltrt_surround_mix_level), FF_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, 0}, -{"loro_cmixlev", "Lo/Ro Center Mix Level", OFFSET(loro_center_mix_level), FF_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, 0}, -{"loro_surmixlev", "Lo/Ro Surround Mix Level", OFFSET(loro_surround_mix_level), FF_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, 0}, +{"dmix_mode", "Preferred Stereo Downmix Mode", OFFSET(preferred_stereo_downmix), AV_OPT_TYPE_INT, {.dbl = -1 }, -1, 2, 0, "dmix_mode"}, +{"ltrt_cmixlev", "Lt/Rt Center Mix Level", OFFSET(ltrt_center_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, 0}, +{"ltrt_surmixlev", "Lt/Rt Surround Mix Level", OFFSET(ltrt_surround_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, 0}, +{"loro_cmixlev", "Lo/Ro Center Mix Level", OFFSET(loro_center_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, 0}, +{"loro_surmixlev", "Lo/Ro Surround Mix Level", OFFSET(loro_surround_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, 0}, { NULL}, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ac3dsp.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ac3dsp.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ac3dsp.c 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ac3dsp.c 2011-11-04 12:38:26.000000000 +0000 @@ -23,6 +23,7 @@ #include "avcodec.h" #include "ac3.h" #include "ac3dsp.h" +#include "mathops.h" static void ac3_exponent_min_c(uint8_t *exp, int num_reuse_blocks, int nb_coefs) { @@ -169,6 +170,48 @@ } } +static void ac3_sum_square_butterfly_int32_c(int64_t sum[4], + const int32_t *coef0, + const int32_t *coef1, + int len) +{ + int i; + + sum[0] = sum[1] = sum[2] = sum[3] = 0; + + for (i = 0; i < len; i++) { + int lt = coef0[i]; + int rt = coef1[i]; + int md = lt + rt; + int sd = lt - rt; + MAC64(sum[0], lt, lt); + MAC64(sum[1], rt, rt); + MAC64(sum[2], md, md); + MAC64(sum[3], sd, sd); + } +} + +static void ac3_sum_square_butterfly_float_c(float sum[4], + const float *coef0, + const float *coef1, + int len) +{ + int i; + + sum[0] = sum[1] = sum[2] = sum[3] = 0; + + for (i = 0; i < len; i++) { + float lt = coef0[i]; + float rt = coef1[i]; + float md = lt + rt; + float sd = lt - rt; + sum[0] += lt * lt; + sum[1] += rt * rt; + sum[2] += md * md; + sum[3] += sd * sd; + } +} + av_cold void ff_ac3dsp_init(AC3DSPContext *c, int bit_exact) { c->ac3_exponent_min = ac3_exponent_min_c; @@ -180,6 +223,8 @@ c->update_bap_counts = ac3_update_bap_counts_c; c->compute_mantissa_size = ac3_compute_mantissa_size_c; c->extract_exponents = ac3_extract_exponents_c; + c->sum_square_butterfly_int32 = ac3_sum_square_butterfly_int32_c; + c->sum_square_butterfly_float = ac3_sum_square_butterfly_float_c; if (ARCH_ARM) ff_ac3dsp_init_arm(c, bit_exact); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ac3dsp.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ac3dsp.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ac3dsp.h 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ac3dsp.h 2011-11-04 12:38:26.000000000 +0000 @@ -125,6 +125,12 @@ int (*compute_mantissa_size)(uint16_t mant_cnt[6][16]); void (*extract_exponents)(uint8_t *exp, int32_t *coef, int nb_coefs); + + void (*sum_square_butterfly_int32)(int64_t sum[4], const int32_t *coef0, + const int32_t *coef1, int len); + + void (*sum_square_butterfly_float)(float sum[4], const float *coef0, + const float *coef1, int len); } AC3DSPContext; void ff_ac3dsp_init (AC3DSPContext *c, int bit_exact); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ac3enc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ac3enc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ac3enc.c 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ac3enc.c 2011-11-04 12:38:26.000000000 +0000 @@ -176,6 +176,8 @@ /** * Adjust the frame size to make the average bit rate match the target bit rate. * This is only needed for 11025, 22050, and 44100 sample rates or any E-AC-3. + * + * @param s AC-3 encoder private context */ void ff_ac3_adjust_frame_size(AC3EncodeContext *s) { @@ -190,6 +192,11 @@ } +/** + * Set the initial coupling strategy parameters prior to coupling analysis. + * + * @param s AC-3 encoder private context + */ void ff_ac3_compute_coupling_strategy(AC3EncodeContext *s) { int blk, ch; @@ -258,6 +265,8 @@ /** * Apply stereo rematrixing to coefficients based on rematrixing flags. + * + * @param s AC-3 encoder private context */ void ff_ac3_apply_rematrixing(AC3EncodeContext *s) { @@ -290,7 +299,7 @@ } -/** +/* * Initialize exponent tables. */ static av_cold void exponent_init(AC3EncodeContext *s) @@ -312,7 +321,7 @@ } -/** +/* * Extract exponents from the MDCT coefficients. */ static void extract_exponents(AC3EncodeContext *s) @@ -341,7 +350,7 @@ { EXP_D45, EXP_D25, EXP_D25, EXP_D15, EXP_D15, EXP_D15 } }; -/** +/* * Calculate exponent strategies for all channels. * Array arrangement is reversed to simplify the per-channel calculation. */ @@ -405,6 +414,11 @@ /** * Update the exponents so that they are the ones the decoder will decode. + * + * @param[in,out] exp array of exponents for 1 block in 1 channel + * @param nb_exps number of exponents in active bandwidth + * @param exp_strategy exponent strategy for the block + * @param cpl indicates if the block is in the coupling channel */ static void encode_exponents_blk_ch(uint8_t *exp, int nb_exps, int exp_strategy, int cpl) @@ -473,7 +487,7 @@ } -/** +/* * Encode exponents from original extracted form to what the decoder will see. * This copies and groups exponents based on exponent strategy and reduces * deltas between adjacent exponent groups so that they can be differentially @@ -526,7 +540,7 @@ } -/** +/* * Count exponent bits based on bandwidth, coupling, and exponent strategies. */ static int count_exponent_bits(AC3EncodeContext *s) @@ -558,6 +572,8 @@ * Group exponents. * 3 delta-encoded exponents are in each 7-bit group. The number of groups * varies depending on exponent strategy and bandwidth. + * + * @param s AC-3 encoder private context */ void ff_ac3_group_exponents(AC3EncodeContext *s) { @@ -614,6 +630,8 @@ * Calculate final exponents from the supplied MDCT coefficients and exponent shift. * Extract exponents from MDCT coefficients, calculate exponent strategies, * and encode final exponents. + * + * @param s AC-3 encoder private context */ void ff_ac3_process_exponents(AC3EncodeContext *s) { @@ -627,7 +645,7 @@ } -/** +/* * Count frame bits that are based solely on fixed parameters. * This only has to be run once when the encoder is initialized. */ @@ -733,7 +751,7 @@ } -/** +/* * Initialize bit allocation. * Set default parameter codes and calculate parameter values. */ @@ -768,7 +786,7 @@ } -/** +/* * Count the bits used to encode the frame, minus exponents and mantissas. * Bits based on fixed parameters have already been counted, so now we just * have to add the bits based on parameters that change during encoding. @@ -915,7 +933,7 @@ } -/** +/* * Calculate masking curve based on the final exponents. * Also calculate the power spectral densities to use in future calculations. */ @@ -945,7 +963,7 @@ } -/** +/* * Ensure that bap for each block and channel point to the current bap_buffer. * They may have been switched during the bit allocation search. */ @@ -971,6 +989,8 @@ * Initialize mantissa counts. * These are set so that they are padded to the next whole group size when bits * are counted in compute_mantissa_size. + * + * @param[in,out] mant_cnt running counts for each bap value for each block */ static void count_mantissa_bits_init(uint16_t mant_cnt[AC3_MAX_BLOCKS][16]) { @@ -987,6 +1007,12 @@ /** * Update mantissa bit counts for all blocks in 1 channel in a given bandwidth * range. + * + * @param s AC-3 encoder private context + * @param ch channel index + * @param[in,out] mant_cnt running counts for each bap value for each block + * @param start starting coefficient bin + * @param end ending coefficient bin */ static void count_mantissa_bits_update_ch(AC3EncodeContext *s, int ch, uint16_t mant_cnt[AC3_MAX_BLOCKS][16], @@ -1005,7 +1031,7 @@ } -/** +/* * Count the number of mantissa bits in the frame based on the bap values. */ static int count_mantissa_bits(AC3EncodeContext *s) @@ -1028,6 +1054,9 @@ * Run the bit allocation with a given SNR offset. * This calculates the bit allocation pointers that will be used to determine * the quantization of each mantissa. + * + * @param s AC-3 encoder private context + * @param snr_offset SNR offset, 0 to 1023 * @return the number of bits needed for mantissas if the given SNR offset is * is used. */ @@ -1058,7 +1087,7 @@ } -/** +/* * Constant bitrate bit allocation search. * Find the largest SNR offset that will allow data to fit in the frame. */ @@ -1107,7 +1136,7 @@ } -/** +/* * Perform bit allocation search. * Finds the SNR offset value that maximizes quality and fits in the specified * frame size. Output is the SNR offset and a set of bit allocation pointers @@ -1127,6 +1156,11 @@ /** * Symmetric quantization on 'levels' levels. + * + * @param c unquantized coefficient + * @param e exponent + * @param levels number of quantization levels + * @return quantized coefficient */ static inline int sym_quant(int c, int e, int levels) { @@ -1138,6 +1172,11 @@ /** * Asymmetric quantization on 2^qbits levels. + * + * @param c unquantized coefficient + * @param e exponent + * @param qbits number of quantization bits + * @return quantized coefficient */ static inline int asym_quant(int c, int e, int qbits) { @@ -1154,6 +1193,14 @@ /** * Quantize a set of mantissas for a single channel in a single block. + * + * @param s Mantissa count context + * @param fixed_coef unquantized fixed-point coefficients + * @param exp exponents + * @param bap bit allocation pointer indices + * @param[out] qmant quantized coefficients + * @param start_freq starting coefficient bin + * @param end_freq ending coefficient bin */ static void quantize_mantissas_blk_ch(AC3Mant *s, int32_t *fixed_coef, uint8_t *exp, uint8_t *bap, @@ -1163,14 +1210,11 @@ int i; for (i = start_freq; i < end_freq; i++) { - int v; int c = fixed_coef[i]; int e = exp[i]; - int b = bap[i]; - switch (b) { - case 0: - v = 0; - break; + int v = bap[i]; + if (v) + switch (v) { case 1: v = sym_quant(c, e, 3); switch (s->mant1_cnt) { @@ -1239,7 +1283,7 @@ v = asym_quant(c, e, 16); break; default: - v = asym_quant(c, e, b - 1); + v = asym_quant(c, e, v - 1); break; } qmant[i] = v; @@ -1249,6 +1293,8 @@ /** * Quantize mantissas using coefficients, exponents, and bit allocation pointers. + * + * @param s AC-3 encoder private context */ void ff_ac3_quantize_mantissas(AC3EncodeContext *s) { @@ -1276,7 +1322,7 @@ } -/** +/* * Write the AC-3 frame header to the output bitstream. */ static void ac3_output_frame_header(AC3EncodeContext *s) @@ -1332,7 +1378,7 @@ } -/** +/* * Write one audio block to the output bitstream. */ static void output_audio_block(AC3EncodeContext *s, int blk) @@ -1560,7 +1606,7 @@ } -/** +/* * Fill the end of the frame with 0's and compute the two CRCs. */ static void output_frame_end(AC3EncodeContext *s) @@ -1608,6 +1654,9 @@ /** * Write the frame to the output bitstream. + * + * @param s AC-3 encoder private context + * @param frame output data buffer */ void ff_ac3_output_frame(AC3EncodeContext *s, unsigned char *frame) { @@ -1778,6 +1827,8 @@ /** * Validate metadata options as set by AVOption system. * These values can optionally be changed per-frame. + * + * @param s AC-3 encoder private context */ int ff_ac3_validate_metadata(AC3EncodeContext *s) { @@ -1960,6 +2011,8 @@ /** * Finalize encoding and free any memory allocated by the encoder. + * + * @param avctx Codec context */ av_cold int ff_ac3_encode_close(AVCodecContext *avctx) { @@ -2003,7 +2056,7 @@ } -/** +/* * Set channel information during initialization. */ static av_cold int set_channel_info(AC3EncodeContext *s, int channels, @@ -2173,7 +2226,7 @@ } -/** +/* * Set bandwidth for all channels. * The user can optionally supply a cutoff frequency. Otherwise an appropriate * default value will be used. @@ -2351,9 +2404,6 @@ } -/** - * Initialize the encoder. - */ av_cold int ff_ac3_encode_init(AVCodecContext *avctx) { AC3EncodeContext *s = avctx->priv_data; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ac3enc_fixed.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ac3enc_fixed.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ac3enc_fixed.c 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ac3enc_fixed.c 2011-11-04 12:38:26.000000000 +0000 @@ -41,6 +41,8 @@ /** * Finalize MDCT and free allocated memory. + * + * @param s AC-3 encoder private context */ av_cold void AC3_NAME(mdct_end)(AC3EncodeContext *s) { @@ -50,7 +52,9 @@ /** * Initialize MDCT tables. - * @param nbits log2(MDCT size) + * + * @param s AC-3 encoder private context + * @return 0 on success, negative error code on failure */ av_cold int AC3_NAME(mdct_init)(AC3EncodeContext *s) { @@ -60,7 +64,7 @@ } -/** +/* * Apply KBD window to input samples prior to MDCT. */ static void apply_window(DSPContext *dsp, int16_t *output, const int16_t *input, @@ -70,11 +74,9 @@ } -/** +/* * Normalize the input samples to use the maximum available precision. * This assumes signed 16-bit input samples. - * - * @return exponent shift */ static int normalize_samples(AC3EncodeContext *s) { @@ -87,7 +89,7 @@ } -/** +/* * Scale MDCT coefficients to 25-bit signed fixed-point. */ static void scale_coefficients(AC3EncodeContext *s) @@ -103,8 +105,14 @@ } } +static void sum_square_butterfly(AC3EncodeContext *s, int64_t sum[4], + const int32_t *coef0, const int32_t *coef1, + int len) +{ + s->ac3dsp.sum_square_butterfly_int32(sum, coef0, coef1, len); +} -/** +/* * Clip MDCT coefficients to allowable range. */ static void clip_coefficients(DSPContext *dsp, int32_t *coef, unsigned int len) @@ -113,7 +121,7 @@ } -/** +/* * Calculate a single coupling coordinate. */ static CoefType calc_cpl_coord(CoefSumType energy_ch, CoefSumType energy_cpl) diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ac3enc_float.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ac3enc_float.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ac3enc_float.c 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ac3enc_float.c 2011-11-04 12:38:26.000000000 +0000 @@ -44,6 +44,8 @@ /** * Finalize MDCT and free allocated memory. + * + * @param s AC-3 encoder private context */ av_cold void ff_ac3_float_mdct_end(AC3EncodeContext *s) { @@ -54,7 +56,9 @@ /** * Initialize MDCT tables. - * @param nbits log2(MDCT size) + * + * @param s AC-3 encoder private context + * @return 0 on success, negative error code on failure */ av_cold int ff_ac3_float_mdct_init(AC3EncodeContext *s) { @@ -78,7 +82,7 @@ } -/** +/* * Apply KBD window to input samples prior to MDCT. */ static void apply_window(DSPContext *dsp, float *output, const float *input, @@ -88,7 +92,7 @@ } -/** +/* * Normalize the input samples. * Not needed for the floating-point encoder. */ @@ -98,7 +102,7 @@ } -/** +/* * Scale MDCT coefficients from float to 24-bit fixed-point. */ static void scale_coefficients(AC3EncodeContext *s) @@ -110,8 +114,14 @@ chan_size * (s->channels + cpl)); } +static void sum_square_butterfly(AC3EncodeContext *s, float sum[4], + const float *coef0, const float *coef1, + int len) +{ + s->ac3dsp.sum_square_butterfly_float(sum, coef0, coef1, len); +} -/** +/* * Clip MDCT coefficients to allowable range. */ static void clip_coefficients(DSPContext *dsp, float *coef, unsigned int len) @@ -120,7 +130,7 @@ } -/** +/* * Calculate a single coupling coordinate. */ static CoefType calc_cpl_coord(CoefSumType energy_ch, CoefSumType energy_cpl) diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ac3enc.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ac3enc.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ac3enc.h 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ac3enc.h 2011-11-04 12:38:26.000000000 +0000 @@ -73,8 +73,8 @@ #define AC3ENC_OPT_OFF 0 #define AC3ENC_OPT_ON 1 #define AC3ENC_OPT_NOT_INDICATED 0 -#define AC3ENC_OPT_MODE_ON 1 -#define AC3ENC_OPT_MODE_OFF 2 +#define AC3ENC_OPT_MODE_ON 2 +#define AC3ENC_OPT_MODE_OFF 1 /* specific option values */ #define AC3ENC_OPT_LARGE_ROOM 1 diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ac3enc_opts_template.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ac3enc_opts_template.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ac3enc_opts_template.c 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ac3enc_opts_template.c 2011-11-04 12:38:26.000000000 +0000 @@ -30,51 +30,51 @@ static const AVOption eac3_options[] = { #endif /* Metadata Options */ -{"per_frame_metadata", "Allow Changing Metadata Per-Frame", OFFSET(allow_per_frame_metadata), FF_OPT_TYPE_INT, {.dbl = 0 }, 0, 1, AC3ENC_PARAM}, +{"per_frame_metadata", "Allow Changing Metadata Per-Frame", OFFSET(allow_per_frame_metadata), AV_OPT_TYPE_INT, {.dbl = 0 }, 0, 1, AC3ENC_PARAM}, #if AC3ENC_TYPE != AC3ENC_TYPE_EAC3 /* AC-3 downmix levels */ -{"center_mixlev", "Center Mix Level", OFFSET(center_mix_level), FF_OPT_TYPE_FLOAT, {.dbl = LEVEL_MINUS_4POINT5DB }, 0.0, 1.0, AC3ENC_PARAM}, -{"surround_mixlev", "Surround Mix Level", OFFSET(surround_mix_level), FF_OPT_TYPE_FLOAT, {.dbl = LEVEL_MINUS_6DB }, 0.0, 1.0, AC3ENC_PARAM}, +{"center_mixlev", "Center Mix Level", OFFSET(center_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = LEVEL_MINUS_4POINT5DB }, 0.0, 1.0, AC3ENC_PARAM}, +{"surround_mixlev", "Surround Mix Level", OFFSET(surround_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = LEVEL_MINUS_6DB }, 0.0, 1.0, AC3ENC_PARAM}, #endif /* audio production information */ -{"mixing_level", "Mixing Level", OFFSET(mixing_level), FF_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, 111, AC3ENC_PARAM}, -{"room_type", "Room Type", OFFSET(room_type), FF_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, AC3ENC_OPT_SMALL_ROOM, AC3ENC_PARAM, "room_type"}, - {"notindicated", "Not Indicated (default)", 0, FF_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_NOT_INDICATED }, INT_MIN, INT_MAX, AC3ENC_PARAM, "room_type"}, - {"large", "Large Room", 0, FF_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_LARGE_ROOM }, INT_MIN, INT_MAX, AC3ENC_PARAM, "room_type"}, - {"small", "Small Room", 0, FF_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_SMALL_ROOM }, INT_MIN, INT_MAX, AC3ENC_PARAM, "room_type"}, +{"mixing_level", "Mixing Level", OFFSET(mixing_level), AV_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, 111, AC3ENC_PARAM}, +{"room_type", "Room Type", OFFSET(room_type), AV_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, AC3ENC_OPT_SMALL_ROOM, AC3ENC_PARAM, "room_type"}, + {"notindicated", "Not Indicated (default)", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_NOT_INDICATED }, INT_MIN, INT_MAX, AC3ENC_PARAM, "room_type"}, + {"large", "Large Room", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_LARGE_ROOM }, INT_MIN, INT_MAX, AC3ENC_PARAM, "room_type"}, + {"small", "Small Room", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_SMALL_ROOM }, INT_MIN, INT_MAX, AC3ENC_PARAM, "room_type"}, /* other metadata options */ -{"copyright", "Copyright Bit", OFFSET(copyright), FF_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, 1, AC3ENC_PARAM}, -{"dialnorm", "Dialogue Level (dB)", OFFSET(dialogue_level), FF_OPT_TYPE_INT, {.dbl = -31 }, -31, -1, AC3ENC_PARAM}, -{"dsur_mode", "Dolby Surround Mode", OFFSET(dolby_surround_mode), FF_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, AC3ENC_OPT_MODE_OFF, AC3ENC_PARAM, "dsur_mode"}, - {"notindicated", "Not Indicated (default)", 0, FF_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_NOT_INDICATED }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsur_mode"}, - {"on", "Dolby Surround Encoded", 0, FF_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_MODE_ON }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsur_mode"}, - {"off", "Not Dolby Surround Encoded", 0, FF_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_MODE_OFF }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsur_mode"}, -{"original", "Original Bit Stream", OFFSET(original), FF_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, 1, AC3ENC_PARAM}, +{"copyright", "Copyright Bit", OFFSET(copyright), AV_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, 1, AC3ENC_PARAM}, +{"dialnorm", "Dialogue Level (dB)", OFFSET(dialogue_level), AV_OPT_TYPE_INT, {.dbl = -31 }, -31, -1, AC3ENC_PARAM}, +{"dsur_mode", "Dolby Surround Mode", OFFSET(dolby_surround_mode), AV_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, AC3ENC_OPT_MODE_ON, AC3ENC_PARAM, "dsur_mode"}, + {"notindicated", "Not Indicated (default)", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_NOT_INDICATED }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsur_mode"}, + {"on", "Dolby Surround Encoded", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_MODE_ON }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsur_mode"}, + {"off", "Not Dolby Surround Encoded", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_MODE_OFF }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsur_mode"}, +{"original", "Original Bit Stream", OFFSET(original), AV_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, 1, AC3ENC_PARAM}, /* extended bitstream information */ -{"dmix_mode", "Preferred Stereo Downmix Mode", OFFSET(preferred_stereo_downmix), FF_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, AC3ENC_OPT_DOWNMIX_LORO, AC3ENC_PARAM, "dmix_mode"}, - {"notindicated", "Not Indicated (default)", 0, FF_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_NOT_INDICATED }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dmix_mode"}, - {"ltrt", "Lt/Rt Downmix Preferred", 0, FF_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_DOWNMIX_LTRT }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dmix_mode"}, - {"loro", "Lo/Ro Downmix Preferred", 0, FF_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_DOWNMIX_LORO }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dmix_mode"}, -{"ltrt_cmixlev", "Lt/Rt Center Mix Level", OFFSET(ltrt_center_mix_level), FF_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, AC3ENC_PARAM}, -{"ltrt_surmixlev", "Lt/Rt Surround Mix Level", OFFSET(ltrt_surround_mix_level), FF_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, AC3ENC_PARAM}, -{"loro_cmixlev", "Lo/Ro Center Mix Level", OFFSET(loro_center_mix_level), FF_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, AC3ENC_PARAM}, -{"loro_surmixlev", "Lo/Ro Surround Mix Level", OFFSET(loro_surround_mix_level), FF_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, AC3ENC_PARAM}, -{"dsurex_mode", "Dolby Surround EX Mode", OFFSET(dolby_surround_ex_mode), FF_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, AC3ENC_OPT_MODE_OFF, AC3ENC_PARAM, "dsurex_mode"}, - {"notindicated", "Not Indicated (default)", 0, FF_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_NOT_INDICATED }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsurex_mode"}, - {"on", "Dolby Surround EX Encoded", 0, FF_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_MODE_ON }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsurex_mode"}, - {"off", "Not Dolby Surround EX Encoded", 0, FF_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_MODE_OFF }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsurex_mode"}, -{"dheadphone_mode", "Dolby Headphone Mode", OFFSET(dolby_headphone_mode), FF_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, AC3ENC_OPT_MODE_OFF, AC3ENC_PARAM, "dheadphone_mode"}, - {"notindicated", "Not Indicated (default)", 0, FF_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_NOT_INDICATED }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dheadphone_mode"}, - {"on", "Dolby Headphone Encoded", 0, FF_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_MODE_ON }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dheadphone_mode"}, - {"off", "Not Dolby Headphone Encoded", 0, FF_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_MODE_OFF }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dheadphone_mode"}, -{"ad_conv_type", "A/D Converter Type", OFFSET(ad_converter_type), FF_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, AC3ENC_OPT_ADCONV_HDCD, AC3ENC_PARAM, "ad_conv_type"}, - {"standard", "Standard (default)", 0, FF_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_ADCONV_STANDARD }, INT_MIN, INT_MAX, AC3ENC_PARAM, "ad_conv_type"}, - {"hdcd", "HDCD", 0, FF_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_ADCONV_HDCD }, INT_MIN, INT_MAX, AC3ENC_PARAM, "ad_conv_type"}, +{"dmix_mode", "Preferred Stereo Downmix Mode", OFFSET(preferred_stereo_downmix), AV_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, AC3ENC_OPT_DOWNMIX_LORO, AC3ENC_PARAM, "dmix_mode"}, + {"notindicated", "Not Indicated (default)", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_NOT_INDICATED }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dmix_mode"}, + {"ltrt", "Lt/Rt Downmix Preferred", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_DOWNMIX_LTRT }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dmix_mode"}, + {"loro", "Lo/Ro Downmix Preferred", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_DOWNMIX_LORO }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dmix_mode"}, +{"ltrt_cmixlev", "Lt/Rt Center Mix Level", OFFSET(ltrt_center_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, AC3ENC_PARAM}, +{"ltrt_surmixlev", "Lt/Rt Surround Mix Level", OFFSET(ltrt_surround_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, AC3ENC_PARAM}, +{"loro_cmixlev", "Lo/Ro Center Mix Level", OFFSET(loro_center_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, AC3ENC_PARAM}, +{"loro_surmixlev", "Lo/Ro Surround Mix Level", OFFSET(loro_surround_mix_level), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1.0, 2.0, AC3ENC_PARAM}, +{"dsurex_mode", "Dolby Surround EX Mode", OFFSET(dolby_surround_ex_mode), AV_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, AC3ENC_OPT_MODE_ON, AC3ENC_PARAM, "dsurex_mode"}, + {"notindicated", "Not Indicated (default)", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_NOT_INDICATED }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsurex_mode"}, + {"on", "Dolby Surround EX Encoded", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_MODE_ON }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsurex_mode"}, + {"off", "Not Dolby Surround EX Encoded", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_MODE_OFF }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dsurex_mode"}, +{"dheadphone_mode", "Dolby Headphone Mode", OFFSET(dolby_headphone_mode), AV_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, AC3ENC_OPT_MODE_ON, AC3ENC_PARAM, "dheadphone_mode"}, + {"notindicated", "Not Indicated (default)", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_NOT_INDICATED }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dheadphone_mode"}, + {"on", "Dolby Headphone Encoded", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_MODE_ON }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dheadphone_mode"}, + {"off", "Not Dolby Headphone Encoded", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_MODE_OFF }, INT_MIN, INT_MAX, AC3ENC_PARAM, "dheadphone_mode"}, +{"ad_conv_type", "A/D Converter Type", OFFSET(ad_converter_type), AV_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_NONE }, AC3ENC_OPT_NONE, AC3ENC_OPT_ADCONV_HDCD, AC3ENC_PARAM, "ad_conv_type"}, + {"standard", "Standard (default)", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_ADCONV_STANDARD }, INT_MIN, INT_MAX, AC3ENC_PARAM, "ad_conv_type"}, + {"hdcd", "HDCD", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_ADCONV_HDCD }, INT_MIN, INT_MAX, AC3ENC_PARAM, "ad_conv_type"}, /* Other Encoding Options */ -{"stereo_rematrixing", "Stereo Rematrixing", OFFSET(stereo_rematrixing), FF_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_ON }, AC3ENC_OPT_OFF, AC3ENC_OPT_ON, AC3ENC_PARAM}, -{"channel_coupling", "Channel Coupling", OFFSET(channel_coupling), FF_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_AUTO }, AC3ENC_OPT_AUTO, AC3ENC_OPT_ON, AC3ENC_PARAM, "channel_coupling"}, - {"auto", "Selected by the Encoder", 0, FF_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_AUTO }, INT_MIN, INT_MAX, AC3ENC_PARAM, "channel_coupling"}, -{"cpl_start_band", "Coupling Start Band", OFFSET(cpl_start), FF_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_AUTO }, AC3ENC_OPT_AUTO, 15, AC3ENC_PARAM, "cpl_start_band"}, - {"auto", "Selected by the Encoder", 0, FF_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_AUTO }, INT_MIN, INT_MAX, AC3ENC_PARAM, "cpl_start_band"}, +{"stereo_rematrixing", "Stereo Rematrixing", OFFSET(stereo_rematrixing), AV_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_ON }, AC3ENC_OPT_OFF, AC3ENC_OPT_ON, AC3ENC_PARAM}, +{"channel_coupling", "Channel Coupling", OFFSET(channel_coupling), AV_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_AUTO }, AC3ENC_OPT_AUTO, AC3ENC_OPT_ON, AC3ENC_PARAM, "channel_coupling"}, + {"auto", "Selected by the Encoder", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_AUTO }, INT_MIN, INT_MAX, AC3ENC_PARAM, "channel_coupling"}, +{"cpl_start_band", "Coupling Start Band", OFFSET(cpl_start), AV_OPT_TYPE_INT, {.dbl = AC3ENC_OPT_AUTO }, AC3ENC_OPT_AUTO, 15, AC3ENC_PARAM, "cpl_start_band"}, + {"auto", "Selected by the Encoder", 0, AV_OPT_TYPE_CONST, {.dbl = AC3ENC_OPT_AUTO }, INT_MIN, INT_MAX, AC3ENC_PARAM, "cpl_start_band"}, {NULL} }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ac3enc_template.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ac3enc_template.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ac3enc_template.c 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ac3enc_template.c 2011-11-04 12:38:26.000000000 +0000 @@ -43,6 +43,9 @@ static CoefType calc_cpl_coord(CoefSumType energy_ch, CoefSumType energy_cpl); +static void sum_square_butterfly(AC3EncodeContext *s, CoefSumType sum[4], + const CoefType *coef0, const CoefType *coef1, + int len); int AC3_NAME(allocate_sample_buffers)(AC3EncodeContext *s) { @@ -64,7 +67,7 @@ } -/** +/* * Deinterleave input samples. * Channels are reordered from Libav's default order to AC-3 order. */ @@ -93,7 +96,7 @@ } -/** +/* * Apply the MDCT to input samples to generate frequency coefficients. * This applies the KBD window and normalizes the input to reduce precision * loss due to fixed-point calculations. @@ -120,7 +123,7 @@ } -/** +/* * Calculate coupling channel and coupling coordinates. */ static void apply_channel_coupling(AC3EncodeContext *s) @@ -328,13 +331,13 @@ } -/** +/* * Determine rematrixing flags for each block and band. */ static void compute_rematrixing_strategy(AC3EncodeContext *s) { int nb_coefs; - int blk, bnd, i; + int blk, bnd; AC3Block *block, *av_uninit(block0); if (s->channel_mode != AC3_CHMODE_STEREO) @@ -362,17 +365,9 @@ /* calculate calculate sum of squared coeffs for one band in one block */ int start = ff_ac3_rematrix_band_tab[bnd]; int end = FFMIN(nb_coefs, ff_ac3_rematrix_band_tab[bnd+1]); - CoefSumType sum[4] = {0,}; - for (i = start; i < end; i++) { - CoefType lt = block->mdct_coef[1][i]; - CoefType rt = block->mdct_coef[2][i]; - CoefType md = lt + rt; - CoefType sd = lt - rt; - MAC_COEF(sum[0], lt, lt); - MAC_COEF(sum[1], rt, rt); - MAC_COEF(sum[2], md, md); - MAC_COEF(sum[3], sd, sd); - } + CoefSumType sum[4]; + sum_square_butterfly(s, sum, block->mdct_coef[1] + start, + block->mdct_coef[2] + start, end - start); /* compare sums to determine if rematrixing will be used for this band */ if (FFMIN(sum[2], sum[3]) < FFMIN(sum[0], sum[1])) @@ -391,9 +386,6 @@ } -/** - * Encode a single AC-3 frame. - */ int AC3_NAME(encode_frame)(AVCodecContext *avctx, unsigned char *frame, int buf_size, void *data) { diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ac3_parser.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ac3_parser.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ac3_parser.c 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ac3_parser.c 2011-11-04 12:38:26.000000000 +0000 @@ -35,7 +35,7 @@ }; -int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr) +int avpriv_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr) { int frame_size_code; @@ -141,7 +141,7 @@ GetBitContext gbc; init_get_bits(&gbc, tmp.u8+8-AC3_HEADER_SIZE, 54); - err = ff_ac3_parse_header(&gbc, &hdr); + err = avpriv_ac3_parse_header(&gbc, &hdr); if(err < 0) return 0; @@ -174,9 +174,9 @@ AVCodecParser ff_ac3_parser = { - { CODEC_ID_AC3, CODEC_ID_EAC3 }, - sizeof(AACAC3ParseContext), - ac3_parse_init, - ff_aac_ac3_parse, - ff_parse_close, + .codec_ids = { CODEC_ID_AC3, CODEC_ID_EAC3 }, + .priv_data_size = sizeof(AACAC3ParseContext), + .parser_init = ac3_parse_init, + .parser_parse = ff_aac_ac3_parse, + .parser_close = ff_parse_close, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ac3_parser.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ac3_parser.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ac3_parser.h 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ac3_parser.h 2011-11-04 12:38:26.000000000 +0000 @@ -36,6 +36,6 @@ * -2 if the bsid (version) element is invalid, -3 if the fscod (sample rate) * element is invalid, or -4 if the frmsizecod (bit rate) element is invalid. */ -int ff_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr); +int avpriv_ac3_parse_header(GetBitContext *gbc, AC3HeaderInfo *hdr); #endif /* AVCODEC_AC3_PARSER_H */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/acelp_filters.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/acelp_filters.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/acelp_filters.h 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/acelp_filters.h 2011-11-04 12:38:26.000000000 +0000 @@ -76,7 +76,7 @@ * * The filter has a cut-off frequency of 1/80 of the sampling freq * - * @note Two items before the top of the out buffer must contain two items from the + * @note Two items before the top of the in buffer must contain two items from the * tail of the previous subframe. * * @remark It is safe to pass the same array in in and out parameters. diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/adpcm.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/adpcm.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/adpcm.c 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/adpcm.c 2011-11-04 12:38:26.000000000 +0000 @@ -315,6 +315,173 @@ } } +/** + * Get the number of samples that will be decoded from the packet. + * In one case, this is actually the maximum number of samples possible to + * decode with the given buf_size. + * + * @param[out] coded_samples set to the number of samples as coded in the + * packet, or 0 if the codec does not encode the + * number of samples in each frame. + */ +static int get_nb_samples(AVCodecContext *avctx, const uint8_t *buf, + int buf_size, int *coded_samples) +{ + ADPCMDecodeContext *s = avctx->priv_data; + int nb_samples = 0; + int ch = avctx->channels; + int has_coded_samples = 0; + int header_size; + + *coded_samples = 0; + + switch (avctx->codec->id) { + /* constant, only check buf_size */ + case CODEC_ID_ADPCM_EA_XAS: + if (buf_size < 76 * ch) + return 0; + nb_samples = 128; + break; + case CODEC_ID_ADPCM_IMA_QT: + if (buf_size < 34 * ch) + return 0; + nb_samples = 64; + break; + /* simple 4-bit adpcm */ + case CODEC_ID_ADPCM_CT: + case CODEC_ID_ADPCM_IMA_EA_SEAD: + case CODEC_ID_ADPCM_IMA_WS: + case CODEC_ID_ADPCM_YAMAHA: + nb_samples = buf_size * 2 / ch; + break; + } + if (nb_samples) + return nb_samples; + + /* simple 4-bit adpcm, with header */ + header_size = 0; + switch (avctx->codec->id) { + case CODEC_ID_ADPCM_4XM: + case CODEC_ID_ADPCM_IMA_ISS: header_size = 4 * ch; break; + case CODEC_ID_ADPCM_IMA_AMV: header_size = 8; break; + case CODEC_ID_ADPCM_IMA_SMJPEG: header_size = 4; break; + } + if (header_size > 0) + return (buf_size - header_size) * 2 / ch; + + /* more complex formats */ + switch (avctx->codec->id) { + case CODEC_ID_ADPCM_EA: + has_coded_samples = 1; + if (buf_size < 4) + return 0; + *coded_samples = AV_RL32(buf); + *coded_samples -= *coded_samples % 28; + nb_samples = (buf_size - 12) / 30 * 28; + break; + case CODEC_ID_ADPCM_IMA_EA_EACS: + has_coded_samples = 1; + if (buf_size < 4) + return 0; + *coded_samples = AV_RL32(buf); + nb_samples = (buf_size - (4 + 8 * ch)) * 2 / ch; + break; + case CODEC_ID_ADPCM_EA_MAXIS_XA: + nb_samples = ((buf_size - ch) / (2 * ch)) * 2 * ch; + break; + case CODEC_ID_ADPCM_EA_R1: + case CODEC_ID_ADPCM_EA_R2: + case CODEC_ID_ADPCM_EA_R3: + /* maximum number of samples */ + /* has internal offsets and a per-frame switch to signal raw 16-bit */ + has_coded_samples = 1; + if (buf_size < 4) + return 0; + switch (avctx->codec->id) { + case CODEC_ID_ADPCM_EA_R1: + header_size = 4 + 9 * ch; + *coded_samples = AV_RL32(buf); + break; + case CODEC_ID_ADPCM_EA_R2: + header_size = 4 + 5 * ch; + *coded_samples = AV_RL32(buf); + break; + case CODEC_ID_ADPCM_EA_R3: + header_size = 4 + 5 * ch; + *coded_samples = AV_RB32(buf); + break; + } + *coded_samples -= *coded_samples % 28; + nb_samples = (buf_size - header_size) * 2 / ch; + nb_samples -= nb_samples % 28; + break; + case CODEC_ID_ADPCM_IMA_DK3: + if (avctx->block_align > 0) + buf_size = FFMIN(buf_size, avctx->block_align); + nb_samples = ((buf_size - 16) * 8 / 3) / ch; + break; + case CODEC_ID_ADPCM_IMA_DK4: + nb_samples = 1 + (buf_size - 4 * ch) * 2 / ch; + break; + case CODEC_ID_ADPCM_IMA_WAV: + if (avctx->block_align > 0) + buf_size = FFMIN(buf_size, avctx->block_align); + nb_samples = 1 + (buf_size - 4 * ch) / (4 * ch) * 8; + break; + case CODEC_ID_ADPCM_MS: + if (avctx->block_align > 0) + buf_size = FFMIN(buf_size, avctx->block_align); + nb_samples = 2 + (buf_size - 7 * ch) * 2 / ch; + break; + case CODEC_ID_ADPCM_SBPRO_2: + case CODEC_ID_ADPCM_SBPRO_3: + case CODEC_ID_ADPCM_SBPRO_4: + { + int samples_per_byte; + switch (avctx->codec->id) { + case CODEC_ID_ADPCM_SBPRO_2: samples_per_byte = 4; break; + case CODEC_ID_ADPCM_SBPRO_3: samples_per_byte = 3; break; + case CODEC_ID_ADPCM_SBPRO_4: samples_per_byte = 2; break; + } + if (!s->status[0].step_index) { + nb_samples++; + buf_size -= ch; + } + nb_samples += buf_size * samples_per_byte / ch; + break; + } + case CODEC_ID_ADPCM_SWF: + { + int buf_bits = buf_size * 8 - 2; + int nbits = (buf[0] >> 6) + 2; + int block_hdr_size = 22 * ch; + int block_size = block_hdr_size + nbits * ch * 4095; + int nblocks = buf_bits / block_size; + int bits_left = buf_bits - nblocks * block_size; + nb_samples = nblocks * 4096; + if (bits_left >= block_hdr_size) + nb_samples += 1 + (bits_left - block_hdr_size) / (nbits * ch); + break; + } + case CODEC_ID_ADPCM_THP: + has_coded_samples = 1; + if (buf_size < 8) + return 0; + *coded_samples = AV_RB32(&buf[4]); + *coded_samples -= *coded_samples % 14; + nb_samples = (buf_size - 80) / (8 * ch) * 14; + break; + case CODEC_ID_ADPCM_XA: + nb_samples = (buf_size / 128) * 224 / ch; + break; + } + + /* validate coded sample count */ + if (has_coded_samples && (*coded_samples <= 0 || *coded_samples > nb_samples)) + return AVERROR_INVALIDDATA; + + return nb_samples; +} /* DK3 ADPCM support macro */ #define DK3_GET_NEXT_NIBBLE() \ @@ -325,8 +492,11 @@ } \ else \ { \ + if (end_of_packet) \ + break; \ last_byte = *src++; \ - if (src >= buf + buf_size) break; \ + if (src >= buf + buf_size) \ + end_of_packet = 1; \ nibble = last_byte & 0x0F; \ decode_top_nibble_next = 1; \ } @@ -341,24 +511,33 @@ ADPCMChannelStatus *cs; int n, m, channel, i; short *samples; - short *samples_end; const uint8_t *src; int st; /* stereo */ - uint32_t samples_in_chunk; int count1, count2; + int nb_samples, coded_samples, out_bps, out_size; - if (!buf_size) - return 0; - - //should protect all 4bit ADPCM variants - //8 is needed for CODEC_ID_ADPCM_IMA_WAV with 2 channels - // - if(*data_size/4 < buf_size + 8) - return -1; + nb_samples = get_nb_samples(avctx, buf, buf_size, &coded_samples); + if (nb_samples <= 0) { + av_log(avctx, AV_LOG_ERROR, "invalid number of samples in packet\n"); + return AVERROR_INVALIDDATA; + } + + out_bps = av_get_bytes_per_sample(avctx->sample_fmt); + out_size = nb_samples * avctx->channels * out_bps; + if (*data_size < out_size) { + av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n"); + return AVERROR(EINVAL); + } + /* use coded_samples when applicable */ + /* it is always <= nb_samples, so the output buffer will be large enough */ + if (coded_samples) { + if (coded_samples != nb_samples) + av_log(avctx, AV_LOG_WARNING, "mismatch in coded sample count\n"); + nb_samples = coded_samples; + out_size = nb_samples * avctx->channels * out_bps; + } samples = data; - samples_end= samples + *data_size/2; - *data_size= 0; src = buf; st = avctx->channels == 2 ? 1 : 0; @@ -367,10 +546,6 @@ case CODEC_ID_ADPCM_IMA_QT: /* In QuickTime, IMA is encoded by chunks of 34 bytes (=64 samples). Channel data is interleaved per-chunk. */ - if (buf_size / 34 < avctx->channels) { - av_log(avctx, AV_LOG_ERROR, "packet is too small\n"); - return AVERROR(EINVAL); - } for (channel = 0; channel < avctx->channels; channel++) { int16_t predictor; int step_index; @@ -411,15 +586,11 @@ src ++; } } - if (st) - samples--; break; case CODEC_ID_ADPCM_IMA_WAV: if (avctx->block_align != 0 && buf_size > avctx->block_align) buf_size = avctx->block_align; -// samples_per_block= (block_align-4*chanels)*8 / (bits_per_sample * chanels) + 1; - for(i=0; ichannels; i++){ cs = &(c->status[i]); cs->predictor = *samples++ = (int16_t)bytestream_get_le16(&src); @@ -432,7 +603,7 @@ if (*src++) av_log(avctx, AV_LOG_ERROR, "unused byte should be null but is %d!!\n", src[-1]); /* unused */ } - while(src < buf + buf_size){ + for (n = (nb_samples - 1) / 8; n > 0; n--) { for (i = 0; i < avctx->channels; i++) { cs = &c->status[i]; for (m = 0; m < 4; m++) { @@ -456,20 +627,17 @@ c->status[i].step_index = av_clip(c->status[i].step_index, 0, 88); } - m= (buf_size - (src - buf))>>st; - for (i = 0; i < avctx->channels; i++) { samples = (short*)data + i; cs = &c->status[i]; - for (n = 0; n < m; n++) { - uint8_t v = *src++; + for (n = nb_samples >> 1; n > 0; n--, src++) { + uint8_t v = *src; *samples = adpcm_ima_expand_nibble(cs, v & 0x0F, 4); samples += avctx->channels; *samples = adpcm_ima_expand_nibble(cs, v >> 4 , 4); samples += avctx->channels; } } - samples -= (avctx->channels - 1); break; case CODEC_ID_ADPCM_MS: { @@ -477,9 +645,6 @@ if (avctx->block_align != 0 && buf_size > avctx->block_align) buf_size = avctx->block_align; - n = buf_size - 7 * avctx->channels; - if (n < 0) - return -1; block_predictor = av_clip(*src++, 0, 6); c->status[0].coeff1 = ff_adpcm_AdaptCoeff1[block_predictor]; @@ -503,10 +668,9 @@ if (st) *samples++ = c->status[1].sample2; *samples++ = c->status[0].sample1; if (st) *samples++ = c->status[1].sample1; - for(;n>0;n--) { + for(n = (nb_samples - 2) >> (1 - st); n > 0; n--, src++) { *samples++ = adpcm_ms_expand_nibble(&c->status[0 ], src[0] >> 4 ); *samples++ = adpcm_ms_expand_nibble(&c->status[st], src[0] & 0x0F); - src ++; } break; } @@ -514,12 +678,6 @@ if (avctx->block_align != 0 && buf_size > avctx->block_align) buf_size = avctx->block_align; - n = buf_size - 4 * avctx->channels; - if (n < 0) { - av_log(avctx, AV_LOG_ERROR, "packet is too small\n"); - return AVERROR(EINVAL); - } - for (channel = 0; channel < avctx->channels; channel++) { cs = &c->status[channel]; cs->predictor = (int16_t)bytestream_get_le16(&src); @@ -527,8 +685,8 @@ src++; *samples++ = cs->predictor; } - while (n-- > 0) { - uint8_t v = *src++; + for (n = nb_samples >> (1 - st); n > 0; n--, src++) { + uint8_t v = *src; *samples++ = adpcm_ima_expand_nibble(&c->status[0 ], v >> 4 , 3); *samples++ = adpcm_ima_expand_nibble(&c->status[st], v & 0x0F, 3); } @@ -538,14 +696,12 @@ unsigned char last_byte = 0; unsigned char nibble; int decode_top_nibble_next = 0; + int end_of_packet = 0; int diff_channel; if (avctx->block_align != 0 && buf_size > avctx->block_align) buf_size = avctx->block_align; - if(buf_size + 16 > (samples_end - samples)*3/8) - return -1; - c->status[0].predictor = (int16_t)AV_RL16(src + 10); c->status[1].predictor = (int16_t)AV_RL16(src + 12); c->status[0].step_index = src[14]; @@ -586,12 +742,6 @@ break; } case CODEC_ID_ADPCM_IMA_ISS: - n = buf_size - 4 * avctx->channels; - if (n < 0) { - av_log(avctx, AV_LOG_ERROR, "packet is too small\n"); - return AVERROR(EINVAL); - } - for (channel = 0; channel < avctx->channels; channel++) { cs = &c->status[channel]; cs->predictor = (int16_t)bytestream_get_le16(&src); @@ -599,9 +749,9 @@ src++; } - while (n-- > 0) { + for (n = nb_samples >> (1 - st); n > 0; n--, src++) { uint8_t v1, v2; - uint8_t v = *src++; + uint8_t v = *src; /* nibbles are swapped for mono */ if (st) { v1 = v >> 4; @@ -630,28 +780,21 @@ buf_size -= 128; } break; - case CODEC_ID_ADPCM_IMA_EA_EACS: { - unsigned header_size = 4 + (8<> (1-st); - - if (buf_size < header_size || samples_in_chunk > buf_size - header_size) { - src += buf_size - 4; - break; - } + case CODEC_ID_ADPCM_IMA_EA_EACS: + src += 4; // skip sample count (already read) for (i=0; i<=st; i++) c->status[i].step_index = bytestream_get_le32(&src); for (i=0; i<=st; i++) c->status[i].predictor = bytestream_get_le32(&src); - for (; samples_in_chunk; samples_in_chunk--, src++) { + for (n = nb_samples >> (1 - st); n > 0; n--, src++) { *samples++ = adpcm_ima_expand_nibble(&c->status[0], *src>>4, 3); *samples++ = adpcm_ima_expand_nibble(&c->status[st], *src&0x0F, 3); } break; - } case CODEC_ID_ADPCM_IMA_EA_SEAD: - for (; src < buf+buf_size; src++) { + for (n = nb_samples >> (1 - st); n > 0; n--, src++) { *samples++ = adpcm_ima_expand_nibble(&c->status[0], src[0] >> 4, 6); *samples++ = adpcm_ima_expand_nibble(&c->status[st],src[0]&0x0F, 6); } @@ -666,35 +809,28 @@ /* Each EA ADPCM frame has a 12-byte header followed by 30-byte pieces, each coding 28 stereo samples. */ - if (buf_size < 12) { - av_log(avctx, AV_LOG_ERROR, "frame too small\n"); - return AVERROR(EINVAL); - } - samples_in_chunk = AV_RL32(src); - if (samples_in_chunk / 28 > (buf_size - 12) / 30) { - av_log(avctx, AV_LOG_ERROR, "invalid frame\n"); - return AVERROR(EINVAL); - } - src += 4; + + src += 4; // skip sample count (already read) + current_left_sample = (int16_t)bytestream_get_le16(&src); previous_left_sample = (int16_t)bytestream_get_le16(&src); current_right_sample = (int16_t)bytestream_get_le16(&src); previous_right_sample = (int16_t)bytestream_get_le16(&src); - for (count1 = 0; count1 < samples_in_chunk/28;count1++) { + for (count1 = 0; count1 < nb_samples / 28; count1++) { coeff1l = ea_adpcm_table[ *src >> 4 ]; coeff2l = ea_adpcm_table[(*src >> 4 ) + 4]; coeff1r = ea_adpcm_table[*src & 0x0F]; coeff2r = ea_adpcm_table[(*src & 0x0F) + 4]; src++; - shift_left = (*src >> 4 ) + 8; - shift_right = (*src & 0x0F) + 8; + shift_left = 20 - (*src >> 4); + shift_right = 20 - (*src & 0x0F); src++; for (count2 = 0; count2 < 28; count2++) { - next_left_sample = (int32_t)((*src & 0xF0) << 24) >> shift_left; - next_right_sample = (int32_t)((*src & 0x0F) << 28) >> shift_right; + next_left_sample = sign_extend(*src >> 4, 4) << shift_left; + next_right_sample = sign_extend(*src, 4) << shift_right; src++; next_left_sample = (next_left_sample + @@ -725,13 +861,13 @@ for(channel = 0; channel < avctx->channels; channel++) { for (i=0; i<2; i++) coeff[channel][i] = ea_adpcm_table[(*src >> 4) + 4*i]; - shift[channel] = (*src & 0x0F) + 8; + shift[channel] = 20 - (*src & 0x0F); src++; } - for (count1 = 0; count1 < (buf_size - avctx->channels) / avctx->channels; count1++) { + for (count1 = 0; count1 < nb_samples / 2; count1++) { for(i = 4; i >= 0; i-=4) { /* Pairwise samples LL RR (st) or LL LL (mono) */ for(channel = 0; channel < avctx->channels; channel++) { - int32_t sample = (int32_t)(((*(src+channel) >> i) & 0x0F) << 0x1C) >> shift[channel]; + int32_t sample = sign_extend(src[channel] >> i, 4) << shift[channel]; sample = (sample + c->status[channel].sample1 * coeff[channel][0] + c->status[channel].sample2 * coeff[channel][1] + 0x80) >> 8; @@ -742,6 +878,8 @@ } src+=avctx->channels; } + /* consume whole packet */ + src = buf + buf_size; break; } case CODEC_ID_ADPCM_EA_R1: @@ -759,14 +897,9 @@ uint16_t *samplesC; const uint8_t *srcC; const uint8_t *src_end = buf + buf_size; + int count = 0; - samples_in_chunk = (big_endian ? bytestream_get_be32(&src) - : bytestream_get_le32(&src)) / 28; - if (samples_in_chunk > UINT32_MAX/(28*avctx->channels) || - 28*samples_in_chunk*avctx->channels > samples_end-samples) { - src += buf_size - 4; - break; - } + src += 4; // skip sample count (already read) for (channel=0; channelchannels; channel++) { int32_t offset = (big_endian ? bytestream_get_be32(&src) @@ -785,7 +918,7 @@ previous_sample = c->status[channel].prev_sample; } - for (count1=0; count1 src_end - 30*2) break; @@ -799,14 +932,14 @@ } else { coeff1 = ea_adpcm_table[ *srcC>>4 ]; coeff2 = ea_adpcm_table[(*srcC>>4) + 4]; - shift = (*srcC++ & 0x0F) + 8; + shift = 20 - (*srcC++ & 0x0F); if (srcC > src_end - 14) break; for (count2=0; count2<28; count2++) { if (count2 & 1) - next_sample = (int32_t)((*srcC++ & 0x0F) << 28) >> shift; + next_sample = sign_extend(*srcC++, 4) << shift; else - next_sample = (int32_t)((*srcC & 0xF0) << 24) >> shift; + next_sample = sign_extend(*srcC >> 4, 4) << shift; next_sample += (current_sample * coeff1) + (previous_sample * coeff2); @@ -819,6 +952,12 @@ } } } + if (!count) { + count = count1; + } else if (count != count1) { + av_log(avctx, AV_LOG_WARNING, "per-channel sample count mismatch\n"); + count = FFMAX(count, count1); + } if (avctx->codec->id != CODEC_ID_ADPCM_EA_R1) { c->status[channel].predictor = current_sample; @@ -826,23 +965,18 @@ } } - src = src + buf_size - (4 + 4*avctx->channels); - samples += 28 * samples_in_chunk * avctx->channels; + out_size = count * 28 * avctx->channels * out_bps; + src = src_end; break; } case CODEC_ID_ADPCM_EA_XAS: - if (samples_end-samples < 32*4*avctx->channels - || buf_size < (4+15)*4*avctx->channels) { - src += buf_size; - break; - } for (channel=0; channelchannels; channel++) { int coeff[2][4], shift[4]; short *s2, *s = &samples[channel]; for (n=0; n<4; n++, s+=32*avctx->channels) { for (i=0; i<2; i++) coeff[i][n] = ea_adpcm_table[(src[0]&0x0F)+4*i]; - shift[n] = (src[2]&0x0F) + 8; + shift[n] = 20 - (src[2] & 0x0F); for (s2=s, i=0; i<2; i++, src+=2, s2+=avctx->channels) s2[0] = (src[0]&0xF0) + (src[1]<<8); } @@ -851,7 +985,7 @@ s = &samples[m*avctx->channels + channel]; for (n=0; n<4; n++, src++, s+=32*avctx->channels) { for (s2=s, i=0; i<8; i+=4, s2+=avctx->channels) { - int level = (int32_t)((*src & (0xF0>>i)) << (24+i)) >> shift[n]; + int level = sign_extend(*src >> (4 - i), 4) << shift[n]; int pred = s2[-1*avctx->channels] * coeff[0][n] + s2[-2*avctx->channels] * coeff[1][n]; s2[0] = av_clip_int16((level + pred + 0x80) >> 8); @@ -859,7 +993,6 @@ } } } - samples += 32*4*avctx->channels; break; case CODEC_ID_ADPCM_IMA_AMV: case CODEC_ID_ADPCM_IMA_SMJPEG: @@ -869,7 +1002,7 @@ if (avctx->codec->id == CODEC_ID_ADPCM_IMA_AMV) src+=4; - while (src < buf + buf_size) { + for (n = nb_samples >> (1 - st); n > 0; n--, src++) { char hi, lo; lo = *src & 0x0F; hi = *src >> 4; @@ -881,12 +1014,11 @@ lo, 3); *samples++ = adpcm_ima_expand_nibble(&c->status[0], hi, 3); - src++; } break; case CODEC_ID_ADPCM_CT: - while (src < buf + buf_size) { - uint8_t v = *src++; + for (n = nb_samples >> (1 - st); n > 0; n--, src++) { + uint8_t v = *src; *samples++ = adpcm_ct_expand_nibble(&c->status[0 ], v >> 4 ); *samples++ = adpcm_ct_expand_nibble(&c->status[st], v & 0x0F); } @@ -900,27 +1032,26 @@ if (st) *samples++ = 128 * (*src++ - 0x80); c->status[0].step_index = 1; + nb_samples--; } if (avctx->codec->id == CODEC_ID_ADPCM_SBPRO_4) { - while (src < buf + buf_size) { + for (n = nb_samples >> (1 - st); n > 0; n--, src++) { *samples++ = adpcm_sbpro_expand_nibble(&c->status[0], src[0] >> 4, 4, 0); *samples++ = adpcm_sbpro_expand_nibble(&c->status[st], src[0] & 0x0F, 4, 0); - src++; } } else if (avctx->codec->id == CODEC_ID_ADPCM_SBPRO_3) { - while (src < buf + buf_size && samples + 2 < samples_end) { + for (n = nb_samples / 3; n > 0; n--, src++) { *samples++ = adpcm_sbpro_expand_nibble(&c->status[0], src[0] >> 5 , 3, 0); *samples++ = adpcm_sbpro_expand_nibble(&c->status[0], (src[0] >> 2) & 0x07, 3, 0); *samples++ = adpcm_sbpro_expand_nibble(&c->status[0], src[0] & 0x03, 2, 0); - src++; } } else { - while (src < buf + buf_size && samples + 3 < samples_end) { + for (n = nb_samples >> (2 - st); n > 0; n--, src++) { *samples++ = adpcm_sbpro_expand_nibble(&c->status[0], src[0] >> 6 , 2, 2); *samples++ = adpcm_sbpro_expand_nibble(&c->status[st], @@ -929,7 +1060,6 @@ (src[0] >> 2) & 0x03, 2, 2); *samples++ = adpcm_sbpro_expand_nibble(&c->status[st], src[0] & 0x03, 2, 2); - src++; } } break; @@ -984,10 +1114,6 @@ c->status[i].predictor = av_clip_int16(c->status[i].predictor); *samples++ = c->status[i].predictor; - if (samples >= samples_end) { - av_log(avctx, AV_LOG_ERROR, "allocated output buffer is too small\n"); - return -1; - } } } } @@ -995,8 +1121,8 @@ break; } case CODEC_ID_ADPCM_YAMAHA: - while (src < buf + buf_size) { - uint8_t v = *src++; + for (n = nb_samples >> (1 - st); n > 0; n--, src++) { + uint8_t v = *src; *samples++ = adpcm_yamaha_expand_nibble(&c->status[0 ], v & 0x0F); *samples++ = adpcm_yamaha_expand_nibble(&c->status[st], v >> 4 ); } @@ -1004,17 +1130,11 @@ case CODEC_ID_ADPCM_THP: { int table[2][16]; - unsigned int samplecnt; int prev[2][2]; int ch; - if (buf_size < 80) { - av_log(avctx, AV_LOG_ERROR, "frame too small\n"); - return -1; - } - - src+=4; - samplecnt = bytestream_get_be32(&src); + src += 4; // skip channel size + src += 4; // skip number of samples (already read) for (i = 0; i < 32; i++) table[0][i] = (int16_t)bytestream_get_be16(&src); @@ -1023,29 +1143,24 @@ for (i = 0; i < 4; i++) prev[0][i] = (int16_t)bytestream_get_be16(&src); - if (samplecnt >= (samples_end - samples) / (st + 1)) { - av_log(avctx, AV_LOG_ERROR, "allocated output buffer is too small\n"); - return -1; - } - for (ch = 0; ch <= st; ch++) { samples = (unsigned short *) data + ch; /* Read in every sample for this channel. */ - for (i = 0; i < samplecnt / 14; i++) { + for (i = 0; i < nb_samples / 14; i++) { int index = (*src >> 4) & 7; - unsigned int exp = 28 - (*src++ & 15); + unsigned int exp = *src++ & 15; int factor1 = table[ch][index * 2]; int factor2 = table[ch][index * 2 + 1]; /* Decode 14 samples. */ for (n = 0; n < 14; n++) { int32_t sampledat; - if(n&1) sampledat= *src++ <<28; - else sampledat= (*src&0xF0)<<24; + if(n&1) sampledat = sign_extend(*src++, 4); + else sampledat = sign_extend(*src >> 4, 4); sampledat = ((prev[ch][0]*factor1 - + prev[ch][1]*factor2) >> 11) + (sampledat>>exp); + + prev[ch][1]*factor2) >> 11) + (sampledat << exp); *samples = av_clip_int16(sampledat); prev[ch][1] = prev[ch][0]; prev[ch][0] = *samples++; @@ -1056,17 +1171,13 @@ } } } - - /* In the previous loop, in case stereo is used, samples is - increased exactly one time too often. */ - samples -= st; break; } default: return -1; } - *data_size = (uint8_t *)samples - (uint8_t *)data; + *data_size = out_size; return src - buf; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/alac.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/alac.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/alac.c 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/alac.c 2011-11-04 12:38:26.000000000 +0000 @@ -72,7 +72,7 @@ int32_t *outputsamples_buffer[MAX_CHANNELS]; - int32_t *wasted_bits_buffer[MAX_CHANNELS]; + int32_t *extra_bits_buffer[MAX_CHANNELS]; /* stuff from setinfo */ uint32_t setinfo_max_samples_per_frame; /* 0x1000 = 4096 */ /* max samples per frame? */ @@ -82,58 +82,9 @@ uint8_t setinfo_rice_kmodifier; /* 0x0e */ /* end setinfo stuff */ - int wasted_bits; + int extra_bits; /**< number of extra bits beyond 16-bit */ } ALACContext; -static void allocate_buffers(ALACContext *alac) -{ - int chan; - for (chan = 0; chan < MAX_CHANNELS; chan++) { - alac->predicterror_buffer[chan] = - av_malloc(alac->setinfo_max_samples_per_frame * 4); - - alac->outputsamples_buffer[chan] = - av_malloc(alac->setinfo_max_samples_per_frame * 4); - - alac->wasted_bits_buffer[chan] = av_malloc(alac->setinfo_max_samples_per_frame * 4); - } -} - -static int alac_set_info(ALACContext *alac) -{ - const unsigned char *ptr = alac->avctx->extradata; - - ptr += 4; /* size */ - ptr += 4; /* alac */ - ptr += 4; /* 0 ? */ - - if(AV_RB32(ptr) >= UINT_MAX/4){ - av_log(alac->avctx, AV_LOG_ERROR, "setinfo_max_samples_per_frame too large\n"); - return -1; - } - - /* buffer size / 2 ? */ - alac->setinfo_max_samples_per_frame = bytestream_get_be32(&ptr); - ptr++; /* ??? */ - alac->setinfo_sample_size = *ptr++; - if (alac->setinfo_sample_size > 32) { - av_log(alac->avctx, AV_LOG_ERROR, "setinfo_sample_size too large\n"); - return -1; - } - alac->setinfo_rice_historymult = *ptr++; - alac->setinfo_rice_initialhistory = *ptr++; - alac->setinfo_rice_kmodifier = *ptr++; - ptr++; /* channels? */ - bytestream_get_be16(&ptr); /* ??? */ - bytestream_get_be32(&ptr); /* max coded frame size */ - bytestream_get_be32(&ptr); /* bitrate ? */ - bytestream_get_be32(&ptr); /* samplerate */ - - allocate_buffers(alac); - - return 0; -} - static inline int decode_scalar(GetBitContext *gb, int k, int limit, int readsamplesize){ /* read x - number of 1s before 0 represent the rice */ int x = get_unary_0_9(gb); @@ -347,93 +298,56 @@ } } -static void reconstruct_stereo_16(int32_t *buffer[MAX_CHANNELS], - int16_t *buffer_out, - int numchannels, int numsamples, - uint8_t interlacing_shift, - uint8_t interlacing_leftweight) +static void decorrelate_stereo(int32_t *buffer[MAX_CHANNELS], + int numsamples, uint8_t interlacing_shift, + uint8_t interlacing_leftweight) { int i; - if (numsamples <= 0) - return; - /* weighted interlacing */ - if (interlacing_leftweight) { - for (i = 0; i < numsamples; i++) { - int32_t a, b; + for (i = 0; i < numsamples; i++) { + int32_t a, b; - a = buffer[0][i]; - b = buffer[1][i]; + a = buffer[0][i]; + b = buffer[1][i]; - a -= (b * interlacing_leftweight) >> interlacing_shift; - b += a; + a -= (b * interlacing_leftweight) >> interlacing_shift; + b += a; - buffer_out[i*numchannels] = b; - buffer_out[i*numchannels + 1] = a; - } - - return; + buffer[0][i] = b; + buffer[1][i] = a; } +} - /* otherwise basic interlacing took place */ - for (i = 0; i < numsamples; i++) { - int16_t left, right; - - left = buffer[0][i]; - right = buffer[1][i]; +static void append_extra_bits(int32_t *buffer[MAX_CHANNELS], + int32_t *extra_bits_buffer[MAX_CHANNELS], + int extra_bits, int numchannels, int numsamples) +{ + int i, ch; - buffer_out[i*numchannels] = left; - buffer_out[i*numchannels + 1] = right; - } + for (ch = 0; ch < numchannels; ch++) + for (i = 0; i < numsamples; i++) + buffer[ch][i] = (buffer[ch][i] << extra_bits) | extra_bits_buffer[ch][i]; } -static void decorrelate_stereo_24(int32_t *buffer[MAX_CHANNELS], - int32_t *buffer_out, - int32_t *wasted_bits_buffer[MAX_CHANNELS], - int wasted_bits, - int numchannels, int numsamples, - uint8_t interlacing_shift, - uint8_t interlacing_leftweight) +static void interleave_stereo_16(int32_t *buffer[MAX_CHANNELS], + int16_t *buffer_out, int numsamples) { int i; - if (numsamples <= 0) - return; - - /* weighted interlacing */ - if (interlacing_leftweight) { - for (i = 0; i < numsamples; i++) { - int32_t a, b; - - a = buffer[0][i]; - b = buffer[1][i]; - - a -= (b * interlacing_leftweight) >> interlacing_shift; - b += a; - - if (wasted_bits) { - b = (b << wasted_bits) | wasted_bits_buffer[0][i]; - a = (a << wasted_bits) | wasted_bits_buffer[1][i]; - } - - buffer_out[i * numchannels] = b << 8; - buffer_out[i * numchannels + 1] = a << 8; - } - } else { - for (i = 0; i < numsamples; i++) { - int32_t left, right; - - left = buffer[0][i]; - right = buffer[1][i]; + for (i = 0; i < numsamples; i++) { + *buffer_out++ = buffer[0][i]; + *buffer_out++ = buffer[1][i]; + } +} - if (wasted_bits) { - left = (left << wasted_bits) | wasted_bits_buffer[0][i]; - right = (right << wasted_bits) | wasted_bits_buffer[1][i]; - } +static void interleave_stereo_24(int32_t *buffer[MAX_CHANNELS], + int32_t *buffer_out, int numsamples) +{ + int i; - buffer_out[i * numchannels] = left << 8; - buffer_out[i * numchannels + 1] = right << 8; - } + for (i = 0; i < numsamples; i++) { + *buffer_out++ = buffer[0][i] << 8; + *buffer_out++ = buffer[1][i] << 8; } } @@ -452,18 +366,14 @@ int isnotcompressed; uint8_t interlacing_shift; uint8_t interlacing_leftweight; - - /* short-circuit null buffers */ - if (!inbuffer || !input_buffer_size) - return -1; + int i, ch; init_get_bits(&alac->gb, inbuffer, input_buffer_size * 8); channels = get_bits(&alac->gb, 3) + 1; - if (channels > MAX_CHANNELS) { - av_log(avctx, AV_LOG_ERROR, "channels > %d not supported\n", - MAX_CHANNELS); - return -1; + if (channels != avctx->channels) { + av_log(avctx, AV_LOG_ERROR, "frame header channel count mismatch\n"); + return AVERROR_INVALIDDATA; } /* 2^result = something to do with output waiting. @@ -476,7 +386,7 @@ /* the output sample size is stored soon */ hassize = get_bits1(&alac->gb); - alac->wasted_bits = get_bits(&alac->gb, 2) << 3; + alac->extra_bits = get_bits(&alac->gb, 2) << 3; /* whether the frame is compressed */ isnotcompressed = get_bits1(&alac->gb); @@ -491,17 +401,7 @@ } else outputsamples = alac->setinfo_max_samples_per_frame; - switch (alac->setinfo_sample_size) { - case 16: avctx->sample_fmt = AV_SAMPLE_FMT_S16; - alac->bytespersample = channels << 1; - break; - case 24: avctx->sample_fmt = AV_SAMPLE_FMT_S32; - alac->bytespersample = channels << 2; - break; - default: av_log(avctx, AV_LOG_ERROR, "Sample depth %d is not supported.\n", - alac->setinfo_sample_size); - return -1; - } + alac->bytespersample = channels * av_get_bytes_per_sample(avctx->sample_fmt); if(outputsamples > *outputsize / alac->bytespersample){ av_log(avctx, AV_LOG_ERROR, "sample buffer too small\n"); @@ -509,7 +409,7 @@ } *outputsize = outputsamples * alac->bytespersample; - readsamplesize = alac->setinfo_sample_size - (alac->wasted_bits) + channels - 1; + readsamplesize = alac->setinfo_sample_size - alac->extra_bits + channels - 1; if (readsamplesize > MIN_CACHE_BITS) { av_log(avctx, AV_LOG_ERROR, "readsamplesize too big (%d)\n", readsamplesize); return -1; @@ -522,51 +422,49 @@ int prediction_type[MAX_CHANNELS]; int prediction_quantitization[MAX_CHANNELS]; int ricemodifier[MAX_CHANNELS]; - int i, chan; interlacing_shift = get_bits(&alac->gb, 8); interlacing_leftweight = get_bits(&alac->gb, 8); - for (chan = 0; chan < channels; chan++) { - prediction_type[chan] = get_bits(&alac->gb, 4); - prediction_quantitization[chan] = get_bits(&alac->gb, 4); + for (ch = 0; ch < channels; ch++) { + prediction_type[ch] = get_bits(&alac->gb, 4); + prediction_quantitization[ch] = get_bits(&alac->gb, 4); - ricemodifier[chan] = get_bits(&alac->gb, 3); - predictor_coef_num[chan] = get_bits(&alac->gb, 5); + ricemodifier[ch] = get_bits(&alac->gb, 3); + predictor_coef_num[ch] = get_bits(&alac->gb, 5); /* read the predictor table */ - for (i = 0; i < predictor_coef_num[chan]; i++) - predictor_coef_table[chan][i] = (int16_t)get_bits(&alac->gb, 16); + for (i = 0; i < predictor_coef_num[ch]; i++) + predictor_coef_table[ch][i] = (int16_t)get_bits(&alac->gb, 16); } - if (alac->wasted_bits) { - int i, ch; + if (alac->extra_bits) { for (i = 0; i < outputsamples; i++) { for (ch = 0; ch < channels; ch++) - alac->wasted_bits_buffer[ch][i] = get_bits(&alac->gb, alac->wasted_bits); + alac->extra_bits_buffer[ch][i] = get_bits(&alac->gb, alac->extra_bits); } } - for (chan = 0; chan < channels; chan++) { + for (ch = 0; ch < channels; ch++) { bastardized_rice_decompress(alac, - alac->predicterror_buffer[chan], + alac->predicterror_buffer[ch], outputsamples, readsamplesize, alac->setinfo_rice_initialhistory, alac->setinfo_rice_kmodifier, - ricemodifier[chan] * alac->setinfo_rice_historymult / 4, + ricemodifier[ch] * alac->setinfo_rice_historymult / 4, (1 << alac->setinfo_rice_kmodifier) - 1); - if (prediction_type[chan] == 0) { + if (prediction_type[ch] == 0) { /* adaptive fir */ - predictor_decompress_fir_adapt(alac->predicterror_buffer[chan], - alac->outputsamples_buffer[chan], + predictor_decompress_fir_adapt(alac->predicterror_buffer[ch], + alac->outputsamples_buffer[ch], outputsamples, readsamplesize, - predictor_coef_table[chan], - predictor_coef_num[chan], - prediction_quantitization[chan]); + predictor_coef_table[ch], + predictor_coef_num[ch], + prediction_quantitization[ch]); } else { - av_log(avctx, AV_LOG_ERROR, "FIXME: unhandled prediction type: %i\n", prediction_type[chan]); + av_log(avctx, AV_LOG_ERROR, "FIXME: unhandled prediction type: %i\n", prediction_type[ch]); /* I think the only other prediction type (or perhaps this is * just a boolean?) runs adaptive fir twice.. like: * predictor_decompress_fir_adapt(predictor_error, tempout, ...) @@ -577,44 +475,35 @@ } } else { /* not compressed, easy case */ - int i, chan; - if (alac->setinfo_sample_size <= 16) { - for (i = 0; i < outputsamples; i++) - for (chan = 0; chan < channels; chan++) { - int32_t audiobits; - - audiobits = get_sbits_long(&alac->gb, alac->setinfo_sample_size); - - alac->outputsamples_buffer[chan][i] = audiobits; - } - } else { - for (i = 0; i < outputsamples; i++) { - for (chan = 0; chan < channels; chan++) { - alac->outputsamples_buffer[chan][i] = get_bits(&alac->gb, - alac->setinfo_sample_size); - alac->outputsamples_buffer[chan][i] = sign_extend(alac->outputsamples_buffer[chan][i], - alac->setinfo_sample_size); - } + for (i = 0; i < outputsamples; i++) { + for (ch = 0; ch < channels; ch++) { + alac->outputsamples_buffer[ch][i] = get_sbits_long(&alac->gb, + alac->setinfo_sample_size); } } - alac->wasted_bits = 0; + alac->extra_bits = 0; interlacing_shift = 0; interlacing_leftweight = 0; } if (get_bits(&alac->gb, 3) != 7) av_log(avctx, AV_LOG_ERROR, "Error : Wrong End Of Frame\n"); + if (channels == 2 && interlacing_leftweight) { + decorrelate_stereo(alac->outputsamples_buffer, outputsamples, + interlacing_shift, interlacing_leftweight); + } + + if (alac->extra_bits) { + append_extra_bits(alac->outputsamples_buffer, alac->extra_bits_buffer, + alac->extra_bits, alac->numchannels, outputsamples); + } + switch(alac->setinfo_sample_size) { case 16: if (channels == 2) { - reconstruct_stereo_16(alac->outputsamples_buffer, - (int16_t*)outbuffer, - alac->numchannels, - outputsamples, - interlacing_shift, - interlacing_leftweight); + interleave_stereo_16(alac->outputsamples_buffer, outbuffer, + outputsamples); } else { - int i; for (i = 0; i < outputsamples; i++) { ((int16_t*)outbuffer)[i] = alac->outputsamples_buffer[0][i]; } @@ -622,16 +511,9 @@ break; case 24: if (channels == 2) { - decorrelate_stereo_24(alac->outputsamples_buffer, - outbuffer, - alac->wasted_bits_buffer, - alac->wasted_bits, - alac->numchannels, - outputsamples, - interlacing_shift, - interlacing_leftweight); + interleave_stereo_24(alac->outputsamples_buffer, outbuffer, + outputsamples); } else { - int i; for (i = 0; i < outputsamples; i++) ((int32_t *)outbuffer)[i] = alac->outputsamples_buffer[0][i] << 8; } @@ -644,11 +526,75 @@ return input_buffer_size; } +static av_cold int alac_decode_close(AVCodecContext *avctx) +{ + ALACContext *alac = avctx->priv_data; + + int ch; + for (ch = 0; ch < alac->numchannels; ch++) { + av_freep(&alac->predicterror_buffer[ch]); + av_freep(&alac->outputsamples_buffer[ch]); + av_freep(&alac->extra_bits_buffer[ch]); + } + + return 0; +} + +static int allocate_buffers(ALACContext *alac) +{ + int ch; + for (ch = 0; ch < alac->numchannels; ch++) { + int buf_size = alac->setinfo_max_samples_per_frame * sizeof(int32_t); + + FF_ALLOC_OR_GOTO(alac->avctx, alac->predicterror_buffer[ch], + buf_size, buf_alloc_fail); + + FF_ALLOC_OR_GOTO(alac->avctx, alac->outputsamples_buffer[ch], + buf_size, buf_alloc_fail); + + FF_ALLOC_OR_GOTO(alac->avctx, alac->extra_bits_buffer[ch], + buf_size, buf_alloc_fail); + } + return 0; +buf_alloc_fail: + alac_decode_close(alac->avctx); + return AVERROR(ENOMEM); +} + +static int alac_set_info(ALACContext *alac) +{ + const unsigned char *ptr = alac->avctx->extradata; + + ptr += 4; /* size */ + ptr += 4; /* alac */ + ptr += 4; /* 0 ? */ + + if(AV_RB32(ptr) >= UINT_MAX/4){ + av_log(alac->avctx, AV_LOG_ERROR, "setinfo_max_samples_per_frame too large\n"); + return -1; + } + + /* buffer size / 2 ? */ + alac->setinfo_max_samples_per_frame = bytestream_get_be32(&ptr); + ptr++; /* ??? */ + alac->setinfo_sample_size = *ptr++; + alac->setinfo_rice_historymult = *ptr++; + alac->setinfo_rice_initialhistory = *ptr++; + alac->setinfo_rice_kmodifier = *ptr++; + alac->numchannels = *ptr++; + bytestream_get_be16(&ptr); /* ??? */ + bytestream_get_be32(&ptr); /* max coded frame size */ + bytestream_get_be32(&ptr); /* bitrate ? */ + bytestream_get_be32(&ptr); /* samplerate */ + + return 0; +} + static av_cold int alac_decode_init(AVCodecContext * avctx) { + int ret; ALACContext *alac = avctx->priv_data; alac->avctx = avctx; - alac->numchannels = alac->avctx->channels; /* initialize from the extradata */ if (alac->avctx->extradata_size != ALAC_EXTRADATA_SIZE) { @@ -661,18 +607,34 @@ return -1; } - return 0; -} + switch (alac->setinfo_sample_size) { + case 16: avctx->sample_fmt = AV_SAMPLE_FMT_S16; + break; + case 24: avctx->sample_fmt = AV_SAMPLE_FMT_S32; + break; + default: av_log_ask_for_sample(avctx, "Sample depth %d is not supported.\n", + alac->setinfo_sample_size); + return AVERROR_PATCHWELCOME; + } -static av_cold int alac_decode_close(AVCodecContext *avctx) -{ - ALACContext *alac = avctx->priv_data; + if (alac->numchannels < 1) { + av_log(avctx, AV_LOG_WARNING, "Invalid channel count\n"); + alac->numchannels = avctx->channels; + } else { + if (alac->numchannels > MAX_CHANNELS) + alac->numchannels = avctx->channels; + else + avctx->channels = alac->numchannels; + } + if (avctx->channels > MAX_CHANNELS) { + av_log(avctx, AV_LOG_ERROR, "Unsupported channel count: %d\n", + avctx->channels); + return AVERROR_PATCHWELCOME; + } - int chan; - for (chan = 0; chan < MAX_CHANNELS; chan++) { - av_freep(&alac->predicterror_buffer[chan]); - av_freep(&alac->outputsamples_buffer[chan]); - av_freep(&alac->wasted_bits_buffer[chan]); + if ((ret = allocate_buffers(alac)) < 0) { + av_log(avctx, AV_LOG_ERROR, "Error allocating buffers\n"); + return ret; } return 0; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/allcodecs.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/allcodecs.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/allcodecs.c 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/allcodecs.c 2011-11-04 12:38:26.000000000 +0000 @@ -57,6 +57,7 @@ REGISTER_HWACCEL (H263_VAAPI, h263_vaapi); REGISTER_HWACCEL (H264_DXVA2, h264_dxva2); REGISTER_HWACCEL (H264_VAAPI, h264_vaapi); + REGISTER_HWACCEL (H264_VDA, h264_vda); REGISTER_HWACCEL (MPEG1_VDPAU, mpeg1_vdpau); REGISTER_HWACCEL (MPEG2_DXVA2, mpeg2_dxva2); REGISTER_HWACCEL (MPEG2_VAAPI, mpeg2_vaapi); @@ -91,6 +92,7 @@ REGISTER_DECODER (CSCD, cscd); REGISTER_DECODER (CYUV, cyuv); REGISTER_DECODER (DFA, dfa); + REGISTER_DECODER (DIRAC, dirac); REGISTER_ENCDEC (DNXHD, dnxhd); REGISTER_ENCDEC (DPX, dpx); REGISTER_DECODER (DSICINVIDEO, dsicinvideo); @@ -172,7 +174,7 @@ REGISTER_DECODER (PICTOR, pictor); REGISTER_ENCDEC (PNG, png); REGISTER_ENCDEC (PPM, ppm); - REGISTER_DECODER (PRORES_GPL, prores_gpl); + REGISTER_ENCDEC (PRORES, prores); REGISTER_DECODER (PRORES_LGPL, prores_lgpl); REGISTER_DECODER (PTX, ptx); REGISTER_DECODER (QDRAW, qdraw); @@ -208,6 +210,7 @@ REGISTER_DECODER (TSCC, tscc); REGISTER_DECODER (TXD, txd); REGISTER_DECODER (ULTI, ulti); + REGISTER_DECODER (UTVIDEO, utvideo); REGISTER_ENCDEC (V210, v210); REGISTER_DECODER (V210X, v210x); REGISTER_DECODER (VB, vb); @@ -258,7 +261,7 @@ REGISTER_DECODER (DSICINAUDIO, dsicinaudio); REGISTER_ENCDEC (EAC3, eac3); REGISTER_ENCDEC (FLAC, flac); - REGISTER_DECODER (G723_1, g723_1); + REGISTER_ENCDEC (G723_1, g723_1); REGISTER_DECODER (G729, g729); REGISTER_DECODER (GSM, gsm); REGISTER_DECODER (GSM_MS, gsm_ms); @@ -295,6 +298,7 @@ REGISTER_DECODER (VMDAUDIO, vmdaudio); REGISTER_ENCDEC (VORBIS, vorbis); REGISTER_DECODER (WAVPACK, wavpack); + REGISTER_DECODER (WMALOSSLESS, wmalossless); REGISTER_DECODER (WMAPRO, wmapro); REGISTER_ENCDEC (WMAV1, wmav1); REGISTER_ENCDEC (WMAV2, wmav2); @@ -327,7 +331,7 @@ REGISTER_ENCDEC (PCM_U24LE, pcm_u24le); REGISTER_ENCDEC (PCM_U32BE, pcm_u32be); REGISTER_ENCDEC (PCM_U32LE, pcm_u32le); - REGISTER_ENCDEC (PCM_ZORK , pcm_zork); + REGISTER_DECODER (PCM_ZORK , pcm_zork); /* DPCM codecs */ REGISTER_DECODER (INTERPLAY_DPCM, interplay_dpcm); @@ -389,6 +393,7 @@ REGISTER_ENCDEC (LIBSPEEX, libspeex); REGISTER_DECODER (LIBSTAGEFRIGHT_H264, libstagefright_h264); REGISTER_ENCODER (LIBTHEORA, libtheora); + REGISTER_DECODER (LIBUTVIDEO, libutvideo); REGISTER_ENCODER (LIBVO_AACENC, libvo_aacenc); REGISTER_ENCODER (LIBVO_AMRWBENC, libvo_amrwbenc); REGISTER_ENCODER (LIBVORBIS, libvorbis); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/alsdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/alsdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/alsdec.c 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/alsdec.c 2011-11-04 12:38:26.000000000 +0000 @@ -289,7 +289,7 @@ init_get_bits(&gb, avctx->extradata, avctx->extradata_size * 8); - config_offset = ff_mpeg4audio_get_config(&m4ac, avctx->extradata, + config_offset = avpriv_mpeg4audio_get_config(&m4ac, avctx->extradata, avctx->extradata_size); if (config_offset < 0) @@ -393,7 +393,7 @@ if (get_bits_left(&gb) < 32) return -1; - if (avctx->error_recognition >= FF_ER_CAREFUL) { + if (avctx->err_recognition & AV_EF_CRCCHECK) { ctx->crc_table = av_crc_get_table(AV_CRC_32_IEEE_LE); ctx->crc = 0xFFFFFFFF; ctx->crc_org = ~get_bits_long(&gb, 32); @@ -1476,7 +1476,7 @@ } // update CRC - if (sconf->crc_enabled && avctx->error_recognition >= FF_ER_CAREFUL) { + if (sconf->crc_enabled && (avctx->err_recognition & AV_EF_CRCCHECK)) { int swap = HAVE_BIGENDIAN != sconf->msb_first; if (ctx->avctx->bits_per_raw_sample == 24) { @@ -1710,7 +1710,7 @@ // allocate crc buffer if (HAVE_BIGENDIAN != sconf->msb_first && sconf->crc_enabled && - avctx->error_recognition >= FF_ER_CAREFUL) { + (avctx->err_recognition & AV_EF_CRCCHECK)) { ctx->crc_buffer = av_malloc(sizeof(*ctx->crc_buffer) * ctx->cur_frame_length * avctx->channels * diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/apedec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/apedec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/apedec.c 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/apedec.c 2011-11-04 12:38:26.000000000 +0000 @@ -26,6 +26,7 @@ #include "get_bits.h" #include "bytestream.h" #include "libavutil/audioconvert.h" +#include "libavutil/avassert.h" /** * @file @@ -163,22 +164,34 @@ // TODO: dsputilize -static av_cold int ape_decode_init(AVCodecContext * avctx) +static av_cold int ape_decode_close(AVCodecContext *avctx) +{ + APEContext *s = avctx->priv_data; + int i; + + for (i = 0; i < APE_FILTER_LEVELS; i++) + av_freep(&s->filterbuf[i]); + + av_freep(&s->data); + return 0; +} + +static av_cold int ape_decode_init(AVCodecContext *avctx) { APEContext *s = avctx->priv_data; int i; if (avctx->extradata_size != 6) { av_log(avctx, AV_LOG_ERROR, "Incorrect extradata\n"); - return -1; + return AVERROR(EINVAL); } if (avctx->bits_per_coded_sample != 16) { av_log(avctx, AV_LOG_ERROR, "Only 16-bit samples are supported\n"); - return -1; + return AVERROR(EINVAL); } if (avctx->channels > 2) { av_log(avctx, AV_LOG_ERROR, "Only mono and stereo is supported\n"); - return -1; + return AVERROR(EINVAL); } s->avctx = avctx; s->channels = avctx->channels; @@ -186,34 +199,29 @@ s->compression_level = AV_RL16(avctx->extradata + 2); s->flags = AV_RL16(avctx->extradata + 4); - av_log(avctx, AV_LOG_DEBUG, "Compression Level: %d - Flags: %d\n", s->compression_level, s->flags); + av_log(avctx, AV_LOG_DEBUG, "Compression Level: %d - Flags: %d\n", + s->compression_level, s->flags); if (s->compression_level % 1000 || s->compression_level > COMPRESSION_LEVEL_INSANE) { - av_log(avctx, AV_LOG_ERROR, "Incorrect compression level %d\n", s->compression_level); - return -1; + av_log(avctx, AV_LOG_ERROR, "Incorrect compression level %d\n", + s->compression_level); + return AVERROR_INVALIDDATA; } s->fset = s->compression_level / 1000 - 1; for (i = 0; i < APE_FILTER_LEVELS; i++) { if (!ape_filter_orders[s->fset][i]) break; - s->filterbuf[i] = av_malloc((ape_filter_orders[s->fset][i] * 3 + HISTORY_SIZE) * 4); + FF_ALLOC_OR_GOTO(avctx, s->filterbuf[i], + (ape_filter_orders[s->fset][i] * 3 + HISTORY_SIZE) * 4, + filter_alloc_fail); } dsputil_init(&s->dsp, avctx); avctx->sample_fmt = AV_SAMPLE_FMT_S16; avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO; return 0; -} - -static av_cold int ape_decode_close(AVCodecContext * avctx) -{ - APEContext *s = avctx->priv_data; - int i; - - for (i = 0; i < APE_FILTER_LEVELS; i++) - av_freep(&s->filterbuf[i]); - - av_freep(&s->data); - return 0; +filter_alloc_fail: + ape_decode_close(avctx); + return AVERROR(ENOMEM); } /** @@ -228,7 +236,7 @@ #define BOTTOM_VALUE (TOP_VALUE >> 8) /** Start the decoder */ -static inline void range_start_decoding(APEContext * ctx) +static inline void range_start_decoding(APEContext *ctx) { ctx->rc.buffer = bytestream_get_byte(&ctx->ptr); ctx->rc.low = ctx->rc.buffer >> (8 - EXTRA_BITS); @@ -236,13 +244,16 @@ } /** Perform normalization */ -static inline void range_dec_normalize(APEContext * ctx) +static inline void range_dec_normalize(APEContext *ctx) { while (ctx->rc.range <= BOTTOM_VALUE) { ctx->rc.buffer <<= 8; - if(ctx->ptr < ctx->data_end) + if(ctx->ptr < ctx->data_end) { ctx->rc.buffer += *ctx->ptr; - ctx->ptr++; + ctx->ptr++; + } else { + ctx->error = 1; + } ctx->rc.low = (ctx->rc.low << 8) | ((ctx->rc.buffer >> 1) & 0xFF); ctx->rc.range <<= 8; } @@ -254,7 +265,7 @@ * @param tot_f is the total frequency or (code_value)1<rc.help = ctx->rc.range / tot_f; @@ -266,7 +277,7 @@ * @param ctx decoder context * @param shift number of bits to decode */ -static inline int range_decode_culshift(APEContext * ctx, int shift) +static inline int range_decode_culshift(APEContext *ctx, int shift) { range_dec_normalize(ctx); ctx->rc.help = ctx->rc.range >> shift; @@ -280,14 +291,14 @@ * @param sy_f the interval length (frequency of the symbol) * @param lt_f the lower end (frequency sum of < symbols) */ -static inline void range_decode_update(APEContext * ctx, int sy_f, int lt_f) +static inline void range_decode_update(APEContext *ctx, int sy_f, int lt_f) { ctx->rc.low -= ctx->rc.help * lt_f; ctx->rc.range = ctx->rc.help * sy_f; } /** Decode n bits (n <= 16) without modelling */ -static inline int range_decode_bits(APEContext * ctx, int n) +static inline int range_decode_bits(APEContext *ctx, int n) { int sym = range_decode_culshift(ctx, n); range_decode_update(ctx, 1, sym); @@ -339,7 +350,7 @@ * @param counts probability range start position * @param counts_diff probability range widths */ -static inline int range_get_symbol(APEContext * ctx, +static inline int range_get_symbol(APEContext *ctx, const uint16_t counts[], const uint16_t counts_diff[]) { @@ -374,7 +385,7 @@ rice->k++; } -static inline int ape_decode_value(APEContext * ctx, APERice *rice) +static inline int ape_decode_value(APEContext *ctx, APERice *rice) { int x, overflow; @@ -441,7 +452,7 @@ return -(x >> 1); } -static void entropy_decode(APEContext * ctx, int blockstodecode, int stereo) +static void entropy_decode(APEContext *ctx, int blockstodecode, int stereo) { int32_t *decoded0 = ctx->decoded0; int32_t *decoded1 = ctx->decoded1; @@ -464,9 +475,11 @@ range_dec_normalize(ctx); /* normalize to use up all bytes */ } -static void init_entropy_decoder(APEContext * ctx) +static int init_entropy_decoder(APEContext *ctx) { /* Read the CRC */ + if (ctx->data_end - ctx->ptr < 6) + return AVERROR_INVALIDDATA; ctx->CRC = bytestream_get_be32(&ctx->ptr); /* Read the frame flags if they exist */ @@ -474,6 +487,8 @@ if ((ctx->fileversion > 3820) && (ctx->CRC & 0x80000000)) { ctx->CRC &= ~0x80000000; + if (ctx->data_end - ctx->ptr < 6) + return AVERROR_INVALIDDATA; ctx->frameflags = bytestream_get_be32(&ctx->ptr); } @@ -490,13 +505,15 @@ ctx->ptr++; range_start_decoding(ctx); + + return 0; } static const int32_t initial_coeffs[4] = { 360, 317, -109, 98 }; -static void init_predictor_decoder(APEContext * ctx) +static void init_predictor_decoder(APEContext *ctx) { APEPredictor *p = &ctx->predictor; @@ -519,7 +536,10 @@ return (x < 0) - (x > 0); } -static av_always_inline int predictor_update_filter(APEPredictor *p, const int decoded, const int filter, const int delayA, const int delayB, const int adaptA, const int adaptB) +static av_always_inline int predictor_update_filter(APEPredictor *p, + const int decoded, const int filter, + const int delayA, const int delayB, + const int adaptA, const int adaptB) { int32_t predictionA, predictionB, sign; @@ -563,7 +583,7 @@ return p->filterA[filter]; } -static void predictor_decode_stereo(APEContext * ctx, int count) +static void predictor_decode_stereo(APEContext *ctx, int count) { APEPredictor *p = &ctx->predictor; int32_t *decoded0 = ctx->decoded0; @@ -571,9 +591,11 @@ while (count--) { /* Predictor Y */ - *decoded0 = predictor_update_filter(p, *decoded0, 0, YDELAYA, YDELAYB, YADAPTCOEFFSA, YADAPTCOEFFSB); + *decoded0 = predictor_update_filter(p, *decoded0, 0, YDELAYA, YDELAYB, + YADAPTCOEFFSA, YADAPTCOEFFSB); decoded0++; - *decoded1 = predictor_update_filter(p, *decoded1, 1, XDELAYA, XDELAYB, XADAPTCOEFFSA, XADAPTCOEFFSB); + *decoded1 = predictor_update_filter(p, *decoded1, 1, XDELAYA, XDELAYB, + XADAPTCOEFFSA, XADAPTCOEFFSB); decoded1++; /* Combined */ @@ -587,7 +609,7 @@ } } -static void predictor_decode_mono(APEContext * ctx, int count) +static void predictor_decode_mono(APEContext *ctx, int count) { APEPredictor *p = &ctx->predictor; int32_t *decoded0 = ctx->decoded0; @@ -632,7 +654,7 @@ p->lastA[0] = currentA; } -static void do_init_filter(APEFilter *f, int16_t * buf, int order) +static void do_init_filter(APEFilter *f, int16_t *buf, int order) { f->coeffs = buf; f->historybuffer = buf + order; @@ -644,20 +666,23 @@ f->avg = 0; } -static void init_filter(APEContext * ctx, APEFilter *f, int16_t * buf, int order) +static void init_filter(APEContext *ctx, APEFilter *f, int16_t *buf, int order) { do_init_filter(&f[0], buf, order); do_init_filter(&f[1], buf + order * 3 + HISTORY_SIZE, order); } -static void do_apply_filter(APEContext * ctx, int version, APEFilter *f, int32_t *data, int count, int order, int fracbits) +static void do_apply_filter(APEContext *ctx, int version, APEFilter *f, + int32_t *data, int count, int order, int fracbits) { int res; int absres; while (count--) { /* round fixedpoint scalar product */ - res = ctx->dsp.scalarproduct_and_madd_int16(f->coeffs, f->delay - order, f->adaptcoeffs - order, order, APESIGN(*data)); + res = ctx->dsp.scalarproduct_and_madd_int16(f->coeffs, f->delay - order, + f->adaptcoeffs - order, + order, APESIGN(*data)); res = (res + (1 << (fracbits - 1))) >> fracbits; res += *data; *data++ = res; @@ -676,7 +701,8 @@ /* Update the adaption coefficients */ absres = FFABS(res); if (absres) - *f->adaptcoeffs = ((res & (1<<31)) - (1<<30)) >> (25 + (absres <= f->avg*3) + (absres <= f->avg*4/3)); + *f->adaptcoeffs = ((res & (1<<31)) - (1<<30)) >> + (25 + (absres <= f->avg*3) + (absres <= f->avg*4/3)); else *f->adaptcoeffs = 0; @@ -699,8 +725,8 @@ } } -static void apply_filter(APEContext * ctx, APEFilter *f, - int32_t * data0, int32_t * data1, +static void apply_filter(APEContext *ctx, APEFilter *f, + int32_t *data0, int32_t *data1, int count, int order, int fracbits) { do_apply_filter(ctx, ctx->fileversion, &f[0], data0, count, order, fracbits); @@ -708,34 +734,38 @@ do_apply_filter(ctx, ctx->fileversion, &f[1], data1, count, order, fracbits); } -static void ape_apply_filters(APEContext * ctx, int32_t * decoded0, - int32_t * decoded1, int count) +static void ape_apply_filters(APEContext *ctx, int32_t *decoded0, + int32_t *decoded1, int count) { int i; for (i = 0; i < APE_FILTER_LEVELS; i++) { if (!ape_filter_orders[ctx->fset][i]) break; - apply_filter(ctx, ctx->filters[i], decoded0, decoded1, count, ape_filter_orders[ctx->fset][i], ape_filter_fracbits[ctx->fset][i]); + apply_filter(ctx, ctx->filters[i], decoded0, decoded1, count, + ape_filter_orders[ctx->fset][i], + ape_filter_fracbits[ctx->fset][i]); } } -static void init_frame_decoder(APEContext * ctx) +static int init_frame_decoder(APEContext *ctx) { - int i; - init_entropy_decoder(ctx); + int i, ret; + if ((ret = init_entropy_decoder(ctx)) < 0) + return ret; init_predictor_decoder(ctx); for (i = 0; i < APE_FILTER_LEVELS; i++) { if (!ape_filter_orders[ctx->fset][i]) break; - init_filter(ctx, ctx->filters[i], ctx->filterbuf[i], ape_filter_orders[ctx->fset][i]); + init_filter(ctx, ctx->filters[i], ctx->filterbuf[i], + ape_filter_orders[ctx->fset][i]); } + return 0; } -static void ape_unpack_mono(APEContext * ctx, int count) +static void ape_unpack_mono(APEContext *ctx, int count) { - int32_t left; int32_t *decoded0 = ctx->decoded0; int32_t *decoded1 = ctx->decoded1; @@ -754,14 +784,11 @@ /* Pseudo-stereo - just copy left channel to right channel */ if (ctx->channels == 2) { - while (count--) { - left = *decoded0; - *(decoded1++) = *(decoded0++) = left; - } + memcpy(decoded1, decoded0, count * sizeof(*decoded1)); } } -static void ape_unpack_stereo(APEContext * ctx, int count) +static void ape_unpack_stereo(APEContext *ctx, int count) { int32_t left, right; int32_t *decoded0 = ctx->decoded0; @@ -789,7 +816,7 @@ } } -static int ape_decode_frame(AVCodecContext * avctx, +static int ape_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { @@ -797,49 +824,65 @@ int buf_size = avpkt->size; APEContext *s = avctx->priv_data; int16_t *samples = data; - int nblocks; - int i, n; + uint32_t nblocks; + int i; int blockstodecode; int bytes_used; - if (buf_size == 0 && !s->samples) { - *data_size = 0; - return 0; - } - /* should not happen but who knows */ if (BLOCKS_PER_LOOP * 2 * avctx->channels > *data_size) { - av_log (avctx, AV_LOG_ERROR, "Packet size is too big to be handled in lavc! (max is %d where you have %d)\n", *data_size, s->samples * 2 * avctx->channels); - return -1; + av_log (avctx, AV_LOG_ERROR, "Output buffer is too small.\n"); + return AVERROR(EINVAL); } + /* this should never be negative, but bad things will happen if it is, so + check it just to make sure. */ + av_assert0(s->samples >= 0); + if(!s->samples){ - s->data = av_realloc(s->data, (buf_size + 3) & ~3); + uint32_t offset; + void *tmp_data; + + if (buf_size < 8) { + av_log(avctx, AV_LOG_ERROR, "Packet is too small\n"); + return AVERROR_INVALIDDATA; + } + + tmp_data = av_realloc(s->data, FFALIGN(buf_size, 4)); + if (!tmp_data) + return AVERROR(ENOMEM); + s->data = tmp_data; s->dsp.bswap_buf((uint32_t*)s->data, (const uint32_t*)buf, buf_size >> 2); s->ptr = s->last_ptr = s->data; s->data_end = s->data + buf_size; - nblocks = s->samples = bytestream_get_be32(&s->ptr); - n = bytestream_get_be32(&s->ptr); - if(n < 0 || n > 3){ + nblocks = bytestream_get_be32(&s->ptr); + offset = bytestream_get_be32(&s->ptr); + if (offset > 3) { av_log(avctx, AV_LOG_ERROR, "Incorrect offset passed\n"); s->data = NULL; - return -1; + return AVERROR_INVALIDDATA; } - s->ptr += n; + if (s->data_end - s->ptr < offset) { + av_log(avctx, AV_LOG_ERROR, "Packet is too small\n"); + return AVERROR_INVALIDDATA; + } + s->ptr += offset; - s->currentframeblocks = nblocks; - buf += 4; - if (s->samples <= 0) { - *data_size = 0; - return buf_size; + if (!nblocks || nblocks > INT_MAX) { + av_log(avctx, AV_LOG_ERROR, "Invalid sample count: %u.\n", nblocks); + return AVERROR_INVALIDDATA; } + s->currentframeblocks = s->samples = nblocks; memset(s->decoded0, 0, sizeof(s->decoded0)); memset(s->decoded1, 0, sizeof(s->decoded1)); /* Initialize the frame decoder */ - init_frame_decoder(s); + if (init_frame_decoder(s) < 0) { + av_log(avctx, AV_LOG_ERROR, "Error reading frame header\n"); + return AVERROR_INVALIDDATA; + } } if (!s->data) { @@ -858,10 +901,10 @@ ape_unpack_stereo(s, blockstodecode); emms_c(); - if(s->error || s->ptr > s->data_end){ + if (s->error) { s->samples=0; av_log(avctx, AV_LOG_ERROR, "Error decoding frame\n"); - return -1; + return AVERROR_INVALIDDATA; } for (i = 0; i < blockstodecode; i++) { diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/arm/ac3dsp_init_arm.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/arm/ac3dsp_init_arm.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/arm/ac3dsp_init_arm.c 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/arm/ac3dsp_init_arm.c 2011-11-04 12:38:26.000000000 +0000 @@ -29,6 +29,14 @@ void ff_ac3_rshift_int32_neon(int32_t *src, unsigned len, unsigned shift); void ff_float_to_fixed24_neon(int32_t *dst, const float *src, unsigned int len); void ff_ac3_extract_exponents_neon(uint8_t *exp, int32_t *coef, int nb_coefs); +void ff_ac3_sum_square_butterfly_int32_neon(int64_t sum[4], + const int32_t *coef0, + const int32_t *coef1, + int len); +void ff_ac3_sum_square_butterfly_float_neon(float sum[4], + const float *coef0, + const float *coef1, + int len); void ff_ac3_bit_alloc_calc_bap_armv6(int16_t *mask, int16_t *psd, int start, int end, @@ -52,5 +60,7 @@ c->ac3_rshift_int32 = ff_ac3_rshift_int32_neon; c->float_to_fixed24 = ff_float_to_fixed24_neon; c->extract_exponents = ff_ac3_extract_exponents_neon; + c->sum_square_butterfly_int32 = ff_ac3_sum_square_butterfly_int32_neon; + c->sum_square_butterfly_float = ff_ac3_sum_square_butterfly_float_neon; } } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/arm/ac3dsp_neon.S ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/arm/ac3dsp_neon.S --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/arm/ac3dsp_neon.S 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/arm/ac3dsp_neon.S 2011-11-04 12:38:26.000000000 +0000 @@ -108,3 +108,47 @@ bgt 1b bx lr endfunc + +function ff_ac3_sum_square_butterfly_int32_neon, export=1 + vmov.i64 q0, #0 + vmov.i64 q1, #0 + vmov.i64 q2, #0 + vmov.i64 q3, #0 +1: + vld1.32 {d16}, [r1]! + vld1.32 {d17}, [r2]! + vadd.s32 d18, d16, d17 + vsub.s32 d19, d16, d17 + vmlal.s32 q0, d16, d16 + vmlal.s32 q1, d17, d17 + vmlal.s32 q2, d18, d18 + vmlal.s32 q3, d19, d19 + subs r3, r3, #2 + bgt 1b + vadd.s64 d0, d0, d1 + vadd.s64 d1, d2, d3 + vadd.s64 d2, d4, d5 + vadd.s64 d3, d6, d7 + vst1.64 {q0-q1}, [r0] + bx lr +endfunc + +function ff_ac3_sum_square_butterfly_float_neon, export=1 + vmov.f32 q0, #0.0 + vmov.f32 q1, #0.0 +1: + vld1.32 {d16}, [r1]! + vld1.32 {d17}, [r2]! + vadd.f32 d18, d16, d17 + vsub.f32 d19, d16, d17 + vmla.f32 d0, d16, d16 + vmla.f32 d1, d17, d17 + vmla.f32 d2, d18, d18 + vmla.f32 d3, d19, d19 + subs r3, r3, #2 + bgt 1b + vpadd.f32 d0, d0, d1 + vpadd.f32 d1, d2, d3 + vst1.32 {q0}, [r0] + bx lr +endfunc diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/arm/asm-offsets.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/arm/asm-offsets.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/arm/asm-offsets.h 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/arm/asm-offsets.h 2011-11-04 12:38:26.000000000 +0000 @@ -29,11 +29,11 @@ #endif /* MpegEncContext */ -#define Y_DC_SCALE 0xac -#define C_DC_SCALE 0xb0 -#define AC_PRED 0xb4 -#define BLOCK_LAST_INDEX 0xb8 -#define H263_AIC 0xe8 -#define INTER_SCANTAB_RASTER_END 0x130 +#define Y_DC_SCALE 0xa8 +#define C_DC_SCALE 0xac +#define AC_PRED 0xb0 +#define BLOCK_LAST_INDEX 0xb4 +#define H263_AIC 0xe4 +#define INTER_SCANTAB_RASTER_END 0x12c #endif /* AVCODEC_ARM_ASM_OFFSETS_H */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/arm/dca.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/arm/dca.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/arm/dca.h 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/arm/dca.h 2011-11-04 12:38:26.000000000 +0000 @@ -23,6 +23,45 @@ #include #include "config.h" +#include "libavutil/intmath.h" + +#if HAVE_ARMV6 && HAVE_INLINE_ASM + +#define decode_blockcode decode_blockcode +static inline int decode_blockcode(int code, int levels, int *values) +{ + int v0, v1, v2, v3; + + __asm__ ("smmul %4, %8, %11 \n" + "smlabb %8, %4, %10, %8 \n" + "smmul %5, %4, %11 \n" + "sub %8, %8, %9, lsr #1 \n" + "smlabb %4, %5, %10, %4 \n" + "smmul %6, %5, %11 \n" + "str %8, %0 \n" + "sub %4, %4, %9, lsr #1 \n" + "smlabb %5, %6, %10, %5 \n" + "smmul %7, %6, %11 \n" + "str %4, %1 \n" + "sub %5, %5, %9, lsr #1 \n" + "smlabb %6, %7, %10, %6 \n" + "cmp %7, #0 \n" + "str %5, %2 \n" + "sub %6, %6, %9, lsr #1 \n" + "it eq \n" + "mvneq %7, #0 \n" + "str %6, %3 \n" + : "=m"(values[0]), "=m"(values[1]), + "=m"(values[2]), "=m"(values[3]), + "=&r"(v0), "=&r"(v1), "=&r"(v2), "=&r"(v3), + "+&r"(code) + : "r"(levels - 1), "r"(-levels), "r"(ff_inverse[levels]) + : "cc"); + + return v3; +} + +#endif #if HAVE_NEON && HAVE_INLINE_ASM && HAVE_ASM_MOD_Y diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/arm/h264dsp_init_arm.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/arm/h264dsp_init_arm.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/arm/h264dsp_init_arm.c 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/arm/h264dsp_init_arm.c 2011-11-04 12:38:26.000000000 +0000 @@ -32,47 +32,22 @@ void ff_h264_h_loop_filter_chroma_neon(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0); -void ff_weight_h264_pixels_16x16_neon(uint8_t *ds, int stride, int log2_den, - int weight, int offset); -void ff_weight_h264_pixels_16x8_neon(uint8_t *ds, int stride, int log2_den, - int weight, int offset); -void ff_weight_h264_pixels_8x16_neon(uint8_t *ds, int stride, int log2_den, - int weight, int offset); -void ff_weight_h264_pixels_8x8_neon(uint8_t *ds, int stride, int log2_den, - int weight, int offset); -void ff_weight_h264_pixels_8x4_neon(uint8_t *ds, int stride, int log2_den, - int weight, int offset); -void ff_weight_h264_pixels_4x8_neon(uint8_t *ds, int stride, int log2_den, - int weight, int offset); -void ff_weight_h264_pixels_4x4_neon(uint8_t *ds, int stride, int log2_den, - int weight, int offset); -void ff_weight_h264_pixels_4x2_neon(uint8_t *ds, int stride, int log2_den, - int weight, int offset); - -void ff_biweight_h264_pixels_16x16_neon(uint8_t *dst, uint8_t *src, int stride, - int log2_den, int weightd, int weights, - int offset); -void ff_biweight_h264_pixels_16x8_neon(uint8_t *dst, uint8_t *src, int stride, - int log2_den, int weightd, int weights, - int offset); -void ff_biweight_h264_pixels_8x16_neon(uint8_t *dst, uint8_t *src, int stride, - int log2_den, int weightd, int weights, - int offset); -void ff_biweight_h264_pixels_8x8_neon(uint8_t *dst, uint8_t *src, int stride, - int log2_den, int weightd, int weights, - int offset); -void ff_biweight_h264_pixels_8x4_neon(uint8_t *dst, uint8_t *src, int stride, - int log2_den, int weightd, int weights, - int offset); -void ff_biweight_h264_pixels_4x8_neon(uint8_t *dst, uint8_t *src, int stride, - int log2_den, int weightd, int weights, - int offset); -void ff_biweight_h264_pixels_4x4_neon(uint8_t *dst, uint8_t *src, int stride, - int log2_den, int weightd, int weights, - int offset); -void ff_biweight_h264_pixels_4x2_neon(uint8_t *dst, uint8_t *src, int stride, - int log2_den, int weightd, int weights, - int offset); +void ff_weight_h264_pixels_16_neon(uint8_t *dst, int stride, int height, + int log2_den, int weight, int offset); +void ff_weight_h264_pixels_8_neon(uint8_t *dst, int stride, int height, + int log2_den, int weight, int offset); +void ff_weight_h264_pixels_4_neon(uint8_t *dst, int stride, int height, + int log2_den, int weight, int offset); + +void ff_biweight_h264_pixels_16_neon(uint8_t *dst, uint8_t *src, int stride, + int height, int log2_den, int weightd, + int weights, int offset); +void ff_biweight_h264_pixels_8_neon(uint8_t *dst, uint8_t *src, int stride, + int height, int log2_den, int weightd, + int weights, int offset); +void ff_biweight_h264_pixels_4_neon(uint8_t *dst, uint8_t *src, int stride, + int height, int log2_den, int weightd, + int weights, int offset); void ff_h264_idct_add_neon(uint8_t *dst, DCTELEM *block, int stride); void ff_h264_idct_dc_add_neon(uint8_t *dst, DCTELEM *block, int stride); @@ -101,23 +76,14 @@ c->h264_v_loop_filter_chroma = ff_h264_v_loop_filter_chroma_neon; c->h264_h_loop_filter_chroma = ff_h264_h_loop_filter_chroma_neon; } - c->weight_h264_pixels_tab[0] = ff_weight_h264_pixels_16x16_neon; - c->weight_h264_pixels_tab[1] = ff_weight_h264_pixels_16x8_neon; - c->weight_h264_pixels_tab[2] = ff_weight_h264_pixels_8x16_neon; - c->weight_h264_pixels_tab[3] = ff_weight_h264_pixels_8x8_neon; - c->weight_h264_pixels_tab[4] = ff_weight_h264_pixels_8x4_neon; - c->weight_h264_pixels_tab[5] = ff_weight_h264_pixels_4x8_neon; - c->weight_h264_pixels_tab[6] = ff_weight_h264_pixels_4x4_neon; - c->weight_h264_pixels_tab[7] = ff_weight_h264_pixels_4x2_neon; - - c->biweight_h264_pixels_tab[0] = ff_biweight_h264_pixels_16x16_neon; - c->biweight_h264_pixels_tab[1] = ff_biweight_h264_pixels_16x8_neon; - c->biweight_h264_pixels_tab[2] = ff_biweight_h264_pixels_8x16_neon; - c->biweight_h264_pixels_tab[3] = ff_biweight_h264_pixels_8x8_neon; - c->biweight_h264_pixels_tab[4] = ff_biweight_h264_pixels_8x4_neon; - c->biweight_h264_pixels_tab[5] = ff_biweight_h264_pixels_4x8_neon; - c->biweight_h264_pixels_tab[6] = ff_biweight_h264_pixels_4x4_neon; - c->biweight_h264_pixels_tab[7] = ff_biweight_h264_pixels_4x2_neon; + + c->weight_h264_pixels_tab[0] = ff_weight_h264_pixels_16_neon; + c->weight_h264_pixels_tab[1] = ff_weight_h264_pixels_8_neon; + c->weight_h264_pixels_tab[2] = ff_weight_h264_pixels_4_neon; + + c->biweight_h264_pixels_tab[0] = ff_biweight_h264_pixels_16_neon; + c->biweight_h264_pixels_tab[1] = ff_biweight_h264_pixels_8_neon; + c->biweight_h264_pixels_tab[2] = ff_biweight_h264_pixels_4_neon; c->h264_idct_add = ff_h264_idct_add_neon; c->h264_idct_dc_add = ff_h264_idct_dc_add_neon; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/arm/h264dsp_neon.S ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/arm/h264dsp_neon.S --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/arm/h264dsp_neon.S 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/arm/h264dsp_neon.S 2011-11-04 12:38:26.000000000 +0000 @@ -1592,7 +1592,7 @@ vdup.8 d1, r5 vmov q2, q8 vmov q3, q8 -1: subs ip, ip, #2 +1: subs r3, r3, #2 vld1.8 {d20-d21},[r0,:128], r2 \macd q2, d0, d20 pld [r0] @@ -1632,7 +1632,7 @@ vdup.8 d1, r5 vmov q1, q8 vmov q10, q8 -1: subs ip, ip, #2 +1: subs r3, r3, #2 vld1.8 {d4},[r0,:64], r2 \macd q1, d0, d4 pld [r0] @@ -1662,7 +1662,7 @@ vdup.8 d1, r5 vmov q1, q8 vmov q10, q8 -1: subs ip, ip, #4 +1: subs r3, r3, #4 vld1.32 {d4[0]},[r0,:32], r2 vld1.32 {d4[1]},[r0,:32], r2 \macd q1, d0, d4 @@ -1700,16 +1700,17 @@ .endm .macro biweight_func w -function biweight_h264_pixels_\w\()_neon +function ff_biweight_h264_pixels_\w\()_neon, export=1 push {r4-r6, lr} - add r4, sp, #16 + ldr r12, [sp, #16] + add r4, sp, #20 ldm r4, {r4-r6} lsr lr, r4, #31 add r6, r6, #1 eors lr, lr, r5, lsr #30 orr r6, r6, #1 - vdup.16 q9, r3 - lsl r6, r6, r3 + vdup.16 q9, r12 + lsl r6, r6, r12 vmvn q9, q9 vdup.16 q8, r6 mov r6, r0 @@ -1730,34 +1731,15 @@ endfunc .endm - .macro biweight_entry w, h, b=1 -function ff_biweight_h264_pixels_\w\()x\h\()_neon, export=1 - mov ip, #\h -.if \b - b biweight_h264_pixels_\w\()_neon -.endif -endfunc - .endm - - biweight_entry 16, 8 - biweight_entry 16, 16, b=0 biweight_func 16 - - biweight_entry 8, 16 - biweight_entry 8, 4 - biweight_entry 8, 8, b=0 biweight_func 8 - - biweight_entry 4, 8 - biweight_entry 4, 2 - biweight_entry 4, 4, b=0 biweight_func 4 @ Weighted prediction .macro weight_16 add - vdup.8 d0, r3 -1: subs ip, ip, #2 + vdup.8 d0, r12 +1: subs r2, r2, #2 vld1.8 {d20-d21},[r0,:128], r1 vmull.u8 q2, d0, d20 pld [r0] @@ -1785,8 +1767,8 @@ .endm .macro weight_8 add - vdup.8 d0, r3 -1: subs ip, ip, #2 + vdup.8 d0, r12 +1: subs r2, r2, #2 vld1.8 {d4},[r0,:64], r1 vmull.u8 q1, d0, d4 pld [r0] @@ -1806,10 +1788,10 @@ .endm .macro weight_4 add - vdup.8 d0, r3 + vdup.8 d0, r12 vmov q1, q8 vmov q10, q8 -1: subs ip, ip, #4 +1: subs r2, r2, #4 vld1.32 {d4[0]},[r0,:32], r1 vld1.32 {d4[1]},[r0,:32], r1 vmull.u8 q1, d0, d4 @@ -1842,50 +1824,32 @@ .endm .macro weight_func w -function weight_h264_pixels_\w\()_neon +function ff_weight_h264_pixels_\w\()_neon, export=1 push {r4, lr} - ldr r4, [sp, #8] - cmp r2, #1 - lsl r4, r4, r2 + ldr r12, [sp, #8] + ldr r4, [sp, #12] + cmp r3, #1 + lsl r4, r4, r3 vdup.16 q8, r4 mov r4, r0 ble 20f - rsb lr, r2, #1 + rsb lr, r3, #1 vdup.16 q9, lr - cmp r3, #0 + cmp r12, #0 blt 10f weight_\w vhadd.s16 -10: rsb r3, r3, #0 +10: rsb r12, r12, #0 weight_\w vhsub.s16 -20: rsb lr, r2, #0 +20: rsb lr, r3, #0 vdup.16 q9, lr - cmp r3, #0 + cmp r12, #0 blt 10f weight_\w vadd.s16 -10: rsb r3, r3, #0 +10: rsb r12, r12, #0 weight_\w vsub.s16 endfunc .endm - .macro weight_entry w, h, b=1 -function ff_weight_h264_pixels_\w\()x\h\()_neon, export=1 - mov ip, #\h -.if \b - b weight_h264_pixels_\w\()_neon -.endif -endfunc - .endm - - weight_entry 16, 8 - weight_entry 16, 16, b=0 weight_func 16 - - weight_entry 8, 16 - weight_entry 8, 4 - weight_entry 8, 8, b=0 weight_func 8 - - weight_entry 4, 8 - weight_entry 4, 2 - weight_entry 4, 4, b=0 weight_func 4 diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/asv1.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/asv1.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/asv1.c 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/asv1.c 2011-11-04 12:38:26.000000000 +0000 @@ -497,7 +497,7 @@ } emms_c(); - align_put_bits(&a->pb); + avpriv_align_put_bits(&a->pb); while(put_bits_count(&a->pb)&31) put_bits(&a->pb, 8, 0); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/atrac1.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/atrac1.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/atrac1.c 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/atrac1.c 2011-11-04 12:38:26.000000000 +0000 @@ -36,6 +36,7 @@ #include "get_bits.h" #include "dsputil.h" #include "fft.h" +#include "fmtconvert.h" #include "sinewin.h" #include "atrac.h" @@ -78,10 +79,11 @@ DECLARE_ALIGNED(32, float, mid)[256]; DECLARE_ALIGNED(32, float, high)[512]; float* bands[3]; - DECLARE_ALIGNED(32, float, out_samples)[AT1_MAX_CHANNELS][AT1_SU_SAMPLES]; + float *out_samples[AT1_MAX_CHANNELS]; FFTContext mdct_ctx[3]; int channels; DSPContext dsp; + FmtConvertContext fmt_conv; } AT1Ctx; /** size of the transform in samples in the long mode for each QMF band */ @@ -129,7 +131,7 @@ nbits = mdct_long_nbits[band_num] - log2_block_count; if (nbits != 5 && nbits != 7 && nbits != 8) - return -1; + return AVERROR_INVALIDDATA; } else { block_size = 32; nbits = 5; @@ -173,14 +175,14 @@ /* low and mid band */ log2_block_count_tmp = get_bits(gb, 2); if (log2_block_count_tmp & 1) - return -1; + return AVERROR_INVALIDDATA; log2_block_cnt[i] = 2 - log2_block_count_tmp; } /* high band */ log2_block_count_tmp = get_bits(gb, 2); if (log2_block_count_tmp != 0 && log2_block_count_tmp != 3) - return -1; + return AVERROR_INVALIDDATA; log2_block_cnt[IDX_HIGH_BAND] = 3 - log2_block_count_tmp; skip_bits(gb, 2); @@ -229,7 +231,7 @@ /* check for bitstream overflow */ if (bits_used > AT1_SU_MAX_BITS) - return -1; + return AVERROR_INVALIDDATA; /* get the position of the 1st spec according to the block size mode */ pos = su->log2_block_count[band_num] ? bfu_start_short[bfu_num] : bfu_start_long[bfu_num]; @@ -276,14 +278,21 @@ const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; AT1Ctx *q = avctx->priv_data; - int ch, ret, i; + int ch, ret, out_size; GetBitContext gb; float* samples = data; if (buf_size < 212 * q->channels) { - av_log(q,AV_LOG_ERROR,"Not enought data to decode!\n"); - return -1; + av_log(avctx,AV_LOG_ERROR,"Not enough data to decode!\n"); + return AVERROR_INVALIDDATA; + } + + out_size = q->channels * AT1_SU_SAMPLES * + av_get_bytes_per_sample(avctx->sample_fmt); + if (*data_size < out_size) { + av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); + return AVERROR(EINVAL); } for (ch = 0; ch < q->channels; ch++) { @@ -303,44 +312,72 @@ ret = at1_imdct_block(su, q); if (ret < 0) return ret; - at1_subband_synthesis(q, su, q->out_samples[ch]); + at1_subband_synthesis(q, su, q->channels == 1 ? samples : q->out_samples[ch]); } - /* interleave; FIXME, should create/use a DSP function */ - if (q->channels == 1) { - /* mono */ - memcpy(samples, q->out_samples[0], AT1_SU_SAMPLES * 4); - } else { - /* stereo */ - for (i = 0; i < AT1_SU_SAMPLES; i++) { - samples[i * 2] = q->out_samples[0][i]; - samples[i * 2 + 1] = q->out_samples[1][i]; - } + /* interleave */ + if (q->channels == 2) { + q->fmt_conv.float_interleave(samples, (const float **)q->out_samples, + AT1_SU_SAMPLES, 2); } - *data_size = q->channels * AT1_SU_SAMPLES * sizeof(*samples); + *data_size = out_size; return avctx->block_align; } +static av_cold int atrac1_decode_end(AVCodecContext * avctx) +{ + AT1Ctx *q = avctx->priv_data; + + av_freep(&q->out_samples[0]); + + ff_mdct_end(&q->mdct_ctx[0]); + ff_mdct_end(&q->mdct_ctx[1]); + ff_mdct_end(&q->mdct_ctx[2]); + + return 0; +} + + static av_cold int atrac1_decode_init(AVCodecContext *avctx) { AT1Ctx *q = avctx->priv_data; + int ret; avctx->sample_fmt = AV_SAMPLE_FMT_FLT; + if (avctx->channels < 1 || avctx->channels > AT1_MAX_CHANNELS) { + av_log(avctx, AV_LOG_ERROR, "Unsupported number of channels: %d\n", + avctx->channels); + return AVERROR(EINVAL); + } q->channels = avctx->channels; + if (avctx->channels == 2) { + q->out_samples[0] = av_malloc(2 * AT1_SU_SAMPLES * sizeof(*q->out_samples[0])); + q->out_samples[1] = q->out_samples[0] + AT1_SU_SAMPLES; + if (!q->out_samples[0]) { + av_freep(&q->out_samples[0]); + return AVERROR(ENOMEM); + } + } + /* Init the mdct transforms */ - ff_mdct_init(&q->mdct_ctx[0], 6, 1, -1.0/ (1 << 15)); - ff_mdct_init(&q->mdct_ctx[1], 8, 1, -1.0/ (1 << 15)); - ff_mdct_init(&q->mdct_ctx[2], 9, 1, -1.0/ (1 << 15)); + if ((ret = ff_mdct_init(&q->mdct_ctx[0], 6, 1, -1.0/ (1 << 15))) || + (ret = ff_mdct_init(&q->mdct_ctx[1], 8, 1, -1.0/ (1 << 15))) || + (ret = ff_mdct_init(&q->mdct_ctx[2], 9, 1, -1.0/ (1 << 15)))) { + av_log(avctx, AV_LOG_ERROR, "Error initializing MDCT\n"); + atrac1_decode_end(avctx); + return ret; + } ff_init_ff_sine_windows(5); atrac_generate_tables(); dsputil_init(&q->dsp, avctx); + ff_fmt_convert_init(&q->fmt_conv, avctx); q->bands[0] = q->low; q->bands[1] = q->mid; @@ -356,16 +393,6 @@ } -static av_cold int atrac1_decode_end(AVCodecContext * avctx) { - AT1Ctx *q = avctx->priv_data; - - ff_mdct_end(&q->mdct_ctx[0]); - ff_mdct_end(&q->mdct_ctx[1]); - ff_mdct_end(&q->mdct_ctx[2]); - return 0; -} - - AVCodec ff_atrac1_decoder = { .name = "atrac1", .type = AVMEDIA_TYPE_AUDIO, diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/atrac3.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/atrac3.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/atrac3.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/atrac3.c 2011-11-04 12:38:26.000000000 +0000 @@ -41,6 +41,7 @@ #include "dsputil.h" #include "bytestream.h" #include "fft.h" +#include "fmtconvert.h" #include "atrac.h" #include "atrac3data.h" @@ -48,6 +49,8 @@ #define JOINT_STEREO 0x12 #define STEREO 0x2 +#define SAMPLES_PER_FRAME 1024 +#define MDCT_SIZE 512 /* These structures are needed to store the parsed gain control data. */ typedef struct { @@ -70,12 +73,12 @@ int bandsCoded; int numComponents; tonal_component components[64]; - float prevFrame[1024]; + float prevFrame[SAMPLES_PER_FRAME]; int gcBlkSwitch; gain_block gainBlock[2]; - DECLARE_ALIGNED(32, float, spectrum)[1024]; - DECLARE_ALIGNED(32, float, IMDCT_buf)[1024]; + DECLARE_ALIGNED(32, float, spectrum)[SAMPLES_PER_FRAME]; + DECLARE_ALIGNED(32, float, IMDCT_buf)[SAMPLES_PER_FRAME]; float delayBuf1[46]; ///mdct_ctx.imdct_calc(&q->mdct_ctx,pOutput,pInput); /* Perform windowing on the output. */ - dsp.vector_fmul(pOutput, pOutput, mdct_window, 512); + dsp.vector_fmul(pOutput, pOutput, mdct_window, MDCT_SIZE); } @@ -192,7 +196,7 @@ } -static av_cold void init_atrac3_transforms(ATRAC3Context *q) { +static av_cold int init_atrac3_transforms(ATRAC3Context *q, int is_float) { float enc_window[256]; int i; @@ -208,7 +212,7 @@ } /* Initialize the MDCT transform. */ - ff_mdct_init(&q->mdct_ctx, 9, 1, 1.0); + return ff_mdct_init(&q->mdct_ctx, 9, 1, is_float ? 1.0 / 32768 : 1.0); } /** @@ -221,6 +225,8 @@ av_free(q->pUnits); av_free(q->decoded_bytes_buffer); + av_freep(&q->outSamples[0]); + ff_mdct_end(&q->mdct_ctx); return 0; @@ -340,7 +346,7 @@ /* Clear the subbands that were not coded. */ first = subbandTab[cnt]; - memset(pOut+first, 0, (1024 - first) * sizeof(float)); + memset(pOut+first, 0, (SAMPLES_PER_FRAME - first) * sizeof(float)); return numSubbands; } @@ -370,7 +376,7 @@ coding_mode_selector = get_bits(gb,2); if (coding_mode_selector == 2) - return -1; + return AVERROR_INVALIDDATA; coding_mode = coding_mode_selector & 1; @@ -382,7 +388,7 @@ quant_step_index = get_bits(gb,3); if (quant_step_index <= 1) - return -1; + return AVERROR_INVALIDDATA; if (coding_mode_selector == 3) coding_mode = get_bits1(gb); @@ -396,7 +402,7 @@ for (k=0; kgb,databuf,q->bits_per_frame); - result = decodeChannelSoundUnit(q,&q->gb, q->pUnits, q->outSamples, 0, JOINT_STEREO); + result = decodeChannelSoundUnit(q,&q->gb, q->pUnits, out_samples[0], 0, JOINT_STEREO); if (result != 0) return (result); @@ -753,7 +760,7 @@ ptr1 = q->decoded_bytes_buffer; for (i = 4; *ptr1 == 0xF8; i++, ptr1++) { if (i >= q->bytes_per_frame) - return -1; + return AVERROR_INVALIDDATA; } @@ -772,14 +779,14 @@ } /* Decode Sound Unit 2. */ - result = decodeChannelSoundUnit(q,&q->gb, &q->pUnits[1], &q->outSamples[1024], 1, JOINT_STEREO); + result = decodeChannelSoundUnit(q,&q->gb, &q->pUnits[1], out_samples[1], 1, JOINT_STEREO); if (result != 0) return (result); /* Reconstruct the channel coefficients. */ - reverseMatrixing(q->outSamples, &q->outSamples[1024], q->matrix_coeff_index_prev, q->matrix_coeff_index_now); + reverseMatrixing(out_samples[0], out_samples[1], q->matrix_coeff_index_prev, q->matrix_coeff_index_now); - channelWeighting(q->outSamples, &q->outSamples[1024], q->weighting_delay); + channelWeighting(out_samples[0], out_samples[1], q->weighting_delay); } else { /* normal stereo mode or mono */ @@ -789,22 +796,21 @@ /* Set the bitstream reader at the start of a channel sound unit. */ init_get_bits(&q->gb, databuf+((i*q->bytes_per_frame)/q->channels), (q->bits_per_frame)/q->channels); - result = decodeChannelSoundUnit(q,&q->gb, &q->pUnits[i], &q->outSamples[i*1024], i, q->codingMode); + result = decodeChannelSoundUnit(q,&q->gb, &q->pUnits[i], out_samples[i], i, q->codingMode); if (result != 0) return (result); } } /* Apply the iQMF synthesis filter. */ - p1= q->outSamples; for (i=0 ; ichannels ; i++) { + p1 = out_samples[i]; p2= p1+256; p3= p2+256; p4= p3+256; atrac_iqmf (p1, p2, 256, p1, q->pUnits[i].delayBuf1, q->tempBuf); atrac_iqmf (p4, p3, 256, p3, q->pUnits[i].delayBuf2, q->tempBuf); atrac_iqmf (p1, p3, 512, p1, q->pUnits[i].delayBuf3, q->tempBuf); - p1 +=1024; } return 0; @@ -823,15 +829,22 @@ const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; ATRAC3Context *q = avctx->priv_data; - int result = 0, i; + int result = 0, out_size; const uint8_t* databuf; - int16_t* samples = data; + float *samples_flt = data; + int16_t *samples_s16 = data; if (buf_size < avctx->block_align) { av_log(avctx, AV_LOG_ERROR, "Frame too small (%d bytes). Truncated file?\n", buf_size); - *data_size = 0; - return buf_size; + return AVERROR_INVALIDDATA; + } + + out_size = SAMPLES_PER_FRAME * q->channels * + av_get_bytes_per_sample(avctx->sample_fmt); + if (*data_size < out_size) { + av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); + return AVERROR(EINVAL); } /* Check if we need to descramble and what buffer to pass on. */ @@ -842,26 +855,27 @@ databuf = buf; } - result = decodeFrame(q, databuf); + if (q->channels == 1 && avctx->sample_fmt == AV_SAMPLE_FMT_FLT) + result = decodeFrame(q, databuf, &samples_flt); + else + result = decodeFrame(q, databuf, q->outSamples); if (result != 0) { av_log(NULL,AV_LOG_ERROR,"Frame decoding error!\n"); - return -1; + return result; } - if (q->channels == 1) { - /* mono */ - for (i = 0; i<1024; i++) - samples[i] = av_clip_int16(round(q->outSamples[i])); - *data_size = 1024 * sizeof(int16_t); - } else { - /* stereo */ - for (i = 0; i < 1024; i++) { - samples[i*2] = av_clip_int16(round(q->outSamples[i])); - samples[i*2+1] = av_clip_int16(round(q->outSamples[1024+i])); - } - *data_size = 2048 * sizeof(int16_t); + /* interleave */ + if (q->channels == 2 && avctx->sample_fmt == AV_SAMPLE_FMT_FLT) { + q->fmt_conv.float_interleave(samples_flt, + (const float **)q->outSamples, + SAMPLES_PER_FRAME, 2); + } else if (avctx->sample_fmt == AV_SAMPLE_FMT_S16) { + q->fmt_conv.float_to_int16_interleave(samples_s16, + (const float **)q->outSamples, + SAMPLES_PER_FRAME, q->channels); } + *data_size = out_size; return avctx->block_align; } @@ -875,7 +889,7 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) { - int i; + int i, ret; const uint8_t *edata_ptr = avctx->extradata; ATRAC3Context *q = avctx->priv_data; static VLC_TYPE atrac3_vlc_table[4096][2]; @@ -899,7 +913,7 @@ av_log(avctx,AV_LOG_DEBUG,"[12-13] %d\n",bytestream_get_le16(&edata_ptr)); //Unknown always 0 /* setup */ - q->samples_per_frame = 1024 * q->channels; + q->samples_per_frame = SAMPLES_PER_FRAME * q->channels; q->atrac3version = 4; q->delay = 0x88E; if (q->codingMode) @@ -912,7 +926,7 @@ if ((q->bytes_per_frame == 96*q->channels*q->frame_factor) || (q->bytes_per_frame == 152*q->channels*q->frame_factor) || (q->bytes_per_frame == 192*q->channels*q->frame_factor)) { } else { av_log(avctx,AV_LOG_ERROR,"Unknown frame/channel/frame_factor configuration %d/%d/%d\n", q->bytes_per_frame, q->channels, q->frame_factor); - return -1; + return AVERROR_INVALIDDATA; } } else if (avctx->extradata_size == 10) { @@ -932,17 +946,17 @@ if (q->atrac3version != 4) { av_log(avctx,AV_LOG_ERROR,"Version %d != 4.\n",q->atrac3version); - return -1; + return AVERROR_INVALIDDATA; } - if (q->samples_per_frame != 1024 && q->samples_per_frame != 2048) { + if (q->samples_per_frame != SAMPLES_PER_FRAME && q->samples_per_frame != SAMPLES_PER_FRAME*2) { av_log(avctx,AV_LOG_ERROR,"Unknown amount of samples per frame %d.\n",q->samples_per_frame); - return -1; + return AVERROR_INVALIDDATA; } if (q->delay != 0x88E) { av_log(avctx,AV_LOG_ERROR,"Unknown amount of delay %x != 0x88E.\n",q->delay); - return -1; + return AVERROR_INVALIDDATA; } if (q->codingMode == STEREO) { @@ -951,17 +965,17 @@ av_log(avctx,AV_LOG_DEBUG,"Joint stereo detected.\n"); } else { av_log(avctx,AV_LOG_ERROR,"Unknown channel coding mode %x!\n",q->codingMode); - return -1; + return AVERROR_INVALIDDATA; } if (avctx->channels <= 0 || avctx->channels > 2 /*|| ((avctx->channels * 1024) != q->samples_per_frame)*/) { av_log(avctx,AV_LOG_ERROR,"Channel configuration error!\n"); - return -1; + return AVERROR(EINVAL); } if(avctx->block_align >= UINT_MAX/2) - return -1; + return AVERROR(EINVAL); /* Pad the data buffer with FF_INPUT_BUFFER_PADDING_SIZE, * this is for the bitstream reader. */ @@ -981,7 +995,16 @@ vlcs_initialized = 1; } - init_atrac3_transforms(q); + if (avctx->request_sample_fmt == AV_SAMPLE_FMT_FLT) + avctx->sample_fmt = AV_SAMPLE_FMT_FLT; + else + avctx->sample_fmt = AV_SAMPLE_FMT_S16; + + if ((ret = init_atrac3_transforms(q, avctx->sample_fmt == AV_SAMPLE_FMT_FLT))) { + av_log(avctx, AV_LOG_ERROR, "Error initializing MDCT\n"); + av_freep(&q->decoded_bytes_buffer); + return ret; + } atrac_generate_tables(); @@ -1007,14 +1030,23 @@ } dsputil_init(&dsp, avctx); + ff_fmt_convert_init(&q->fmt_conv, avctx); q->pUnits = av_mallocz(sizeof(channel_unit)*q->channels); if (!q->pUnits) { - av_free(q->decoded_bytes_buffer); + atrac3_decode_close(avctx); return AVERROR(ENOMEM); } - avctx->sample_fmt = AV_SAMPLE_FMT_S16; + if (avctx->channels > 1 || avctx->sample_fmt == AV_SAMPLE_FMT_S16) { + q->outSamples[0] = av_mallocz(SAMPLES_PER_FRAME * avctx->channels * sizeof(*q->outSamples[0])); + q->outSamples[1] = q->outSamples[0] + SAMPLES_PER_FRAME; + if (!q->outSamples[0]) { + atrac3_decode_close(avctx); + return AVERROR(ENOMEM); + } + } + return 0; } @@ -1028,5 +1060,6 @@ .init = atrac3_decode_init, .close = atrac3_decode_close, .decode = atrac3_decode_frame, + .capabilities = CODEC_CAP_SUBFRAMES, .long_name = NULL_IF_CONFIG_SMALL("Atrac 3 (Adaptive TRansform Acoustic Coding 3)"), }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/avcodec.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/avcodec.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/avcodec.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/avcodec.h 2011-11-04 12:38:26.000000000 +0000 @@ -47,7 +47,8 @@ * * If you add a codec ID to this list, add it so that * 1. no value of a existing codec ID changes (that would break ABI), - * 2. it is as close as possible to similar codecs. + * 2. Give it a value which when taken as ASCII is recognized uniquely by a human as this specific codec. + * This ensures that 2 forks can independantly add CodecIDs without producing conflicts. */ enum CodecID { CODEC_ID_NONE, @@ -210,8 +211,14 @@ CODEC_ID_DFA, CODEC_ID_WMV3IMAGE, CODEC_ID_VC1IMAGE, - CODEC_ID_8SVX_RAW, - CODEC_ID_G2M, +#if LIBAVCODEC_VERSION_MAJOR == 53 + CODEC_ID_G723_1_DEPRECATED, + CODEC_ID_G729_DEPRECATED, +#endif + CODEC_ID_UTVIDEO_DEPRECATED, + CODEC_ID_UTVIDEO = 0x800, + + CODEC_ID_G2M = MKBETAG( 0 ,'G','2','M'), /* various PCM "codecs" */ CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs @@ -344,8 +351,13 @@ CODEC_ID_AAC_LATM, CODEC_ID_QDMC, CODEC_ID_CELT, +#if LIBAVCODEC_VERSION_MAJOR > 53 + CODEC_ID_G723_1_DEPRECATED, + CODEC_ID_G729_DEPRECATED, +#endif CODEC_ID_G729 = 0x15800, CODEC_ID_G723_1= 0x15801, + CODEC_ID_8SVX_RAW = MKBETAG('8','S','V','X'), /* subtitle codecs */ CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. @@ -358,19 +370,21 @@ CODEC_ID_HDMV_PGS_SUBTITLE, CODEC_ID_DVB_TELETEXT, CODEC_ID_SRT, - CODEC_ID_MICRODVD, + CODEC_ID_MICRODVD = MKBETAG('m','D','V','D'), /* other specific kind of codecs (generally used for attachments) */ CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs. CODEC_ID_TTF= 0x18000, - CODEC_ID_BINTEXT, - CODEC_ID_XBIN, - CODEC_ID_IDF, + CODEC_ID_BINTEXT = MKBETAG('B','T','X','T'), + CODEC_ID_XBIN = MKBETAG('X','B','I','N'), + CODEC_ID_IDF = MKBETAG( 0 ,'I','D','F'), CODEC_ID_PROBE= 0x19000, ///< codec_id is not known (like CODEC_ID_NONE) but lavf should attempt to identify it CODEC_ID_MPEG2TS= 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS * stream (only used by libavformat) */ + CODEC_ID_MPEG4SYSTEMS = 0x20001, /**< _FAKE_ codec to indicate a MPEG-4 Systems + * stream (only used by libavformat) */ CODEC_ID_FFMETADATA=0x21000, ///< Dummy codec for streams containing only metadata information. }; @@ -496,6 +510,7 @@ AVCOL_TRC_UNSPECIFIED=2, AVCOL_TRC_GAMMA22 =4, ///< also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM AVCOL_TRC_GAMMA28 =5, ///< also ITU-R BT470BG + AVCOL_TRC_SMPTE240M =7, AVCOL_TRC_NB , ///< Not part of ABI }; @@ -507,6 +522,7 @@ AVCOL_SPC_BT470BG =5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 AVCOL_SPC_SMPTE170M =6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above AVCOL_SPC_SMPTE240M =7, + AVCOL_SPC_YCGCO =8, AVCOL_SPC_NB , ///< Not part of ABI }; @@ -537,7 +553,7 @@ /** * LPC analysis type */ -attribute_deprecated enum AVLPCType { +enum AVLPCType { AV_LPC_TYPE_DEFAULT = -1, ///< use the codec default LPC type AV_LPC_TYPE_NONE = 0, ///< do not use LPC prediction or use all zero coefficients AV_LPC_TYPE_FIXED = 1, ///< fixed LPC coefficients @@ -668,14 +684,18 @@ * assume the buffer was allocated by avcodec_default_get_buffer. */ #define CODEC_CAP_DR1 0x0002 +#if FF_API_PARSE_FRAME /* If 'parse_only' field is true, then avcodec_parse_frame() can be used. */ #define CODEC_CAP_PARSE_ONLY 0x0004 +#endif #define CODEC_CAP_TRUNCATED 0x0008 /* Codec can export data for HW decoding (XvMC). */ #define CODEC_CAP_HWACCEL 0x0010 /** - * Codec has a nonzero delay and needs to be fed with NULL at the end to get the delayed data. - * If this is not set, the codec is guaranteed to never be fed with NULL data. + * Codec has a nonzero delay and needs to be fed with avpkt->data=NULL, + * avpkt->size=0 at the end to get the delayed data until the decoder no longer + * returns frames. If this is not set, the codec is guaranteed to never be fed + * with NULL data. */ #define CODEC_CAP_DELAY 0x0020 /** @@ -1518,22 +1538,20 @@ */ float b_quant_offset; +#if FF_API_ER /** * Error recognition; higher values will detect more errors but may * misdetect some more or less valid parts as errors. * - encoding: unused * - decoding: Set by user. */ - int error_recognition; + attribute_deprecated int error_recognition; #define FF_ER_CAREFUL 1 #define FF_ER_COMPLIANT 2 #define FF_ER_AGGRESSIVE 3 -#if FF_API_VERY_AGGRESSIVE #define FF_ER_VERY_AGGRESSIVE 4 #define FF_ER_EXPLODE 5 -#else -#define FF_ER_EXPLODE 4 -#endif /* FF_API_VERY_AGGRESSIVE */ +#endif /* FF_API_ER */ /** * Called at the beginning of each frame to get a buffer for it. @@ -1576,9 +1594,15 @@ */ int block_align; - int parse_only; /* - decoding only: If true, only parsing is done - (function avcodec_parse_frame()). The frame - data is returned. Only MPEG codecs support this now. */ +#if FF_API_PARSE_FRAME + /** + * If true, only parsing is done. The frame data is returned. + * Only MPEG audio decoders support this now. + * - encoding: unused + * - decoding: Set by user + */ + attribute_deprecated int parse_only; +#endif /** * 0-> h263 quant 1-> mpeg quant @@ -2961,6 +2985,17 @@ enum AVSampleFormat request_sample_fmt; /** + * Error recognition; may misdetect some more or less valid parts as errors. + * - encoding: unused + * - decoding: Set by user. + */ + int err_recognition; +#define AV_EF_CRCCHECK (1<<0) +#define AV_EF_BITSTREAM (1<<1) +#define AV_EF_BUFFER (1<<2) +#define AV_EF_EXPLODE (1<<3) + + /** * Current statistics for PTS correction. * - decoding: maintained and used by libavcodec, not intended to be used by user apps * - encoding: unused @@ -2970,7 +3005,6 @@ int64_t pts_correction_last_pts; /// PTS of the last frame int64_t pts_correction_last_dts; /// DTS of the last frame - } AVCodecContext; /** @@ -3598,6 +3632,7 @@ enum PixelFormat avcodec_find_best_pix_fmt2(enum PixelFormat dst_pix_fmt1, enum PixelFormat dst_pix_fmt2, enum PixelFormat src_pix_fmt, int has_alpha, int *loss_ptr); +#if FF_API_GET_ALPHA_INFO #define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */ #define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */ @@ -3605,8 +3640,10 @@ * Tell if an image really has transparent alpha values. * @return ored mask of FF_ALPHA_xxx constants */ +attribute_deprecated int img_get_alpha_info(const AVPicture *src, enum PixelFormat pix_fmt, int width, int height); +#endif /* deinterlace a picture */ /* deinterlace - if not supported return -1 */ @@ -3698,19 +3735,31 @@ */ const char *av_get_profile_name(const AVCodec *codec, int profile); +#if FF_API_ALLOC_CONTEXT /** * Set the fields of the given AVCodecContext to default values. * * @param s The AVCodecContext of which the fields should be set to default values. + * @deprecated use avcodec_get_context_defaults3 */ +attribute_deprecated void avcodec_get_context_defaults(AVCodecContext *s); /** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API! * we WILL change its arguments and name a few times! */ +attribute_deprecated void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType); +#endif -/** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API! - * we WILL change its arguments and name a few times! */ +/** + * Set the fields of the given AVCodecContext to default values corresponding + * to the given codec (defaults may be codec-dependent). + * + * Do not call this function if a non-NULL codec has been passed + * to avcodec_alloc_context3() that allocated this AVCodecContext. + * If codec is non-NULL, it is illegal to call avcodec_open2() with a + * different codec on this AVCodecContext. + */ int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec); #if FF_API_ALLOC_CONTEXT @@ -3742,8 +3791,6 @@ * * @return An AVCodecContext filled with default values or NULL on failure. * @see avcodec_get_context_defaults - * - * @deprecated use avcodec_alloc_context3() */ AVCodecContext *avcodec_alloc_context3(AVCodec *codec); @@ -3920,6 +3967,10 @@ * samples should be 16 byte aligned unless the CPU doesn't need it * (AltiVec and SSE do). * + * @note Codecs which have the CODEC_CAP_DELAY capability set have a delay + * between input and output, these need to be fed with avpkt->data=NULL, + * avpkt->size=0 at the end to return the remaining frames. + * * @param avctx the codec context * @param[out] samples the output buffer, sample type in avctx->sample_fmt * @param[in,out] frame_size_ptr the output buffer size in bytes @@ -3953,8 +4004,9 @@ * * In practice, avpkt->data should have 4 byte alignment at minimum. * - * @note Some codecs have a delay between input and output, these need to be - * fed with avpkt->data=NULL, avpkt->size=0 at the end to return the remaining frames. + * @note Codecs which have the CODEC_CAP_DELAY capability set have a delay + * between input and output, these need to be fed with avpkt->data=NULL, + * avpkt->size=0 at the end to return the remaining frames. * * @param avctx the codec context * @param[out] picture The AVFrame in which the decoded video frame will be stored. @@ -4005,10 +4057,6 @@ */ void avsubtitle_free(AVSubtitle *sub); -int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata, - int *data_size_ptr, - uint8_t *buf, int buf_size); - /** * Encode an audio frame from samples into buf. * diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/binkaudio.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/binkaudio.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/binkaudio.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/binkaudio.c 2011-11-04 12:38:26.000000000 +0000 @@ -39,6 +39,8 @@ extern const uint16_t ff_wma_critical_freqs[25]; +static float quant_table[95]; + #define MAX_CHANNELS 2 #define BINK_BLOCK_MAX_SIZE (MAX_CHANNELS << 11) @@ -56,8 +58,11 @@ unsigned int *bands; float root; DECLARE_ALIGNED(32, FFTSample, coeffs)[BINK_BLOCK_MAX_SIZE]; - DECLARE_ALIGNED(16, short, previous)[BINK_BLOCK_MAX_SIZE / 16]; ///< coeffs from previous audio block + DECLARE_ALIGNED(16, int16_t, previous)[BINK_BLOCK_MAX_SIZE / 16]; ///< coeffs from previous audio block + DECLARE_ALIGNED(16, int16_t, current)[BINK_BLOCK_MAX_SIZE / 16]; float *coeffs_ptr[MAX_CHANNELS]; ///< pointers to the coeffs arrays for float_to_int16_interleave + float *prev_ptr[MAX_CHANNELS]; ///< pointers to the overlap points in the coeffs array + uint8_t *packet_buffer; union { RDFTContext rdft; DCTContext dct; @@ -107,6 +112,10 @@ s->block_size = (s->frame_len - s->overlap_len) * s->channels; sample_rate_half = (sample_rate + 1) / 2; s->root = 2.0 / sqrt(s->frame_len); + for (i = 0; i < 95; i++) { + /* constant is result of 0.066399999/log10(M_E) */ + quant_table[i] = expf(i * 0.15289164787221953823f) * s->root; + } /* calculate number of bands */ for (s->num_bands = 1; s->num_bands < 25; s->num_bands++) @@ -126,8 +135,10 @@ s->first = 1; avctx->sample_fmt = AV_SAMPLE_FMT_S16; - for (i = 0; i < s->channels; i++) + for (i = 0; i < s->channels; i++) { s->coeffs_ptr[i] = s->coeffs + i * s->frame_len; + s->prev_ptr[i] = s->coeffs_ptr[i] + s->frame_len - s->overlap_len; + } if (CONFIG_BINKAUDIO_RDFT_DECODER && avctx->codec->id == CODEC_ID_BINKAUDIO_RDFT) ff_rdft_init(&s->trans.rdft, frame_len_bits, DFT_C2R); @@ -152,11 +163,18 @@ 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 32, 64 }; +#define GET_BITS_SAFE(out, nbits) do { \ + if (get_bits_left(gb) < nbits) \ + return AVERROR_INVALIDDATA; \ + out = get_bits(gb, nbits); \ +} while (0) + /** * Decode Bink Audio block * @param[out] out Output buffer (must contain s->block_size elements) + * @return 0 on success, negative error code on failure */ -static void decode_block(BinkAudioContext *s, short *out, int use_dct) +static int decode_block(BinkAudioContext *s, int16_t *out, int use_dct) { int ch, i, j, k; float q, quant[25]; @@ -169,17 +187,22 @@ for (ch = 0; ch < s->channels; ch++) { FFTSample *coeffs = s->coeffs_ptr[ch]; if (s->version_b) { + if (get_bits_left(gb) < 64) + return AVERROR_INVALIDDATA; coeffs[0] = av_int2flt(get_bits(gb, 32)) * s->root; coeffs[1] = av_int2flt(get_bits(gb, 32)) * s->root; } else { + if (get_bits_left(gb) < 58) + return AVERROR_INVALIDDATA; coeffs[0] = get_float(gb) * s->root; coeffs[1] = get_float(gb) * s->root; } + if (get_bits_left(gb) < s->num_bands * 8) + return AVERROR_INVALIDDATA; for (i = 0; i < s->num_bands; i++) { - /* constant is result of 0.066399999/log10(M_E) */ int value = get_bits(gb, 8); - quant[i] = expf(FFMIN(value, 95) * 0.15289164787221953823f) * s->root; + quant[i] = quant_table[FFMIN(value, 95)]; } k = 0; @@ -190,15 +213,20 @@ while (i < s->frame_len) { if (s->version_b) { j = i + 16; - } else if (get_bits1(gb)) { - j = i + rle_length_tab[get_bits(gb, 4)] * 8; } else { - j = i + 8; + int v; + GET_BITS_SAFE(v, 1); + if (v) { + GET_BITS_SAFE(v, 4); + j = i + rle_length_tab[v] * 8; + } else { + j = i + 8; + } } j = FFMIN(j, s->frame_len); - width = get_bits(gb, 4); + GET_BITS_SAFE(width, 4); if (width == 0) { memset(coeffs + i, 0, (j - i) * sizeof(*coeffs)); i = j; @@ -208,9 +236,11 @@ while (i < j) { if (s->bands[k] == i) q = quant[k++]; - coeff = get_bits(gb, width); + GET_BITS_SAFE(coeff, width); if (coeff) { - if (get_bits1(gb)) + int v; + GET_BITS_SAFE(v, 1); + if (v) coeffs[i] = -q * coeff; else coeffs[i] = q * coeff; @@ -231,8 +261,12 @@ s->trans.rdft.rdft_calc(&s->trans.rdft, coeffs); } + s->fmt_conv.float_to_int16_interleave(s->current, + (const float **)s->prev_ptr, + s->overlap_len, s->channels); s->fmt_conv.float_to_int16_interleave(out, (const float **)s->coeffs_ptr, - s->frame_len, s->channels); + s->frame_len - s->overlap_len, + s->channels); if (!s->first) { int count = s->overlap_len * s->channels; @@ -242,16 +276,19 @@ } } - memcpy(s->previous, out + s->block_size, - s->overlap_len * s->channels * sizeof(*out)); + memcpy(s->previous, s->current, + s->overlap_len * s->channels * sizeof(*s->previous)); s->first = 0; + + return 0; } static av_cold int decode_end(AVCodecContext *avctx) { BinkAudioContext * s = avctx->priv_data; av_freep(&s->bands); + av_freep(&s->packet_buffer); if (CONFIG_BINKAUDIO_RDFT_DECODER && avctx->codec->id == CODEC_ID_BINKAUDIO_RDFT) ff_rdft_end(&s->trans.rdft); else if (CONFIG_BINKAUDIO_DCT_DECODER) @@ -270,25 +307,47 @@ AVPacket *avpkt) { BinkAudioContext *s = avctx->priv_data; - const uint8_t *buf = avpkt->data; - int buf_size = avpkt->size; - short *samples = data; - short *samples_end = (short*)((uint8_t*)data + *data_size); - int reported_size; + int16_t *samples = data; GetBitContext *gb = &s->gb; + int out_size, consumed = 0; - init_get_bits(gb, buf, buf_size * 8); + if (!get_bits_left(gb)) { + uint8_t *buf; + /* handle end-of-stream */ + if (!avpkt->size) { + *data_size = 0; + return 0; + } + if (avpkt->size < 4) { + av_log(avctx, AV_LOG_ERROR, "Packet is too small\n"); + return AVERROR_INVALIDDATA; + } + buf = av_realloc(s->packet_buffer, avpkt->size + FF_INPUT_BUFFER_PADDING_SIZE); + if (!buf) + return AVERROR(ENOMEM); + s->packet_buffer = buf; + memcpy(s->packet_buffer, avpkt->data, avpkt->size); + init_get_bits(gb, s->packet_buffer, avpkt->size * 8); + consumed = avpkt->size; + + /* skip reported size */ + skip_bits_long(gb, 32); + } + + out_size = s->block_size * av_get_bytes_per_sample(avctx->sample_fmt); + if (*data_size < out_size) { + av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); + return AVERROR(EINVAL); + } - reported_size = get_bits_long(gb, 32); - while (get_bits_count(gb) / 8 < buf_size && - samples + s->block_size <= samples_end) { - decode_block(s, samples, avctx->codec->id == CODEC_ID_BINKAUDIO_DCT); - samples += s->block_size; - get_bits_align32(gb); + if (decode_block(s, samples, avctx->codec->id == CODEC_ID_BINKAUDIO_DCT)) { + av_log(avctx, AV_LOG_ERROR, "Incomplete packet\n"); + return AVERROR_INVALIDDATA; } + get_bits_align32(gb); - *data_size = FFMIN(reported_size, (uint8_t*)samples - (uint8_t*)data); - return buf_size; + *data_size = out_size; + return consumed; } AVCodec ff_binkaudio_rdft_decoder = { @@ -299,6 +358,7 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, + .capabilities = CODEC_CAP_DELAY, .long_name = NULL_IF_CONFIG_SMALL("Bink Audio (RDFT)") }; @@ -310,5 +370,6 @@ .init = decode_init, .close = decode_end, .decode = decode_frame, + .capabilities = CODEC_CAP_DELAY, .long_name = NULL_IF_CONFIG_SMALL("Bink Audio (DCT)") }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/bink.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/bink.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/bink.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/bink.c 2011-11-04 12:38:26.000000000 +0000 @@ -458,8 +458,8 @@ int start_bits, int has_sign) { int i, j, len, len2, bsize, sign, v, v2; - int16_t *dst = (int16_t*)b->cur_dec; - int16_t *dst_end =( int16_t*)b->data_end; + int16_t *dst = (int16_t*)b->cur_dec; + int16_t *dst_end = (int16_t*)b->data_end; CHECK_READ_VAL(gb, b, len); v = get_bits(gb, start_bits - has_sign); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/bintext.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/bintext.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/bintext.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/bintext.c 2011-11-04 12:38:26.000000000 +0000 @@ -131,6 +131,7 @@ int buf_size = avpkt->size; const uint8_t *buf_end = buf+buf_size; + s->x = s->y = 0; s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/bitstream.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/bitstream.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/bitstream.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/bitstream.c 2011-11-04 12:38:26.000000000 +0000 @@ -41,7 +41,7 @@ 24, }; -void align_put_bits(PutBitContext *s) +void avpriv_align_put_bits(PutBitContext *s) { put_bits(s,s->bit_left & 7,0); } @@ -56,7 +56,7 @@ put_bits(pb, 8, 0); } -void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length) +void avpriv_copy_bits(PutBitContext *pb, const uint8_t *src, int length) { int words= length>>4; int bits= length&15; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/cavsdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/cavsdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/cavsdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/cavsdec.c 2011-11-04 12:38:26.000000000 +0000 @@ -625,8 +625,8 @@ s->low_delay = get_bits1(&s->gb); h->mb_width = (s->width + 15) >> 4; h->mb_height = (s->height + 15) >> 4; - h->s.avctx->time_base.den = ff_frame_rate_tab[frame_rate_code].num; - h->s.avctx->time_base.num = ff_frame_rate_tab[frame_rate_code].den; + h->s.avctx->time_base.den = avpriv_frame_rate_tab[frame_rate_code].num; + h->s.avctx->time_base.num = avpriv_frame_rate_tab[frame_rate_code].den; h->s.avctx->width = s->width; h->s.avctx->height = s->height; if(!h->top_qp) @@ -664,7 +664,7 @@ buf_ptr = buf; buf_end = buf + buf_size; for(;;) { - buf_ptr = ff_find_start_code(buf_ptr,buf_end, &stc); + buf_ptr = avpriv_mpv_find_start_code(buf_ptr,buf_end, &stc); if((stc & 0xFFFFFE00) || buf_ptr == buf_end) return FFMAX(0, buf_ptr - buf - s->parse_context.last_index); input_size = (buf_end - buf_ptr)*8; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/cavs_parser.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/cavs_parser.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/cavs_parser.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/cavs_parser.c 2011-11-04 12:38:26.000000000 +0000 @@ -98,10 +98,9 @@ } AVCodecParser ff_cavsvideo_parser = { - { CODEC_ID_CAVS }, - sizeof(ParseContext1), - NULL, - cavsvideo_parse, - ff_parse1_close, - ff_mpeg4video_split, + .codec_ids = { CODEC_ID_CAVS }, + .priv_data_size = sizeof(ParseContext1), + .parser_parse = cavsvideo_parse, + .parser_close = ff_parse1_close, + .split = ff_mpeg4video_split, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/cljr.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/cljr.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/cljr.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/cljr.c 2011-11-04 12:38:26.000000000 +0000 @@ -105,7 +105,7 @@ emms_c(); - align_put_bits(&a->pb); + avpriv_align_put_bits(&a->pb); while(get_bit_count(&a->pb)&31) put_bits(&a->pb, 8, 0); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/codec_names.sh ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/codec_names.sh --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/codec_names.sh 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/codec_names.sh 2011-11-04 12:38:26.000000000 +0000 @@ -21,8 +21,7 @@ set -e config="$1" -codecs="$2" -out="$3" +out="$2" test -n "$out" outval="" @@ -63,7 +62,7 @@ while read line; do case "$line" in "};") break;; - *CODEC_ID_FIRST*///*dummy*) ;; + *CODEC_ID_FIRST*=*) ;; CODEC_ID_*) define_codecid ${line%%[=,]*};; esac done @@ -78,7 +77,7 @@ } parse_config_h < "$config" -parse_avcodec_h < "$codecs" +parse_avcodec_h # use stdin sed -e '/case.*:/!y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/' \ -e 's/extern avcodec /extern AVCodec /' > "$out" < -#include -#include - #include "libavutil/lfg.h" -#include "libavutil/random_seed.h" #include "avcodec.h" #include "get_bits.h" #include "dsputil.h" @@ -124,7 +119,7 @@ void (* interpolate) (struct cook *q, float* buffer, int gain_index, int gain_index_next); - void (* saturate_output) (struct cook *q, int chan, int16_t *out); + void (* saturate_output) (struct cook *q, int chan, float *out); AVCodecContext* avctx; GetBitContext gb; @@ -217,11 +212,11 @@ } static av_cold int init_cook_mlt(COOKContext *q) { - int j; + int j, ret; int mlt_size = q->samples_per_channel; - if ((q->mlt_window = av_malloc(sizeof(float)*mlt_size)) == 0) - return -1; + if ((q->mlt_window = av_malloc(mlt_size * sizeof(*q->mlt_window))) == 0) + return AVERROR(ENOMEM); /* Initialize the MLT window: simple sine window. */ ff_sine_window_init(q->mlt_window, mlt_size); @@ -229,9 +224,9 @@ q->mlt_window[j] *= sqrt(2.0 / q->samples_per_channel); /* Initialize the MDCT. */ - if (ff_mdct_init(&q->mdct_ctx, av_log2(mlt_size)+1, 1, 1.0)) { - av_free(q->mlt_window); - return -1; + if ((ret = ff_mdct_init(&q->mdct_ctx, av_log2(mlt_size)+1, 1, 1.0/32768.0))) { + av_free(q->mlt_window); + return ret; } av_log(q->avctx,AV_LOG_DEBUG,"MDCT initialized, order = %d.\n", av_log2(mlt_size)+1); @@ -410,9 +405,9 @@ //av_log(q->avctx, AV_LOG_ERROR, "bits_left = %d\n",bits_left); } - memset(&exp_index1,0,102*sizeof(int)); - memset(&exp_index2,0,102*sizeof(int)); - memset(&tmp_categorize_array,0,128*2*sizeof(int)); + memset(&exp_index1, 0, sizeof(exp_index1)); + memset(&exp_index2, 0, sizeof(exp_index2)); + memset(&tmp_categorize_array, 0, sizeof(tmp_categorize_array)); bias=-32; @@ -633,8 +628,8 @@ int quant_index_table[102]; int category[128]; - memset(&category, 0, 128*sizeof(int)); - memset(&category_index, 0, 128*sizeof(int)); + memset(&category, 0, sizeof(category)); + memset(&category_index, 0, sizeof(category_index)); decode_envelope(q, p, quant_index_table); q->num_vectors = get_bits(&q->gb,p->log2_numvector_size); @@ -663,14 +658,12 @@ for(i=0 ; igain_size_factor ; i++){ buffer[i]*=fc1; } - return; } else { //smooth gain fc2 = q->gain_table[11 + (gain_index_next-gain_index)]; for(i=0 ; igain_size_factor ; i++){ buffer[i]*=fc1; fc1*=fc2; } - return; } } @@ -733,7 +726,8 @@ } /* Save away the current to be previous block. */ - memcpy(previous_buffer, buffer0, sizeof(float)*q->samples_per_channel); + memcpy(previous_buffer, buffer0, + q->samples_per_channel * sizeof(*previous_buffer)); } @@ -744,27 +738,24 @@ * @param decouple_tab decoupling array * */ +static void decouple_info(COOKContext *q, COOKSubpacket *p, int *decouple_tab) +{ + int i; + int vlc = get_bits1(&q->gb); + int start = cplband[p->js_subband_start]; + int end = cplband[p->subbands-1]; + int length = end - start + 1; -static void decouple_info(COOKContext *q, COOKSubpacket *p, int* decouple_tab){ - int length, i; - - if(get_bits1(&q->gb)) { - if(cplband[p->js_subband_start] > cplband[p->subbands-1]) return; - - length = cplband[p->subbands-1] - cplband[p->js_subband_start] + 1; - for (i=0 ; ijs_subband_start] + i] = get_vlc2(&q->gb, p->ccpl.table, p->ccpl.bits, 2); - } + if (start > end) return; - } - - if(cplband[p->js_subband_start] > cplband[p->subbands-1]) return; - length = cplband[p->subbands-1] - cplband[p->js_subband_start] + 1; - for (i=0 ; ijs_subband_start] + i] = get_bits(&q->gb, p->js_vlc_bits); + if (vlc) { + for (i = 0; i < length; i++) + decouple_tab[start + i] = get_vlc2(&q->gb, p->ccpl.table, p->ccpl.bits, 2); + } else { + for (i = 0; i < length; i++) + decouple_tab[start + i] = get_bits(&q->gb, p->js_vlc_bits); } - return; } /* @@ -811,11 +802,11 @@ const float* cplscale; memset(decouple_tab, 0, sizeof(decouple_tab)); - memset(decode_buffer, 0, sizeof(decode_buffer)); + memset(decode_buffer, 0, sizeof(q->decode_buffer_0)); /* Make sure the buffers are zeroed out. */ - memset(mlt_buffer1,0, 1024*sizeof(float)); - memset(mlt_buffer2,0, 1024*sizeof(float)); + memset(mlt_buffer1, 0, 1024 * sizeof(*mlt_buffer1)); + memset(mlt_buffer2, 0, 1024 * sizeof(*mlt_buffer2)); decouple_info(q, p, decouple_tab); mono_decode(q, p, decode_buffer); @@ -867,22 +858,18 @@ } /** - * Saturate the output signal to signed 16bit integers. + * Saturate the output signal and interleave. * * @param q pointer to the COOKContext * @param chan channel to saturate * @param out pointer to the output vector */ -static void -saturate_output_float (COOKContext *q, int chan, int16_t *out) +static void saturate_output_float(COOKContext *q, int chan, float *out) { int j; float *output = q->mono_mdct_output + q->samples_per_channel; - /* Clip and convert floats to 16 bits. - */ for (j = 0; j < q->samples_per_channel; j++) { - out[chan + q->nb_channels * j] = - av_clip_int16(lrintf(output[j])); + out[chan + q->nb_channels * j] = av_clipf(output[j], -1.0, 1.0); } } @@ -902,7 +889,7 @@ static inline void mlt_compensate_output(COOKContext *q, float *decode_buffer, cook_gains *gains_ptr, float *previous_buffer, - int16_t *out, int chan) + float *out, int chan) { imlt_gain(q, decode_buffer, gains_ptr, previous_buffer); q->saturate_output (q, chan, out); @@ -917,7 +904,9 @@ * @param inbuffer pointer to the inbuffer * @param outbuffer pointer to the outbuffer */ -static void decode_subpacket(COOKContext *q, COOKSubpacket* p, const uint8_t *inbuffer, int16_t *outbuffer) { +static void decode_subpacket(COOKContext *q, COOKSubpacket *p, + const uint8_t *inbuffer, float *outbuffer) +{ int sub_packet_size = p->size; /* packet dump */ // for (i=0 ; idata; int buf_size = avpkt->size; COOKContext *q = avctx->priv_data; - int i; + int i, out_size; int offset = 0; int chidx = 0; if (buf_size < avctx->block_align) return buf_size; + out_size = q->nb_channels * q->samples_per_channel * + av_get_bytes_per_sample(avctx->sample_fmt); + if (*data_size < out_size) { + av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); + return AVERROR(EINVAL); + } + /* estimate subpacket sizes */ q->subpacket[0].size = avctx->block_align; @@ -981,22 +977,21 @@ q->subpacket[0].size -= q->subpacket[i].size + 1; if (q->subpacket[0].size < 0) { av_log(avctx,AV_LOG_DEBUG,"frame subpacket size total > avctx->block_align!\n"); - return -1; + return AVERROR_INVALIDDATA; } } /* decode supbackets */ - *data_size = 0; for(i=0;inum_subpackets;i++){ q->subpacket[i].bits_per_subpacket = (q->subpacket[i].size*8)>>q->subpacket[i].bits_per_subpdiv; q->subpacket[i].ch_idx = chidx; av_log(avctx,AV_LOG_DEBUG,"subpacket[%i] size %i js %i %i block_align %i\n",i,q->subpacket[i].size,q->subpacket[i].joint_stereo,offset,avctx->block_align); - decode_subpacket(q, &q->subpacket[i], buf + offset, (int16_t*)data); + decode_subpacket(q, &q->subpacket[i], buf + offset, data); offset += q->subpacket[i].size; chidx += q->subpacket[i].num_channels; av_log(avctx,AV_LOG_DEBUG,"subpacket[%i] %i %i\n",i,q->subpacket[i].size * 8,get_bits_count(&q->gb)); } - *data_size = sizeof(int16_t) * q->nb_channels * q->samples_per_channel; + *data_size = out_size; /* Discard the first two frames: no valid audio. */ if (avctx->frame_number < 2) *data_size = 0; @@ -1053,12 +1048,13 @@ int extradata_size = avctx->extradata_size; int s = 0; unsigned int channel_mask = 0; + int ret; q->avctx = avctx; /* Take care of the codec specific extradata. */ if (extradata_size <= 0) { av_log(avctx,AV_LOG_ERROR,"Necessary extradata missing!\n"); - return -1; + return AVERROR_INVALIDDATA; } av_log(avctx,AV_LOG_DEBUG,"codecdata_length=%d\n",avctx->extradata_size); @@ -1103,7 +1099,7 @@ case MONO: if (q->nb_channels != 1) { av_log_ask_for_sample(avctx, "Container channels != 1.\n"); - return -1; + return AVERROR_PATCHWELCOME; } av_log(avctx,AV_LOG_DEBUG,"MONO\n"); break; @@ -1117,7 +1113,7 @@ case JOINT_STEREO: if (q->nb_channels != 2) { av_log_ask_for_sample(avctx, "Container channels != 2.\n"); - return -1; + return AVERROR_PATCHWELCOME; } av_log(avctx,AV_LOG_DEBUG,"JOINT_STEREO\n"); if (avctx->extradata_size >= 16){ @@ -1155,12 +1151,12 @@ break; default: av_log_ask_for_sample(avctx, "Unknown Cook version.\n"); - return -1; + return AVERROR_PATCHWELCOME; } if(s > 1 && q->subpacket[s].samples_per_channel != q->samples_per_channel) { av_log(avctx,AV_LOG_ERROR,"different number of samples per channel!\n"); - return -1; + return AVERROR_INVALIDDATA; } else q->samples_per_channel = q->subpacket[0].samples_per_channel; @@ -1171,18 +1167,18 @@ /* Try to catch some obviously faulty streams, othervise it might be exploitable */ if (q->subpacket[s].total_subbands > 53) { av_log_ask_for_sample(avctx, "total_subbands > 53\n"); - return -1; + return AVERROR_PATCHWELCOME; } if ((q->subpacket[s].js_vlc_bits > 6) || (q->subpacket[s].js_vlc_bits < 2*q->subpacket[s].joint_stereo)) { av_log(avctx,AV_LOG_ERROR,"js_vlc_bits = %d, only >= %d and <= 6 allowed!\n", q->subpacket[s].js_vlc_bits, 2*q->subpacket[s].joint_stereo); - return -1; + return AVERROR_INVALIDDATA; } if (q->subpacket[s].subbands > 50) { av_log_ask_for_sample(avctx, "subbands > 50\n"); - return -1; + return AVERROR_PATCHWELCOME; } q->subpacket[s].gains1.now = q->subpacket[s].gain_1; q->subpacket[s].gains1.previous = q->subpacket[s].gain_2; @@ -1193,7 +1189,7 @@ s++; if (s > MAX_SUBPACKETS) { av_log_ask_for_sample(avctx, "Too many subpackets > 5\n"); - return -1; + return AVERROR_PATCHWELCOME; } } /* Generate tables */ @@ -1201,12 +1197,12 @@ init_gain_table(q); init_cplscales_table(q); - if (init_cook_vlc_tables(q) != 0) - return -1; + if ((ret = init_cook_vlc_tables(q))) + return ret; if(avctx->block_align >= UINT_MAX/2) - return -1; + return AVERROR(EINVAL); /* Pad the databuffer with: DECODE_BYTES_PAD1 or DECODE_BYTES_PAD2 for decode_bytes(), @@ -1216,11 +1212,11 @@ + DECODE_BYTES_PAD1(avctx->block_align) + FF_INPUT_BUFFER_PADDING_SIZE); if (q->decoded_bytes_buffer == NULL) - return -1; + return AVERROR(ENOMEM); /* Initialize transform. */ - if ( init_cook_mlt(q) != 0 ) - return -1; + if ((ret = init_cook_mlt(q))) + return ret; /* Initialize COOK signal arithmetic handling */ if (1) { @@ -1237,10 +1233,10 @@ av_log_ask_for_sample(avctx, "unknown amount of samples_per_channel = %d\n", q->samples_per_channel); - return -1; + return AVERROR_PATCHWELCOME; } - avctx->sample_fmt = AV_SAMPLE_FMT_S16; + avctx->sample_fmt = AV_SAMPLE_FMT_FLT; if (channel_mask) avctx->channel_layout = channel_mask; else diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/crystalhd.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/crystalhd.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/crystalhd.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/crystalhd.c 2011-11-04 12:38:26.000000000 +0000 @@ -150,7 +150,7 @@ { "crystalhd_downscale_width", "Turn on downscaling to the specified width", offsetof(CHDContext, sWidth), - FF_OPT_TYPE_INT, 0, 0, UINT32_MAX, + AV_OPT_TYPE_INT, 0, 0, UINT32_MAX, AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM, }, { NULL, }, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dca.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dca.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dca.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dca.c 2011-11-04 12:38:26.000000000 +0000 @@ -293,7 +293,6 @@ /* Primary audio coding header */ int subframes; ///< number of subframes - int is_channels_set; ///< check for if the channel number is already set int total_channels; ///< number of channels including extensions int prim_channels; ///< number of primary audio channels int subband_activity[DCA_PRIM_CHANNELS_MAX]; ///< subband activity count @@ -529,15 +528,15 @@ s->sample_blocks = get_bits(&s->gb, 7) + 1; s->frame_size = get_bits(&s->gb, 14) + 1; if (s->frame_size < 95) - return -1; + return AVERROR_INVALIDDATA; s->amode = get_bits(&s->gb, 6); s->sample_rate = dca_sample_rates[get_bits(&s->gb, 4)]; if (!s->sample_rate) - return -1; + return AVERROR_INVALIDDATA; s->bit_rate_index = get_bits(&s->gb, 5); s->bit_rate = dca_bit_rates[s->bit_rate_index]; if (!s->bit_rate) - return -1; + return AVERROR_INVALIDDATA; s->downmix = get_bits(&s->gb, 1); s->dynrange = get_bits(&s->gb, 1); @@ -627,7 +626,7 @@ int j, k; if (get_bits_left(&s->gb) < 0) - return -1; + return AVERROR_INVALIDDATA; if (!base_channel) { s->subsubframes[s->current_subframe] = get_bits(&s->gb, 2) + 1; @@ -659,7 +658,7 @@ else if (s->bitalloc_huffman[j] == 7) { av_log(s->avctx, AV_LOG_ERROR, "Invalid bit allocation index\n"); - return -1; + return AVERROR_INVALIDDATA; } else { s->bitalloc[j][k] = get_bitalloc(&s->gb, &dca_bitalloc_index, s->bitalloc_huffman[j]); @@ -668,7 +667,7 @@ if (s->bitalloc[j][k] > 26) { // av_log(s->avctx,AV_LOG_DEBUG,"bitalloc index [%i][%i] too big (%i)\n", // j, k, s->bitalloc[j][k]); - return -1; + return AVERROR_INVALIDDATA; } } } @@ -686,7 +685,7 @@ } if (get_bits_left(&s->gb) < 0) - return -1; + return AVERROR_INVALIDDATA; for (j = base_channel; j < s->prim_channels; j++) { const uint32_t *scale_table; @@ -724,7 +723,7 @@ } if (get_bits_left(&s->gb) < 0) - return -1; + return AVERROR_INVALIDDATA; /* Scale factors for joint subband coding */ for (j = base_channel; j < s->prim_channels; j++) { @@ -909,7 +908,8 @@ for (subindex = 0; subindex < 8; subindex++) { /* Load in one sample from each subband and clear inactive subbands */ for (i = 0; i < sb_act; i++){ - uint32_t v = AV_RN32A(&samples_in[i][subindex]) ^ ((i-1)&2)<<30; + unsigned sign = (i - 1) & 2; + uint32_t v = AV_RN32A(&samples_in[i][subindex]) ^ sign << 30; AV_WN32A(&s->raXin[i], v); } @@ -1037,6 +1037,7 @@ } +#ifndef decode_blockcode /* Very compact version of the block code decoder that does not use table * look-up but is slightly slower */ static int decode_blockcode(int code, int levels, int *values) @@ -1054,9 +1055,10 @@ return 0; else { av_log(NULL, AV_LOG_ERROR, "ERROR: block code look-up failed\n"); - return -1; + return AVERROR_INVALIDDATA; } } +#endif static const uint8_t abits_sizes[7] = { 7, 10, 12, 13, 15, 17, 19 }; static const uint8_t abits_levels[7] = { 3, 5, 7, 9, 13, 17, 25 }; @@ -1094,7 +1096,7 @@ for (k = base_channel; k < s->prim_channels; k++) { if (get_bits_left(&s->gb) < 0) - return -1; + return AVERROR_INVALIDDATA; for (l = 0; l < s->vq_start_subband[k]; l++) { int m; @@ -1273,12 +1275,13 @@ static int dca_decode_block(DCAContext * s, int base_channel, int block_index) { + int ret; /* Sanity check */ if (s->current_subframe >= s->subframes) { av_log(s->avctx, AV_LOG_DEBUG, "check failed: %i>%i", s->current_subframe, s->subframes); - return -1; + return AVERROR_INVALIDDATA; } if (!s->current_subsubframe) { @@ -1286,16 +1289,16 @@ av_log(s->avctx, AV_LOG_DEBUG, "DSYNC dca_subframe_header\n"); #endif /* Read subframe header */ - if (dca_subframe_header(s, base_channel, block_index)) - return -1; + if ((ret = dca_subframe_header(s, base_channel, block_index))) + return ret; } /* Read subsubframe */ #ifdef TRACE av_log(s->avctx, AV_LOG_DEBUG, "DSYNC dca_subsubframe\n"); #endif - if (dca_subsubframe(s, base_channel, block_index)) - return -1; + if ((ret = dca_subsubframe(s, base_channel, block_index))) + return ret; /* Update state */ s->current_subsubframe++; @@ -1308,8 +1311,8 @@ av_log(s->avctx, AV_LOG_DEBUG, "DSYNC dca_subframe_footer\n"); #endif /* Read subframe footer */ - if (dca_subframe_footer(s, base_channel)) - return -1; + if ((ret = dca_subframe_footer(s, base_channel))) + return ret; } return 0; @@ -1352,7 +1355,7 @@ flush_put_bits(&pb); return (put_bits_count(&pb) + 7) >> 3; default: - return -1; + return AVERROR_INVALIDDATA; } } @@ -1635,7 +1638,7 @@ int lfe_samples; int num_core_channels = 0; - int i; + int i, ret; float *samples_flt = data; int16_t *samples_s16 = data; int out_size; @@ -1648,16 +1651,15 @@ s->dca_buffer_size = dca_convert_bitstream(buf, buf_size, s->dca_buffer, DCA_MAX_FRAME_SIZE + DCA_MAX_EXSS_HEADER_SIZE); - if (s->dca_buffer_size == -1) { + if (s->dca_buffer_size == AVERROR_INVALIDDATA) { av_log(avctx, AV_LOG_ERROR, "Not a valid DCA frame\n"); - return -1; + return AVERROR_INVALIDDATA; } init_get_bits(&s->gb, s->dca_buffer, s->dca_buffer_size * 8); - if (dca_parse_frame_header(s) < 0) { + if ((ret = dca_parse_frame_header(s)) < 0) { //seems like the frame is corrupt, try with the next one - *data_size=0; - return buf_size; + return ret; } //set AVCodec values with parsed data avctx->sample_rate = s->sample_rate; @@ -1667,7 +1669,10 @@ s->profile = FF_PROFILE_DTS; for (i = 0; i < (s->sample_blocks / 8); i++) { - dca_decode_block(s, 0, i); + if ((ret = dca_decode_block(s, 0, i))) { + av_log(avctx, AV_LOG_ERROR, "error decoding block\n"); + return ret; + } } /* record number of core channels incase less than max channels are requested */ @@ -1723,7 +1728,10 @@ dca_parse_audio_coding_header(s, s->xch_base_channel); for (i = 0; i < (s->sample_blocks / 8); i++) { - dca_decode_block(s, s->xch_base_channel, i); + if ((ret = dca_decode_block(s, s->xch_base_channel, i))) { + av_log(avctx, AV_LOG_ERROR, "error decoding XCh extension\n"); + continue; + } } s->xch_present = 1; @@ -1797,7 +1805,7 @@ if (channels > !!s->lfe && s->channel_order_tab[channels - 1 - !!s->lfe] < 0) - return -1; + return AVERROR_INVALIDDATA; if (avctx->request_channels == 2 && s->prim_channels > 2) { channels = 2; @@ -1810,29 +1818,19 @@ } } else { av_log(avctx, AV_LOG_ERROR, "Non standard configuration %d !\n",s->amode); - return -1; + return AVERROR_INVALIDDATA; } - - /* There is nothing that prevents a dts frame to change channel configuration - but FFmpeg doesn't support that so only set the channels if it is previously - unset. Ideally during the first probe for channels the crc should be checked - and only set avctx->channels when the crc is ok. Right now the decoder could - set the channels based on a broken first frame.*/ - if (s->is_channels_set == 0) { - s->is_channels_set = 1; - avctx->channels = channels; - } if (avctx->channels != channels) { - av_log(avctx, AV_LOG_ERROR, "DCA decoder does not support number of " - "channels changing in stream. Skipping frame.\n"); - return -1; + if (avctx->channels) + av_log(avctx, AV_LOG_INFO, "Number of channels changed in DCA decoder (%d -> %d)\n", avctx->channels, channels); + avctx->channels = channels; } out_size = 256 / 8 * s->sample_blocks * channels * av_get_bytes_per_sample(avctx->sample_fmt); if (*data_size < out_size) - return -1; + return AVERROR(EINVAL); *data_size = out_size; /* filter to get final output */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dca_parser.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dca_parser.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dca_parser.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dca_parser.c 2011-11-04 12:38:26.000000000 +0000 @@ -36,7 +36,7 @@ #define IS_MARKER(state, i, buf, buf_size) \ ((state == DCA_MARKER_14B_LE && (i < buf_size-2) && (buf[i+1] & 0xF0) == 0xF0 && buf[i+2] == 0x07) \ || (state == DCA_MARKER_14B_BE && (i < buf_size-2) && buf[i+1] == 0x07 && (buf[i+2] & 0xF0) == 0xF0) \ - || state == DCA_MARKER_RAW_LE || state == DCA_MARKER_RAW_BE) + || state == DCA_MARKER_RAW_LE || state == DCA_MARKER_RAW_BE || state == DCA_HD_MARKER) /** * finds the end of the current frame in the bitstream. @@ -57,10 +57,7 @@ for (i = 0; i < buf_size; i++) { state = (state << 8) | buf[i]; if (IS_MARKER(state, i, buf, buf_size)) { - if (pc1->lastmarker && state == pc1->lastmarker) { - start_found = 1; - break; - } else if (!pc1->lastmarker) { + if (!pc1->lastmarker || state == pc1->lastmarker || pc1->lastmarker == DCA_HD_MARKER) { start_found = 1; pc1->lastmarker = state; break; @@ -74,10 +71,11 @@ state = (state << 8) | buf[i]; if (state == DCA_HD_MARKER && !pc1->hd_pos) pc1->hd_pos = pc1->size; - if (state == pc1->lastmarker && IS_MARKER(state, i, buf, buf_size)) { + if (IS_MARKER(state, i, buf, buf_size) && (state == pc1->lastmarker || pc1->lastmarker == DCA_HD_MARKER)) { if(pc1->framesize > pc1->size) continue; - if(!pc1->framesize){ + // We have to check that we really read a full frame here, and that it isn't a pure HD frame, because their size is not constant. + if(!pc1->framesize && state == pc1->lastmarker && state != DCA_HD_MARKER){ pc1->framesize = pc1->hd_pos ? pc1->hd_pos : pc1->size; } pc->frame_start_found = 0; @@ -126,9 +124,9 @@ } AVCodecParser ff_dca_parser = { - {CODEC_ID_DTS}, - sizeof(DCAParseContext), - dca_parse_init, - dca_parse, - ff_parse_close, + .codec_ids = { CODEC_ID_DTS }, + .priv_data_size = sizeof(DCAParseContext), + .parser_init = dca_parse_init, + .parser_parse = dca_parse, + .parser_close = ff_parse_close, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dct-test.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dct-test.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dct-test.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dct-test.c 2011-11-04 12:38:26.000000000 +0000 @@ -71,7 +71,7 @@ const char *name; void (*func)(DCTELEM *block); enum formattag { NO_PERM, MMX_PERM, MMX_SIMPLE_PERM, SCALE_PERM, - SSE2_PERM, PARTTRANS_PERM } format; + SSE2_PERM, PARTTRANS_PERM, TRANSPOSE_PERM } format; int mm_support; int nonspec; }; @@ -107,6 +107,22 @@ { 0 } }; +#if HAVE_MMX +void ff_prores_idct_put_10_sse2(uint16_t *dst, int linesize, + DCTELEM *block, int16_t *qmat); + +static void ff_prores_idct_put_10_sse2_wrap(uint16_t *dst){ + int16_t qmat[64]; int i; + int16_t tmp[64]; + + for(i=0; i<64; i++){ + qmat[i]=4; + tmp[i]= dst[i]; + } + ff_prores_idct_put_10_sse2(dst, 16, tmp, qmat); +} +#endif + static const struct algo idct_tab[] = { { "FAANI", ff_faanidct, NO_PERM }, { "REF-DBL", ff_ref_idct, NO_PERM }, @@ -122,6 +138,9 @@ { "XVID-MMX", ff_idct_xvid_mmx, NO_PERM, AV_CPU_FLAG_MMX, 1 }, { "XVID-MMX2", ff_idct_xvid_mmx2, NO_PERM, AV_CPU_FLAG_MMX2, 1 }, { "XVID-SSE2", ff_idct_xvid_sse2, SSE2_PERM, AV_CPU_FLAG_SSE2, 1 }, +#if ARCH_X86_64 + { "PR-SSE2", ff_prores_idct_put_10_sse2_wrap, TRANSPOSE_PERM, AV_CPU_FLAG_SSE2, 1 }, +#endif #endif #if ARCH_BFIN @@ -243,6 +262,9 @@ } else if (perm == PARTTRANS_PERM) { for (i = 0; i < 64; i++) dst[(i & 0x24) | ((i & 3) << 3) | ((i >> 3) & 3)] = src[i]; + } else if (perm == TRANSPOSE_PERM) { + for (i = 0; i < 64; i++) + dst[(i>>3) | ((i<<3)&0x38)] = src[i]; } else { for (i = 0; i < 64; i++) dst[i] = src[i]; @@ -316,7 +338,7 @@ spec_err = is_idct && (err_inf > 1 || omse > 0.02 || fabs(ome) > 0.0015); - printf("%s %s: ppe=%d omse=%0.8f ome=%0.8f syserr=%0.8f maxout=%d blockSumErr=%d\n", + printf("%s %s: max_err=%d omse=%0.8f ome=%0.8f syserr=%0.8f maxout=%d blockSumErr=%d\n", is_idct ? "IDCT" : "DCT", dct->name, err_inf, omse, ome, (double) sysErrMax / NB_ITS, maxout, blockSumErrMax); @@ -511,10 +533,11 @@ static void help(void) { - printf("dct-test [-i] []\n" + printf("dct-test [-i] [] []\n" "test-number 0 -> test with random matrixes\n" " 1 -> test with random sparse matrixes\n" " 2 -> do 3. test from mpeg4 std\n" + "bits Number of time domain bits to use, 8 is default\n" "-i test IDCT implementations\n" "-4 test IDCT248 implementations\n" "-t speed test\n"); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dirac_arith.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dirac_arith.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dirac_arith.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dirac_arith.c 2011-11-04 12:38:26.000000000 +0000 @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2007 Marco Gerards + * Copyright (C) 2009 David Conrad + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * Arithmetic decoder for Dirac + * @author Marco Gerards + */ + +#include "dirac_arith.h" + + +const uint16_t ff_dirac_prob[256] = { + 0, 2, 5, 8, 11, 15, 20, 24, + 29, 35, 41, 47, 53, 60, 67, 74, + 82, 89, 97, 106, 114, 123, 132, 141, + 150, 160, 170, 180, 190, 201, 211, 222, + 233, 244, 256, 267, 279, 291, 303, 315, + 327, 340, 353, 366, 379, 392, 405, 419, + 433, 447, 461, 475, 489, 504, 518, 533, + 548, 563, 578, 593, 609, 624, 640, 656, + 672, 688, 705, 721, 738, 754, 771, 788, + 805, 822, 840, 857, 875, 892, 910, 928, + 946, 964, 983, 1001, 1020, 1038, 1057, 1076, + 1095, 1114, 1133, 1153, 1172, 1192, 1211, 1231, + 1251, 1271, 1291, 1311, 1332, 1352, 1373, 1393, + 1414, 1435, 1456, 1477, 1498, 1520, 1541, 1562, + 1584, 1606, 1628, 1649, 1671, 1694, 1716, 1738, + 1760, 1783, 1806, 1828, 1851, 1874, 1897, 1920, + 1935, 1942, 1949, 1955, 1961, 1968, 1974, 1980, + 1985, 1991, 1996, 2001, 2006, 2011, 2016, 2021, + 2025, 2029, 2033, 2037, 2040, 2044, 2047, 2050, + 2053, 2056, 2058, 2061, 2063, 2065, 2066, 2068, + 2069, 2070, 2071, 2072, 2072, 2072, 2072, 2072, + 2072, 2071, 2070, 2069, 2068, 2066, 2065, 2063, + 2060, 2058, 2055, 2052, 2049, 2045, 2042, 2038, + 2033, 2029, 2024, 2019, 2013, 2008, 2002, 1996, + 1989, 1982, 1975, 1968, 1960, 1952, 1943, 1934, + 1925, 1916, 1906, 1896, 1885, 1874, 1863, 1851, + 1839, 1827, 1814, 1800, 1786, 1772, 1757, 1742, + 1727, 1710, 1694, 1676, 1659, 1640, 1622, 1602, + 1582, 1561, 1540, 1518, 1495, 1471, 1447, 1422, + 1396, 1369, 1341, 1312, 1282, 1251, 1219, 1186, + 1151, 1114, 1077, 1037, 995, 952, 906, 857, + 805, 750, 690, 625, 553, 471, 376, 255 +}; + +const uint8_t ff_dirac_next_ctx[DIRAC_CTX_COUNT] = { + [CTX_ZPZN_F1] = CTX_ZP_F2, + [CTX_ZPNN_F1] = CTX_ZP_F2, + [CTX_ZP_F2] = CTX_ZP_F3, + [CTX_ZP_F3] = CTX_ZP_F4, + [CTX_ZP_F4] = CTX_ZP_F5, + [CTX_ZP_F5] = CTX_ZP_F6, + [CTX_ZP_F6] = CTX_ZP_F6, + [CTX_NPZN_F1] = CTX_NP_F2, + [CTX_NPNN_F1] = CTX_NP_F2, + [CTX_NP_F2] = CTX_NP_F3, + [CTX_NP_F3] = CTX_NP_F4, + [CTX_NP_F4] = CTX_NP_F5, + [CTX_NP_F5] = CTX_NP_F6, + [CTX_NP_F6] = CTX_NP_F6, + [CTX_DELTA_Q_F] = CTX_DELTA_Q_F, +}; + +int16_t ff_dirac_prob_branchless[256][2]; + +void ff_dirac_init_arith_decoder(DiracArith *c, GetBitContext *gb, int length) +{ + int i; + align_get_bits(gb); + + length = FFMIN(length, get_bits_left(gb)/8); + + c->bytestream = gb->buffer + get_bits_count(gb)/8; + c->bytestream_end = c->bytestream + length; + skip_bits_long(gb, length*8); + + c->low = 0; + for (i = 0; i < 4; i++) { + c->low <<= 8; + if (c->bytestream < c->bytestream_end) + c->low |= *c->bytestream++; + else + c->low |= 0xff; + } + + c->counter = -16; + c->range = 0xffff; + + for (i = 0; i < 256; i++) { + ff_dirac_prob_branchless[i][0] = ff_dirac_prob[255-i]; + ff_dirac_prob_branchless[i][1] = -ff_dirac_prob[i]; + } + + for (i = 0; i < DIRAC_CTX_COUNT; i++) + c->contexts[i] = 0x8000; +} diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dirac_arith.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dirac_arith.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dirac_arith.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dirac_arith.h 2011-11-04 12:38:26.000000000 +0000 @@ -0,0 +1,190 @@ +/* + * Copyright (C) 2007 Marco Gerards + * Copyright (C) 2009 David Conrad + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * Arithmetic decoder for Dirac + * @author Marco Gerards + */ + +#ifndef AVCODEC_DIRAC_ARITH_H +#define AVCODEC_DIRAC_ARITH_H + +#include "bytestream.h" +#include "get_bits.h" + +enum dirac_arith_contexts { + CTX_ZPZN_F1, + CTX_ZPNN_F1, + CTX_NPZN_F1, + CTX_NPNN_F1, + CTX_ZP_F2, + CTX_ZP_F3, + CTX_ZP_F4, + CTX_ZP_F5, + CTX_ZP_F6, + CTX_NP_F2, + CTX_NP_F3, + CTX_NP_F4, + CTX_NP_F5, + CTX_NP_F6, + CTX_COEFF_DATA, + CTX_SIGN_NEG, + CTX_SIGN_ZERO, + CTX_SIGN_POS, + CTX_ZERO_BLOCK, + CTX_DELTA_Q_F, + CTX_DELTA_Q_DATA, + CTX_DELTA_Q_SIGN, + + DIRAC_CTX_COUNT +}; + +// Dirac resets the arith decoder between decoding various types of data, +// so many contexts are never used simultaneously. Thus, we can reduce +// the number of contexts needed by reusing them. +#define CTX_SB_F1 CTX_ZP_F5 +#define CTX_SB_DATA 0 +#define CTX_PMODE_REF1 0 +#define CTX_PMODE_REF2 1 +#define CTX_GLOBAL_BLOCK 2 +#define CTX_MV_F1 CTX_ZP_F2 +#define CTX_MV_DATA 0 +#define CTX_DC_F1 CTX_ZP_F5 +#define CTX_DC_DATA 0 + +typedef struct { + unsigned low; + uint16_t range; + int16_t counter; + + const uint8_t *bytestream; + const uint8_t *bytestream_end; + + uint16_t contexts[DIRAC_CTX_COUNT]; +} DiracArith; + +extern const uint8_t ff_dirac_next_ctx[DIRAC_CTX_COUNT]; +extern const uint16_t ff_dirac_prob[256]; +extern int16_t ff_dirac_prob_branchless[256][2]; + +static inline void renorm(DiracArith *c) +{ +#if HAVE_FAST_CLZ + int shift = 14 - av_log2_16bit(c->range-1) + ((c->range-1)>>15); + + c->low <<= shift; + c->range <<= shift; + c->counter += shift; +#else + while (c->range <= 0x4000) { + c->low <<= 1; + c->range <<= 1; + c->counter++; + } +#endif +} + +static inline void refill(DiracArith *c) +{ + int counter = c->counter; + + if (counter >= 0) { + int new = bytestream_get_be16(&c->bytestream); + + // the spec defines overread bits to be 1, and streams rely on this + if (c->bytestream > c->bytestream_end) { + new |= 0xff; + if (c->bytestream > c->bytestream_end+1) + new |= 0xff00; + + c->bytestream = c->bytestream_end; + } + + c->low += new << counter; + counter -= 16; + } + c->counter = counter; +} + +static inline int dirac_get_arith_bit(DiracArith *c, int ctx) +{ + int prob_zero = c->contexts[ctx]; + int range_times_prob, bit; + unsigned low = c->low; + int range = c->range; + + range_times_prob = (c->range * prob_zero) >> 16; + +#if HAVE_FAST_CMOV + low -= range_times_prob << 16; + range -= range_times_prob; + bit = 0; + __asm__( + "cmpl %5, %4 \n\t" + "setae %b0 \n\t" + "cmovb %3, %2 \n\t" + "cmovb %5, %1 \n\t" + : "+q"(bit), "+r"(range), "+r"(low) + : "r"(c->low), "r"(c->low>>16), + "r"(range_times_prob) + ); +#else + bit = (low >> 16) >= range_times_prob; + if (bit) { + low -= range_times_prob << 16; + range -= range_times_prob; + } else { + range = range_times_prob; + } +#endif + + c->contexts[ctx] += ff_dirac_prob_branchless[prob_zero>>8][bit]; + c->low = low; + c->range = range; + + renorm(c); + refill(c); + return bit; +} + +static inline int dirac_get_arith_uint(DiracArith *c, int follow_ctx, int data_ctx) +{ + int ret = 1; + while (!dirac_get_arith_bit(c, follow_ctx)) { + ret <<= 1; + ret += dirac_get_arith_bit(c, data_ctx); + follow_ctx = ff_dirac_next_ctx[follow_ctx]; + } + return ret-1; +} + +static inline int dirac_get_arith_int(DiracArith *c, int follow_ctx, int data_ctx) +{ + int ret = dirac_get_arith_uint(c, follow_ctx, data_ctx); + if (ret && dirac_get_arith_bit(c, data_ctx+1)) + ret = -ret; + return ret; +} + +void ff_dirac_init_arith_decoder(DiracArith *c, GetBitContext *gb, int length); + +#endif /* AVCODEC_DIRAC_ARITH_H */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dirac.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dirac.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dirac.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dirac.c 2011-11-04 12:38:26.000000000 +0000 @@ -1,6 +1,7 @@ /* * Copyright (C) 2007 Marco Gerards * Copyright (C) 2009 David Conrad + * Copyright (C) 2011 Jordi Ortiz * * This file is part of FFmpeg. * @@ -22,7 +23,7 @@ /** * @file * Dirac Decoder - * @author Marco Gerards + * @author Marco Gerards , David Conrad, Jordi Ortiz */ #include "libavutil/imgutils.h" @@ -31,7 +32,7 @@ #include "golomb.h" #include "mpeg12data.h" -// defaults for source parameters +/* defaults for source parameters */ static const dirac_source_params dirac_source_parameters_defaults[] = { { 640, 480, 2, 0, 0, 1, 1, 640, 480, 0, 0, 1, 0 }, { 176, 120, 2, 0, 0, 9, 2, 176, 120, 0, 0, 1, 1 }, @@ -42,7 +43,6 @@ { 704, 576, 2, 0, 1, 10, 3, 704, 576, 0, 0, 1, 2 }, { 720, 480, 1, 1, 0, 4, 2, 704, 480, 8, 0, 3, 1 }, { 720, 576, 1, 1, 1, 3, 3, 704, 576, 8, 0, 3, 2 }, - { 1280, 720, 1, 0, 1, 7, 1, 1280, 720, 0, 0, 3, 3 }, { 1280, 720, 1, 0, 1, 6, 1, 1280, 720, 0, 0, 3, 3 }, { 1920, 1080, 1, 1, 1, 4, 1, 1920, 1080, 0, 0, 3, 3 }, @@ -51,13 +51,16 @@ { 1920, 1080, 1, 0, 1, 6, 1, 1920, 1080, 0, 0, 3, 3 }, { 2048, 1080, 0, 0, 1, 2, 1, 2048, 1080, 0, 0, 4, 4 }, { 4096, 2160, 0, 0, 1, 2, 1, 4096, 2160, 0, 0, 4, 4 }, - { 3840, 2160, 1, 0, 1, 7, 1, 3840, 2160, 0, 0, 3, 3 }, { 3840, 2160, 1, 0, 1, 6, 1, 3840, 2160, 0, 0, 3, 3 }, { 7680, 4320, 1, 0, 1, 7, 1, 3840, 2160, 0, 0, 3, 3 }, { 7680, 4320, 1, 0, 1, 6, 1, 3840, 2160, 0, 0, 3, 3 }, }; +/** + * Dirac Specification -> + * Table 10.4 - Available preset pixel aspect ratio values + */ static const AVRational dirac_preset_aspect_ratios[] = { {1, 1}, {10, 11}, @@ -67,11 +70,19 @@ {4, 3}, }; +/** + * Dirac Specification -> + * Values 9,10 of 10.3.5 Frame Rate. Table 10.3 Available preset frame rate values + */ static const AVRational dirac_frame_rate[] = { {15000, 1001}, {25, 2}, }; +/** + * Dirac Specification -> + * This should be equivalent to Table 10.5 Available signal range presets + */ static const struct { uint8_t bitdepth; enum AVColorRange color_range; @@ -100,11 +111,19 @@ { AVCOL_PRI_BT709, AVCOL_SPC_BT709, AVCOL_TRC_UNSPECIFIED /* DCinema */ }, }; +/** + * Dirac Specification -> + * Table 10.2 Supported chroma sampling formats + Luma Offset + */ static const enum PixelFormat dirac_pix_fmt[2][3] = { { PIX_FMT_YUV444P, PIX_FMT_YUV422P, PIX_FMT_YUV420P }, { PIX_FMT_YUVJ444P, PIX_FMT_YUVJ422P, PIX_FMT_YUVJ420P }, }; +/** + * Dirac Specification -> + * 10.3 Parse Source Parameters. source_parameters(base_video_format) + */ static int parse_source_parameters(AVCodecContext *avctx, GetBitContext *gb, dirac_source_params *source) { @@ -112,49 +131,52 @@ unsigned luma_depth = 8, luma_offset = 16; int idx; - if (get_bits1(gb)) { - source->width = svq3_get_ue_golomb(gb); - source->height = svq3_get_ue_golomb(gb); + /* [DIRAC_STD] 10.3.2 Frame size. frame_size(video_params) */ + if (get_bits1(gb)) { /* [DIRAC_STD] custom_dimensions_flag */ + source->width = svq3_get_ue_golomb(gb); /* [DIRAC_STD] FRAME_WIDTH */ + source->height = svq3_get_ue_golomb(gb); /* [DIRAC_STD] FRAME_HEIGHT */ } - // chroma subsampling - if (get_bits1(gb)) - source->chroma_format = svq3_get_ue_golomb(gb); + /* [DIRAC_STD] 10.3.3 Chroma Sampling Format. + chroma_sampling_format(video_params) */ + if (get_bits1(gb)) /* [DIRAC_STD] custom_chroma_format_flag */ + source->chroma_format = svq3_get_ue_golomb(gb); /*[DIRAC_STD] CHROMA_FORMAT_INDEX */ if (source->chroma_format > 2U) { av_log(avctx, AV_LOG_ERROR, "Unknown chroma format %d\n", source->chroma_format); return -1; } - if (get_bits1(gb)) - source->interlaced = svq3_get_ue_golomb(gb); + /* [DIRAC_STD] 10.3.4 Scan Format. scan_format(video_params) */ + if (get_bits1(gb)) /* [DIRAC_STD] custom_scan_format_flag */ + source->interlaced = svq3_get_ue_golomb(gb); /* [DIRAC_STD] SOURCE_SAMPLING */ if (source->interlaced > 1U) return -1; - // frame rate - if (get_bits1(gb)) { + /* [DIRAC_STD] 10.3.5 Frame Rate. frame_rate(video_params) */ + if (get_bits1(gb)) { /* [DIRAC_STD] custom_frame_rate_flag */ source->frame_rate_index = svq3_get_ue_golomb(gb); if (source->frame_rate_index > 10U) return -1; - if (!source->frame_rate_index) { - frame_rate.num = svq3_get_ue_golomb(gb); - frame_rate.den = svq3_get_ue_golomb(gb); + if (!source->frame_rate_index){ + frame_rate.num = svq3_get_ue_golomb(gb); /* [DIRAC_STD] FRAME_RATE_NUMER */ + frame_rate.den = svq3_get_ue_golomb(gb); /* [DIRAC_STD] FRAME_RATE_DENOM */ } } - if (source->frame_rate_index > 0) { + if (source->frame_rate_index > 0) { /* [DIRAC_STD] preset_frame_rate(video_params,index) */ if (source->frame_rate_index <= 8) - frame_rate = ff_frame_rate_tab[source->frame_rate_index]; + frame_rate = avpriv_frame_rate_tab[source->frame_rate_index]; /* [DIRAC_STD] Table 10.3 values 1-8 */ else - frame_rate = dirac_frame_rate[source->frame_rate_index-9]; + frame_rate = dirac_frame_rate[source->frame_rate_index-9]; /* [DIRAC_STD] Table 10.3 values 9-10 */ } av_reduce(&avctx->time_base.num, &avctx->time_base.den, frame_rate.den, frame_rate.num, 1<<30); - // aspect ratio - if (get_bits1(gb)) { - source->aspect_ratio_index = svq3_get_ue_golomb(gb); + /* [DIRAC_STD] 10.3.6 Pixel Aspect Ratio. pixel_aspect_ratio(video_params) */ + if (get_bits1(gb)) { /* [DIRAC_STD] custom_pixel_aspect_ratio_flag */ + source->aspect_ratio_index = svq3_get_ue_golomb(gb); /* [DIRAC_STD] index */ if (source->aspect_ratio_index > 6U) return -1; @@ -164,35 +186,37 @@ avctx->sample_aspect_ratio.den = svq3_get_ue_golomb(gb); } } - if (source->aspect_ratio_index > 0) + if (source->aspect_ratio_index > 0) /* [DIRAC_STD] Take value from Table 10.4 Available preset pixel aspect ratio values */ avctx->sample_aspect_ratio = - dirac_preset_aspect_ratios[source->aspect_ratio_index-1]; + dirac_preset_aspect_ratios[source->aspect_ratio_index-1]; - if (get_bits1(gb)) { - source->clean_width = svq3_get_ue_golomb(gb); - source->clean_height = svq3_get_ue_golomb(gb); - source->clean_left_offset = svq3_get_ue_golomb(gb); - source->clean_right_offset = svq3_get_ue_golomb(gb); + /* [DIRAC_STD] 10.3.7 Clean area. clean_area(video_params) */ + if (get_bits1(gb)) { /* [DIRAC_STD] custom_clean_area_flag */ + source->clean_width = svq3_get_ue_golomb(gb); /* [DIRAC_STD] CLEAN_WIDTH */ + source->clean_height = svq3_get_ue_golomb(gb); /* [DIRAC_STD] CLEAN_HEIGHT */ + source->clean_left_offset = svq3_get_ue_golomb(gb); /* [DIRAC_STD] CLEAN_LEFT_OFFSET */ + source->clean_right_offset = svq3_get_ue_golomb(gb); /* [DIRAC_STD] CLEAN_RIGHT_OFFSET */ } - // Override signal range. - if (get_bits1(gb)) { - source->pixel_range_index = svq3_get_ue_golomb(gb); + /*[DIRAC_STD] 10.3.8 Signal range. signal_range(video_params) + WARNING: Some adaptation seemed to be done using the AVCOL_RANGE_MPEG/JPEG values */ + if (get_bits1(gb)) { /*[DIRAC_STD] custom_signal_range_flag */ + source->pixel_range_index = svq3_get_ue_golomb(gb); /*[DIRAC_STD] index */ if (source->pixel_range_index > 4U) return -1; - // This assumes either fullrange or MPEG levels only + /* This assumes either fullrange or MPEG levels only */ if (!source->pixel_range_index) { luma_offset = svq3_get_ue_golomb(gb); luma_depth = av_log2(svq3_get_ue_golomb(gb))+1; - svq3_get_ue_golomb(gb); // chroma offset - svq3_get_ue_golomb(gb); // chroma excursion + svq3_get_ue_golomb(gb); /* chroma offset @Jordi: Why are these two ignored? */ + svq3_get_ue_golomb(gb); /* chroma excursion */ avctx->color_range = luma_offset ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG; } } - if (source->pixel_range_index > 0) { + if (source->pixel_range_index > 0) { /*[DIRAC_STD] Take values from Table 10.5 Available signal range presets */ idx = source->pixel_range_index-1; luma_depth = pixel_range_presets[idx].bitdepth; avctx->color_range = pixel_range_presets[idx].color_range; @@ -203,9 +227,9 @@ avctx->pix_fmt = dirac_pix_fmt[!luma_offset][source->chroma_format]; - // color spec - if (get_bits1(gb)) { - idx = source->color_spec_index = svq3_get_ue_golomb(gb); + /* [DIRAC_STD] 10.3.9 Colour specification. colour_spec(video_params) */ + if (get_bits1(gb)) { /* [DIRAC_STD] custom_colour_spec_flag */ + idx = source->color_spec_index = svq3_get_ue_golomb(gb); /* [DIRAC_STD] index */ if (source->color_spec_index > 4U) return -1; @@ -215,12 +239,13 @@ avctx->color_trc = dirac_color_presets[idx].color_trc; if (!source->color_spec_index) { + /* [DIRAC_STD] 10.3.9.1 Color primaries */ if (get_bits1(gb)) { idx = svq3_get_ue_golomb(gb); if (idx < 3U) avctx->color_primaries = dirac_primaries[idx]; } - + /* [DIRAC_STD] 10.3.9.2 Color matrix */ if (get_bits1(gb)) { idx = svq3_get_ue_golomb(gb); if (!idx) @@ -228,7 +253,7 @@ else if (idx == 1) avctx->colorspace = AVCOL_SPC_BT470BG; } - + /* [DIRAC_STD] 10.3.9.3 Transfer function */ if (get_bits1(gb) && !svq3_get_ue_golomb(gb)) avctx->color_trc = AVCOL_TRC_BT709; } @@ -242,16 +267,23 @@ return 0; } -int ff_dirac_parse_sequence_header(AVCodecContext *avctx, GetBitContext *gb, +/** + * Dirac Specification -> + * 10. Sequence Header. sequence_header() + */ +int avpriv_dirac_parse_sequence_header(AVCodecContext *avctx, GetBitContext *gb, dirac_source_params *source) { unsigned version_major; unsigned video_format, picture_coding_mode; + /* [DIRAC_SPEC] 10.1 Parse Parameters. parse_parameters() */ version_major = svq3_get_ue_golomb(gb); svq3_get_ue_golomb(gb); /* version_minor */ avctx->profile = svq3_get_ue_golomb(gb); avctx->level = svq3_get_ue_golomb(gb); + /* [DIRAC_SPEC] sequence_header() -> base_video_format as defined in + 10.2 Base Video Format, table 10.1 Dirac predefined video formats */ video_format = svq3_get_ue_golomb(gb); if (version_major < 2) @@ -262,10 +294,11 @@ if (video_format > 20U) return -1; - // Fill in defaults for the source parameters. + /* Fill in defaults for the source parameters. */ *source = dirac_source_parameters_defaults[video_format]; - // Override the defaults. + /*[DIRAC_STD] 10.3 Source Parameters + Override the defaults. */ if (parse_source_parameters(avctx, gb, source)) return -1; @@ -274,7 +307,8 @@ avcodec_set_dimensions(avctx, source->width, source->height); - // currently only used to signal field coding + /*[DIRAC_STD] picture_coding_mode shall be 0 for fields and 1 for frames + currently only used to signal field coding */ picture_coding_mode = svq3_get_ue_golomb(gb); if (picture_coding_mode != 0) { av_log(avctx, AV_LOG_ERROR, "Unsupported picture coding mode %d", diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/diracdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/diracdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/diracdec.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/diracdec.c 2011-11-04 12:38:26.000000000 +0000 @@ -0,0 +1,1910 @@ +/* + * Copyright (C) 2007 Marco Gerards + * Copyright (C) 2009 David Conrad + * Copyright (C) 2011 Jordi Ortiz + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file libavcodec/diracdec.c + * Dirac Decoder + * @author Marco Gerards , David Conrad, Jordi Ortiz + */ + +#include "avcodec.h" +#include "dsputil.h" +#include "get_bits.h" +#include "bytestream.h" +#include "golomb.h" +#include "dirac_arith.h" +#include "mpeg12data.h" +#include "dwt.h" +#include "dirac.h" +#include "diracdsp.h" + +/** + * The spec limits the number of wavelet decompositions to 4 for both + * level 1 (VC-2) and 128 (long-gop default). + * 5 decompositions is the maximum before >16-bit buffers are needed. + * Schroedinger allows this for DD 9,7 and 13,7 wavelets only, limiting + * the others to 4 decompositions (or 3 for the fidelity filter). + * + * We use this instead of MAX_DECOMPOSITIONS to save some memory. + */ +#define MAX_DWT_LEVELS 5 + +/** + * The spec limits this to 3 for frame coding, but in practice can be as high as 6 + */ +#define MAX_REFERENCE_FRAMES 8 +#define MAX_DELAY 5 /* limit for main profile for frame coding (TODO: field coding) */ +#define MAX_FRAMES (MAX_REFERENCE_FRAMES + MAX_DELAY + 1) +#define MAX_QUANT 68 /* max quant for VC-2 */ +#define MAX_BLOCKSIZE 32 /* maximum xblen/yblen we support */ + +/** + * DiracBlock->ref flags, if set then the block does MC from the given ref + */ +#define DIRAC_REF_MASK_REF1 1 +#define DIRAC_REF_MASK_REF2 2 +#define DIRAC_REF_MASK_GLOBAL 4 + +/** + * Value of Picture.reference when Picture is not a reference picture, but + * is held for delayed output. + */ +#define DELAYED_PIC_REF 4 + +#define ff_emulated_edge_mc ff_emulated_edge_mc_8 /* Fix: change the calls to this function regarding bit depth */ + +#define CALC_PADDING(size, depth) \ + (((size + (1 << depth) - 1) >> depth) << depth) + +#define DIVRNDUP(a, b) (((a) + (b) - 1) / (b)) + +typedef struct { + AVFrame avframe; + int interpolated[3]; /* 1 if hpel[] is valid */ + uint8_t *hpel[3][4]; + uint8_t *hpel_base[3][4]; +} DiracFrame; + +typedef struct { + union { + int16_t mv[2][2]; + int16_t dc[3]; + } u; /* anonymous unions aren't in C99 :( */ + uint8_t ref; +} DiracBlock; + +typedef struct SubBand { + int level; + int orientation; + int stride; + int width; + int height; + int quant; + IDWTELEM *ibuf; + struct SubBand *parent; + + /* for low delay */ + unsigned length; + const uint8_t *coeff_data; +} SubBand; + +typedef struct Plane { + int width; + int height; + int stride; + + int idwt_width; + int idwt_height; + int idwt_stride; + IDWTELEM *idwt_buf; + IDWTELEM *idwt_buf_base; + IDWTELEM *idwt_tmp; + + /* block length */ + uint8_t xblen; + uint8_t yblen; + /* block separation (block n+1 starts after this many pixels in block n) */ + uint8_t xbsep; + uint8_t ybsep; + /* amount of overspill on each edge (half of the overlap between blocks) */ + uint8_t xoffset; + uint8_t yoffset; + + SubBand band[MAX_DWT_LEVELS][4]; +} Plane; + +typedef struct DiracContext { + AVCodecContext *avctx; + DSPContext dsp; + DiracDSPContext diracdsp; + GetBitContext gb; + dirac_source_params source; + int seen_sequence_header; + int frame_number; /* number of the next frame to display */ + Plane plane[3]; + int chroma_x_shift; + int chroma_y_shift; + + int zero_res; /* zero residue flag */ + int is_arith; /* whether coeffs use arith or golomb coding */ + int low_delay; /* use the low delay syntax */ + int globalmc_flag; /* use global motion compensation */ + int num_refs; /* number of reference pictures */ + + /* wavelet decoding */ + unsigned wavelet_depth; /* depth of the IDWT */ + unsigned wavelet_idx; + + /** + * schroedinger older than 1.0.8 doesn't store + * quant delta if only one codebook exists in a band + */ + unsigned old_delta_quant; + unsigned codeblock_mode; + + struct { + unsigned width; + unsigned height; + } codeblock[MAX_DWT_LEVELS+1]; + + struct { + unsigned num_x; /* number of horizontal slices */ + unsigned num_y; /* number of vertical slices */ + AVRational bytes; /* average bytes per slice */ + uint8_t quant[MAX_DWT_LEVELS][4]; /* [DIRAC_STD] E.1 */ + } lowdelay; + + struct { + int pan_tilt[2]; /* pan/tilt vector */ + int zrs[2][2]; /* zoom/rotate/shear matrix */ + int perspective[2]; /* perspective vector */ + unsigned zrs_exp; + unsigned perspective_exp; + } globalmc[2]; + + /* motion compensation */ + uint8_t mv_precision; /* [DIRAC_STD] REFS_WT_PRECISION */ + int16_t weight[2]; /* [DIRAC_STD] REF1_WT and REF2_WT */ + unsigned weight_log2denom; /* [DIRAC_STD] REFS_WT_PRECISION */ + + int blwidth; /* number of blocks (horizontally) */ + int blheight; /* number of blocks (vertically) */ + int sbwidth; /* number of superblocks (horizontally) */ + int sbheight; /* number of superblocks (vertically) */ + + uint8_t *sbsplit; + DiracBlock *blmotion; + + uint8_t *edge_emu_buffer[4]; + uint8_t *edge_emu_buffer_base; + + uint16_t *mctmp; /* buffer holding the MC data multipled by OBMC weights */ + uint8_t *mcscratch; + + DECLARE_ALIGNED(16, uint8_t, obmc_weight)[3][MAX_BLOCKSIZE*MAX_BLOCKSIZE]; + + void (*put_pixels_tab[4])(uint8_t *dst, const uint8_t *src[5], int stride, int h); + void (*avg_pixels_tab[4])(uint8_t *dst, const uint8_t *src[5], int stride, int h); + void (*add_obmc)(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen); + dirac_weight_func weight_func; + dirac_biweight_func biweight_func; + + DiracFrame *current_picture; + DiracFrame *ref_pics[2]; + + DiracFrame *ref_frames[MAX_REFERENCE_FRAMES+1]; + DiracFrame *delay_frames[MAX_DELAY+1]; + DiracFrame all_frames[MAX_FRAMES]; +} DiracContext; + +/** + * Dirac Specification -> + * Parse code values. 9.6.1 Table 9.1 + */ +enum dirac_parse_code { + pc_seq_header = 0x00, + pc_eos = 0x10, + pc_aux_data = 0x20, + pc_padding = 0x30, +}; + +enum dirac_subband { + subband_ll = 0, + subband_hl = 1, + subband_lh = 2, + subband_hh = 3 +}; + +static const uint8_t default_qmat[][4][4] = { + { { 5, 3, 3, 0}, { 0, 4, 4, 1}, { 0, 5, 5, 2}, { 0, 6, 6, 3} }, + { { 4, 2, 2, 0}, { 0, 4, 4, 2}, { 0, 5, 5, 3}, { 0, 7, 7, 5} }, + { { 5, 3, 3, 0}, { 0, 4, 4, 1}, { 0, 5, 5, 2}, { 0, 6, 6, 3} }, + { { 8, 4, 4, 0}, { 0, 4, 4, 0}, { 0, 4, 4, 0}, { 0, 4, 4, 0} }, + { { 8, 4, 4, 0}, { 0, 4, 4, 0}, { 0, 4, 4, 0}, { 0, 4, 4, 0} }, + { { 0, 4, 4, 8}, { 0, 8, 8, 12}, { 0, 13, 13, 17}, { 0, 17, 17, 21} }, + { { 3, 1, 1, 0}, { 0, 4, 4, 2}, { 0, 6, 6, 5}, { 0, 9, 9, 7} }, +}; + +static const int qscale_tab[MAX_QUANT+1] = { + 4, 5, 6, 7, 8, 10, 11, 13, + 16, 19, 23, 27, 32, 38, 45, 54, + 64, 76, 91, 108, 128, 152, 181, 215, + 256, 304, 362, 431, 512, 609, 724, 861, + 1024, 1218, 1448, 1722, 2048, 2435, 2896, 3444, + 4096, 4871, 5793, 6889, 8192, 9742, 11585, 13777, + 16384, 19484, 23170, 27554, 32768, 38968, 46341, 55109, + 65536, 77936 +}; + +static const int qoffset_intra_tab[MAX_QUANT+1] = { + 1, 2, 3, 4, 4, 5, 6, 7, + 8, 10, 12, 14, 16, 19, 23, 27, + 32, 38, 46, 54, 64, 76, 91, 108, + 128, 152, 181, 216, 256, 305, 362, 431, + 512, 609, 724, 861, 1024, 1218, 1448, 1722, + 2048, 2436, 2897, 3445, 4096, 4871, 5793, 6889, + 8192, 9742, 11585, 13777, 16384, 19484, 23171, 27555, + 32768, 38968 +}; + +static const int qoffset_inter_tab[MAX_QUANT+1] = { + 1, 2, 2, 3, 3, 4, 4, 5, + 6, 7, 9, 10, 12, 14, 17, 20, + 24, 29, 34, 41, 48, 57, 68, 81, + 96, 114, 136, 162, 192, 228, 272, 323, + 384, 457, 543, 646, 768, 913, 1086, 1292, + 1536, 1827, 2172, 2583, 3072, 3653, 4344, 5166, + 6144, 7307, 8689, 10333, 12288, 14613, 17378, 20666, + 24576, 29226 +}; + +/* magic number division by 3 from schroedinger */ +static inline int divide3(int x) +{ + return ((x+1)*21845 + 10922) >> 16; +} + +static DiracFrame *remove_frame(DiracFrame *framelist[], int picnum) +{ + DiracFrame *remove_pic = NULL; + int i, remove_idx = -1; + + for (i = 0; framelist[i]; i++) + if (framelist[i]->avframe.display_picture_number == picnum) { + remove_pic = framelist[i]; + remove_idx = i; + } + + if (remove_pic) + for (i = remove_idx; framelist[i]; i++) + framelist[i] = framelist[i+1]; + + return remove_pic; +} + +static int add_frame(DiracFrame *framelist[], int maxframes, DiracFrame *frame) +{ + int i; + for (i = 0; i < maxframes; i++) + if (!framelist[i]) { + framelist[i] = frame; + return 0; + } + return -1; +} + +static int alloc_sequence_buffers(DiracContext *s) +{ + int sbwidth = DIVRNDUP(s->source.width, 4); + int sbheight = DIVRNDUP(s->source.height, 4); + int i, w, h, top_padding; + + /* todo: think more about this / use or set Plane here */ + for (i = 0; i < 3; i++) { + int max_xblen = MAX_BLOCKSIZE >> (i ? s->chroma_x_shift : 0); + int max_yblen = MAX_BLOCKSIZE >> (i ? s->chroma_y_shift : 0); + w = s->source.width >> (i ? s->chroma_x_shift : 0); + h = s->source.height >> (i ? s->chroma_y_shift : 0); + + /* we allocate the max we support here since num decompositions can + * change from frame to frame. Stride is aligned to 16 for SIMD, and + * 1<0) in arith decoding + * MAX_BLOCKSIZE padding for MC: blocks can spill up to half of that + * on each side */ + top_padding = FFMAX(1<plane[i].idwt_buf_base = av_mallocz((w+max_xblen)*h * sizeof(IDWTELEM)); + s->plane[i].idwt_tmp = av_malloc((w+16) * sizeof(IDWTELEM)); + s->plane[i].idwt_buf = s->plane[i].idwt_buf_base + top_padding*w; + if (!s->plane[i].idwt_buf_base || !s->plane[i].idwt_tmp) + return AVERROR(ENOMEM); + } + + w = s->source.width; + h = s->source.height; + + /* fixme: allocate using real stride here */ + s->sbsplit = av_malloc(sbwidth * sbheight); + s->blmotion = av_malloc(sbwidth * sbheight * 4 * sizeof(*s->blmotion)); + s->edge_emu_buffer_base = av_malloc((w+64)*MAX_BLOCKSIZE); + + s->mctmp = av_malloc((w+64+MAX_BLOCKSIZE) * (h*MAX_BLOCKSIZE) * sizeof(*s->mctmp)); + s->mcscratch= av_malloc((w+64)*MAX_BLOCKSIZE); + + if (!s->sbsplit || !s->blmotion) + return AVERROR(ENOMEM); + return 0; +} + +static void free_sequence_buffers(DiracContext *s) +{ + int i, j, k; + + for (i = 0; i < MAX_FRAMES; i++) { + if (s->all_frames[i].avframe.data[0]) { + s->avctx->release_buffer(s->avctx, &s->all_frames[i].avframe); + memset(s->all_frames[i].interpolated, 0, sizeof(s->all_frames[i].interpolated)); + } + + for (j = 0; j < 3; j++) + for (k = 1; k < 4; k++) + av_freep(&s->all_frames[i].hpel_base[j][k]); + } + + memset(s->ref_frames, 0, sizeof(s->ref_frames)); + memset(s->delay_frames, 0, sizeof(s->delay_frames)); + + for (i = 0; i < 3; i++) { + av_freep(&s->plane[i].idwt_buf_base); + av_freep(&s->plane[i].idwt_tmp); + } + + av_freep(&s->sbsplit); + av_freep(&s->blmotion); + av_freep(&s->edge_emu_buffer_base); + + av_freep(&s->mctmp); + av_freep(&s->mcscratch); +} + +static av_cold int dirac_decode_init(AVCodecContext *avctx) +{ + DiracContext *s = avctx->priv_data; + s->avctx = avctx; + s->frame_number = -1; + + if (avctx->flags&CODEC_FLAG_EMU_EDGE) { + av_log(avctx, AV_LOG_ERROR, "Edge emulation not supported!\n"); + return AVERROR_PATCHWELCOME; + } + + dsputil_init(&s->dsp, avctx); + ff_diracdsp_init(&s->diracdsp); + + return 0; +} + +static void dirac_decode_flush(AVCodecContext *avctx) +{ + DiracContext *s = avctx->priv_data; + free_sequence_buffers(s); + s->seen_sequence_header = 0; + s->frame_number = -1; +} + +static av_cold int dirac_decode_end(AVCodecContext *avctx) +{ + dirac_decode_flush(avctx); + return 0; +} + +#define SIGN_CTX(x) (CTX_SIGN_ZERO + ((x) > 0) - ((x) < 0)) + +static inline void coeff_unpack_arith(DiracArith *c, int qfactor, int qoffset, + SubBand *b, IDWTELEM *buf, int x, int y) +{ + int coeff, sign; + int sign_pred = 0; + int pred_ctx = CTX_ZPZN_F1; + + /* Check if the parent subband has a 0 in the corresponding position */ + if (b->parent) + pred_ctx += !!b->parent->ibuf[b->parent->stride * (y>>1) + (x>>1)] << 1; + + if (b->orientation == subband_hl) + sign_pred = buf[-b->stride]; + + /* Determine if the pixel has only zeros in its neighbourhood */ + if (x) { + pred_ctx += !(buf[-1] | buf[-b->stride] | buf[-1-b->stride]); + if (b->orientation == subband_lh) + sign_pred = buf[-1]; + } else { + pred_ctx += !buf[-b->stride]; + } + + coeff = dirac_get_arith_uint(c, pred_ctx, CTX_COEFF_DATA); + if (coeff) { + coeff = (coeff*qfactor + qoffset + 2)>>2; + sign = dirac_get_arith_bit(c, SIGN_CTX(sign_pred)); + coeff = (coeff ^ -sign) + sign; + } + *buf = coeff; +} + +static inline int coeff_unpack_golomb(GetBitContext *gb, int qfactor, int qoffset) +{ + int sign, coeff; + + coeff = svq3_get_ue_golomb(gb); + if (coeff) { + coeff = (coeff*qfactor + qoffset + 2)>>2; + sign = get_bits1(gb); + coeff = (coeff ^ -sign) + sign; + } + return coeff; +} + +/** + * Decode the coeffs in the rectangle defined by left, right, top, bottom + * [DIRAC_STD] 13.4.3.2 Codeblock unpacking loop. codeblock() + */ +static inline void codeblock(DiracContext *s, SubBand *b, + GetBitContext *gb, DiracArith *c, + int left, int right, int top, int bottom, + int blockcnt_one, int is_arith) +{ + int x, y, zero_block; + int qoffset, qfactor; + IDWTELEM *buf; + + /* check for any coded coefficients in this codeblock */ + if (!blockcnt_one) { + if (is_arith) + zero_block = dirac_get_arith_bit(c, CTX_ZERO_BLOCK); + else + zero_block = get_bits1(gb); + + if (zero_block) + return; + } + + if (s->codeblock_mode && !(s->old_delta_quant && blockcnt_one)) { + if (is_arith) + b->quant += dirac_get_arith_int(c, CTX_DELTA_Q_F, CTX_DELTA_Q_DATA); + else + b->quant += dirac_get_se_golomb(gb); + } + + b->quant = FFMIN(b->quant, MAX_QUANT); + + qfactor = qscale_tab[b->quant]; + /* TODO: context pointer? */ + if (!s->num_refs) + qoffset = qoffset_intra_tab[b->quant]; + else + qoffset = qoffset_inter_tab[b->quant]; + + buf = b->ibuf + top*b->stride; + for (y = top; y < bottom; y++) { + for (x = left; x < right; x++) { + /* [DIRAC_STD] 13.4.4 Subband coefficients. coeff_unpack() */ + if (is_arith) + coeff_unpack_arith(c, qfactor, qoffset, b, buf+x, x, y); + else + buf[x] = coeff_unpack_golomb(gb, qfactor, qoffset); + } + buf += b->stride; + } +} + +/** + * Dirac Specification -> + * 13.3 intra_dc_prediction(band) + */ +static inline void intra_dc_prediction(SubBand *b) +{ + IDWTELEM *buf = b->ibuf; + int x, y; + + for (x = 1; x < b->width; x++) + buf[x] += buf[x-1]; + buf += b->stride; + + for (y = 1; y < b->height; y++) { + buf[0] += buf[-b->stride]; + + for (x = 1; x < b->width; x++) { + int pred = buf[x - 1] + buf[x - b->stride] + buf[x - b->stride-1]; + buf[x] += divide3(pred); + } + buf += b->stride; + } +} + +/** + * Dirac Specification -> + * 13.4.2 Non-skipped subbands. subband_coeffs() + */ +static av_always_inline +void decode_subband_internal(DiracContext *s, SubBand *b, int is_arith) +{ + int cb_x, cb_y, left, right, top, bottom; + DiracArith c; + GetBitContext gb; + int cb_width = s->codeblock[b->level + (b->orientation != subband_ll)].width; + int cb_height = s->codeblock[b->level + (b->orientation != subband_ll)].height; + int blockcnt_one = (cb_width + cb_height) == 2; + + if (!b->length) + return; + + init_get_bits(&gb, b->coeff_data, b->length*8); + + if (is_arith) + ff_dirac_init_arith_decoder(&c, &gb, b->length); + + top = 0; + for (cb_y = 0; cb_y < cb_height; cb_y++) { + bottom = (b->height * (cb_y+1)) / cb_height; + left = 0; + for (cb_x = 0; cb_x < cb_width; cb_x++) { + right = (b->width * (cb_x+1)) / cb_width; + codeblock(s, b, &gb, &c, left, right, top, bottom, blockcnt_one, is_arith); + left = right; + } + top = bottom; + } + + if (b->orientation == subband_ll && s->num_refs == 0) + intra_dc_prediction(b); +} + +static int decode_subband_arith(AVCodecContext *avctx, void *b) +{ + DiracContext *s = avctx->priv_data; + decode_subband_internal(s, b, 1); + return 0; +} + +static int decode_subband_golomb(AVCodecContext *avctx, void *arg) +{ + DiracContext *s = avctx->priv_data; + SubBand **b = arg; + decode_subband_internal(s, *b, 0); + return 0; +} + +/** + * Dirac Specification -> + * [DIRAC_STD] 13.4.1 core_transform_data() + */ +static void decode_component(DiracContext *s, int comp) +{ + AVCodecContext *avctx = s->avctx; + SubBand *bands[3*MAX_DWT_LEVELS+1]; + enum dirac_subband orientation; + int level, num_bands = 0; + + /* Unpack all subbands at all levels. */ + for (level = 0; level < s->wavelet_depth; level++) { + for (orientation = !!level; orientation < 4; orientation++) { + SubBand *b = &s->plane[comp].band[level][orientation]; + bands[num_bands++] = b; + + align_get_bits(&s->gb); + /* [DIRAC_STD] 13.4.2 subband() */ + b->length = svq3_get_ue_golomb(&s->gb); + if (b->length) { + b->quant = svq3_get_ue_golomb(&s->gb); + align_get_bits(&s->gb); + b->coeff_data = s->gb.buffer + get_bits_count(&s->gb)/8; + b->length = FFMIN(b->length, get_bits_left(&s->gb)/8); + skip_bits_long(&s->gb, b->length*8); + } + } + /* arithmetic coding has inter-level dependencies, so we can only execute one level at a time */ + if (s->is_arith) + avctx->execute(avctx, decode_subband_arith, &s->plane[comp].band[level][!!level], + NULL, 4-!!level, sizeof(SubBand)); + } + /* golomb coding has no inter-level dependencies, so we can execute all subbands in parallel */ + if (!s->is_arith) + avctx->execute(avctx, decode_subband_golomb, bands, NULL, num_bands, sizeof(SubBand*)); +} + +/* [DIRAC_STD] 13.5.5.2 Luma slice subband data. luma_slice_band(level,orient,sx,sy) --> if b2 == NULL */ +/* [DIRAC_STD] 13.5.5.3 Chroma slice subband data. chroma_slice_band(level,orient,sx,sy) --> if b2 != NULL */ +static void lowdelay_subband(DiracContext *s, GetBitContext *gb, int quant, + int slice_x, int slice_y, int bits_end, + SubBand *b1, SubBand *b2) +{ + int left = b1->width * slice_x / s->lowdelay.num_x; + int right = b1->width *(slice_x+1) / s->lowdelay.num_x; + int top = b1->height* slice_y / s->lowdelay.num_y; + int bottom = b1->height*(slice_y+1) / s->lowdelay.num_y; + + int qfactor = qscale_tab[FFMIN(quant, MAX_QUANT)]; + int qoffset = qoffset_intra_tab[FFMIN(quant, MAX_QUANT)]; + + IDWTELEM *buf1 = b1->ibuf + top*b1->stride; + IDWTELEM *buf2 = b2 ? b2->ibuf + top*b2->stride : NULL; + int x, y; + /* we have to constantly check for overread since the spec explictly + requires this, with the meaning that all remaining coeffs are set to 0 */ + if (get_bits_count(gb) >= bits_end) + return; + + for (y = top; y < bottom; y++) { + for (x = left; x < right; x++) { + buf1[x] = coeff_unpack_golomb(gb, qfactor, qoffset); + if (get_bits_count(gb) >= bits_end) + return; + if (buf2) { + buf2[x] = coeff_unpack_golomb(gb, qfactor, qoffset); + if (get_bits_count(gb) >= bits_end) + return; + } + } + buf1 += b1->stride; + if (buf2) + buf2 += b2->stride; + } +} + +struct lowdelay_slice { + GetBitContext gb; + int slice_x; + int slice_y; + int bytes; +}; + + +/** + * Dirac Specification -> + * 13.5.2 Slices. slice(sx,sy) + */ +static int decode_lowdelay_slice(AVCodecContext *avctx, void *arg) +{ + DiracContext *s = avctx->priv_data; + struct lowdelay_slice *slice = arg; + GetBitContext *gb = &slice->gb; + enum dirac_subband orientation; + int level, quant, chroma_bits, chroma_end; + + int quant_base = get_bits(gb, 7); /*[DIRAC_STD] qindex */ + int length_bits = av_log2(8*slice->bytes)+1; + int luma_bits = get_bits_long(gb, length_bits); + int luma_end = get_bits_count(gb) + FFMIN(luma_bits, get_bits_left(gb)); + + /* [DIRAC_STD] 13.5.5.2 luma_slice_band */ + for (level = 0; level < s->wavelet_depth; level++) + for (orientation = !!level; orientation < 4; orientation++) { + quant = FFMAX(quant_base - s->lowdelay.quant[level][orientation], 0); + lowdelay_subband(s, gb, quant, slice->slice_x, slice->slice_y, luma_end, + &s->plane[0].band[level][orientation], NULL); + } + + /* consume any unused bits from luma */ + skip_bits_long(gb, get_bits_count(gb) - luma_end); + + chroma_bits = 8*slice->bytes - 7 - length_bits - luma_bits; + chroma_end = get_bits_count(gb) + FFMIN(chroma_bits, get_bits_left(gb)); + /* [DIRAC_STD] 13.5.5.3 chroma_slice_band */ + for (level = 0; level < s->wavelet_depth; level++) + for (orientation = !!level; orientation < 4; orientation++) { + quant = FFMAX(quant_base - s->lowdelay.quant[level][orientation], 0); + lowdelay_subband(s, gb, quant, slice->slice_x, slice->slice_y, chroma_end, + &s->plane[1].band[level][orientation], + &s->plane[2].band[level][orientation]); + } + + return 0; +} + +/** + * Dirac Specification -> + * 13.5.1 low_delay_transform_data() + */ +static void decode_lowdelay(DiracContext *s) +{ + AVCodecContext *avctx = s->avctx; + int slice_x, slice_y, bytes, bufsize; + const uint8_t *buf; + struct lowdelay_slice *slices; + int slice_num = 0; + + slices = av_mallocz(s->lowdelay.num_x * s->lowdelay.num_y * sizeof(struct lowdelay_slice)); + + align_get_bits(&s->gb); + /*[DIRAC_STD] 13.5.2 Slices. slice(sx,sy) */ + buf = s->gb.buffer + get_bits_count(&s->gb)/8; + bufsize = get_bits_left(&s->gb); + + for (slice_y = 0; slice_y < s->lowdelay.num_y; slice_y++) + for (slice_x = 0; slice_x < s->lowdelay.num_x; slice_x++) { + bytes = (slice_num+1) * s->lowdelay.bytes.num / s->lowdelay.bytes.den + - slice_num * s->lowdelay.bytes.num / s->lowdelay.bytes.den; + + slices[slice_num].bytes = bytes; + slices[slice_num].slice_x = slice_x; + slices[slice_num].slice_y = slice_y; + init_get_bits(&slices[slice_num].gb, buf, bufsize); + slice_num++; + + buf += bytes; + bufsize -= bytes*8; + if (bufsize <= 0) + goto end; + } +end: + + avctx->execute(avctx, decode_lowdelay_slice, slices, NULL, slice_num, + sizeof(struct lowdelay_slice)); /* [DIRAC_STD] 13.5.2 Slices */ + intra_dc_prediction(&s->plane[0].band[0][0]); /* [DIRAC_STD] 13.3 intra_dc_prediction() */ + intra_dc_prediction(&s->plane[1].band[0][0]); /* [DIRAC_STD] 13.3 intra_dc_prediction() */ + intra_dc_prediction(&s->plane[2].band[0][0]); /* [DIRAC_STD] 13.3 intra_dc_prediction() */ + av_free(slices); +} + +static void init_planes(DiracContext *s) +{ + int i, w, h, level, orientation; + + for (i = 0; i < 3; i++) { + Plane *p = &s->plane[i]; + + p->width = s->source.width >> (i ? s->chroma_x_shift : 0); + p->height = s->source.height >> (i ? s->chroma_y_shift : 0); + p->idwt_width = w = CALC_PADDING(p->width , s->wavelet_depth); + p->idwt_height = h = CALC_PADDING(p->height, s->wavelet_depth); + p->idwt_stride = FFALIGN(p->idwt_width, 8); + + for (level = s->wavelet_depth-1; level >= 0; level--) { + w = w>>1; + h = h>>1; + for (orientation = !!level; orientation < 4; orientation++) { + SubBand *b = &p->band[level][orientation]; + + b->ibuf = p->idwt_buf; + b->level = level; + b->stride = p->idwt_stride << (s->wavelet_depth - level); + b->width = w; + b->height = h; + b->orientation = orientation; + + if (orientation & 1) + b->ibuf += w; + if (orientation > 1) + b->ibuf += b->stride>>1; + + if (level) + b->parent = &p->band[level-1][orientation]; + } + } + + if (i > 0) { + p->xblen = s->plane[0].xblen >> s->chroma_x_shift; + p->yblen = s->plane[0].yblen >> s->chroma_y_shift; + p->xbsep = s->plane[0].xbsep >> s->chroma_x_shift; + p->ybsep = s->plane[0].ybsep >> s->chroma_y_shift; + } + + p->xoffset = (p->xblen - p->xbsep)/2; + p->yoffset = (p->yblen - p->ybsep)/2; + } +} + +/** + * Unpack the motion compensation parameters + * Dirac Specification -> + * 11.2 Picture prediction data. picture_prediction() + */ +static int dirac_unpack_prediction_parameters(DiracContext *s) +{ + static const uint8_t default_blen[] = { 4, 12, 16, 24 }; + static const uint8_t default_bsep[] = { 4, 8, 12, 16 }; + + GetBitContext *gb = &s->gb; + unsigned idx, ref; + + align_get_bits(gb); + /* [DIRAC_STD] 11.2.2 Block parameters. block_parameters() */ + /* Luma and Chroma are equal. 11.2.3 */ + idx = svq3_get_ue_golomb(gb); /* [DIRAC_STD] index */ + + if (idx > 4) + { + av_log(s->avctx, AV_LOG_ERROR, "Block prediction index too high\n"); + return -1; + } + + if (idx == 0) { + s->plane[0].xblen = svq3_get_ue_golomb(gb); + s->plane[0].yblen = svq3_get_ue_golomb(gb); + s->plane[0].xbsep = svq3_get_ue_golomb(gb); + s->plane[0].ybsep = svq3_get_ue_golomb(gb); + } else { + /*[DIRAC_STD] preset_block_params(index). Table 11.1 */ + s->plane[0].xblen = default_blen[idx-1]; + s->plane[0].yblen = default_blen[idx-1]; + s->plane[0].xbsep = default_bsep[idx-1]; + s->plane[0].ybsep = default_bsep[idx-1]; + } + /*[DIRAC_STD] 11.2.4 motion_data_dimensions() + Calculated in function dirac_unpack_block_motion_data */ + + if (s->plane[0].xbsep < s->plane[0].xblen/2 || s->plane[0].ybsep < s->plane[0].yblen/2) { + av_log(s->avctx, AV_LOG_ERROR, "Block separation too small\n"); + return -1; + } + if (s->plane[0].xbsep > s->plane[0].xblen || s->plane[0].ybsep > s->plane[0].yblen) { + av_log(s->avctx, AV_LOG_ERROR, "Block seperation greater than size\n"); + return -1; + } + if (FFMAX(s->plane[0].xblen, s->plane[0].yblen) > MAX_BLOCKSIZE) { + av_log(s->avctx, AV_LOG_ERROR, "Unsupported large block size\n"); + return -1; + } + + /*[DIRAC_STD] 11.2.5 Motion vector precision. motion_vector_precision() + Read motion vector precision */ + s->mv_precision = svq3_get_ue_golomb(gb); + if (s->mv_precision > 3) { + av_log(s->avctx, AV_LOG_ERROR, "MV precision finer than eighth-pel\n"); + return -1; + } + + /*[DIRAC_STD] 11.2.6 Global motion. global_motion() + Read the global motion compensation parameters */ + s->globalmc_flag = get_bits1(gb); + if (s->globalmc_flag) { + memset(s->globalmc, 0, sizeof(s->globalmc)); + /* [DIRAC_STD] pan_tilt(gparams) */ + for (ref = 0; ref < s->num_refs; ref++) { + if (get_bits1(gb)) { + s->globalmc[ref].pan_tilt[0] = dirac_get_se_golomb(gb); + s->globalmc[ref].pan_tilt[1] = dirac_get_se_golomb(gb); + } + /* [DIRAC_STD] zoom_rotate_shear(gparams) + zoom/rotation/shear parameters */ + if (get_bits1(gb)) { + s->globalmc[ref].zrs_exp = svq3_get_ue_golomb(gb); + s->globalmc[ref].zrs[0][0] = dirac_get_se_golomb(gb); + s->globalmc[ref].zrs[0][1] = dirac_get_se_golomb(gb); + s->globalmc[ref].zrs[1][0] = dirac_get_se_golomb(gb); + s->globalmc[ref].zrs[1][1] = dirac_get_se_golomb(gb); + } else { + s->globalmc[ref].zrs[0][0] = 1; + s->globalmc[ref].zrs[1][1] = 1; + } + /* [DIRAC_STD] perspective(gparams) */ + if (get_bits1(gb)) { + s->globalmc[ref].perspective_exp = svq3_get_ue_golomb(gb); + s->globalmc[ref].perspective[0] = dirac_get_se_golomb(gb); + s->globalmc[ref].perspective[1] = dirac_get_se_golomb(gb); + } + } + } + + /*[DIRAC_STD] 11.2.7 Picture prediction mode. prediction_mode() + Picture prediction mode, not currently used. */ + if (svq3_get_ue_golomb(gb)) { + av_log(s->avctx, AV_LOG_ERROR, "Unknown picture prediction mode\n"); + return -1; + } + + /* [DIRAC_STD] 11.2.8 Reference picture weight. reference_picture_weights() + just data read, weight calculation will be done later on. */ + s->weight_log2denom = 1; + s->weight[0] = 1; + s->weight[1] = 1; + + if (get_bits1(gb)) { + s->weight_log2denom = svq3_get_ue_golomb(gb); + s->weight[0] = dirac_get_se_golomb(gb); + if (s->num_refs == 2) + s->weight[1] = dirac_get_se_golomb(gb); + } + return 0; +} + +/** + * Dirac Specification -> + * 11.3 Wavelet transform data. wavelet_transform() + */ +static int dirac_unpack_idwt_params(DiracContext *s) +{ + GetBitContext *gb = &s->gb; + int i, level; + + align_get_bits(gb); + + s->zero_res = s->num_refs ? get_bits1(gb) : 0; + if (s->zero_res) + return 0; + + /*[DIRAC_STD] 11.3.1 Transform parameters. transform_parameters() */ + s->wavelet_idx = svq3_get_ue_golomb(gb); + if (s->wavelet_idx > 6) + return -1; + + s->wavelet_depth = svq3_get_ue_golomb(gb); + if (s->wavelet_depth > MAX_DWT_LEVELS) { + av_log(s->avctx, AV_LOG_ERROR, "too many dwt decompositions\n"); + return -1; + } + + if (!s->low_delay) { + /* Codeblock paramaters (core syntax only) */ + if (get_bits1(gb)) { + for (i = 0; i <= s->wavelet_depth; i++) { + s->codeblock[i].width = svq3_get_ue_golomb(gb); + s->codeblock[i].height = svq3_get_ue_golomb(gb); + } + + s->codeblock_mode = svq3_get_ue_golomb(gb); + if (s->codeblock_mode > 1) { + av_log(s->avctx, AV_LOG_ERROR, "unknown codeblock mode\n"); + return -1; + } + } else + for (i = 0; i <= s->wavelet_depth; i++) + s->codeblock[i].width = s->codeblock[i].height = 1; + } else { + /* Slice parameters + quantization matrix*/ + /*[DIRAC_STD] 11.3.4 Slice coding Parameters (low delay syntax only). slice_parameters() */ + s->lowdelay.num_x = svq3_get_ue_golomb(gb); + s->lowdelay.num_y = svq3_get_ue_golomb(gb); + s->lowdelay.bytes.num = svq3_get_ue_golomb(gb); + s->lowdelay.bytes.den = svq3_get_ue_golomb(gb); + + /* [DIRAC_STD] 11.3.5 Quantisation matrices (low-delay syntax). quant_matrix() */ + if (get_bits1(gb)) { + av_log(s->avctx,AV_LOG_DEBUG,"Low Delay: Has Custom Quantization Matrix!\n"); + /* custom quantization matrix */ + s->lowdelay.quant[0][0] = svq3_get_ue_golomb(gb); + for (level = 0; level < s->wavelet_depth; level++) { + s->lowdelay.quant[level][1] = svq3_get_ue_golomb(gb); + s->lowdelay.quant[level][2] = svq3_get_ue_golomb(gb); + s->lowdelay.quant[level][3] = svq3_get_ue_golomb(gb); + } + } else { + /* default quantization matrix */ + for (level = 0; level < s->wavelet_depth; level++) + for (i = 0; i < 4; i++) { + s->lowdelay.quant[level][i] = default_qmat[s->wavelet_idx][level][i]; + /* haar with no shift differs for different depths */ + if (s->wavelet_idx == 3) + s->lowdelay.quant[level][i] += 4*(s->wavelet_depth-1 - level); + } + } + } + return 0; +} + +static inline int pred_sbsplit(uint8_t *sbsplit, int stride, int x, int y) +{ + static const uint8_t avgsplit[7] = { 0, 0, 1, 1, 1, 2, 2 }; + + if (!(x|y)) + return 0; + else if (!y) + return sbsplit[-1]; + else if (!x) + return sbsplit[-stride]; + + return avgsplit[sbsplit[-1] + sbsplit[-stride] + sbsplit[-stride-1]]; +} + +static inline int pred_block_mode(DiracBlock *block, int stride, int x, int y, int refmask) +{ + int pred; + + if (!(x|y)) + return 0; + else if (!y) + return block[-1].ref & refmask; + else if (!x) + return block[-stride].ref & refmask; + + /* return the majority */ + pred = (block[-1].ref & refmask) + (block[-stride].ref & refmask) + (block[-stride-1].ref & refmask); + return (pred >> 1) & refmask; +} + +static inline void pred_block_dc(DiracBlock *block, int stride, int x, int y) +{ + int i, n = 0; + + memset(block->u.dc, 0, sizeof(block->u.dc)); + + if (x && !(block[-1].ref & 3)) { + for (i = 0; i < 3; i++) + block->u.dc[i] += block[-1].u.dc[i]; + n++; + } + + if (y && !(block[-stride].ref & 3)) { + for (i = 0; i < 3; i++) + block->u.dc[i] += block[-stride].u.dc[i]; + n++; + } + + if (x && y && !(block[-1-stride].ref & 3)) { + for (i = 0; i < 3; i++) + block->u.dc[i] += block[-1-stride].u.dc[i]; + n++; + } + + if (n == 2) { + for (i = 0; i < 3; i++) + block->u.dc[i] = (block->u.dc[i]+1)>>1; + } else if (n == 3) { + for (i = 0; i < 3; i++) + block->u.dc[i] = divide3(block->u.dc[i]); + } +} + +static inline void pred_mv(DiracBlock *block, int stride, int x, int y, int ref) +{ + int16_t *pred[3]; + int refmask = ref+1; + int mask = refmask | DIRAC_REF_MASK_GLOBAL; /* exclude gmc blocks */ + int n = 0; + + if (x && (block[-1].ref & mask) == refmask) + pred[n++] = block[-1].u.mv[ref]; + + if (y && (block[-stride].ref & mask) == refmask) + pred[n++] = block[-stride].u.mv[ref]; + + if (x && y && (block[-stride-1].ref & mask) == refmask) + pred[n++] = block[-stride-1].u.mv[ref]; + + switch (n) { + case 0: + block->u.mv[ref][0] = 0; + block->u.mv[ref][1] = 0; + break; + case 1: + block->u.mv[ref][0] = pred[0][0]; + block->u.mv[ref][1] = pred[0][1]; + break; + case 2: + block->u.mv[ref][0] = (pred[0][0] + pred[1][0] + 1) >> 1; + block->u.mv[ref][1] = (pred[0][1] + pred[1][1] + 1) >> 1; + break; + case 3: + block->u.mv[ref][0] = mid_pred(pred[0][0], pred[1][0], pred[2][0]); + block->u.mv[ref][1] = mid_pred(pred[0][1], pred[1][1], pred[2][1]); + break; + } +} + +static void global_mv(DiracContext *s, DiracBlock *block, int x, int y, int ref) +{ + int ez = s->globalmc[ref].zrs_exp; + int ep = s->globalmc[ref].perspective_exp; + int (*A)[2] = s->globalmc[ref].zrs; + int *b = s->globalmc[ref].pan_tilt; + int *c = s->globalmc[ref].perspective; + + int m = (1<u.mv[ref][0] = (mx + (1<<(ez+ep))) >> (ez+ep); + block->u.mv[ref][1] = (my + (1<<(ez+ep))) >> (ez+ep); +} + +static void decode_block_params(DiracContext *s, DiracArith arith[8], DiracBlock *block, + int stride, int x, int y) +{ + int i; + + block->ref = pred_block_mode(block, stride, x, y, DIRAC_REF_MASK_REF1); + block->ref ^= dirac_get_arith_bit(arith, CTX_PMODE_REF1); + + if (s->num_refs == 2) { + block->ref |= pred_block_mode(block, stride, x, y, DIRAC_REF_MASK_REF2); + block->ref ^= dirac_get_arith_bit(arith, CTX_PMODE_REF2) << 1; + } + + if (!block->ref) { + pred_block_dc(block, stride, x, y); + for (i = 0; i < 3; i++) + block->u.dc[i] += dirac_get_arith_int(arith+1+i, CTX_DC_F1, CTX_DC_DATA); + return; + } + + if (s->globalmc_flag) { + block->ref |= pred_block_mode(block, stride, x, y, DIRAC_REF_MASK_GLOBAL); + block->ref ^= dirac_get_arith_bit(arith, CTX_GLOBAL_BLOCK) << 2; + } + + for (i = 0; i < s->num_refs; i++) + if (block->ref & (i+1)) { + if (block->ref & DIRAC_REF_MASK_GLOBAL) { + global_mv(s, block, x, y, i); + } else { + pred_mv(block, stride, x, y, i); + block->u.mv[i][0] += dirac_get_arith_int(arith+4+2*i, CTX_MV_F1, CTX_MV_DATA); + block->u.mv[i][1] += dirac_get_arith_int(arith+5+2*i, CTX_MV_F1, CTX_MV_DATA); + } + } +} + +/** + * Copies the current block to the other blocks covered by the current superblock split mode + */ +static void propagate_block_data(DiracBlock *block, int stride, int size) +{ + int x, y; + DiracBlock *dst = block; + + for (x = 1; x < size; x++) + dst[x] = *block; + + for (y = 1; y < size; y++) { + dst += stride; + for (x = 0; x < size; x++) + dst[x] = *block; + } +} + +/** + * Dirac Specification -> + * 12. Block motion data syntax + */ +static void dirac_unpack_block_motion_data(DiracContext *s) +{ + GetBitContext *gb = &s->gb; + uint8_t *sbsplit = s->sbsplit; + int i, x, y, q, p; + DiracArith arith[8]; + + align_get_bits(gb); + + /* [DIRAC_STD] 11.2.4 and 12.2.1 Number of blocks and superblocks */ + s->sbwidth = DIVRNDUP(s->source.width, 4*s->plane[0].xbsep); + s->sbheight = DIVRNDUP(s->source.height, 4*s->plane[0].ybsep); + s->blwidth = 4*s->sbwidth; + s->blheight = 4*s->sbheight; + + /* [DIRAC_STD] 12.3.1 Superblock splitting modes. superblock_split_modes() + decode superblock split modes */ + ff_dirac_init_arith_decoder(arith, gb, svq3_get_ue_golomb(gb)); /* svq3_get_ue_golomb(gb) is the length */ + for (y = 0; y < s->sbheight; y++) { + for (x = 0; x < s->sbwidth; x++) { + int split = dirac_get_arith_uint(arith, CTX_SB_F1, CTX_SB_DATA); + sbsplit[x] = (split + pred_sbsplit(sbsplit+x, s->sbwidth, x, y)) % 3; + } + sbsplit += s->sbwidth; + } + + /* setup arith decoding */ + ff_dirac_init_arith_decoder(arith, gb, svq3_get_ue_golomb(gb)); + for (i = 0; i < s->num_refs; i++) { + ff_dirac_init_arith_decoder(arith+4+2*i, gb, svq3_get_ue_golomb(gb)); + ff_dirac_init_arith_decoder(arith+5+2*i, gb, svq3_get_ue_golomb(gb)); + } + for (i = 0; i < 3; i++) + ff_dirac_init_arith_decoder(arith+1+i, gb, svq3_get_ue_golomb(gb)); + + for (y = 0; y < s->sbheight; y++) + for (x = 0; x < s->sbwidth; x++) { + int blkcnt = 1 << s->sbsplit[y*s->sbwidth + x]; + int step = 4 >> s->sbsplit[y*s->sbwidth + x]; + + for (q = 0; q < blkcnt; q++) + for (p = 0; p < blkcnt; p++) { + int bx = 4*x + p*step; + int by = 4*y + q*step; + DiracBlock *block = &s->blmotion[by*s->blwidth + bx]; + decode_block_params(s, arith, block, s->blwidth, bx, by); + propagate_block_data(block, s->blwidth, step); + } + } +} + +static int weight(int i, int blen, int offset) +{ +#define ROLLOFF(i) offset == 1 ? ((i) ? 5 : 3) : \ + (1 + (6*(i) + offset - 1) / (2*offset - 1)) + + if (i < 2*offset) + return ROLLOFF(i); + else if (i > blen-1 - 2*offset) + return ROLLOFF(blen-1 - i); + return 8; +} + +static void init_obmc_weight_row(Plane *p, uint8_t *obmc_weight, int stride, + int left, int right, int wy) +{ + int x; + for (x = 0; left && x < p->xblen >> 1; x++) + obmc_weight[x] = wy*8; + for (; x < p->xblen >> right; x++) + obmc_weight[x] = wy*weight(x, p->xblen, p->xoffset); + for (; x < p->xblen; x++) + obmc_weight[x] = wy*8; + for (; x < stride; x++) + obmc_weight[x] = 0; +} + +static void init_obmc_weight(Plane *p, uint8_t *obmc_weight, int stride, + int left, int right, int top, int bottom) +{ + int y; + for (y = 0; top && y < p->yblen >> 1; y++) { + init_obmc_weight_row(p, obmc_weight, stride, left, right, 8); + obmc_weight += stride; + } + for (; y < p->yblen >> bottom; y++) { + int wy = weight(y, p->yblen, p->yoffset); + init_obmc_weight_row(p, obmc_weight, stride, left, right, wy); + obmc_weight += stride; + } + for (; y < p->yblen; y++) { + init_obmc_weight_row(p, obmc_weight, stride, left, right, 8); + obmc_weight += stride; + } +} + +static void init_obmc_weights(DiracContext *s, Plane *p, int by) +{ + int top = !by; + int bottom = by == s->blheight-1; + + /* don't bother re-initing for rows 2 to blheight-2, the weights don't change */ + if (top || bottom || by == 1) { + init_obmc_weight(p, s->obmc_weight[0], MAX_BLOCKSIZE, 1, 0, top, bottom); + init_obmc_weight(p, s->obmc_weight[1], MAX_BLOCKSIZE, 0, 0, top, bottom); + init_obmc_weight(p, s->obmc_weight[2], MAX_BLOCKSIZE, 0, 1, top, bottom); + } +} + +static const uint8_t epel_weights[4][4][4] = { + {{ 16, 0, 0, 0 }, + { 12, 4, 0, 0 }, + { 8, 8, 0, 0 }, + { 4, 12, 0, 0 }}, + {{ 12, 0, 4, 0 }, + { 9, 3, 3, 1 }, + { 6, 6, 2, 2 }, + { 3, 9, 1, 3 }}, + {{ 8, 0, 8, 0 }, + { 6, 2, 6, 2 }, + { 4, 4, 4, 4 }, + { 2, 6, 2, 6 }}, + {{ 4, 0, 12, 0 }, + { 3, 1, 9, 3 }, + { 2, 2, 6, 6 }, + { 1, 3, 3, 9 }} +}; + +/** + * For block x,y, determine which of the hpel planes to do bilinear + * interpolation from and set src[] to the location in each hpel plane + * to MC from. + * + * @return the index of the put_dirac_pixels_tab function to use + * 0 for 1 plane (fpel,hpel), 1 for 2 planes (qpel), 2 for 4 planes (qpel), and 3 for epel + */ +static int mc_subpel(DiracContext *s, DiracBlock *block, const uint8_t *src[5], + int x, int y, int ref, int plane) +{ + Plane *p = &s->plane[plane]; + uint8_t **ref_hpel = s->ref_pics[ref]->hpel[plane]; + int motion_x = block->u.mv[ref][0]; + int motion_y = block->u.mv[ref][1]; + int mx, my, i, epel, nplanes = 0; + + if (plane) { + motion_x >>= s->chroma_x_shift; + motion_y >>= s->chroma_y_shift; + } + + mx = motion_x & ~(-1 << s->mv_precision); + my = motion_y & ~(-1 << s->mv_precision); + motion_x >>= s->mv_precision; + motion_y >>= s->mv_precision; + /* normalize subpel coordinates to epel */ + /* TODO: template this function? */ + mx <<= 3-s->mv_precision; + my <<= 3-s->mv_precision; + + x += motion_x; + y += motion_y; + epel = (mx|my)&1; + + /* hpel position */ + if (!((mx|my)&3)) { + nplanes = 1; + src[0] = ref_hpel[(my>>1)+(mx>>2)] + y*p->stride + x; + } else { + /* qpel or epel */ + nplanes = 4; + for (i = 0; i < 4; i++) + src[i] = ref_hpel[i] + y*p->stride + x; + + /* if we're interpolating in the right/bottom halves, adjust the planes as needed + we increment x/y because the edge changes for half of the pixels */ + if (mx > 4) { + src[0] += 1; + src[2] += 1; + x++; + } + if (my > 4) { + src[0] += p->stride; + src[1] += p->stride; + y++; + } + + /* hpel planes are: + [0]: F [1]: H + [2]: V [3]: C */ + if (!epel) { + /* check if we really only need 2 planes since either mx or my is + a hpel position. (epel weights of 0 handle this there) */ + if (!(mx&3)) { + /* mx == 0: average [0] and [2] + mx == 4: average [1] and [3] */ + src[!mx] = src[2 + !!mx]; + nplanes = 2; + } else if (!(my&3)) { + src[0] = src[(my>>1) ]; + src[1] = src[(my>>1)+1]; + nplanes = 2; + } + } else { + /* adjust the ordering if needed so the weights work */ + if (mx > 4) { + FFSWAP(const uint8_t *, src[0], src[1]); + FFSWAP(const uint8_t *, src[2], src[3]); + } + if (my > 4) { + FFSWAP(const uint8_t *, src[0], src[2]); + FFSWAP(const uint8_t *, src[1], src[3]); + } + src[4] = epel_weights[my&3][mx&3]; + } + } + + /* fixme: v/h _edge_pos */ + if ((unsigned)x > p->width +EDGE_WIDTH/2 - p->xblen || + (unsigned)y > p->height+EDGE_WIDTH/2 - p->yblen) { + for (i = 0; i < nplanes; i++) { + ff_emulated_edge_mc(s->edge_emu_buffer[i], src[i], p->stride, + p->xblen, p->yblen, x, y, + p->width+EDGE_WIDTH/2, p->height+EDGE_WIDTH/2); + src[i] = s->edge_emu_buffer[i]; + } + } + return (nplanes>>1) + epel; +} + +static void add_dc(uint16_t *dst, int dc, int stride, + uint8_t *obmc_weight, int xblen, int yblen) +{ + int x, y; + dc += 128; + + for (y = 0; y < yblen; y++) { + for (x = 0; x < xblen; x += 2) { + dst[x ] += dc * obmc_weight[x ]; + dst[x+1] += dc * obmc_weight[x+1]; + } + dst += stride; + obmc_weight += MAX_BLOCKSIZE; + } +} + +static void block_mc(DiracContext *s, DiracBlock *block, + uint16_t *mctmp, uint8_t *obmc_weight, + int plane, int dstx, int dsty) +{ + Plane *p = &s->plane[plane]; + const uint8_t *src[5]; + int idx; + + switch (block->ref&3) { + case 0: /* DC */ + add_dc(mctmp, block->u.dc[plane], p->stride, obmc_weight, p->xblen, p->yblen); + return; + case 1: + case 2: + idx = mc_subpel(s, block, src, dstx, dsty, (block->ref&3)-1, plane); + s->put_pixels_tab[idx](s->mcscratch, src, p->stride, p->yblen); + if (s->weight_func) + s->weight_func(s->mcscratch, p->stride, s->weight_log2denom, + s->weight[0] + s->weight[1], p->yblen); + break; + case 3: + idx = mc_subpel(s, block, src, dstx, dsty, 0, plane); + s->put_pixels_tab[idx](s->mcscratch, src, p->stride, p->yblen); + idx = mc_subpel(s, block, src, dstx, dsty, 1, plane); + if (s->biweight_func) { + /* fixme: +32 is a quick hack */ + s->put_pixels_tab[idx](s->mcscratch + 32, src, p->stride, p->yblen); + s->biweight_func(s->mcscratch, s->mcscratch+32, p->stride, s->weight_log2denom, + s->weight[0], s->weight[1], p->yblen); + } else + s->avg_pixels_tab[idx](s->mcscratch, src, p->stride, p->yblen); + break; + } + s->add_obmc(mctmp, s->mcscratch, p->stride, obmc_weight, p->yblen); +} + +static void mc_row(DiracContext *s, DiracBlock *block, uint16_t *mctmp, int plane, int dsty) +{ + Plane *p = &s->plane[plane]; + int x, dstx = p->xbsep - p->xoffset; + + block_mc(s, block, mctmp, s->obmc_weight[0], plane, -p->xoffset, dsty); + mctmp += p->xbsep; + + for (x = 1; x < s->blwidth-1; x++) { + block_mc(s, block+x, mctmp, s->obmc_weight[1], plane, dstx, dsty); + dstx += p->xbsep; + mctmp += p->xbsep; + } + block_mc(s, block+x, mctmp, s->obmc_weight[2], plane, dstx, dsty); +} + +static void select_dsp_funcs(DiracContext *s, int width, int height, int xblen, int yblen) +{ + int idx = 0; + if (xblen > 8) + idx = 1; + if (xblen > 16) + idx = 2; + + memcpy(s->put_pixels_tab, s->diracdsp.put_dirac_pixels_tab[idx], sizeof(s->put_pixels_tab)); + memcpy(s->avg_pixels_tab, s->diracdsp.avg_dirac_pixels_tab[idx], sizeof(s->avg_pixels_tab)); + s->add_obmc = s->diracdsp.add_dirac_obmc[idx]; + if (s->weight_log2denom > 1 || s->weight[0] != 1 || s->weight[1] != 1) { + s->weight_func = s->diracdsp.weight_dirac_pixels_tab[idx]; + s->biweight_func = s->diracdsp.biweight_dirac_pixels_tab[idx]; + } else { + s->weight_func = NULL; + s->biweight_func = NULL; + } +} + +static void interpolate_refplane(DiracContext *s, DiracFrame *ref, int plane, int width, int height) +{ + /* chroma allocates an edge of 8 when subsampled + which for 4:2:2 means an h edge of 16 and v edge of 8 + just use 8 for everything for the moment */ + int i, edge = EDGE_WIDTH/2; + + ref->hpel[plane][0] = ref->avframe.data[plane]; + s->dsp.draw_edges(ref->hpel[plane][0], ref->avframe.linesize[plane], width, height, edge, edge, EDGE_TOP | EDGE_BOTTOM); /* EDGE_TOP | EDGE_BOTTOM values just copied to make it build, this needs to be ensured */ + + /* no need for hpel if we only have fpel vectors */ + if (!s->mv_precision) + return; + + for (i = 1; i < 4; i++) { + if (!ref->hpel_base[plane][i]) + ref->hpel_base[plane][i] = av_malloc((height+2*edge) * ref->avframe.linesize[plane] + 32); + /* we need to be 16-byte aligned even for chroma */ + ref->hpel[plane][i] = ref->hpel_base[plane][i] + edge*ref->avframe.linesize[plane] + 16; + } + + if (!ref->interpolated[plane]) { + s->diracdsp.dirac_hpel_filter(ref->hpel[plane][1], ref->hpel[plane][2], + ref->hpel[plane][3], ref->hpel[plane][0], + ref->avframe.linesize[plane], width, height); + s->dsp.draw_edges(ref->hpel[plane][1], ref->avframe.linesize[plane], width, height, edge, edge, EDGE_TOP | EDGE_BOTTOM); + s->dsp.draw_edges(ref->hpel[plane][2], ref->avframe.linesize[plane], width, height, edge, edge, EDGE_TOP | EDGE_BOTTOM); + s->dsp.draw_edges(ref->hpel[plane][3], ref->avframe.linesize[plane], width, height, edge, edge, EDGE_TOP | EDGE_BOTTOM); + } + ref->interpolated[plane] = 1; +} + +/** + * Dirac Specification -> + * 13.0 Transform data syntax. transform_data() + */ +static int dirac_decode_frame_internal(DiracContext *s) +{ + DWTContext d; + int y, i, comp, dsty; + + if (s->low_delay) { + /* [DIRAC_STD] 13.5.1 low_delay_transform_data() */ + for (comp = 0; comp < 3; comp++) { + Plane *p = &s->plane[comp]; + memset(p->idwt_buf, 0, p->idwt_stride * p->idwt_height * sizeof(IDWTELEM)); + } + if (!s->zero_res) + decode_lowdelay(s); + } + + for (comp = 0; comp < 3; comp++) { + Plane *p = &s->plane[comp]; + uint8_t *frame = s->current_picture->avframe.data[comp]; + + /* FIXME: small resolutions */ + for (i = 0; i < 4; i++) + s->edge_emu_buffer[i] = s->edge_emu_buffer_base + i*FFALIGN(p->width, 16); + + if (!s->zero_res && !s->low_delay) + { + memset(p->idwt_buf, 0, p->idwt_stride * p->idwt_height * sizeof(IDWTELEM)); + decode_component(s, comp); /* [DIRAC_STD] 13.4.1 core_transform_data() */ + } + if (ff_spatial_idwt_init2(&d, p->idwt_buf, p->idwt_width, p->idwt_height, p->idwt_stride, + s->wavelet_idx+2, s->wavelet_depth, p->idwt_tmp)) + return -1; + + if (!s->num_refs) { /* intra */ + for (y = 0; y < p->height; y += 16) { + ff_spatial_idwt_slice2(&d, y+16); /* decode */ + s->diracdsp.put_signed_rect_clamped(frame + y*p->stride, p->stride, + p->idwt_buf + y*p->idwt_stride, p->idwt_stride, p->width, 16); + } + } else { /* inter */ + int rowheight = p->ybsep*p->stride; + + select_dsp_funcs(s, p->width, p->height, p->xblen, p->yblen); + + for (i = 0; i < s->num_refs; i++) + interpolate_refplane(s, s->ref_pics[i], comp, p->width, p->height); + + memset(s->mctmp, 0, 4*p->yoffset*p->stride); + + dsty = -p->yoffset; + for (y = 0; y < s->blheight; y++) { + int h = 0, start = FFMAX(dsty, 0); + uint16_t *mctmp = s->mctmp + y*rowheight; + DiracBlock *blocks = s->blmotion + y*s->blwidth; + + init_obmc_weights(s, p, y); + + if (y == s->blheight-1 || start+p->ybsep > p->height) + h = p->height - start; + else + h = p->ybsep - (start - dsty); + if (h < 0) + break; + + memset(mctmp+2*p->yoffset*p->stride, 0, 2*rowheight); + mc_row(s, blocks, mctmp, comp, dsty); + + mctmp += (start - dsty)*p->stride + p->xoffset; + ff_spatial_idwt_slice2(&d, start + h); /* decode */ + s->diracdsp.add_rect_clamped(frame + start*p->stride, mctmp, p->stride, + p->idwt_buf + start*p->idwt_stride, p->idwt_stride, p->width, h); + + dsty += p->ybsep; + } + } + } + + + return 0; +} + +/** + * Dirac Specification -> + * 11.1.1 Picture Header. picture_header() + */ +static int dirac_decode_picture_header(DiracContext *s) +{ + int retire, picnum; + int i, j, refnum, refdist; + GetBitContext *gb = &s->gb; + + /* [DIRAC_STD] 11.1.1 Picture Header. picture_header() PICTURE_NUM */ + picnum = s->current_picture->avframe.display_picture_number = get_bits_long(gb, 32); + + + av_log(s->avctx,AV_LOG_DEBUG,"PICTURE_NUM: %d\n",picnum); + + /* if this is the first keyframe after a sequence header, start our + reordering from here */ + if (s->frame_number < 0) + s->frame_number = picnum; + + s->ref_pics[0] = s->ref_pics[1] = NULL; + for (i = 0; i < s->num_refs; i++) { + refnum = picnum + dirac_get_se_golomb(gb); + refdist = INT_MAX; + + /* find the closest reference to the one we want */ + /* Jordi: this is needed if the referenced picture hasn't yet arrived */ + for (j = 0; j < MAX_REFERENCE_FRAMES && refdist; j++) + if (s->ref_frames[j] + && FFABS(s->ref_frames[j]->avframe.display_picture_number - refnum) < refdist) { + s->ref_pics[i] = s->ref_frames[j]; + refdist = FFABS(s->ref_frames[j]->avframe.display_picture_number - refnum); + } + + if (!s->ref_pics[i] || refdist) + av_log(s->avctx, AV_LOG_DEBUG, "Reference not found\n"); + + /* if there were no references at all, allocate one */ + if (!s->ref_pics[i]) + for (j = 0; j < MAX_FRAMES; j++) + if (!s->all_frames[j].avframe.data[0]) { + s->ref_pics[i] = &s->all_frames[j]; + s->avctx->get_buffer(s->avctx, &s->ref_pics[i]->avframe); + } + } + + /* retire the reference frames that are not used anymore */ + if (s->current_picture->avframe.reference) { + retire = picnum + dirac_get_se_golomb(gb); + if (retire != picnum) { + DiracFrame *retire_pic = remove_frame(s->ref_frames, retire); + + if (retire_pic) + retire_pic->avframe.reference &= DELAYED_PIC_REF; + else + av_log(s->avctx, AV_LOG_DEBUG, "Frame to retire not found\n"); + } + + /* if reference array is full, remove the oldest as per the spec */ + while (add_frame(s->ref_frames, MAX_REFERENCE_FRAMES, s->current_picture)) { + av_log(s->avctx, AV_LOG_ERROR, "Reference frame overflow\n"); + remove_frame(s->ref_frames, s->ref_frames[0]->avframe.display_picture_number)->avframe.reference &= DELAYED_PIC_REF; + } + } + + if (s->num_refs) { + if (dirac_unpack_prediction_parameters(s)) /* [DIRAC_STD] 11.2 Picture Prediction Data. picture_prediction() */ + return -1; + dirac_unpack_block_motion_data(s); /* [DIRAC_STD] 12. Block motion data syntax */ + } + if (dirac_unpack_idwt_params(s)) /* [DIRAC_STD] 11.3 Wavelet transform data */ + return -1; + + init_planes(s); + return 0; +} + +static int get_delayed_pic(DiracContext *s, AVFrame *picture, int *data_size) +{ + DiracFrame *out = s->delay_frames[0]; + int i, out_idx = 0; + + /* find frame with lowest picture number */ + for (i = 1; s->delay_frames[i]; i++) + if (s->delay_frames[i]->avframe.display_picture_number < out->avframe.display_picture_number) { + out = s->delay_frames[i]; + out_idx = i; + } + + for (i = out_idx; s->delay_frames[i]; i++) + s->delay_frames[i] = s->delay_frames[i+1]; + + if (out) { + out->avframe.reference ^= DELAYED_PIC_REF; + *data_size = sizeof(AVFrame); + *(AVFrame *)picture = out->avframe; + } + + return 0; +} + +/** + * Dirac Specification -> + * 9.6 Parse Info Header Syntax. parse_info() + * 4 byte start code + byte parse code + 4 byte size + 4 byte previous size + */ +#define DATA_UNIT_HEADER_SIZE 13 + +/* [DIRAC_STD] dirac_decode_data_unit makes reference to the while defined in 9.3 + inside the function parse_sequence() */ +static int dirac_decode_data_unit(AVCodecContext *avctx, const uint8_t *buf, int size) +{ + DiracContext *s = avctx->priv_data; + DiracFrame *pic = NULL; + int i, parse_code = buf[4]; + + if (size < DATA_UNIT_HEADER_SIZE) + return -1; + + init_get_bits(&s->gb, &buf[13], 8*(size - DATA_UNIT_HEADER_SIZE)); + + if (parse_code == pc_seq_header) { + if (s->seen_sequence_header) + return 0; + + /* [DIRAC_STD] 10. Sequence header */ + if (avpriv_dirac_parse_sequence_header(avctx, &s->gb, &s->source)) + return -1; + + avcodec_get_chroma_sub_sample(avctx->pix_fmt, &s->chroma_x_shift, &s->chroma_y_shift); + + if (alloc_sequence_buffers(s)) + return -1; + + s->seen_sequence_header = 1; + } else if (parse_code == pc_eos) { /* [DIRAC_STD] End of Sequence */ + free_sequence_buffers(s); + s->seen_sequence_header = 0; + } else if (parse_code == pc_aux_data) { + if (buf[13] == 1) { /* encoder implementation/version */ + int ver[3]; + /* versions older than 1.0.8 don't store quant delta for + subbands with only one codeblock */ + if (sscanf(buf+14, "Schroedinger %d.%d.%d", ver, ver+1, ver+2) == 3) + if (ver[0] == 1 && ver[1] == 0 && ver[2] <= 7) + s->old_delta_quant = 1; + } + } else if (parse_code & 0x8) { /* picture data unit */ + if (!s->seen_sequence_header) { + av_log(avctx, AV_LOG_DEBUG, "Dropping frame without sequence header\n"); + return -1; + } + + /* find an unused frame */ + for (i = 0; i < MAX_FRAMES; i++) + if (s->all_frames[i].avframe.data[0] == NULL) + pic = &s->all_frames[i]; + if (!pic) { + av_log(avctx, AV_LOG_ERROR, "framelist full\n"); + return -1; + } + + avcodec_get_frame_defaults(&pic->avframe); + + /* [DIRAC_STD] Defined in 9.6.1 ... */ + s->num_refs = parse_code & 0x03; /* [DIRAC_STD] num_refs() */ + s->is_arith = (parse_code & 0x48) == 0x08; /* [DIRAC_STD] using_ac() */ + s->low_delay = (parse_code & 0x88) == 0x88; /* [DIRAC_STD] is_low_delay() */ + pic->avframe.reference = (parse_code & 0x0C) == 0x0C; /* [DIRAC_STD] is_reference() */ + pic->avframe.key_frame = s->num_refs == 0; /* [DIRAC_STD] is_intra() */ + pic->avframe.pict_type = s->num_refs + 1; /* Definition of AVPictureType in avutil.h */ + + if (avctx->get_buffer(avctx, &pic->avframe) < 0) { + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); + return -1; + } + s->current_picture = pic; + s->plane[0].stride = pic->avframe.linesize[0]; + s->plane[1].stride = pic->avframe.linesize[1]; + s->plane[2].stride = pic->avframe.linesize[2]; + + /* [DIRAC_STD] 11.1 Picture parse. picture_parse() */ + if (dirac_decode_picture_header(s)) + return -1; + + /* [DIRAC_STD] 13.0 Transform data syntax. transform_data() */ + if (dirac_decode_frame_internal(s)) + return -1; + } + return 0; +} + +static int dirac_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *pkt) +{ + DiracContext *s = avctx->priv_data; + DiracFrame *picture = data; + uint8_t *buf = pkt->data; + int buf_size = pkt->size; + int i, data_unit_size, buf_idx = 0; + + /* release unused frames */ + for (i = 0; i < MAX_FRAMES; i++) + if (s->all_frames[i].avframe.data[0] && !s->all_frames[i].avframe.reference) { + avctx->release_buffer(avctx, &s->all_frames[i].avframe); + memset(s->all_frames[i].interpolated, 0, sizeof(s->all_frames[i].interpolated)); + } + + s->current_picture = NULL; + *data_size = 0; + + /* end of stream, so flush delayed pics */ + if (buf_size == 0) + return get_delayed_pic(s, (AVFrame *)data, data_size); + + for (;;) { + /*[DIRAC_STD] Here starts the code from parse_info() defined in 9.6 + [DIRAC_STD] PARSE_INFO_PREFIX = "BBCD" as defined in ISO/IEC 646 + BBCD start code search */ + for (; buf_idx + DATA_UNIT_HEADER_SIZE < buf_size; buf_idx++) { + if (buf[buf_idx ] == 'B' && buf[buf_idx+1] == 'B' && + buf[buf_idx+2] == 'C' && buf[buf_idx+3] == 'D') + break; + } + /* BBCD found or end of data */ + if (buf_idx + DATA_UNIT_HEADER_SIZE >= buf_size) + break; + + data_unit_size = AV_RB32(buf+buf_idx+5); + if (buf_idx + data_unit_size > buf_size) { + av_log(s->avctx, AV_LOG_ERROR, + "Data unit with size %d is larger than input buffer, discarding\n", + data_unit_size); + buf_idx += 4; + continue; + } + /* [DIRAC_STD] dirac_decode_data_unit makes reference to the while defined in 9.3 inside the function parse_sequence() */ + if (dirac_decode_data_unit(avctx, buf+buf_idx, data_unit_size)) + { + av_log(s->avctx, AV_LOG_ERROR,"Error in dirac_decode_data_unit\n"); + return -1; + } + buf_idx += data_unit_size; + } + + if (!s->current_picture) + return 0; + + if (s->current_picture->avframe.display_picture_number > s->frame_number) { + DiracFrame *delayed_frame = remove_frame(s->delay_frames, s->frame_number); + + s->current_picture->avframe.reference |= DELAYED_PIC_REF; + + if (add_frame(s->delay_frames, MAX_DELAY, s->current_picture)) { + int min_num = s->delay_frames[0]->avframe.display_picture_number; + /* Too many delayed frames, so we display the frame with the lowest pts */ + av_log(avctx, AV_LOG_ERROR, "Delay frame overflow\n"); + delayed_frame = s->delay_frames[0]; + + for (i = 1; s->delay_frames[i]; i++) + if (s->delay_frames[i]->avframe.display_picture_number < min_num) + min_num = s->delay_frames[i]->avframe.display_picture_number; + + delayed_frame = remove_frame(s->delay_frames, min_num); + add_frame(s->delay_frames, MAX_DELAY, s->current_picture); + } + + if (delayed_frame) { + delayed_frame->avframe.reference ^= DELAYED_PIC_REF; + *(AVFrame*)data = delayed_frame->avframe; + *data_size = sizeof(AVFrame); + } + } else if (s->current_picture->avframe.display_picture_number == s->frame_number) { + /* The right frame at the right time :-) */ + *(AVFrame*)data = s->current_picture->avframe; + *data_size = sizeof(AVFrame); + } + + if (*data_size) + s->frame_number = picture->avframe.display_picture_number + 1; + + return buf_idx; +} + +AVCodec ff_dirac_decoder = { + "dirac", + AVMEDIA_TYPE_VIDEO, + CODEC_ID_DIRAC, + sizeof(DiracContext), + dirac_decode_init, + NULL, + dirac_decode_end, + dirac_decode_frame, + CODEC_CAP_DELAY, + .flush = dirac_decode_flush, + .long_name = NULL_IF_CONFIG_SMALL("BBC Dirac VC-2"), +}; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/diracdsp.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/diracdsp.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/diracdsp.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/diracdsp.c 2011-11-04 12:38:26.000000000 +0000 @@ -0,0 +1,201 @@ +/* + * Copyright (C) 2009 David Conrad + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "dsputil.h" +#include "diracdsp.h" +#include "libavcodec/x86/diracdsp_mmx.h" + +#define FILTER(src, stride) \ + ((21*((src)[ 0*stride] + (src)[1*stride]) \ + -7*((src)[-1*stride] + (src)[2*stride]) \ + +3*((src)[-2*stride] + (src)[3*stride]) \ + -1*((src)[-3*stride] + (src)[4*stride]) + 16) >> 5) + +static void dirac_hpel_filter(uint8_t *dsth, uint8_t *dstv, uint8_t *dstc, uint8_t *src, + int stride, int width, int height) +{ + int x, y; + + for (y = 0; y < height; y++) { + for (x = -3; x < width+5; x++) + dstv[x] = av_clip_uint8(FILTER(src+x, stride)); + + for (x = 0; x < width; x++) + dstc[x] = av_clip_uint8(FILTER(dstv+x, 1)); + + for (x = 0; x < width; x++) + dsth[x] = av_clip_uint8(FILTER(src+x, 1)); + + src += stride; + dsth += stride; + dstv += stride; + dstc += stride; + } +} + +#define PIXOP_BILINEAR(PFX, OP, WIDTH) \ + static void ff_ ## PFX ## _dirac_pixels ## WIDTH ## _bilinear_c(uint8_t *dst, const uint8_t *src[5], int stride, int h) \ + { \ + int x; \ + const uint8_t *s0 = src[0]; \ + const uint8_t *s1 = src[1]; \ + const uint8_t *s2 = src[2]; \ + const uint8_t *s3 = src[3]; \ + const uint8_t *w = src[4]; \ + \ + while (h--) { \ + for (x = 0; x < WIDTH; x++) { \ + OP(dst[x], (s0[x]*w[0] + s1[x]*w[1] + s2[x]*w[2] + s3[x]*w[3] + 8) >> 4); \ + } \ + \ + dst += stride; \ + s0 += stride; \ + s1 += stride; \ + s2 += stride; \ + s3 += stride; \ + } \ + } + +#define OP_PUT(dst, val) (dst) = (val) +#define OP_AVG(dst, val) (dst) = (((dst) + (val) + 1)>>1) + +PIXOP_BILINEAR(put, OP_PUT, 8) +PIXOP_BILINEAR(put, OP_PUT, 16) +PIXOP_BILINEAR(put, OP_PUT, 32) +PIXOP_BILINEAR(avg, OP_AVG, 8) +PIXOP_BILINEAR(avg, OP_AVG, 16) +PIXOP_BILINEAR(avg, OP_AVG, 32) + +#define op_scale1(x) block[x] = av_clip_uint8( (block[x]*weight + (1<<(log2_denom-1))) >> log2_denom) +#define op_scale2(x) dst[x] = av_clip_uint8( (src[x]*weights + dst[x]*weightd + (1<<(log2_denom-1))) >> log2_denom) + +#define DIRAC_WEIGHT(W) \ + static void weight_dirac_pixels ## W ## _c(uint8_t *block, int stride, int log2_denom, \ + int weight, int h) { \ + int x; \ + while (h--) { \ + for (x = 0; x < W; x++) { \ + op_scale1(x); \ + op_scale1(x+1); \ + } \ + block += stride; \ + } \ + } \ + static void biweight_dirac_pixels ## W ## _c(uint8_t *dst, uint8_t *src, int stride, int log2_denom, \ + int weightd, int weights, int h) { \ + int x; \ + while (h--) { \ + for (x = 0; x < W; x++) { \ + op_scale2(x); \ + op_scale2(x+1); \ + } \ + dst += stride; \ + src += stride; \ + } \ + } + +DIRAC_WEIGHT(8) +DIRAC_WEIGHT(16) +DIRAC_WEIGHT(32) + +#define ADD_OBMC(xblen) \ + static void add_obmc ## xblen ## _c(uint16_t *dst, const uint8_t *src, int stride, \ + const uint8_t *obmc_weight, int yblen) \ + { \ + int x; \ + while (yblen--) { \ + for (x = 0; x < xblen; x += 2) { \ + dst[x ] += src[x ] * obmc_weight[x ]; \ + dst[x+1] += src[x+1] * obmc_weight[x+1]; \ + } \ + dst += stride; \ + src += stride; \ + obmc_weight += 32; \ + } \ + } + +ADD_OBMC(8) +ADD_OBMC(16) +ADD_OBMC(32) + +static void put_signed_rect_clamped_c(uint8_t *dst, int dst_stride, const int16_t *src, int src_stride, int width, int height) +{ + int x, y; + for (y = 0; y < height; y++) { + for (x = 0; x < width; x+=4) { + dst[x ] = av_clip_uint8(src[x ] + 128); + dst[x+1] = av_clip_uint8(src[x+1] + 128); + dst[x+2] = av_clip_uint8(src[x+2] + 128); + dst[x+3] = av_clip_uint8(src[x+3] + 128); + } + dst += dst_stride; + src += src_stride; + } +} + +static void add_rect_clamped_c(uint8_t *dst, const uint16_t *src, int stride, + const int16_t *idwt, int idwt_stride, + int width, int height) +{ + int x, y; + + for (y = 0; y < height; y++) { + for (x = 0; x < width; x+=2) { + dst[x ] = av_clip_uint8(((src[x ]+32)>>6) + idwt[x ]); + dst[x+1] = av_clip_uint8(((src[x+1]+32)>>6) + idwt[x+1]); + } + dst += stride; + src += stride; + idwt += idwt_stride; + } +} + +#define PIXFUNC(PFX, WIDTH) \ + c->PFX ## _dirac_pixels_tab[WIDTH>>4][0] = ff_ ## PFX ## _dirac_pixels ## WIDTH ## _c; \ + c->PFX ## _dirac_pixels_tab[WIDTH>>4][1] = ff_ ## PFX ## _dirac_pixels ## WIDTH ## _l2_c; \ + c->PFX ## _dirac_pixels_tab[WIDTH>>4][2] = ff_ ## PFX ## _dirac_pixels ## WIDTH ## _l4_c; \ + c->PFX ## _dirac_pixels_tab[WIDTH>>4][3] = ff_ ## PFX ## _dirac_pixels ## WIDTH ## _bilinear_c + +void ff_diracdsp_init(DiracDSPContext *c) +{ + c->dirac_hpel_filter = dirac_hpel_filter; + c->add_rect_clamped = add_rect_clamped_c; + c->put_signed_rect_clamped = put_signed_rect_clamped_c; + + c->add_dirac_obmc[0] = add_obmc8_c; + c->add_dirac_obmc[1] = add_obmc16_c; + c->add_dirac_obmc[2] = add_obmc32_c; + + c->weight_dirac_pixels_tab[0] = weight_dirac_pixels8_c; + c->weight_dirac_pixels_tab[1] = weight_dirac_pixels16_c; + c->weight_dirac_pixels_tab[2] = weight_dirac_pixels32_c; + c->biweight_dirac_pixels_tab[0] = biweight_dirac_pixels8_c; + c->biweight_dirac_pixels_tab[1] = biweight_dirac_pixels16_c; + c->biweight_dirac_pixels_tab[2] = biweight_dirac_pixels32_c; + + PIXFUNC(put, 8); + PIXFUNC(put, 16); + PIXFUNC(put, 32); + PIXFUNC(avg, 8); + PIXFUNC(avg, 16); + PIXFUNC(avg, 32); + + if (HAVE_MMX && HAVE_YASM) ff_diracdsp_init_mmx(c); +} diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/diracdsp.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/diracdsp.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/diracdsp.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/diracdsp.h 2011-11-04 12:38:26.000000000 +0000 @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2010 David Conrad + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_DIRACDSP_H +#define AVCODEC_DIRACDSP_H + +typedef void (*dirac_weight_func)(uint8_t *block, int stride, int log2_denom, int weight, int h); +typedef void (*dirac_biweight_func)(uint8_t *dst, uint8_t *src, int stride, int log2_denom, int weightd, int weights, int h); + +typedef struct { + void (*dirac_hpel_filter)(uint8_t *dsth, uint8_t *dstv, uint8_t *dstc, uint8_t *src, int stride, int width, int height); + /** + * dirac_pixels_tab[width][subpel] + * width is 2 for 32, 1 for 16, 0 for 8 + * subpel is 0 for fpel and hpel (only need to copy from the first plane in src) + * 1 if an average of the first 2 planes is needed (TODO: worth it?) + * 2 for general qpel (avg of 4) + * 3 for general epel (biweight of 4 using the weights in src[4]) + * src[0-3] is each of the hpel planes + * src[4] is the 1/8 pel weights if needed + */ + void (*put_dirac_pixels_tab[3][4])(uint8_t *dst, const uint8_t *src[5], int stride, int h); + void (*avg_dirac_pixels_tab[3][4])(uint8_t *dst, const uint8_t *src[5], int stride, int h); + + void (*put_signed_rect_clamped)(uint8_t *dst/*align 16*/, int dst_stride, const int16_t *src/*align 16*/, int src_stride, int width, int height/*mod 2*/); + void (*put_rect_clamped)(uint8_t *dst/*align 16*/, int dst_stride, const int16_t *src/*align 16*/, int src_stride, int width, int height/*mod 2*/); + void (*add_rect_clamped)(uint8_t *dst/*align 16*/, const uint16_t *src/*align 16*/, int stride, const int16_t *idwt/*align 16*/, int idwt_stride, int width, int height/*mod 2*/); + void (*add_dirac_obmc[3])(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen); + + dirac_weight_func weight_dirac_pixels_tab[3]; + dirac_biweight_func biweight_dirac_pixels_tab[3]; +} DiracDSPContext; + +#define DECL_DIRAC_PIXOP(PFX, EXT) \ + void ff_ ## PFX ## _dirac_pixels8_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h); \ + void ff_ ## PFX ## _dirac_pixels16_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h); \ + void ff_ ## PFX ## _dirac_pixels32_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h) + +DECL_DIRAC_PIXOP(put, c); +DECL_DIRAC_PIXOP(avg, c); +DECL_DIRAC_PIXOP(put, l2_c); +DECL_DIRAC_PIXOP(avg, l2_c); +DECL_DIRAC_PIXOP(put, l4_c); +DECL_DIRAC_PIXOP(avg, l4_c); + +void ff_diracdsp_init(DiracDSPContext *c); + +#endif diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dirac.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dirac.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dirac.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dirac.h 2011-11-04 12:38:26.000000000 +0000 @@ -1,6 +1,7 @@ /* * Copyright (C) 2007 Marco Gerards * Copyright (C) 2009 David Conrad + * Copyright (C) 2011 Jordi Ortiz * * This file is part of FFmpeg. * @@ -26,6 +27,8 @@ * @file * Interface to Dirac Decoder/Encoder * @author Marco Gerards + * @author David Conrad + * @author Jordi Ortiz */ #include "avcodec.h" @@ -51,7 +54,7 @@ uint8_t color_spec_index; ///< index into dirac_color_spec_presets[] } dirac_source_params; -int ff_dirac_parse_sequence_header(AVCodecContext *avctx, GetBitContext *gb, - dirac_source_params *source); +int avpriv_dirac_parse_sequence_header(AVCodecContext *avctx, GetBitContext *gb, + dirac_source_params *source); #endif /* AVCODEC_DIRAC_H */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dirac_parser.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dirac_parser.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dirac_parser.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dirac_parser.c 2011-11-04 12:38:26.000000000 +0000 @@ -248,9 +248,8 @@ } AVCodecParser ff_dirac_parser = { - { CODEC_ID_DIRAC }, - sizeof(DiracParseContext), - NULL, - dirac_parse, - dirac_parse_close, + .codec_ids = { CODEC_ID_DIRAC }, + .priv_data_size = sizeof(DiracParseContext), + .parser_parse = dirac_parse, + .parser_close = dirac_parse_close, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dnxhddata.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dnxhddata.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dnxhddata.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dnxhddata.c 2011-11-04 12:38:26.000000000 +0000 @@ -284,63 +284,43 @@ }; static const uint8_t dnxhd_1237_ac_level[257] = { - 1, 1, 2, 0, 3, 4, 2, 5, 6, 7, 3, 8, 9, 10, 11, 12, - 4, 5, 13, 14, 15, 16, 6, 17, 18, 19, 20, 21, 7, 22, 23, 24, - 25, 26, 27, 8, 9, 28, 29, 30, 31, 32, 33, 34, 10, 11, 12, 35, - 36, 37, 38, 39, 40, 41, 13, 14, 15, 16, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 17, 18, 19, 20, 21, 53, 54, 55, 56, 57, 58, - 59, 60, 61, 64, 1, 22, 23, 24, 25, 26, 27, 62, 63, 2, 3, 4, - 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, - 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, -}; - -static const uint8_t dnxhd_1237_ac_run_flag[257] = { - 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, - 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, - 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, - 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, + 3, 3, 5, 0, 7, 9, 5, 11, 13, 15, 7, 17, 19, 21, 23, 25, + 9, 11, 27, 29, 31, 33, 13, 35, 37, 39, 41, 43, 15, 45, 47, 49, + 51, 53, 55, 17, 19, 57, 59, 61, 63, 65, 67, 69, 21, 23, 25, 71, + 73, 75, 77, 79, 81, 83, 27, 29, 31, 33, 85, 87, 89, 91, 93, 95, + 97, 99,101,103,105, 35, 37, 39, 41, 43,107,109,111,113,115,117, + 119,121,123,129, 3, 45, 47, 49, 51, 53, 55,125,127, 5, 7, 9, + 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, + 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, + 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99,101,103,105, + 107,109,111,113,115,117,119,121,123,125,127,129, 57, 59, 61, 63, + 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, + 97, 99,101,103,105,107,109,111,113,115,117,119,121,123,125,127, + 129, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, + 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, + 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, + 97, 99,101,103,105,107,109,111,113,115,117,119,121,123,125,127, + 129, +}; + +static const uint8_t dnxhd_1237_ac_flags[257] = { + 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 0, 0, + 2, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, + 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, + 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 2, 2, 2, 2, 2, 2, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, -}; - -static const uint8_t dnxhd_1237_ac_index_flag[257] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, }; static const uint16_t dnxhd_1237_run_codes[62] = { @@ -433,63 +413,46 @@ }; static const uint8_t dnxhd_1238_ac_level[257] = { - 1, 1, 2, 3, 0, 4, 5, 2, 6, 7, 8, 3, 9, 10, 11, 4, - 12, 13, 14, 15, 16, 5, 17, 18, 19, 20, 21, 22, 6, 7, 23, 24, - 25, 26, 27, 28, 29, 8, 9, 30, 31, 32, 33, 34, 35, 36, 37, 10, - 11, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 12, 13, 14, 49, - 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 15, 16, 17, 18, - 62, 63, 64, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 19, 20, 21, 22, 23, 24, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 40, 25, - 26, 27, 28, 29, 30, 38, 39, 41, 42, 43, 44, 45, 46, 47, 48, 49, - 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, + 3, 3, 5, 7, 0, 9, 11, 5, 13, 15, 17, 7, 19, 21, 23, 9, + 25, 27, 29, 31, 33, 11, 35, 37, 39, 41, 43, 45, 13, 15, 47, 49, + 51, 53, 55, 57, 59, 17, 19, 61, 63, 65, 67, 69, 71, 73, 75, 21, + 23, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 25, 27, 29, 99, + 101,103,105,107,109,111,113,115,117,119,121,123, 31, 33, 35, 37, + 125,127,129, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, + 29, 31, 33, 39, 41, 43, 45, 47, 49, 35, 37, 39, 41, 43, 45, 47, + 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 81, 51, + 53, 55, 57, 59, 61, 77, 79, 83, 85, 87, 89, 91, 93, 95, 97, 99, + 101,103,105,107,109,111,113,115,117,119,121,123,125,127,129, 63, + 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, + 97, 99,101,103,105,107,109,111,113,115,117,119,121,123,125,127, + 129, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, + 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, + 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, + 97, 99,101,103,105,107,109,111,113,115,117,119,121,123,125,127, + 129, }; /* 0 is EOB */ -static const uint8_t dnxhd_1238_ac_run_flag[257] = { - 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, - 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, - 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, +static const uint8_t dnxhd_1238_ac_flags[257] = { + 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, + 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, + 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, + 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, + 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, }; static const uint8_t dnxhd_1238_ac_index_flag[257] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, - 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, }; static const uint16_t dnxhd_1235_1238_1241_run_codes[62] = { @@ -582,63 +545,43 @@ }; static const uint8_t dnxhd_1235_1241_ac_level[257] = { - 1, 1, 2, 3, 0, 4, 5, 2, 6, 7, 8, 3, 9, 10, 11, 4, - 12, 13, 14, 15, 16, 5, 17, 18, 19, 20, 21, 6, 7, 22, 23, 24, - 25, 26, 27, 28, 29, 8, 9, 30, 31, 32, 33, 34, 35, 36, 37, 38, - 10, 11, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 12, 13, - 14, 15, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 1, - 16, 17, 18, 19, 64, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, - 13, 14, 15, 16, 17, 20, 21, 22, 23, 24, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 25, 26, 27, 28, 29, 30, 31, 32, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, -}; - -static const uint8_t dnxhd_1235_1241_ac_run_flag[257] = { - 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, - 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, - 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, -}; - -static const uint8_t dnxhd_1235_1241_ac_index_flag[257] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, + 3, 3, 5, 7, 0, 9, 11, 5, 13, 15, 17, 7, 19, 21, 23, 9, + 25, 27, 29, 31, 33, 11, 35, 37, 39, 41, 43, 13, 15, 45, 47, 49, + 51, 53, 55, 57, 59, 17, 19, 61, 63, 65, 67, 69, 71, 73, 75, 77, + 21, 23, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99,101, 25, 27, + 29, 31,103,105,107,109,111,113,115,117,119,121,123,125,127, 3, + 33, 35, 37, 39,129, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, + 27, 29, 31, 33, 35, 41, 43, 45, 47, 49, 37, 39, 41, 43, 45, 47, + 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, + 81, 83, 85, 51, 53, 55, 57, 59, 61, 63, 65, 87, 89, 91, 93, 95, + 97, 99,101,103,105,107,109,111,113,115,117,119,121,123,125,127, + 129, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, + 97, 99,101,103,105,107,109,111,113,115,117,119,121,123,125,127, + 129, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, + 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, + 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, + 97, 99,101,103,105,107,109,111,113,115,117,119,121,123,125,127, + 129, +}; + +static const uint8_t dnxhd_1235_1241_ac_flags[257] = { + 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, + 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 2, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, }; static const uint8_t dnxhd_1235_1241_run[62] = { @@ -709,61 +652,42 @@ 16 }; static const uint8_t dnxhd_1250_ac_level[257] = { - 1, 1, 2, 3, 0, 4, 5, 2, 6, 7, 8, 3, 9, 10, 11, 4, - 12, 13, 14, 15, 16, 5, 17, 18, 19, 20, 21, 22, 6, 23, 24, 25, - 26, 27, 28, 29, 7, 8, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - 9, 10, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 11, - 12, 13, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 1, 2, - 3, 4, 5, 14, 15, 16, 17, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 18, 19, 20, 21, - 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, - 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 55, 56, 22, 23, 24, - 25, 26, 27, 54, 57, 58, 59, 60, 61, 62, 63, 64, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64 -}; -static const uint8_t dnxhd_1250_ac_run_flag[257] = { - 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, - 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, - 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, - 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1 -}; -static const uint8_t dnxhd_1250_ac_index_flag[257] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, - 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, - 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1 + 3, 3, 5, 7, 0, 9, 11, 5, 13, 15, 17, 7, 19, 21, 23, 9, + 25, 27, 29, 31, 33, 11, 35, 37, 39, 41, 43, 45, 13, 47, 49, 51, + 53, 55, 57, 59, 15, 17, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, + 19, 21, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99,101,103,105, 23, + 25, 27,107,109,111,113,115,117,119,121,123,125,127,129, 3, 5, + 7, 9, 11, 29, 31, 33, 35, 13, 15, 17, 19, 21, 23, 25, 27, 29, + 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 37, 39, 41, 43, + 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, + 87, 89, 91, 93, 95, 97, 99,101,103,105,107,111,113, 45, 47, 49, + 51, 53, 55,109,115,117,119,121,123,125,127,129, 57, 59, 61, 63, + 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, + 97, 99,101,103,105,107,109,111,113,115,117,119,121,123,125,127, + 129, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, + 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, + 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, + 97, 99,101,103,105,107,109,111,113,115,117,119,121,123,125,127, + 129 +}; +static const uint8_t dnxhd_1250_ac_flags[257] = { + 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, + 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, + 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, + 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, }; static const uint16_t dnxhd_1250_run_codes[62] = { 0, 4, 5, 12, 26, 27, 28, 58, @@ -853,63 +777,43 @@ }; static const uint8_t dnxhd_1251_ac_level[257] = { - 1, 1, 2, 3, 0, 4, 5, 2, 6, 7, 8, 3, 9, 10, 11, 4, - 12, 13, 14, 15, 16, 5, 17, 18, 19, 20, 21, 6, 22, 23, 24, 25, - 26, 27, 28, 29, 7, 8, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, - 40, 9, 10, 11, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, - 12, 13, 14, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 1, - 2, 3, 4, 5, 6, 7, 8, 15, 16, 17, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 18, - 19, 20, 21, 22, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, - 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - 58, 23, 24, 25, 26, 27, 28, 59, 60, 61, 62, 63, 64, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, -}; - -static const uint8_t dnxhd_1251_ac_run_flag[257] = { - 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, - 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, -}; - -static const uint8_t dnxhd_1251_ac_index_flag[257] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, - 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, + 3, 3, 5, 7, 0, 9, 11, 5, 13, 15, 17, 7, 19, 21, 23, 9, + 25, 27, 29, 31, 33, 11, 35, 37, 39, 41, 43, 13, 45, 47, 49, 51, + 53, 55, 57, 59, 15, 17, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, + 81, 19, 21, 23, 83, 85, 87, 89, 91, 93, 95, 97, 99,101,103,105, + 25, 27, 29,107,109,111,113,115,117,119,121,123,125,127,129, 3, + 5, 7, 9, 11, 13, 15, 17, 31, 33, 35, 19, 21, 23, 25, 27, 29, + 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 37, + 39, 41, 43, 45, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, + 85, 87, 89, 91, 93, 95, 97, 99,101,103,105,107,109,111,113,115, + 117, 47, 49, 51, 53, 55, 57,119,121,123,125,127,129, 59, 61, 63, + 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, + 97, 99,101,103,105,107,109,111,113,115,117,119,121,123,125,127, + 129, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, + 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, + 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, + 97, 99,101,103,105,107,109,111,113,115,117,119,121,123,125,127, + 129, +}; + +static const uint8_t dnxhd_1251_ac_flags[257] = { + 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 0, 0, 2, + 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, + 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, + 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, }; static const uint16_t dnxhd_1251_run_codes[62] = { @@ -1002,134 +906,114 @@ }; static const uint8_t dnxhd_1252_ac_level[257] = { - 1, 1, 2, 3, 2, 0, 4, 5, 6, 7, 3, 8, 9, 10, 11, 12, - 13, 14, 4, 5, 15, 16, 17, 18, 6, 19, 20, 21, 22, 23, 24, 7, - 8, 25, 26, 27, 28, 29, 30, 31, 32, 9, 10, 33, 34, 35, 36, 37, - 38, 39, 40, 41, 11, 12, 13, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52, 53, 14, 15, 16, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 1, 2, 3, 17, 18, 19, 20, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 21, 22, 23, 24, 25, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, - 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, -}; - -static const uint8_t dnxhd_1252_ac_run_flag[257] = { - 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, - 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, - 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, -}; - -static const uint8_t dnxhd_1252_ac_index_flag[257] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, + 3, 3, 5, 7, 5, 0, 9, 11, 13, 15, 7, 17, 19, 21, 23, 25, + 27, 29, 9, 11, 31, 33, 35, 37, 13, 39, 41, 43, 45, 47, 49, 15, + 17, 51, 53, 55, 57, 59, 61, 63, 65, 19, 21, 67, 69, 71, 73, 75, + 77, 79, 81, 83, 23, 25, 27, 85, 87, 89, 91, 93, 95, 97, 99,101, + 103,105,107, 29, 31, 33,109,111,113,115,117,119,121,123,125,127, + 129, 3, 5, 7, 35, 37, 39, 41, 9, 11, 13, 15, 17, 19, 21, 23, + 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 43, 45, 47, 49, 51, 45, + 47, 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, + 79, 81, 83, 85, 87, 89, 91, 93, 95, 97, 99,101,103,105,107,109, + 111,113,115,117,119,121,123,125,127,129, 53, 55, 57, 59, 61, 63, + 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, + 97, 99,101,103,105,107,109,111,113,115,117,119,121,123,125,127, + 129, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, + 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 63, + 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, + 97, 99,101,103,105,107,109,111,113,115,117,119,121,123,125,127, + 129, +}; + +static const uint8_t dnxhd_1252_ac_flags[257] = { + 0, 2, 0, 0, 2, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 2, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 2, + 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, }; const CIDEntry ff_dnxhd_cid_table[] = { - { 1235, 1920, 1080, 0, 917504, 917504, 6, 10, + { 1235, 1920, 1080, 0, 917504, 917504, 6, 10, 4, dnxhd_1235_luma_weight, dnxhd_1235_chroma_weight, dnxhd_1235_1241_dc_codes, dnxhd_1235_1241_dc_bits, dnxhd_1235_1241_ac_codes, dnxhd_1235_1241_ac_bits, dnxhd_1235_1241_ac_level, - dnxhd_1235_1241_ac_run_flag, dnxhd_1235_1241_ac_index_flag, + dnxhd_1235_1241_ac_flags, dnxhd_1235_1238_1241_run_codes, dnxhd_1235_1238_1241_run_bits, dnxhd_1235_1241_run, { 175, 185, 365, 440 } }, - { 1237, 1920, 1080, 0, 606208, 606208, 4, 8, + { 1237, 1920, 1080, 0, 606208, 606208, 4, 8, 3, dnxhd_1237_luma_weight, dnxhd_1237_chroma_weight, dnxhd_1237_dc_codes, dnxhd_1237_dc_bits, dnxhd_1237_ac_codes, dnxhd_1237_ac_bits, dnxhd_1237_ac_level, - dnxhd_1237_ac_run_flag, dnxhd_1237_ac_index_flag, + dnxhd_1237_ac_flags, dnxhd_1237_run_codes, dnxhd_1237_run_bits, dnxhd_1237_run, { 115, 120, 145, 240, 290 } }, - { 1238, 1920, 1080, 0, 917504, 917504, 4, 8, + { 1238, 1920, 1080, 0, 917504, 917504, 4, 8, 4, dnxhd_1238_luma_weight, dnxhd_1238_chroma_weight, dnxhd_1238_dc_codes, dnxhd_1238_dc_bits, dnxhd_1238_ac_codes, dnxhd_1238_ac_bits, dnxhd_1238_ac_level, - dnxhd_1238_ac_run_flag, dnxhd_1238_ac_index_flag, + dnxhd_1238_ac_flags, dnxhd_1235_1238_1241_run_codes, dnxhd_1235_1238_1241_run_bits, dnxhd_1238_run, { 175, 185, 220, 365, 440 } }, - { 1241, 1920, 1080, 1, 917504, 458752, 6, 10, + { 1241, 1920, 1080, 1, 917504, 458752, 6, 10, 4, dnxhd_1241_luma_weight, dnxhd_1241_chroma_weight, dnxhd_1235_1241_dc_codes, dnxhd_1235_1241_dc_bits, dnxhd_1235_1241_ac_codes, dnxhd_1235_1241_ac_bits, dnxhd_1235_1241_ac_level, - dnxhd_1235_1241_ac_run_flag, dnxhd_1235_1241_ac_index_flag, + dnxhd_1235_1241_ac_flags, dnxhd_1235_1238_1241_run_codes, dnxhd_1235_1238_1241_run_bits, dnxhd_1235_1241_run, { 185, 220 } }, - { 1242, 1920, 1080, 1, 606208, 303104, 4, 8, + { 1242, 1920, 1080, 1, 606208, 303104, 4, 8, 3, dnxhd_1242_luma_weight, dnxhd_1242_chroma_weight, dnxhd_1237_dc_codes, dnxhd_1237_dc_bits, dnxhd_1237_ac_codes, dnxhd_1237_ac_bits, dnxhd_1237_ac_level, - dnxhd_1237_ac_run_flag, dnxhd_1237_ac_index_flag, + dnxhd_1237_ac_flags, dnxhd_1237_run_codes, dnxhd_1237_run_bits, dnxhd_1237_run, { 120, 145 } }, - { 1243, 1920, 1080, 1, 917504, 458752, 4, 8, + { 1243, 1920, 1080, 1, 917504, 458752, 4, 8, 4, dnxhd_1243_luma_weight, dnxhd_1243_chroma_weight, dnxhd_1238_dc_codes, dnxhd_1238_dc_bits, dnxhd_1238_ac_codes, dnxhd_1238_ac_bits, dnxhd_1238_ac_level, - dnxhd_1238_ac_run_flag, dnxhd_1238_ac_index_flag, + dnxhd_1238_ac_flags, dnxhd_1235_1238_1241_run_codes, dnxhd_1235_1238_1241_run_bits, dnxhd_1238_run, { 185, 220 } }, - { 1250, 1280, 720, 0, 458752, 458752, 6, 10, + { 1250, 1280, 720, 0, 458752, 458752, 6, 10, 4, dnxhd_1250_luma_weight, dnxhd_1250_chroma_weight, dnxhd_1250_dc_codes, dnxhd_1250_dc_bits, dnxhd_1250_ac_codes, dnxhd_1250_ac_bits, dnxhd_1250_ac_level, - dnxhd_1250_ac_run_flag, dnxhd_1250_ac_index_flag, + dnxhd_1250_ac_flags, dnxhd_1250_run_codes, dnxhd_1250_run_bits, dnxhd_1250_run, { 90, 180, 220 } }, - { 1251, 1280, 720, 0, 458752, 458752, 4, 8, + { 1251, 1280, 720, 0, 458752, 458752, 4, 8, 4, dnxhd_1251_luma_weight, dnxhd_1251_chroma_weight, dnxhd_1251_dc_codes, dnxhd_1251_dc_bits, dnxhd_1251_ac_codes, dnxhd_1251_ac_bits, dnxhd_1251_ac_level, - dnxhd_1251_ac_run_flag, dnxhd_1251_ac_index_flag, + dnxhd_1251_ac_flags, dnxhd_1251_run_codes, dnxhd_1251_run_bits, dnxhd_1251_run, { 90, 110, 175, 220 } }, - { 1252, 1280, 720, 0, 303104, 303104, 4, 8, + { 1252, 1280, 720, 0, 303104, 303104, 4, 8, 5, dnxhd_1252_luma_weight, dnxhd_1252_chroma_weight, dnxhd_1252_dc_codes, dnxhd_1252_dc_bits, dnxhd_1252_ac_codes, dnxhd_1252_ac_bits, dnxhd_1252_ac_level, - dnxhd_1252_ac_run_flag, dnxhd_1252_ac_index_flag, + dnxhd_1252_ac_flags, dnxhd_1251_run_codes, dnxhd_1251_run_bits, dnxhd_1251_run, { 60, 75, 115, 145 } }, - { 1253, 1920, 1080, 0, 188416, 188416, 4, 8, + { 1253, 1920, 1080, 0, 188416, 188416, 4, 8, 3, dnxhd_1237_luma_weight, dnxhd_1237_chroma_weight, dnxhd_1237_dc_codes, dnxhd_1237_dc_bits, dnxhd_1237_ac_codes, dnxhd_1237_ac_bits, dnxhd_1237_ac_level, - dnxhd_1237_ac_run_flag, dnxhd_1237_ac_index_flag, + dnxhd_1237_ac_flags, dnxhd_1237_run_codes, dnxhd_1237_run_bits, dnxhd_1237_run, { 36, 45, 75, 90 } }, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dnxhddata.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dnxhddata.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dnxhddata.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dnxhddata.h 2011-11-04 12:38:26.000000000 +0000 @@ -33,11 +33,12 @@ unsigned int coding_unit_size; int index_bits; int bit_depth; + int eob_index; const uint8_t *luma_weight, *chroma_weight; const uint8_t *dc_codes, *dc_bits; const uint16_t *ac_codes; const uint8_t *ac_bits, *ac_level; - const uint8_t *ac_run_flag, *ac_index_flag; + const uint8_t *ac_flags; const uint16_t *run_codes; const uint8_t *run_bits, *run; int bit_rates[5]; ///< Helpher to choose variants, rounded to nearest 5Mb/s diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dnxhddec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dnxhddec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dnxhddec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dnxhddec.c 2011-11-04 12:38:26.000000000 +0000 @@ -49,6 +49,9 @@ int bit_depth; // 8, 10 or 0 if not initialized at all. void (*decode_dct_block)(struct DNXHDContext *ctx, DCTELEM *block, int n, int qscale); + int last_qscale; + int luma_scale[64]; + int chroma_scale[64]; } DNXHDContext; #define DNXHD_VLC_BITS 9 @@ -186,16 +189,22 @@ int level_bias, int level_shift) { - int i, j, index1, index2, len; + int i, j, index1, index2, len, flags; int level, component, sign; + const int *scale; const uint8_t *weight_matrix; + const uint8_t *ac_level = ctx->cid_table->ac_level; + const uint8_t *ac_flags = ctx->cid_table->ac_flags; + const int eob_index = ctx->cid_table->eob_index; OPEN_READER(bs, &ctx->gb); if (n&2) { component = 1 + (n&1); + scale = ctx->chroma_scale; weight_matrix = ctx->cid_table->chroma_weight; } else { component = 0; + scale = ctx->luma_scale; weight_matrix = ctx->cid_table->luma_weight; } @@ -211,33 +220,32 @@ block[0] = ctx->last_dc[component]; //av_log(ctx->avctx, AV_LOG_DEBUG, "dc %d\n", block[0]); - for (i = 1; ; i++) { - UPDATE_CACHE(bs, &ctx->gb); - GET_VLC(index1, bs, &ctx->gb, ctx->ac_vlc.table, - DNXHD_VLC_BITS, 2); - //av_log(ctx->avctx, AV_LOG_DEBUG, "index %d\n", index1); - level = ctx->cid_table->ac_level[index1]; - if (!level) { /* EOB */ - //av_log(ctx->avctx, AV_LOG_DEBUG, "EOB\n"); - break; - } + i = 0; + + UPDATE_CACHE(bs, &ctx->gb); + GET_VLC(index1, bs, &ctx->gb, ctx->ac_vlc.table, + DNXHD_VLC_BITS, 2); + + while (index1 != eob_index) { + level = ac_level[index1]; + flags = ac_flags[index1]; sign = SHOW_SBITS(bs, &ctx->gb, 1); SKIP_BITS(bs, &ctx->gb, 1); - if (ctx->cid_table->ac_index_flag[index1]) { - level += SHOW_UBITS(bs, &ctx->gb, index_bits) << 6; + if (flags & 1) { + level += SHOW_UBITS(bs, &ctx->gb, index_bits) << 7; SKIP_BITS(bs, &ctx->gb, index_bits); } - if (ctx->cid_table->ac_run_flag[index1]) { + if (flags & 2) { UPDATE_CACHE(bs, &ctx->gb); GET_VLC(index2, bs, &ctx->gb, ctx->run_vlc.table, DNXHD_VLC_BITS, 2); i += ctx->cid_table->run[index2]; } - if (i > 63) { + if (++i > 63) { av_log(ctx->avctx, AV_LOG_ERROR, "ac tex damaged %d, %d\n", n, i); break; } @@ -245,13 +253,17 @@ j = ctx->scantable.permutated[i]; //av_log(ctx->avctx, AV_LOG_DEBUG, "j %d\n", j); //av_log(ctx->avctx, AV_LOG_DEBUG, "level %d, weight %d\n", level, weight_matrix[i]); - level = (2*level+1) * qscale * weight_matrix[i]; + level *= scale[i]; if (level_bias < 32 || weight_matrix[i] != level_bias) level += level_bias; level >>= level_shift; //av_log(NULL, AV_LOG_DEBUG, "i %d, j %d, end level %d\n", i, j, level); block[j] = (level^sign) - sign; + + UPDATE_CACHE(bs, &ctx->gb); + GET_VLC(index1, bs, &ctx->gb, ctx->ac_vlc.table, + DNXHD_VLC_BITS, 2); } CLOSE_READER(bs, &ctx->gb); @@ -282,6 +294,14 @@ skip_bits1(&ctx->gb); //av_log(ctx->avctx, AV_LOG_DEBUG, "qscale %d\n", qscale); + if (qscale != ctx->last_qscale) { + for (i = 0; i < 64; i++) { + ctx->luma_scale[i] = qscale * ctx->cid_table->luma_weight[i]; + ctx->chroma_scale[i] = qscale * ctx->cid_table->chroma_weight[i]; + } + ctx->last_qscale = qscale; + } + for (i = 0; i < 8; i++) { ctx->dsp.clear_block(ctx->blocks[i]); ctx->decode_dct_block(ctx, ctx->blocks[i], i, qscale); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dnxhdenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dnxhdenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dnxhdenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dnxhdenc.c 2011-11-04 12:38:26.000000000 +0000 @@ -37,7 +37,7 @@ #define DNX10BIT_QMAT_SHIFT 18 // The largest value that will not lead to overflow for 10bit samples. static const AVOption options[]={ - {"nitris_compat", "encode with Avid Nitris compatibility", offsetof(DNXHDEncContext, nitris_compat), FF_OPT_TYPE_INT, {.dbl = 0}, 0, 1, VE}, + {"nitris_compat", "encode with Avid Nitris compatibility", offsetof(DNXHDEncContext, nitris_compat), AV_OPT_TYPE_INT, {.dbl = 0}, 0, 1, VE}, {NULL} }; static const AVClass class = { "dnxhd", av_default_item_name, options, LIBAVUTIL_VERSION_INT }; @@ -122,9 +122,9 @@ alevel -= offset<<6; } for (j = 0; j < 257; j++) { - if (ctx->cid_table->ac_level[j] == alevel && - (!offset || (ctx->cid_table->ac_index_flag[j] && offset)) && - (!run || (ctx->cid_table->ac_run_flag [j] && run))) { + if (ctx->cid_table->ac_level[j] >> 1 == alevel && + (!offset || (ctx->cid_table->ac_flags[j] & 1) && offset) && + (!run || (ctx->cid_table->ac_flags[j] & 2) && run)) { assert(!ctx->vlc_codes[index]); if (alevel) { ctx->vlc_codes[index] = (ctx->cid_table->ac_codes[j]<<1)|(sign&1); @@ -621,7 +621,7 @@ for (mb_x = 0; mb_x < ctx->m.mb_width; ++mb_x, pix += 16) { unsigned mb = mb_y * ctx->m.mb_width + mb_x; int sum = ctx->m.dsp.pix_sum(pix, ctx->m.linesize); - int varc = (ctx->m.dsp.pix_norm1(pix, ctx->m.linesize) - (((unsigned)(sum*sum))>>8)+128)>>8; + int varc = (ctx->m.dsp.pix_norm1(pix, ctx->m.linesize) - (((unsigned)sum*sum)>>8)+128)>>8; ctx->mb_cmp[mb].value = varc; ctx->mb_cmp[mb].mb = mb; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dnxhd_parser.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dnxhd_parser.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dnxhd_parser.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dnxhd_parser.c 2011-11-04 12:38:26.000000000 +0000 @@ -87,9 +87,8 @@ } AVCodecParser ff_dnxhd_parser = { - { CODEC_ID_DNXHD }, - sizeof(ParseContext), - NULL, - dnxhd_parse, - ff_parse_close, + .codec_ids = { CODEC_ID_DNXHD }, + .priv_data_size = sizeof(ParseContext), + .parser_parse = dnxhd_parse, + .parser_close = ff_parse_close, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dsicinav.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dsicinav.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dsicinav.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dsicinav.c 2011-11-04 12:38:26.000000000 +0000 @@ -26,6 +26,7 @@ #include "avcodec.h" #include "bytestream.h" +#include "mathops.h" typedef enum CinVideoBitmapIndex { @@ -43,7 +44,6 @@ } CinVideoContext; typedef struct CinAudioContext { - AVCodecContext *avctx; int initial_decode_frame; int delta; } CinAudioContext; @@ -309,7 +309,11 @@ { CinAudioContext *cin = avctx->priv_data; - cin->avctx = avctx; + if (avctx->channels != 1) { + av_log_ask_for_sample(avctx, "Number of channels is not supported\n"); + return AVERROR_PATCHWELCOME; + } + cin->initial_decode_frame = 1; cin->delta = 0; avctx->sample_fmt = AV_SAMPLE_FMT_S16; @@ -322,29 +326,35 @@ AVPacket *avpkt) { const uint8_t *buf = avpkt->data; - int buf_size = avpkt->size; CinAudioContext *cin = avctx->priv_data; - const uint8_t *src = buf; - int16_t *samples = (int16_t *)data; - - buf_size = FFMIN(buf_size, *data_size/2); + const uint8_t *buf_end = buf + avpkt->size; + int16_t *samples = data; + int delta, out_size; + + out_size = (avpkt->size - cin->initial_decode_frame) * + av_get_bytes_per_sample(avctx->sample_fmt); + if (*data_size < out_size) { + av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); + return AVERROR(EINVAL); + } + delta = cin->delta; if (cin->initial_decode_frame) { cin->initial_decode_frame = 0; - cin->delta = (int16_t)AV_RL16(src); src += 2; - *samples++ = cin->delta; - buf_size -= 2; + delta = sign_extend(AV_RL16(buf), 16); + buf += 2; + *samples++ = delta; } - while (buf_size > 0) { - cin->delta += cinaudio_delta16_table[*src++]; - cin->delta = av_clip_int16(cin->delta); - *samples++ = cin->delta; - --buf_size; + while (buf < buf_end) { + delta += cinaudio_delta16_table[*buf++]; + delta = av_clip_int16(delta); + *samples++ = delta; } + cin->delta = delta; - *data_size = (uint8_t *)samples - (uint8_t *)data; + *data_size = out_size; - return src - buf; + return avpkt->size; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dsputil.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dsputil.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dsputil.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dsputil.c 2011-11-04 12:38:26.000000000 +0000 @@ -38,6 +38,7 @@ #include "config.h" #include "ac3dec.h" #include "vorbis.h" +#include "diracdsp.h" uint8_t ff_cropTbl[256 + 2 * MAX_NEG_CROP] = {0, }; uint32_t ff_squareTbl[512] = {0, }; @@ -144,6 +145,41 @@ } } +void ff_init_scantable_permutation(uint8_t *idct_permutation, + int idct_permutation_type) +{ + int i; + + switch(idct_permutation_type){ + case FF_NO_IDCT_PERM: + for(i=0; i<64; i++) + idct_permutation[i]= i; + break; + case FF_LIBMPEG2_IDCT_PERM: + for(i=0; i<64; i++) + idct_permutation[i]= (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2); + break; + case FF_SIMPLE_IDCT_PERM: + for(i=0; i<64; i++) + idct_permutation[i]= simple_mmx_permutation[i]; + break; + case FF_TRANSPOSE_IDCT_PERM: + for(i=0; i<64; i++) + idct_permutation[i]= ((i&7)<<3) | (i>>3); + break; + case FF_PARTTRANS_IDCT_PERM: + for(i=0; i<64; i++) + idct_permutation[i]= (i&0x24) | ((i&3)<<3) | ((i>>3)&3); + break; + case FF_SSE2_IDCT_PERM: + for(i=0; i<64; i++) + idct_permutation[i]= (i&0x38) | idct_sse2_row_perm[i&7]; + break; + default: + av_log(NULL, AV_LOG_ERROR, "Internal error, IDCT permutation not set\n"); + } +} + static int pix_sum_c(uint8_t * pix, int line_size) { int s, i, j; @@ -1293,6 +1329,51 @@ } #endif /* CONFIG_RV40_DECODER */ +#if CONFIG_DIRAC_DECODER +#define DIRAC_MC(OPNAME)\ +void ff_ ## OPNAME ## _dirac_pixels8_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\ +{\ + OPNAME ## _pixels8_8_c(dst, src[0], stride, h);\ +}\ +void ff_ ## OPNAME ## _dirac_pixels16_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\ +{\ + OPNAME ## _pixels16_8_c(dst, src[0], stride, h);\ +}\ +void ff_ ## OPNAME ## _dirac_pixels32_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\ +{\ + OPNAME ## _pixels16_8_c(dst , src[0] , stride, h);\ + OPNAME ## _pixels16_8_c(dst+16, src[0]+16, stride, h);\ +}\ +void ff_ ## OPNAME ## _dirac_pixels8_l2_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\ +{\ + OPNAME ## _pixels8_l2_8(dst, src[0], src[1], stride, stride, stride, h);\ +}\ +void ff_ ## OPNAME ## _dirac_pixels16_l2_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\ +{\ + OPNAME ## _pixels16_l2_8(dst, src[0], src[1], stride, stride, stride, h);\ +}\ +void ff_ ## OPNAME ## _dirac_pixels32_l2_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\ +{\ + OPNAME ## _pixels16_l2_8(dst , src[0] , src[1] , stride, stride, stride, h);\ + OPNAME ## _pixels16_l2_8(dst+16, src[0]+16, src[1]+16, stride, stride, stride, h);\ +}\ +void ff_ ## OPNAME ## _dirac_pixels8_l4_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\ +{\ + OPNAME ## _pixels8_l4_8(dst, src[0], src[1], src[2], src[3], stride, stride, stride, stride, stride, h);\ +}\ +void ff_ ## OPNAME ## _dirac_pixels16_l4_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\ +{\ + OPNAME ## _pixels16_l4_8(dst, src[0], src[1], src[2], src[3], stride, stride, stride, stride, stride, h);\ +}\ +void ff_ ## OPNAME ## _dirac_pixels32_l4_c(uint8_t *dst, const uint8_t *src[5], int stride, int h)\ +{\ + OPNAME ## _pixels16_l4_8(dst , src[0] , src[1] , src[2] , src[3] , stride, stride, stride, stride, stride, h);\ + OPNAME ## _pixels16_l4_8(dst+16, src[0]+16, src[1]+16, src[2]+16, src[3]+16, stride, stride, stride, stride, stride, h);\ +} +DIRAC_MC(put) +DIRAC_MC(avg) +#endif + static void wmv2_mspel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int w){ uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; int i; @@ -3107,32 +3188,6 @@ c->avg_2tap_qpel_pixels_tab[0][i]= c->avg_h264_qpel_pixels_tab[0][i]; } - switch(c->idct_permutation_type){ - case FF_NO_IDCT_PERM: - for(i=0; i<64; i++) - c->idct_permutation[i]= i; - break; - case FF_LIBMPEG2_IDCT_PERM: - for(i=0; i<64; i++) - c->idct_permutation[i]= (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2); - break; - case FF_SIMPLE_IDCT_PERM: - for(i=0; i<64; i++) - c->idct_permutation[i]= simple_mmx_permutation[i]; - break; - case FF_TRANSPOSE_IDCT_PERM: - for(i=0; i<64; i++) - c->idct_permutation[i]= ((i&7)<<3) | (i>>3); - break; - case FF_PARTTRANS_IDCT_PERM: - for(i=0; i<64; i++) - c->idct_permutation[i]= (i&0x24) | ((i&3)<<3) | ((i>>3)&3); - break; - case FF_SSE2_IDCT_PERM: - for(i=0; i<64; i++) - c->idct_permutation[i]= (i&0x38) | idct_sse2_row_perm[i&7]; - break; - default: - av_log(avctx, AV_LOG_ERROR, "Internal error, IDCT permutation not set\n"); - } + ff_init_scantable_permutation(c->idct_permutation, + c->idct_permutation_type); } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dsputil.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dsputil.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dsputil.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dsputil.h 2011-11-04 12:38:26.000000000 +0000 @@ -204,6 +204,8 @@ } ScanTable; void ff_init_scantable(uint8_t *, ScanTable *st, const uint8_t *src_scantable); +void ff_init_scantable_permutation(uint8_t *idct_permutation, + int idct_permutation_type); #define EMULATED_EDGE(depth) \ void ff_emulated_edge_mc_ ## depth (uint8_t *buf, const uint8_t *src, int linesize,\ @@ -477,8 +479,8 @@ * with the zigzag/alternate scan
* an example to avoid confusion: * - (->decode coeffs -> zigzag reorder -> dequant -> reference idct ->...) - * - (x -> referece dct -> reference idct -> x) - * - (x -> referece dct -> simple_mmx_perm = idct_permutation -> simple_idct_mmx -> x) + * - (x -> reference dct -> reference idct -> x) + * - (x -> reference dct -> simple_mmx_perm = idct_permutation -> simple_idct_mmx -> x) * - (->decode coeffs -> zigzag reorder -> simple_mmx_perm -> dequant -> simple_idct_mmx ->...) */ uint8_t idct_permutation[64]; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dvbsub.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dvbsub.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dvbsub.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dvbsub.c 2011-11-04 12:38:26.000000000 +0000 @@ -1,5 +1,5 @@ /* - * DVB subtitle encoding for ffmpeg + * DVB subtitle encoding * Copyright (c) 2005 Fabrice Bellard * * This file is part of FFmpeg. @@ -194,6 +194,61 @@ *pq = q; } +static void dvb_encode_rle8(uint8_t **pq, + const uint8_t *bitmap, int linesize, + int w, int h) +{ + uint8_t *q; + int x, y, len, x1, f, color; + + q = *pq; + + for (y = 0; y < h; y++) { + *q++ = 0x12; + + x = 0; + f = 0; + while (x < w) { + x1 = x; + color = bitmap[x1++]; + while (x1 < w && bitmap[x1] == color) + x1++; + len = x1 - x; + if (len == 1 && color) { + // 00000001 to 11111111 1 pixel in colour x + *q++ = color; + } else { + if (color == 0x00) { + // 00000000 0LLLLLLL L pixels (1-127) in colour 0 (L > 0) + len = FFMIN(len, 127); + *q++ = 0x00; + *q++ = len; + } else if (len > 2) { + // 00000000 1LLLLLLL CCCCCCCC L pixels (3-127) in colour C (L > 2) + len = FFMIN(len, 127); + *q++ = 0x00; + *q++ = 0x80+len; + *q++ = color; + } + else if (len == 2) { + *q++ = color; + *q++ = color; + } else { + *q++ = color; + len = 1; + } + } + x += len; + } + /* end of line */ + // 00000000 00000000 end of 8-bit/pixel_code_string + *q++ = 0x00; + *q++ = 0x00; + bitmap += linesize; + } + *pq = q; +} + static int encode_dvb_subtitles(DVBSubtitleContext *s, uint8_t *outbuf, AVSubtitle *h) { @@ -245,10 +300,15 @@ } else if (h->rects[clut_id]->nb_colors <= 16) { /* 4 bpp, standard encoding */ bpp_index = 1; + } else if (h->rects[clut_id]->nb_colors <= 256) { + /* 8 bpp, standard encoding */ + bpp_index = 2; } else { return -1; } + + /* CLUT segment */ *q++ = 0x0f; /* sync byte */ *q++ = 0x12; /* CLUT definition segment */ bytestream_put_be16(&q, page_id); @@ -321,18 +381,25 @@ if (!s->hide_state) { for (object_id = 0; object_id < h->num_rects; object_id++) { - /* Object Data segment */ + void (*dvb_encode_rle)(uint8_t **pq, + const uint8_t *bitmap, int linesize, + int w, int h); + /* bpp_index maths */ if (h->rects[object_id]->nb_colors <= 4) { /* 2 bpp, some decoders do not support it correctly */ - bpp_index = 0; + dvb_encode_rle = dvb_encode_rle2; } else if (h->rects[object_id]->nb_colors <= 16) { /* 4 bpp, standard encoding */ - bpp_index = 1; + dvb_encode_rle = dvb_encode_rle4; + } else if (h->rects[object_id]->nb_colors <= 256) { + /* 8 bpp, standard encoding */ + dvb_encode_rle = dvb_encode_rle8; } else { return -1; } + /* Object Data segment */ *q++ = 0x0f; /* sync byte */ *q++ = 0x13; bytestream_put_be16(&q, page_id); @@ -345,19 +412,12 @@ non_modifying_color_flag */ { uint8_t *ptop_field_len, *pbottom_field_len, *top_ptr, *bottom_ptr; - void (*dvb_encode_rle)(uint8_t **pq, - const uint8_t *bitmap, int linesize, - int w, int h); + ptop_field_len = q; q += 2; pbottom_field_len = q; q += 2; - if (bpp_index == 0) - dvb_encode_rle = dvb_encode_rle2; - else - dvb_encode_rle = dvb_encode_rle4; - top_ptr = q; dvb_encode_rle(&q, h->rects[object_id]->pict.data[0], h->rects[object_id]->w * 2, h->rects[object_id]->w, h->rects[object_id]->h >> 1); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dvbsubdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dvbsubdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dvbsubdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dvbsubdec.c 2011-11-04 12:38:26.000000000 +0000 @@ -1,5 +1,5 @@ /* - * DVB subtitle decoding for ffmpeg + * DVB subtitle decoding * Copyright (c) 2005 Ian Caulfield * * This file is part of FFmpeg. @@ -154,6 +154,7 @@ typedef struct DVBSubCLUT { int id; + int version; uint32_t clut4[4]; uint32_t clut16[16]; @@ -180,6 +181,7 @@ typedef struct DVBSubObject { int id; + int version; int type; @@ -199,6 +201,7 @@ typedef struct DVBSubRegion { int id; + int version; int width; int height; @@ -209,6 +212,7 @@ uint8_t *pbuf; int buf_size; + int dirty; DVBSubObjectDisplay *display_list; @@ -228,6 +232,7 @@ int composition_id; int ancillary_id; + int version; int time_out; DVBSubRegion *region_list; DVBSubCLUT *clut_list; @@ -374,6 +379,8 @@ ctx->ancillary_id = AV_RB16(avctx->extradata + 2); } + ctx->version = -1; + default_clut.id = -1; default_clut.next = NULL; @@ -462,16 +469,18 @@ static int dvbsub_read_2bit_string(uint8_t *destbuf, int dbuf_len, const uint8_t **srcbuf, int buf_size, - int non_mod, uint8_t *map_table) + int non_mod, uint8_t *map_table, int x_pos) { GetBitContext gb; int bits; int run_length; - int pixels_read = 0; + int pixels_read = x_pos; init_get_bits(&gb, *srcbuf, buf_size << 3); + destbuf += x_pos; + while (get_bits_count(&gb) < buf_size << 3 && pixels_read < dbuf_len) { bits = get_bits(&gb, 2); @@ -532,14 +541,14 @@ } } } else if (bits == 1) { - pixels_read += 2; if (map_table) bits = map_table[0]; else bits = 0; - if (pixels_read <= dbuf_len) { - *destbuf++ = bits; + run_length = 2; + while (run_length-- > 0 && pixels_read < dbuf_len) { *destbuf++ = bits; + pixels_read++; } } else { (*srcbuf) += (get_bits_count(&gb) + 7) >> 3; @@ -567,16 +576,18 @@ static int dvbsub_read_4bit_string(uint8_t *destbuf, int dbuf_len, const uint8_t **srcbuf, int buf_size, - int non_mod, uint8_t *map_table) + int non_mod, uint8_t *map_table, int x_pos) { GetBitContext gb; int bits; int run_length; - int pixels_read = 0; + int pixels_read = x_pos; init_get_bits(&gb, *srcbuf, buf_size << 3); + destbuf += x_pos; + while (get_bits_count(&gb) < buf_size << 3 && pixels_read < dbuf_len) { bits = get_bits(&gb, 4); @@ -656,14 +667,14 @@ } } } else if (bits == 1) { - pixels_read += 2; if (map_table) bits = map_table[0]; else bits = 0; - if (pixels_read <= dbuf_len) { - *destbuf++ = bits; + run_length = 2; + while (run_length-- > 0 && pixels_read < dbuf_len) { *destbuf++ = bits; + pixels_read++; } } else { if (map_table) @@ -688,12 +699,14 @@ static int dvbsub_read_8bit_string(uint8_t *destbuf, int dbuf_len, const uint8_t **srcbuf, int buf_size, - int non_mod, uint8_t *map_table) + int non_mod, uint8_t *map_table, int x_pos) { const uint8_t *sbuf_end = (*srcbuf) + buf_size; int bits; int run_length; - int pixels_read = 0; + int pixels_read = x_pos; + + destbuf += x_pos; while (*srcbuf < sbuf_end && pixels_read < dbuf_len) { bits = *(*srcbuf)++; @@ -762,6 +775,7 @@ 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}; uint8_t *map_table; +#if 0 av_dlog(avctx, "DVB pixel block size %d, %s field:\n", buf_size, top_bottom ? "bottom" : "top"); @@ -776,21 +790,22 @@ if (i % 16) av_dlog(avctx, "\n"); +#endif if (region == 0) return; pbuf = region->pbuf; + region->dirty = 1; x_pos = display->x_pos; y_pos = display->y_pos; - if ((y_pos & 1) != top_bottom) - y_pos++; + y_pos += top_bottom; while (buf < buf_end) { - if (x_pos > region->width || y_pos > region->height) { - av_log(avctx, AV_LOG_ERROR, "Invalid object location!\n"); + if ((*buf!=0xf0 && x_pos >= region->width) || y_pos >= region->height) { + av_log(avctx, AV_LOG_ERROR, "Invalid object location! %d-%d %d-%d %02x\n", x_pos, region->width, y_pos, region->height, *buf); return; } @@ -803,9 +818,9 @@ else map_table = NULL; - x_pos += dvbsub_read_2bit_string(pbuf + (y_pos * region->width) + x_pos, - region->width - x_pos, &buf, buf_end - buf, - non_mod, map_table); + x_pos = dvbsub_read_2bit_string(pbuf + (y_pos * region->width), + region->width, &buf, buf_end - buf, + non_mod, map_table, x_pos); break; case 0x11: if (region->depth < 4) { @@ -818,9 +833,9 @@ else map_table = NULL; - x_pos += dvbsub_read_4bit_string(pbuf + (y_pos * region->width) + x_pos, - region->width - x_pos, &buf, buf_end - buf, - non_mod, map_table); + x_pos = dvbsub_read_4bit_string(pbuf + (y_pos * region->width), + region->width, &buf, buf_end - buf, + non_mod, map_table, x_pos); break; case 0x12: if (region->depth < 8) { @@ -828,9 +843,9 @@ return; } - x_pos += dvbsub_read_8bit_string(pbuf + (y_pos * region->width) + x_pos, - region->width - x_pos, &buf, buf_end - buf, - non_mod, NULL); + x_pos = dvbsub_read_8bit_string(pbuf + (y_pos * region->width), + region->width, &buf, buf_end - buf, + non_mod, NULL, x_pos); break; case 0x20: @@ -865,7 +880,6 @@ DVBSubContext *ctx = avctx->priv_data; const uint8_t *buf_end = buf + buf_size; - const uint8_t *block; int object_id; DVBSubObject *object; DVBSubObjectDisplay *display; @@ -896,7 +910,8 @@ } for (display = object->display_list; display; display = display->object_list_next) { - block = buf; + const uint8_t *block = buf; + int bfl = bottom_field_len; dvbsub_parse_pixel_data_block(avctx, display, block, top_field_len, 0, non_modifying_color); @@ -904,9 +919,9 @@ if (bottom_field_len > 0) block = buf + top_field_len; else - bottom_field_len = top_field_len; + bfl = top_field_len; - dvbsub_parse_pixel_data_block(avctx, display, block, bottom_field_len, 1, + dvbsub_parse_pixel_data_block(avctx, display, block, bfl, 1, non_modifying_color); } @@ -925,6 +940,7 @@ const uint8_t *buf_end = buf + buf_size; int i, clut_id; + int version; DVBSubCLUT *clut; int entry_id, depth , full_range; int y, cr, cb, alpha; @@ -942,6 +958,7 @@ av_dlog(avctx, "\n"); clut_id = *buf++; + version = ((*buf)>>4)&15; buf += 1; clut = get_clut(ctx, clut_id); @@ -952,11 +969,16 @@ memcpy(clut, &default_clut, sizeof(DVBSubCLUT)); clut->id = clut_id; + clut->version = -1; clut->next = ctx->clut_list; ctx->clut_list = clut; } + if (clut->version != version) { + + clut->version = version; + while (buf + 4 < buf_end) { entry_id = *buf++; @@ -998,6 +1020,7 @@ if (depth & 0x20) clut->clut256[entry_id] = RGBA(r,g,b,255 - alpha); } + } } @@ -1008,6 +1031,7 @@ const uint8_t *buf_end = buf + buf_size; int region_id, object_id; + int version; DVBSubRegion *region; DVBSubObject *object; DVBSubObjectDisplay *display; @@ -1024,11 +1048,13 @@ region = av_mallocz(sizeof(DVBSubRegion)); region->id = region_id; + region->version = -1; region->next = ctx->region_list; ctx->region_list = region; } + version = ((*buf)>>4) & 15; fill = ((*buf++) >> 3) & 1; region->width = AV_RB16(buf); @@ -1044,6 +1070,7 @@ region->pbuf = av_malloc(region->buf_size); fill = 1; + region->dirty = 0; } region->depth = 1 << (((*buf++) >> 2) & 7); @@ -1053,9 +1080,10 @@ } region->clut = *buf++; - if (region->depth == 8) + if (region->depth == 8) { region->bgcolor = *buf++; - else { + buf += 1; + } else { buf += 1; if (region->depth == 4) @@ -1122,16 +1150,24 @@ const uint8_t *buf_end = buf + buf_size; int region_id; int page_state; + int timeout; + int version; if (buf_size < 1) return; - ctx->time_out = *buf++; + timeout = *buf++; + version = ((*buf)>>4) & 15; page_state = ((*buf++) >> 2) & 3; + if (ctx->version != version) { + + ctx->time_out = timeout; + ctx->version = version; + av_dlog(avctx, "Page time out %ds, state %d\n", ctx->time_out, page_state); - if (page_state == 2) { + if (page_state == 1 || page_state == 2) { delete_regions(ctx); delete_objects(ctx); delete_cluts(ctx); @@ -1179,6 +1215,7 @@ av_free(display); } + } } @@ -1345,17 +1382,19 @@ sub->rects = av_mallocz(sizeof(*sub->rects) * sub->num_rects); for(i=0; inum_rects; i++) sub->rects[i] = av_mallocz(sizeof(*sub->rects[i])); - } i = 0; for (display = ctx->display_list; display; display = display->next) { region = get_region(ctx, display->region_id); - rect = sub->rects[i]; if (!region) continue; + if (!region->dirty) + continue; + + rect = sub->rects[i]; rect->x = display->x_pos + offset_x; rect->y = display->y_pos + offset_y; rect->w = region->width; @@ -1392,7 +1431,7 @@ } sub->num_rects = i; - + } #ifdef DEBUG save_display_set(ctx); #endif diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dvbsub_parser.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dvbsub_parser.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dvbsub_parser.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dvbsub_parser.c 2011-11-04 12:38:26.000000000 +0000 @@ -172,9 +172,9 @@ } AVCodecParser ff_dvbsub_parser = { - { CODEC_ID_DVB_SUBTITLE }, - sizeof(DVBSubParseContext), - dvbsub_parse_init, - dvbsub_parse, - dvbsub_parse_close, + .codec_ids = { CODEC_ID_DVB_SUBTITLE }, + .priv_data_size = sizeof(DVBSubParseContext), + .parser_init = dvbsub_parse_init, + .parser_parse = dvbsub_parse, + .parser_close = dvbsub_parse_close, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dv.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dv.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dv.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dv.c 2011-11-04 12:38:26.000000000 +0000 @@ -349,7 +349,7 @@ static av_cold int dvvideo_init_encoder(AVCodecContext *avctx) { - if (!ff_dv_codec_profile(avctx)) { + if (!avpriv_dv_codec_profile(avctx)) { av_log(avctx, AV_LOG_ERROR, "Found no DV profile for %ix%i %s video\n", avctx->width, avctx->height, av_get_pix_fmt_name(avctx->pix_fmt)); return -1; @@ -1072,7 +1072,7 @@ const uint8_t* vsc_pack; int apt, is16_9; - s->sys = ff_dv_frame_profile2(avctx, s->sys, buf, buf_size); + s->sys = avpriv_dv_frame_profile2(avctx, s->sys, buf, buf_size); if (!s->sys || buf_size < s->sys->frame_size || dv_init_dynamic_tables(s->sys)) { av_log(avctx, AV_LOG_ERROR, "could not find dv frame profile\n"); return -1; /* NOTE: we only accept several full frames */ @@ -1246,7 +1246,7 @@ { DVVideoContext *s = c->priv_data; - s->sys = ff_dv_codec_profile(c); + s->sys = avpriv_dv_codec_profile(c); if (!s->sys || buf_size < s->sys->frame_size || dv_init_dynamic_tables(s->sys)) return -1; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dvdata.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dvdata.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dvdata.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dvdata.c 2011-11-04 12:38:26.000000000 +0000 @@ -246,7 +246,7 @@ } }; -const DVprofile* ff_dv_frame_profile2(AVCodecContext* codec, const DVprofile *sys, +const DVprofile* avpriv_dv_frame_profile2(AVCodecContext* codec, const DVprofile *sys, const uint8_t* frame, unsigned buf_size) { int i, dsf, stype; @@ -276,13 +276,13 @@ return NULL; } -const DVprofile* ff_dv_frame_profile(const DVprofile *sys, +const DVprofile* avpriv_dv_frame_profile(const DVprofile *sys, const uint8_t* frame, unsigned buf_size) { - return ff_dv_frame_profile2(NULL, sys, frame, buf_size); + return avpriv_dv_frame_profile2(NULL, sys, frame, buf_size); } -const DVprofile* ff_dv_codec_profile(AVCodecContext* codec) +const DVprofile* avpriv_dv_codec_profile(AVCodecContext* codec) { int i; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dvdata.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dvdata.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dvdata.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dvdata.h 2011-11-04 12:38:26.000000000 +0000 @@ -274,11 +274,11 @@ */ #define DV_MAX_BPM 8 -const DVprofile* ff_dv_frame_profile(const DVprofile *sys, +const DVprofile* avpriv_dv_frame_profile(const DVprofile *sys, const uint8_t* frame, unsigned buf_size); -const DVprofile* ff_dv_frame_profile2(AVCodecContext* codec, const DVprofile *sys, +const DVprofile* avpriv_dv_frame_profile2(AVCodecContext* codec, const DVprofile *sys, const uint8_t* frame, unsigned buf_size); -const DVprofile* ff_dv_codec_profile(AVCodecContext* codec); +const DVprofile* avpriv_dv_codec_profile(AVCodecContext* codec); static inline int dv_write_dif_id(enum dv_section_type t, uint8_t chan_num, uint8_t seq_num, uint8_t dif_num, diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dvdsubdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dvdsubdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dvdsubdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dvdsubdec.c 2011-11-04 12:38:26.000000000 +0000 @@ -1,5 +1,5 @@ /* - * DVD subtitle decoding for ffmpeg + * DVD subtitle decoding * Copyright (c) 2005 Fabrice Bellard * * This file is part of FFmpeg. diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dvdsubenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dvdsubenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dvdsubenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dvdsubenc.c 2011-11-04 12:38:26.000000000 +0000 @@ -1,5 +1,5 @@ /* - * DVD subtitle encoding for ffmpeg + * DVD subtitle encoding * Copyright (c) 2005 Wolfram Gloger * * This file is part of FFmpeg. diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dvdsub_parser.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dvdsub_parser.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dvdsub_parser.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dvdsub_parser.c 2011-11-04 12:38:26.000000000 +0000 @@ -1,5 +1,5 @@ /* - * DVD subtitle decoding for ffmpeg + * DVD subtitle decoding * Copyright (c) 2005 Fabrice Bellard * * This file is part of FFmpeg. @@ -77,9 +77,9 @@ } AVCodecParser ff_dvdsub_parser = { - { CODEC_ID_DVD_SUBTITLE }, - sizeof(DVDSubParseContext), - dvdsub_parse_init, - dvdsub_parse, - dvdsub_parse_close, + .codec_ids = { CODEC_ID_DVD_SUBTITLE }, + .priv_data_size = sizeof(DVDSubParseContext), + .parser_init = dvdsub_parse_init, + .parser_parse = dvdsub_parse, + .parser_close = dvdsub_parse_close, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dwt.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dwt.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dwt.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dwt.c 2011-11-04 12:38:26.000000000 +0000 @@ -1,5 +1,6 @@ /* * Copyright (C) 2004-2010 Michael Niedermayer + * Copyright (C) 2008 David Conrad * * This file is part of FFmpeg. * @@ -21,6 +22,7 @@ #include "libavutil/attributes.h" #include "dsputil.h" #include "dwt.h" +#include "libavcodec/x86/dwt.h" void ff_slice_buffer_init(slice_buffer * buf, int line_count, int max_allocated_lines, int line_width, IDWTELEM * base_buffer) { @@ -841,3 +843,541 @@ if (HAVE_MMX) ff_dwt_init_x86(c); } + + +static av_always_inline +void interleave(IDWTELEM *dst, IDWTELEM *src0, IDWTELEM *src1, int w2, int add, int shift) +{ + int i; + for (i = 0; i < w2; i++) { + dst[2*i ] = (src0[i] + add) >> shift; + dst[2*i+1] = (src1[i] + add) >> shift; + } +} + +static void horizontal_compose_dirac53i(IDWTELEM *b, IDWTELEM *temp, int w) +{ + const int w2 = w >> 1; + int x; + + temp[0] = COMPOSE_53iL0(b[w2], b[0], b[w2]); + for (x = 1; x < w2; x++) { + temp[x ] = COMPOSE_53iL0 (b[x+w2-1], b[x ], b[x+w2]); + temp[x+w2-1] = COMPOSE_DIRAC53iH0(temp[x-1], b[x+w2-1], temp[x]); + } + temp[w-1] = COMPOSE_DIRAC53iH0(temp[w2-1], b[w-1], temp[w2-1]); + + interleave(b, temp, temp+w2, w2, 1, 1); +} + +static void horizontal_compose_dd97i(IDWTELEM *b, IDWTELEM *tmp, int w) +{ + const int w2 = w >> 1; + int x; + + tmp[0] = COMPOSE_53iL0(b[w2], b[0], b[w2]); + for (x = 1; x < w2; x++) + tmp[x] = COMPOSE_53iL0(b[x+w2-1], b[x], b[x+w2]); + + // extend the edges + tmp[-1] = tmp[0]; + tmp[w2+1] = tmp[w2] = tmp[w2-1]; + + for (x = 0; x < w2; x++) { + b[2*x ] = (tmp[x] + 1)>>1; + b[2*x+1] = (COMPOSE_DD97iH0(tmp[x-1], tmp[x], b[x+w2], tmp[x+1], tmp[x+2]) + 1)>>1; + } +} + +static void horizontal_compose_dd137i(IDWTELEM *b, IDWTELEM *tmp, int w) +{ + const int w2 = w >> 1; + int x; + + tmp[0] = COMPOSE_DD137iL0(b[w2], b[w2], b[0], b[w2 ], b[w2+1]); + tmp[1] = COMPOSE_DD137iL0(b[w2], b[w2], b[1], b[w2+1], b[w2+2]); + for (x = 2; x < w2-1; x++) + tmp[x] = COMPOSE_DD137iL0(b[x+w2-2], b[x+w2-1], b[x], b[x+w2], b[x+w2+1]); + tmp[w2-1] = COMPOSE_DD137iL0(b[w-3], b[w-2], b[w2-1], b[w-1], b[w-1]); + + // extend the edges + tmp[-1] = tmp[0]; + tmp[w2+1] = tmp[w2] = tmp[w2-1]; + + for (x = 0; x < w2; x++) { + b[2*x ] = (tmp[x] + 1)>>1; + b[2*x+1] = (COMPOSE_DD97iH0(tmp[x-1], tmp[x], b[x+w2], tmp[x+1], tmp[x+2]) + 1)>>1; + } +} + +static av_always_inline +void horizontal_compose_haari(IDWTELEM *b, IDWTELEM *temp, int w, int shift) +{ + const int w2 = w >> 1; + int x; + + for (x = 0; x < w2; x++) { + temp[x ] = COMPOSE_HAARiL0(b[x ], b[x+w2]); + temp[x+w2] = COMPOSE_HAARiH0(b[x+w2], temp[x]); + } + + interleave(b, temp, temp+w2, w2, shift, shift); +} + +static void horizontal_compose_haar0i(IDWTELEM *b, IDWTELEM *temp, int w) +{ + horizontal_compose_haari(b, temp, w, 0); +} + +static void horizontal_compose_haar1i(IDWTELEM *b, IDWTELEM *temp, int w) +{ + horizontal_compose_haari(b, temp, w, 1); +} + +static void horizontal_compose_fidelityi(IDWTELEM *b, IDWTELEM *tmp, int w) +{ + const int w2 = w >> 1; + int i, x; + IDWTELEM v[8]; + + for (x = 0; x < w2; x++) { + for (i = 0; i < 8; i++) + v[i] = b[av_clip(x-3+i, 0, w2-1)]; + tmp[x] = COMPOSE_FIDELITYiH0(v[0], v[1], v[2], v[3], b[x+w2], v[4], v[5], v[6], v[7]); + } + + for (x = 0; x < w2; x++) { + for (i = 0; i < 8; i++) + v[i] = tmp[av_clip(x-4+i, 0, w2-1)]; + tmp[x+w2] = COMPOSE_FIDELITYiL0(v[0], v[1], v[2], v[3], b[x], v[4], v[5], v[6], v[7]); + } + + interleave(b, tmp+w2, tmp, w2, 0, 0); +} + +static void horizontal_compose_daub97i(IDWTELEM *b, IDWTELEM *temp, int w) +{ + const int w2 = w >> 1; + int x, b0, b1, b2; + + temp[0] = COMPOSE_DAUB97iL1(b[w2], b[0], b[w2]); + for (x = 1; x < w2; x++) { + temp[x ] = COMPOSE_DAUB97iL1(b[x+w2-1], b[x ], b[x+w2]); + temp[x+w2-1] = COMPOSE_DAUB97iH1(temp[x-1], b[x+w2-1], temp[x]); + } + temp[w-1] = COMPOSE_DAUB97iH1(temp[w2-1], b[w-1], temp[w2-1]); + + // second stage combined with interleave and shift + b0 = b2 = COMPOSE_DAUB97iL0(temp[w2], temp[0], temp[w2]); + b[0] = (b0 + 1) >> 1; + for (x = 1; x < w2; x++) { + b2 = COMPOSE_DAUB97iL0(temp[x+w2-1], temp[x ], temp[x+w2]); + b1 = COMPOSE_DAUB97iH0( b0, temp[x+w2-1], b2 ); + b[2*x-1] = (b1 + 1) >> 1; + b[2*x ] = (b2 + 1) >> 1; + b0 = b2; + } + b[w-1] = (COMPOSE_DAUB97iH0(b2, temp[w-1], b2) + 1) >> 1; +} + +static void vertical_compose_dirac53iH0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width) +{ + int i; + + for(i=0; ivertical_compose_l0; + vertical_compose_5tap vertical_compose_h0 = d->vertical_compose_h0; + DWTCompose *cs = d->cs + level; + + int i, y = cs->y; + IDWTELEM *b[8]; + for (i = 0; i < 6; i++) + b[i] = cs->b[i]; + b[6] = d->buffer + av_clip(y+5, 0, height-2)*stride; + b[7] = d->buffer + av_clip(y+6, 1, height-1)*stride; + + if(y+5<(unsigned)height) vertical_compose_l0( b[5], b[6], b[7], width); + if(y+1<(unsigned)height) vertical_compose_h0(b[0], b[2], b[3], b[4], b[6], width); + + if(y-1<(unsigned)height) d->horizontal_compose(b[0], d->temp, width); + if(y+0<(unsigned)height) d->horizontal_compose(b[1], d->temp, width); + + for (i = 0; i < 6; i++) + cs->b[i] = b[i+2]; + cs->y += 2; +} + +static void spatial_compose_dirac53i_dy(DWTContext *d, int level, int width, int height, int stride) +{ + vertical_compose_3tap vertical_compose_l0 = d->vertical_compose_l0; + vertical_compose_3tap vertical_compose_h0 = d->vertical_compose_h0; + DWTCompose *cs = d->cs + level; + + int y= cs->y; + IDWTELEM *b[4] = { cs->b[0], cs->b[1] }; + b[2] = d->buffer + mirror(y+1, height-1)*stride; + b[3] = d->buffer + mirror(y+2, height-1)*stride; + + if(y+1<(unsigned)height) vertical_compose_l0(b[1], b[2], b[3], width); + if(y+0<(unsigned)height) vertical_compose_h0(b[0], b[1], b[2], width); + + if(y-1<(unsigned)height) d->horizontal_compose(b[0], d->temp, width); + if(y+0<(unsigned)height) d->horizontal_compose(b[1], d->temp, width); + + cs->b[0] = b[2]; + cs->b[1] = b[3]; + cs->y += 2; +} + + +static void spatial_compose_dd137i_dy(DWTContext *d, int level, int width, int height, int stride) +{ + vertical_compose_5tap vertical_compose_l0 = d->vertical_compose_l0; + vertical_compose_5tap vertical_compose_h0 = d->vertical_compose_h0; + DWTCompose *cs = d->cs + level; + + int i, y = cs->y; + IDWTELEM *b[10]; + for (i = 0; i < 8; i++) + b[i] = cs->b[i]; + b[8] = d->buffer + av_clip(y+7, 0, height-2)*stride; + b[9] = d->buffer + av_clip(y+8, 1, height-1)*stride; + + if(y+5<(unsigned)height) vertical_compose_l0(b[3], b[5], b[6], b[7], b[9], width); + if(y+1<(unsigned)height) vertical_compose_h0(b[0], b[2], b[3], b[4], b[6], width); + + if(y-1<(unsigned)height) d->horizontal_compose(b[0], d->temp, width); + if(y+0<(unsigned)height) d->horizontal_compose(b[1], d->temp, width); + + for (i = 0; i < 8; i++) + cs->b[i] = b[i+2]; + cs->y += 2; +} + +// haar makes the assumption that height is even (always true for dirac) +static void spatial_compose_haari_dy(DWTContext *d, int level, int width, int height, int stride) +{ + vertical_compose_2tap vertical_compose = d->vertical_compose; + int y = d->cs[level].y; + IDWTELEM *b0 = d->buffer + (y-1)*stride; + IDWTELEM *b1 = d->buffer + (y )*stride; + + vertical_compose(b0, b1, width); + d->horizontal_compose(b0, d->temp, width); + d->horizontal_compose(b1, d->temp, width); + + d->cs[level].y += 2; +} + +// Don't do sliced idwt for fidelity; the 9 tap filter makes it a bit annoying +// Fortunately, this filter isn't used in practice. +static void spatial_compose_fidelity(DWTContext *d, int level, int width, int height, int stride) +{ + vertical_compose_9tap vertical_compose_l0 = d->vertical_compose_l0; + vertical_compose_9tap vertical_compose_h0 = d->vertical_compose_h0; + int i, y; + IDWTELEM *b[8]; + + for (y = 1; y < height; y += 2) { + for (i = 0; i < 8; i++) + b[i] = d->buffer + av_clip((y-7 + 2*i), 0, height-2)*stride; + vertical_compose_h0(d->buffer + y*stride, b, width); + } + + for (y = 0; y < height; y += 2) { + for (i = 0; i < 8; i++) + b[i] = d->buffer + av_clip((y-7 + 2*i), 1, height-1)*stride; + vertical_compose_l0(d->buffer + y*stride, b, width); + } + + for (y = 0; y < height; y++) + d->horizontal_compose(d->buffer + y*stride, d->temp, width); + + d->cs[level].y = height+1; +} + +static void spatial_compose_daub97i_dy(DWTContext *d, int level, int width, int height, int stride) +{ + vertical_compose_3tap vertical_compose_l0 = d->vertical_compose_l0; + vertical_compose_3tap vertical_compose_h0 = d->vertical_compose_h0; + vertical_compose_3tap vertical_compose_l1 = d->vertical_compose_l1; + vertical_compose_3tap vertical_compose_h1 = d->vertical_compose_h1; + DWTCompose *cs = d->cs + level; + + int i, y = cs->y; + IDWTELEM *b[6]; + for (i = 0; i < 4; i++) + b[i] = cs->b[i]; + b[4] = d->buffer + mirror(y+3, height-1)*stride; + b[5] = d->buffer + mirror(y+4, height-1)*stride; + + if(y+3<(unsigned)height) vertical_compose_l1(b[3], b[4], b[5], width); + if(y+2<(unsigned)height) vertical_compose_h1(b[2], b[3], b[4], width); + if(y+1<(unsigned)height) vertical_compose_l0(b[1], b[2], b[3], width); + if(y+0<(unsigned)height) vertical_compose_h0(b[0], b[1], b[2], width); + + if(y-1<(unsigned)height) d->horizontal_compose(b[0], d->temp, width); + if(y+0<(unsigned)height) d->horizontal_compose(b[1], d->temp, width); + + for (i = 0; i < 4; i++) + cs->b[i] = b[i+2]; + cs->y += 2; +} + + +static void spatial_compose97i_init2(DWTCompose *cs, IDWTELEM *buffer, int height, int stride) +{ + cs->b[0] = buffer + mirror(-3-1, height-1)*stride; + cs->b[1] = buffer + mirror(-3 , height-1)*stride; + cs->b[2] = buffer + mirror(-3+1, height-1)*stride; + cs->b[3] = buffer + mirror(-3+2, height-1)*stride; + cs->y = -3; +} + +static void spatial_compose53i_init2(DWTCompose *cs, IDWTELEM *buffer, int height, int stride) +{ + cs->b[0] = buffer + mirror(-1-1, height-1)*stride; + cs->b[1] = buffer + mirror(-1 , height-1)*stride; + cs->y = -1; +} + +static void spatial_compose_dd97i_init(DWTCompose *cs, IDWTELEM *buffer, int height, int stride) +{ + cs->b[0] = buffer + av_clip(-5-1, 0, height-2)*stride; + cs->b[1] = buffer + av_clip(-5 , 1, height-1)*stride; + cs->b[2] = buffer + av_clip(-5+1, 0, height-2)*stride; + cs->b[3] = buffer + av_clip(-5+2, 1, height-1)*stride; + cs->b[4] = buffer + av_clip(-5+3, 0, height-2)*stride; + cs->b[5] = buffer + av_clip(-5+4, 1, height-1)*stride; + cs->y = -5; +} + +static void spatial_compose_dd137i_init(DWTCompose *cs, IDWTELEM *buffer, int height, int stride) +{ + cs->b[0] = buffer + av_clip(-5-1, 0, height-2)*stride; + cs->b[1] = buffer + av_clip(-5 , 1, height-1)*stride; + cs->b[2] = buffer + av_clip(-5+1, 0, height-2)*stride; + cs->b[3] = buffer + av_clip(-5+2, 1, height-1)*stride; + cs->b[4] = buffer + av_clip(-5+3, 0, height-2)*stride; + cs->b[5] = buffer + av_clip(-5+4, 1, height-1)*stride; + cs->b[6] = buffer + av_clip(-5+5, 0, height-2)*stride; + cs->b[7] = buffer + av_clip(-5+6, 1, height-1)*stride; + cs->y = -5; +} + +int ff_spatial_idwt_init2(DWTContext *d, IDWTELEM *buffer, int width, int height, + int stride, enum dwt_type type, int decomposition_count, + IDWTELEM *temp) +{ + int level; + + d->buffer = buffer; + d->width = width; + d->height = height; + d->stride = stride; + d->decomposition_count = decomposition_count; + d->temp = temp + 8; + + for(level=decomposition_count-1; level>=0; level--){ + int hl = height >> level; + int stride_l = stride << level; + + switch(type){ + case DWT_DIRAC_DD9_7: + spatial_compose_dd97i_init(d->cs+level, buffer, hl, stride_l); + break; + case DWT_DIRAC_LEGALL5_3: + spatial_compose53i_init2(d->cs+level, buffer, hl, stride_l); + break; + case DWT_DIRAC_DD13_7: + spatial_compose_dd137i_init(d->cs+level, buffer, hl, stride_l); + break; + case DWT_DIRAC_HAAR0: + case DWT_DIRAC_HAAR1: + d->cs[level].y = 1; + break; + case DWT_DIRAC_DAUB9_7: + spatial_compose97i_init2(d->cs+level, buffer, hl, stride_l); + break; + default: + d->cs[level].y = 0; + break; + } + } + + switch (type) { + case DWT_DIRAC_DD9_7: + d->spatial_compose = spatial_compose_dd97i_dy; + d->vertical_compose_l0 = vertical_compose53iL0; + d->vertical_compose_h0 = vertical_compose_dd97iH0; + d->horizontal_compose = horizontal_compose_dd97i; + d->support = 7; + break; + case DWT_DIRAC_LEGALL5_3: + d->spatial_compose = spatial_compose_dirac53i_dy; + d->vertical_compose_l0 = vertical_compose53iL0; + d->vertical_compose_h0 = vertical_compose_dirac53iH0; + d->horizontal_compose = horizontal_compose_dirac53i; + d->support = 3; + break; + case DWT_DIRAC_DD13_7: + d->spatial_compose = spatial_compose_dd137i_dy; + d->vertical_compose_l0 = vertical_compose_dd137iL0; + d->vertical_compose_h0 = vertical_compose_dd97iH0; + d->horizontal_compose = horizontal_compose_dd137i; + d->support = 7; + break; + case DWT_DIRAC_HAAR0: + case DWT_DIRAC_HAAR1: + d->spatial_compose = spatial_compose_haari_dy; + d->vertical_compose = vertical_compose_haar; + if (type == DWT_DIRAC_HAAR0) + d->horizontal_compose = horizontal_compose_haar0i; + else + d->horizontal_compose = horizontal_compose_haar1i; + d->support = 1; + break; + case DWT_DIRAC_FIDELITY: + d->spatial_compose = spatial_compose_fidelity; + d->vertical_compose_l0 = vertical_compose_fidelityiL0; + d->vertical_compose_h0 = vertical_compose_fidelityiH0; + d->horizontal_compose = horizontal_compose_fidelityi; + break; + case DWT_DIRAC_DAUB9_7: + d->spatial_compose = spatial_compose_daub97i_dy; + d->vertical_compose_l0 = vertical_compose_daub97iL0; + d->vertical_compose_h0 = vertical_compose_daub97iH0; + d->vertical_compose_l1 = vertical_compose_daub97iL1; + d->vertical_compose_h1 = vertical_compose_daub97iH1; + d->horizontal_compose = horizontal_compose_daub97i; + d->support = 5; + break; + default: + av_log(NULL, AV_LOG_ERROR, "Unknown wavelet type %d\n", type); + return -1; + } + + if (HAVE_MMX) ff_spatial_idwt_init_mmx(d, type); + + return 0; +} + +void ff_spatial_idwt_slice2(DWTContext *d, int y) +{ + int level, support = d->support; + + for (level = d->decomposition_count-1; level >= 0; level--) { + int wl = d->width >> level; + int hl = d->height >> level; + int stride_l = d->stride << level; + + while (d->cs[level].y <= FFMIN((y>>level)+support, hl)) + d->spatial_compose(d, level, wl, hl, stride_l); + } +} + +int ff_spatial_idwt2(IDWTELEM *buffer, int width, int height, int stride, + enum dwt_type type, int decomposition_count, IDWTELEM *temp) +{ + DWTContext d; + int y; + + if (ff_spatial_idwt_init2(&d, buffer, width, height, stride, type, decomposition_count, temp)) + return -1; + + for (y = 0; y < d.height; y += 4) + ff_spatial_idwt_slice2(&d, y); + + return 0; +} diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dwt.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dwt.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/dwt.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/dwt.h 2011-11-04 12:38:26.000000000 +0000 @@ -26,7 +26,12 @@ typedef int DWTELEM; typedef short IDWTELEM; +#define MAX_DWT_SUPPORT 8 +#define MAX_DECOMPOSITIONS 8 + typedef struct { + IDWTELEM *b[MAX_DWT_SUPPORT]; + IDWTELEM *b0; IDWTELEM *b1; IDWTELEM *b2; @@ -45,13 +50,99 @@ IDWTELEM * base_buffer; ///< Buffer that this structure is caching. } slice_buffer; +struct DWTContext; + +// Possible prototypes for vertical_compose functions +typedef void (*vertical_compose_2tap)(IDWTELEM *b0, IDWTELEM *b1, int width); +typedef void (*vertical_compose_3tap)(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width); +typedef void (*vertical_compose_5tap)(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, IDWTELEM *b3, IDWTELEM *b4, int width); +typedef void (*vertical_compose_9tap)(IDWTELEM *dst, IDWTELEM *b[8], int width); + typedef struct DWTContext { + IDWTELEM *buffer; + IDWTELEM *temp; + int width; + int height; + int stride; + int decomposition_count; + int support; + + void (*spatial_compose)(struct DWTContext *cs, int level, int width, int height, int stride); + void (*vertical_compose_l0)(); + void (*vertical_compose_h0)(); + void (*vertical_compose_l1)(); + void (*vertical_compose_h1)(); + void (*vertical_compose)(); ///< one set of lowpass and highpass combined + void (*horizontal_compose)(IDWTELEM *b, IDWTELEM *tmp, int width); + void (*vertical_compose97i)(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, IDWTELEM *b3, IDWTELEM *b4, IDWTELEM *b5, int width); void (*horizontal_compose97i)(IDWTELEM *b, int width); void (*inner_add_yblock)(const uint8_t *obmc, const int obmc_stride, uint8_t * * block, int b_w, int b_h, int src_x, int src_y, int src_stride, slice_buffer * sb, int add, uint8_t * dst8); + + DWTCompose cs[MAX_DECOMPOSITIONS]; } DWTContext; -#define MAX_DECOMPOSITIONS 8 +enum dwt_type { + DWT_SNOW_DAUB9_7, + DWT_SNOW_LEGALL5_3, + DWT_DIRAC_DD9_7, + DWT_DIRAC_LEGALL5_3, + DWT_DIRAC_DD13_7, + DWT_DIRAC_HAAR0, + DWT_DIRAC_HAAR1, + DWT_DIRAC_FIDELITY, + DWT_DIRAC_DAUB9_7, + DWT_NUM_TYPES +}; + +// -1 if an error occurred, e.g. the dwt_type isn't recognized +int ff_spatial_idwt_init2(DWTContext *d, IDWTELEM *buffer, int width, int height, + int stride, enum dwt_type type, int decomposition_count, + IDWTELEM *temp); + +int ff_spatial_idwt2(IDWTELEM *buffer, int width, int height, int stride, + enum dwt_type type, int decomposition_count, IDWTELEM *temp); + +void ff_spatial_idwt_slice2(DWTContext *d, int y); + +// shared stuff for simd optimiztions +#define COMPOSE_53iL0(b0, b1, b2)\ + (b1 - ((b0 + b2 + 2) >> 2)) + +#define COMPOSE_DIRAC53iH0(b0, b1, b2)\ + (b1 + ((b0 + b2 + 1) >> 1)) + +#define COMPOSE_DD97iH0(b0, b1, b2, b3, b4)\ + (b2 + ((-b0 + 9*b1 + 9*b3 - b4 + 8) >> 4)) + +#define COMPOSE_DD137iL0(b0, b1, b2, b3, b4)\ + (b2 - ((-b0 + 9*b1 + 9*b3 - b4 + 16) >> 5)) + +#define COMPOSE_HAARiL0(b0, b1)\ + (b0 - ((b1 + 1) >> 1)) + +#define COMPOSE_HAARiH0(b0, b1)\ + (b0 + b1) + +#define COMPOSE_FIDELITYiL0(b0, b1, b2, b3, b4, b5, b6, b7, b8)\ + (b4 - ((-8*(b0+b8) + 21*(b1+b7) - 46*(b2+b6) + 161*(b3+b5) + 128) >> 8)) + +#define COMPOSE_FIDELITYiH0(b0, b1, b2, b3, b4, b5, b6, b7, b8)\ + (b4 + ((-2*(b0+b8) + 10*(b1+b7) - 25*(b2+b6) + 81*(b3+b5) + 128) >> 8)) + +#define COMPOSE_DAUB97iL1(b0, b1, b2)\ + (b1 - ((1817*(b0 + b2) + 2048) >> 12)) + +#define COMPOSE_DAUB97iH1(b0, b1, b2)\ + (b1 - (( 113*(b0 + b2) + 64) >> 7)) + +#define COMPOSE_DAUB97iL0(b0, b1, b2)\ + (b1 + (( 217*(b0 + b2) + 2048) >> 12)) + +#define COMPOSE_DAUB97iH0(b0, b1, b2)\ + (b1 + ((6497*(b0 + b2) + 2048) >> 12)) + + #define DWT_97 0 #define DWT_53 1 diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/eamad.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/eamad.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/eamad.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/eamad.c 2011-11-04 12:38:26.000000000 +0000 @@ -85,15 +85,21 @@ { MpegEncContext *s = &t->s; if (j < 4) { + unsigned offset = (mb_y*16 + ((j&2)<<2) + mv_y)*t->last_frame.linesize[0] + mb_x*16 + ((j&1)<<3) + mv_x; + if (offset >= (s->height - 7) * t->last_frame.linesize[0] - 7) + return; comp(t->frame.data[0] + (mb_y*16 + ((j&2)<<2))*t->frame.linesize[0] + mb_x*16 + ((j&1)<<3), t->frame.linesize[0], - t->last_frame.data[0] + (mb_y*16 + ((j&2)<<2) + mv_y)*t->last_frame.linesize[0] + mb_x*16 + ((j&1)<<3) + mv_x, + t->last_frame.data[0] + offset, t->last_frame.linesize[0], add); } else if (!(s->avctx->flags & CODEC_FLAG_GRAY)) { int index = j - 3; + unsigned offset = (mb_y * 8 + (mv_y/2))*t->last_frame.linesize[index] + mb_x * 8 + (mv_x/2); + if (offset >= (s->height/2 - 7) * t->last_frame.linesize[index] - 7) + return; comp(t->frame.data[index] + (mb_y*8)*t->frame.linesize[index] + mb_x * 8, t->frame.linesize[index], - t->last_frame.data[index] + (mb_y * 8 + (mv_y/2))*t->last_frame.linesize[index] + mb_x * 8 + (mv_x/2), + t->last_frame.data[index] + offset, t->last_frame.linesize[index], add); } } @@ -205,7 +211,8 @@ for (j=0; j<6; j++) { if (mv_map & (1<gb); - comp_block(t, s->mb_x, s->mb_y, j, mv_x, mv_y, add); + if (t->last_frame.data[0]) + comp_block(t, s->mb_x, s->mb_y, j, mv_x, mv_y, add); } else { s->dsp.clear_block(t->block); decode_block_intra(t, t->block); @@ -266,6 +273,8 @@ avcodec_set_dimensions(avctx, s->width, s->height); if (t->frame.data[0]) avctx->release_buffer(avctx, &t->frame); + if (t->last_frame.data[0]) + avctx->release_buffer(avctx, &t->last_frame); } t->frame.reference = 1; @@ -280,6 +289,7 @@ if (!t->bitstream_buf) return AVERROR(ENOMEM); bswap16_buf(t->bitstream_buf, (const uint16_t*)buf, (buf_end-buf)/2); + memset((uint8_t*)t->bitstream_buf + (buf_end-buf), 0, FF_INPUT_BUFFER_PADDING_SIZE); init_get_bits(&s->gb, t->bitstream_buf, 8*(buf_end-buf)); for (s->mb_y=0; s->mb_y < (avctx->height+15)/16; s->mb_y++) diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/eatgv.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/eatgv.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/eatgv.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/eatgv.c 2011-11-04 12:38:26.000000000 +0000 @@ -74,7 +74,7 @@ else src += 2; - if (src+3>src_end) + if (src_end - src < 3) return -1; size = AV_RB24(src); src += 3; @@ -138,7 +138,7 @@ * @return 0 on success, -1 on critical buffer underflow */ static int tgv_decode_inter(TgvContext * s, const uint8_t *buf, const uint8_t *buf_end){ - unsigned char *frame0_end = s->last_frame.data[0] + s->avctx->width*s->last_frame.linesize[0]; + unsigned last_frame_size = s->avctx->height*s->last_frame.linesize[0]; int num_mvs; int num_blocks_raw; int num_blocks_packed; @@ -148,7 +148,7 @@ int mvbits; const unsigned char *blocks_raw; - if(buf+12>buf_end) + if(buf_end - buf < 12) return -1; num_mvs = AV_RL16(&buf[0]); @@ -171,7 +171,7 @@ /* read motion vectors */ mvbits = (num_mvs*2*10+31) & ~31; - if (buf+(mvbits>>3)+16*num_blocks_raw+8*num_blocks_packed>buf_end) + if (buf_end - buf < (mvbits>>3)+16*num_blocks_raw+8*num_blocks_packed) return -1; init_get_bits(&gb, buf, mvbits); @@ -207,12 +207,14 @@ int src_stride; if (vector < num_mvs) { - src = s->last_frame.data[0] + - (y*4 + s->mv_codebook[vector][1])*s->last_frame.linesize[0] + - x*4 + s->mv_codebook[vector][0]; + unsigned offset = + (y*4 + s->mv_codebook[vector][1])*s->last_frame.linesize[0] + + x*4 + s->mv_codebook[vector][0]; + src_stride = s->last_frame.linesize[0]; - if (src+3*src_stride+3>=frame0_end) + if (offset >= last_frame_size - (3*src_stride+3)) continue; + src = s->last_frame.data[0] + offset; }else{ int offset = vector - num_mvs; if (offsetbuf_end) { + if(buf_end - buf < 12) { av_log(avctx, AV_LOG_WARNING, "truncated header\n"); return -1; } @@ -272,7 +277,7 @@ pal_count = AV_RL16(&buf[6]); buf += 12; - for(i=0; i= 3; i++) { s->palette[i] = AV_RB24(buf); buf += 3; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/error_resilience.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/error_resilience.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/error_resilience.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/error_resilience.c 2011-11-04 12:38:26.000000000 +0000 @@ -358,7 +358,7 @@ } static void guess_mv(MpegEncContext *s){ - uint8_t fixed[s->mb_stride * s->mb_height]; + uint8_t *fixed = av_malloc(s->mb_stride * s->mb_height); #define MV_FROZEN 3 #define MV_CHANGED 2 #define MV_UNCHANGED 1 @@ -414,7 +414,7 @@ decode_mb(s, 0); } } - return; + goto end; } for(depth=0;; depth++){ @@ -634,7 +634,7 @@ } if(none_left) - return; + goto end; for(i=0; imb_num; i++){ int mb_xy= s->mb_index2xy[i]; @@ -643,6 +643,8 @@ } // printf(":"); fflush(stdout); } +end: + av_free(fixed); } static int is_intra_more_likely(MpegEncContext *s){ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/flacdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/flacdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/flacdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/flacdec.c 2011-11-04 12:38:26.000000000 +0000 @@ -63,7 +63,7 @@ static void allocate_buffers(FLACContext *s); -int ff_flac_is_extradata_valid(AVCodecContext *avctx, +int avpriv_flac_is_extradata_valid(AVCodecContext *avctx, enum FLACExtradataFormat *format, uint8_t **streaminfo_start) { @@ -104,11 +104,11 @@ if (!avctx->extradata) return 0; - if (!ff_flac_is_extradata_valid(avctx, &format, &streaminfo)) + if (!avpriv_flac_is_extradata_valid(avctx, &format, &streaminfo)) return -1; /* initialize based on the demuxer-supplied streamdata header */ - ff_flac_parse_streaminfo(avctx, (FLACStreaminfo *)s, streaminfo); + avpriv_flac_parse_streaminfo(avctx, (FLACStreaminfo *)s, streaminfo); if (s->bps > 16) avctx->sample_fmt = AV_SAMPLE_FMT_S32; else @@ -140,7 +140,7 @@ } } -void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, +void avpriv_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, const uint8_t *buffer) { GetBitContext gb; @@ -174,7 +174,7 @@ dump_headers(avctx, s); } -void ff_flac_parse_block_header(const uint8_t *block_header, +void avpriv_flac_parse_block_header(const uint8_t *block_header, int *last, int *type, int *size) { int tmp = bytestream_get_byte(&block_header); @@ -201,12 +201,12 @@ /* need more data */ return 0; } - ff_flac_parse_block_header(&buf[4], NULL, &metadata_type, &metadata_size); + avpriv_flac_parse_block_header(&buf[4], NULL, &metadata_type, &metadata_size); if (metadata_type != FLAC_METADATA_TYPE_STREAMINFO || metadata_size != FLAC_STREAMINFO_SIZE) { return AVERROR_INVALIDDATA; } - ff_flac_parse_streaminfo(s->avctx, (FLACStreaminfo *)s, &buf[8]); + avpriv_flac_parse_streaminfo(s->avctx, (FLACStreaminfo *)s, &buf[8]); allocate_buffers(s); s->got_streaminfo = 1; @@ -228,7 +228,7 @@ do { if (buf_end - buf < 4) return 0; - ff_flac_parse_block_header(buf, &metadata_last, NULL, &metadata_size); + avpriv_flac_parse_block_header(buf, &metadata_last, NULL, &metadata_size); buf += 4; if (buf_end - buf < metadata_size) { /* need more data in order to read the complete header */ @@ -587,7 +587,8 @@ bytes_read = (get_bits_count(&s->gb)+7)/8; /* check if allocated data size is large enough for output */ - output_size = s->blocksize * s->channels * (s->is32 ? 4 : 2); + output_size = s->blocksize * s->channels * + av_get_bytes_per_sample(avctx->sample_fmt); if (output_size > alloc_data_size) { av_log(s->avctx, AV_LOG_ERROR, "output data size is larger than " "allocated data size\n"); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/flacenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/flacenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/flacenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/flacenc.c 2011-11-04 12:38:26.000000000 +0000 @@ -1352,22 +1352,22 @@ #define FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM static const AVOption options[] = { -{ "lpc_coeff_precision", "LPC coefficient precision", offsetof(FlacEncodeContext, options.lpc_coeff_precision), FF_OPT_TYPE_INT, {.dbl = 15 }, 0, MAX_LPC_PRECISION, FLAGS }, -{ "lpc_type", "LPC algorithm", offsetof(FlacEncodeContext, options.lpc_type), FF_OPT_TYPE_INT, {.dbl = FF_LPC_TYPE_DEFAULT }, FF_LPC_TYPE_DEFAULT, FF_LPC_TYPE_NB-1, FLAGS, "lpc_type" }, -{ "none", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_LPC_TYPE_NONE }, INT_MIN, INT_MAX, FLAGS, "lpc_type" }, -{ "fixed", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_LPC_TYPE_FIXED }, INT_MIN, INT_MAX, FLAGS, "lpc_type" }, -{ "levinson", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_LPC_TYPE_LEVINSON }, INT_MIN, INT_MAX, FLAGS, "lpc_type" }, -{ "cholesky", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_LPC_TYPE_CHOLESKY }, INT_MIN, INT_MAX, FLAGS, "lpc_type" }, -{ "lpc_passes", "Number of passes to use for Cholesky factorization during LPC analysis", offsetof(FlacEncodeContext, options.lpc_passes), FF_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, FLAGS }, -{ "min_partition_order", NULL, offsetof(FlacEncodeContext, options.min_partition_order), FF_OPT_TYPE_INT, {.dbl = -1 }, -1, MAX_PARTITION_ORDER, FLAGS }, -{ "max_partition_order", NULL, offsetof(FlacEncodeContext, options.max_partition_order), FF_OPT_TYPE_INT, {.dbl = -1 }, -1, MAX_PARTITION_ORDER, FLAGS }, -{ "prediction_order_method", "Search method for selecting prediction order", offsetof(FlacEncodeContext, options.prediction_order_method), FF_OPT_TYPE_INT, {.dbl = -1 }, -1, ORDER_METHOD_LOG, FLAGS, "predm" }, -{ "estimation", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = ORDER_METHOD_EST }, INT_MIN, INT_MAX, FLAGS, "predm" }, -{ "2level", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = ORDER_METHOD_2LEVEL }, INT_MIN, INT_MAX, FLAGS, "predm" }, -{ "4level", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = ORDER_METHOD_4LEVEL }, INT_MIN, INT_MAX, FLAGS, "predm" }, -{ "8level", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = ORDER_METHOD_8LEVEL }, INT_MIN, INT_MAX, FLAGS, "predm" }, -{ "search", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = ORDER_METHOD_SEARCH }, INT_MIN, INT_MAX, FLAGS, "predm" }, -{ "log", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = ORDER_METHOD_LOG }, INT_MIN, INT_MAX, FLAGS, "predm" }, +{ "lpc_coeff_precision", "LPC coefficient precision", offsetof(FlacEncodeContext, options.lpc_coeff_precision), AV_OPT_TYPE_INT, {.dbl = 15 }, 0, MAX_LPC_PRECISION, FLAGS }, +{ "lpc_type", "LPC algorithm", offsetof(FlacEncodeContext, options.lpc_type), AV_OPT_TYPE_INT, {.dbl = FF_LPC_TYPE_DEFAULT }, FF_LPC_TYPE_DEFAULT, FF_LPC_TYPE_NB-1, FLAGS, "lpc_type" }, +{ "none", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_LPC_TYPE_NONE }, INT_MIN, INT_MAX, FLAGS, "lpc_type" }, +{ "fixed", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_LPC_TYPE_FIXED }, INT_MIN, INT_MAX, FLAGS, "lpc_type" }, +{ "levinson", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_LPC_TYPE_LEVINSON }, INT_MIN, INT_MAX, FLAGS, "lpc_type" }, +{ "cholesky", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_LPC_TYPE_CHOLESKY }, INT_MIN, INT_MAX, FLAGS, "lpc_type" }, +{ "lpc_passes", "Number of passes to use for Cholesky factorization during LPC analysis", offsetof(FlacEncodeContext, options.lpc_passes), AV_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, FLAGS }, +{ "min_partition_order", NULL, offsetof(FlacEncodeContext, options.min_partition_order), AV_OPT_TYPE_INT, {.dbl = -1 }, -1, MAX_PARTITION_ORDER, FLAGS }, +{ "max_partition_order", NULL, offsetof(FlacEncodeContext, options.max_partition_order), AV_OPT_TYPE_INT, {.dbl = -1 }, -1, MAX_PARTITION_ORDER, FLAGS }, +{ "prediction_order_method", "Search method for selecting prediction order", offsetof(FlacEncodeContext, options.prediction_order_method), AV_OPT_TYPE_INT, {.dbl = -1 }, -1, ORDER_METHOD_LOG, FLAGS, "predm" }, +{ "estimation", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = ORDER_METHOD_EST }, INT_MIN, INT_MAX, FLAGS, "predm" }, +{ "2level", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = ORDER_METHOD_2LEVEL }, INT_MIN, INT_MAX, FLAGS, "predm" }, +{ "4level", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = ORDER_METHOD_4LEVEL }, INT_MIN, INT_MAX, FLAGS, "predm" }, +{ "8level", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = ORDER_METHOD_8LEVEL }, INT_MIN, INT_MAX, FLAGS, "predm" }, +{ "search", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = ORDER_METHOD_SEARCH }, INT_MIN, INT_MAX, FLAGS, "predm" }, +{ "log", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = ORDER_METHOD_LOG }, INT_MIN, INT_MAX, FLAGS, "predm" }, { NULL }, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/flac.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/flac.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/flac.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/flac.h 2011-11-04 12:38:26.000000000 +0000 @@ -95,8 +95,8 @@ * @param[out] s where parsed information is stored * @param[in] buffer pointer to start of 34-byte streaminfo data */ -void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, - const uint8_t *buffer); +void avpriv_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s, + const uint8_t *buffer); /** * Validate the FLAC extradata. @@ -105,9 +105,9 @@ * @param[out] streaminfo_start pointer to start of 34-byte STREAMINFO data. * @return 1 if valid, 0 if not valid. */ -int ff_flac_is_extradata_valid(AVCodecContext *avctx, - enum FLACExtradataFormat *format, - uint8_t **streaminfo_start); +int avpriv_flac_is_extradata_valid(AVCodecContext *avctx, + enum FLACExtradataFormat *format, + uint8_t **streaminfo_start); /** * Parse the metadata block parameters from the header. @@ -116,8 +116,8 @@ * @param[out] type metadata block type * @param[out] size metadata block size */ -void ff_flac_parse_block_header(const uint8_t *block_header, - int *last, int *type, int *size); +void avpriv_flac_parse_block_header(const uint8_t *block_header, + int *last, int *type, int *size); /** * Calculate an estimate for the maximum frame size based on verbatim mode. diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/flac_parser.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/flac_parser.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/flac_parser.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/flac_parser.c 2011-11-04 12:38:26.000000000 +0000 @@ -674,9 +674,9 @@ } AVCodecParser ff_flac_parser = { - { CODEC_ID_FLAC }, - sizeof(FLACParseContext), - flac_parse_init, - flac_parse, - flac_parse_close, + .codec_ids = { CODEC_ID_FLAC }, + .priv_data_size = sizeof(FLACParseContext), + .parser_init = flac_parse_init, + .parser_parse = flac_parse, + .parser_close = flac_parse_close, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/flashsv.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/flashsv.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/flashsv.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/flashsv.c 2011-11-04 12:38:26.000000000 +0000 @@ -301,7 +301,7 @@ /* check for changes of image width and image height */ if (avctx->width != s->image_width || avctx->height != s->image_height) { av_log(avctx, AV_LOG_ERROR, - "Frame width or height differs from first frames!\n"); + "Frame width or height differs from first frame!\n"); av_log(avctx, AV_LOG_ERROR, "fh = %d, fv %d vs ch = %d, cv = %d\n", avctx->height, avctx->width, s->image_height, s->image_width); return AVERROR_INVALIDDATA; @@ -367,7 +367,7 @@ if (s->color_depth != 0 && s->color_depth != 2) { av_log(avctx, AV_LOG_ERROR, "%dx%d invalid color depth %d\n", i, j, s->color_depth); - return -1; + return AVERROR_INVALIDDATA; } if (has_diff) { diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/flvenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/flvenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/flvenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/flvenc.c 2011-11-04 12:38:26.000000000 +0000 @@ -25,7 +25,7 @@ { int format; - align_put_bits(&s->pb); + avpriv_align_put_bits(&s->pb); put_bits(&s->pb, 17, 1); put_bits(&s->pb, 5, (s->h263_flv-1)); /* 0: h263 escape codes 1: 11-bit escape codes */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/fmtconvert.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/fmtconvert.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/fmtconvert.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/fmtconvert.h 2011-11-04 12:38:26.000000000 +0000 @@ -70,7 +70,15 @@ long len, int channels); /** - * Convert an array of interleaved float to multiple arrays of float. + * Convert multiple arrays of float to an array of interleaved float. + * + * @param dst destination array of interleaved float. + * constraints: 16-byte aligned + * @param src source array of float arrays, one for each channel. + * constraints: 16-byte aligned + * @param len number of elements to convert. + * constraints: multiple of 8 + * @param channels number of channels */ void (*float_interleave)(float *dst, const float **src, unsigned int len, int channels); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/g722.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/g722.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/g722.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/g722.c 2011-11-04 12:38:26.000000000 +0000 @@ -36,45 +36,8 @@ * respectively of each byte are ignored. */ -#include "avcodec.h" #include "mathops.h" -#include "get_bits.h" - -#define PREV_SAMPLES_BUF_SIZE 1024 - -#define FREEZE_INTERVAL 128 - -typedef struct { - int16_t prev_samples[PREV_SAMPLES_BUF_SIZE]; ///< memory of past decoded samples - int prev_samples_pos; ///< the number of values in prev_samples - - /** - * The band[0] and band[1] correspond respectively to the lower band and higher band. - */ - struct G722Band { - int16_t s_predictor; ///< predictor output value - int32_t s_zero; ///< previous output signal from zero predictor - int8_t part_reconst_mem[2]; ///< signs of previous partially reconstructed signals - int16_t prev_qtzd_reconst; ///< previous quantized reconstructed signal (internal value, using low_inv_quant4) - int16_t pole_mem[2]; ///< second-order pole section coefficient buffer - int32_t diff_mem[6]; ///< quantizer difference signal memory - int16_t zero_mem[6]; ///< Seventh-order zero section coefficient buffer - int16_t log_factor; ///< delayed 2-logarithmic quantizer factor - int16_t scale_factor; ///< delayed quantizer scale factor - } band[2]; - - struct TrellisNode { - struct G722Band state; - uint32_t ssd; - int path; - } *node_buf[2], **nodep_buf[2]; - - struct TrellisPath { - int value; - int prev; - } *paths[2]; -} G722Context; - +#include "g722.h" static const int8_t sign_lookup[2] = { -1, 1 }; @@ -85,7 +48,7 @@ 3444, 3520, 3597, 3676, 3756, 3838, 3922, 4008 }; static const int16_t high_log_factor_step[2] = { 798, -214 }; -static const int16_t high_inv_quant[4] = { -926, -202, 926, 202 }; +const int16_t ff_g722_high_inv_quant[4] = { -926, -202, 926, 202 }; /** * low_log_factor_step[index] == wl[rl42[index]] */ @@ -93,11 +56,11 @@ -60, 3042, 1198, 538, 334, 172, 58, -30, 3042, 1198, 538, 334, 172, 58, -30, -60 }; -static const int16_t low_inv_quant4[16] = { +const int16_t ff_g722_low_inv_quant4[16] = { 0, -2557, -1612, -1121, -786, -530, -323, -150, 2557, 1612, 1121, 786, 530, 323, 150, 0 }; -static const int16_t low_inv_quant6[64] = { +const int16_t ff_g722_low_inv_quant6[64] = { -17, -17, -17, -17, -3101, -2738, -2376, -2088, -1873, -1689, -1535, -1399, -1279, -1170, -1072, -982, -899, -822, -750, -682, -618, -558, -501, -447, @@ -173,10 +136,10 @@ return shift < 0 ? wd1 >> -shift : wd1 << shift; } -static void update_low_predictor(struct G722Band *band, const int ilow) +void ff_g722_update_low_predictor(struct G722Band *band, const int ilow) { do_adaptive_prediction(band, - band->scale_factor * low_inv_quant4[ilow] >> 10); + band->scale_factor * ff_g722_low_inv_quant4[ilow] >> 10); // quantizer adaptation band->log_factor = av_clip((band->log_factor * 127 >> 7) + @@ -184,7 +147,7 @@ band->scale_factor = linear_scale_factor(band->log_factor - (8 << 11)); } -static void update_high_predictor(struct G722Band *band, const int dhigh, +void ff_g722_update_high_predictor(struct G722Band *band, const int dhigh, const int ihigh) { do_adaptive_prediction(band, dhigh); @@ -195,7 +158,7 @@ band->scale_factor = linear_scale_factor(band->log_factor - (10 << 11)); } -static void apply_qmf(const int16_t *prev_samples, int *xout1, int *xout2) +void ff_g722_apply_qmf(const int16_t *prev_samples, int *xout1, int *xout2) { int i; @@ -206,377 +169,3 @@ MAC16(*xout1, prev_samples[2*i+1], qmf_coeffs[11-i]); } } - -static av_cold int g722_init(AVCodecContext * avctx) -{ - G722Context *c = avctx->priv_data; - - if (avctx->channels != 1) { - av_log(avctx, AV_LOG_ERROR, "Only mono tracks are allowed.\n"); - return AVERROR_INVALIDDATA; - } - avctx->sample_fmt = AV_SAMPLE_FMT_S16; - - switch (avctx->bits_per_coded_sample) { - case 8: - case 7: - case 6: - break; - default: - av_log(avctx, AV_LOG_WARNING, "Unsupported bits_per_coded_sample [%d], " - "assuming 8\n", - avctx->bits_per_coded_sample); - case 0: - avctx->bits_per_coded_sample = 8; - break; - } - - c->band[0].scale_factor = 8; - c->band[1].scale_factor = 2; - c->prev_samples_pos = 22; - - if (avctx->lowres) - avctx->sample_rate /= 2; - - if (avctx->trellis) { - int frontier = 1 << avctx->trellis; - int max_paths = frontier * FREEZE_INTERVAL; - int i; - for (i = 0; i < 2; i++) { - c->paths[i] = av_mallocz(max_paths * sizeof(**c->paths)); - c->node_buf[i] = av_mallocz(2 * frontier * sizeof(**c->node_buf)); - c->nodep_buf[i] = av_mallocz(2 * frontier * sizeof(**c->nodep_buf)); - } - } - - return 0; -} - -static av_cold int g722_close(AVCodecContext *avctx) -{ - G722Context *c = avctx->priv_data; - int i; - for (i = 0; i < 2; i++) { - av_freep(&c->paths[i]); - av_freep(&c->node_buf[i]); - av_freep(&c->nodep_buf[i]); - } - return 0; -} - -#if CONFIG_ADPCM_G722_DECODER -static const int16_t low_inv_quant5[32] = { - -35, -35, -2919, -2195, -1765, -1458, -1219, -1023, - -858, -714, -587, -473, -370, -276, -190, -110, - 2919, 2195, 1765, 1458, 1219, 1023, 858, 714, - 587, 473, 370, 276, 190, 110, 35, -35 -}; - -static const int16_t *low_inv_quants[3] = { low_inv_quant6, low_inv_quant5, - low_inv_quant4 }; - -static int g722_decode_frame(AVCodecContext *avctx, void *data, - int *data_size, AVPacket *avpkt) -{ - G722Context *c = avctx->priv_data; - int16_t *out_buf = data; - int j, out_len = 0; - const int skip = 8 - avctx->bits_per_coded_sample; - const int16_t *quantizer_table = low_inv_quants[skip]; - GetBitContext gb; - - init_get_bits(&gb, avpkt->data, avpkt->size * 8); - - for (j = 0; j < avpkt->size; j++) { - int ilow, ihigh, rlow; - - ihigh = get_bits(&gb, 2); - ilow = get_bits(&gb, 6 - skip); - skip_bits(&gb, skip); - - rlow = av_clip((c->band[0].scale_factor * quantizer_table[ilow] >> 10) - + c->band[0].s_predictor, -16384, 16383); - - update_low_predictor(&c->band[0], ilow >> (2 - skip)); - - if (!avctx->lowres) { - const int dhigh = c->band[1].scale_factor * - high_inv_quant[ihigh] >> 10; - const int rhigh = av_clip(dhigh + c->band[1].s_predictor, - -16384, 16383); - int xout1, xout2; - - update_high_predictor(&c->band[1], dhigh, ihigh); - - c->prev_samples[c->prev_samples_pos++] = rlow + rhigh; - c->prev_samples[c->prev_samples_pos++] = rlow - rhigh; - apply_qmf(c->prev_samples + c->prev_samples_pos - 24, - &xout1, &xout2); - out_buf[out_len++] = av_clip_int16(xout1 >> 12); - out_buf[out_len++] = av_clip_int16(xout2 >> 12); - if (c->prev_samples_pos >= PREV_SAMPLES_BUF_SIZE) { - memmove(c->prev_samples, - c->prev_samples + c->prev_samples_pos - 22, - 22 * sizeof(c->prev_samples[0])); - c->prev_samples_pos = 22; - } - } else - out_buf[out_len++] = rlow; - } - *data_size = out_len << 1; - return avpkt->size; -} - -AVCodec ff_adpcm_g722_decoder = { - .name = "g722", - .type = AVMEDIA_TYPE_AUDIO, - .id = CODEC_ID_ADPCM_G722, - .priv_data_size = sizeof(G722Context), - .init = g722_init, - .decode = g722_decode_frame, - .long_name = NULL_IF_CONFIG_SMALL("G.722 ADPCM"), - .max_lowres = 1, -}; -#endif - -#if CONFIG_ADPCM_G722_ENCODER -static const int16_t low_quant[33] = { - 35, 72, 110, 150, 190, 233, 276, 323, - 370, 422, 473, 530, 587, 650, 714, 786, - 858, 940, 1023, 1121, 1219, 1339, 1458, 1612, - 1765, 1980, 2195, 2557, 2919 -}; - -static inline void filter_samples(G722Context *c, const int16_t *samples, - int *xlow, int *xhigh) -{ - int xout1, xout2; - c->prev_samples[c->prev_samples_pos++] = samples[0]; - c->prev_samples[c->prev_samples_pos++] = samples[1]; - apply_qmf(c->prev_samples + c->prev_samples_pos - 24, &xout1, &xout2); - *xlow = xout1 + xout2 >> 13; - *xhigh = xout1 - xout2 >> 13; - if (c->prev_samples_pos >= PREV_SAMPLES_BUF_SIZE) { - memmove(c->prev_samples, - c->prev_samples + c->prev_samples_pos - 22, - 22 * sizeof(c->prev_samples[0])); - c->prev_samples_pos = 22; - } -} - -static inline int encode_high(const struct G722Band *state, int xhigh) -{ - int diff = av_clip_int16(xhigh - state->s_predictor); - int pred = 141 * state->scale_factor >> 8; - /* = diff >= 0 ? (diff < pred) + 2 : diff >= -pred */ - return ((diff ^ (diff >> (sizeof(diff)*8-1))) < pred) + 2*(diff >= 0); -} - -static inline int encode_low(const struct G722Band* state, int xlow) -{ - int diff = av_clip_int16(xlow - state->s_predictor); - /* = diff >= 0 ? diff : -(diff + 1) */ - int limit = diff ^ (diff >> (sizeof(diff)*8-1)); - int i = 0; - limit = limit + 1 << 10; - if (limit > low_quant[8] * state->scale_factor) - i = 9; - while (i < 29 && limit > low_quant[i] * state->scale_factor) - i++; - return (diff < 0 ? (i < 2 ? 63 : 33) : 61) - i; -} - -static int g722_encode_trellis(AVCodecContext *avctx, - uint8_t *dst, int buf_size, void *data) -{ - G722Context *c = avctx->priv_data; - const int16_t *samples = data; - int i, j, k; - int frontier = 1 << avctx->trellis; - struct TrellisNode **nodes[2]; - struct TrellisNode **nodes_next[2]; - int pathn[2] = {0, 0}, froze = -1; - struct TrellisPath *p[2]; - - for (i = 0; i < 2; i++) { - nodes[i] = c->nodep_buf[i]; - nodes_next[i] = c->nodep_buf[i] + frontier; - memset(c->nodep_buf[i], 0, 2 * frontier * sizeof(*c->nodep_buf)); - nodes[i][0] = c->node_buf[i] + frontier; - nodes[i][0]->ssd = 0; - nodes[i][0]->path = 0; - nodes[i][0]->state = c->band[i]; - } - - for (i = 0; i < buf_size >> 1; i++) { - int xlow, xhigh; - struct TrellisNode *next[2]; - int heap_pos[2] = {0, 0}; - - for (j = 0; j < 2; j++) { - next[j] = c->node_buf[j] + frontier*(i & 1); - memset(nodes_next[j], 0, frontier * sizeof(**nodes_next)); - } - - filter_samples(c, &samples[2*i], &xlow, &xhigh); - - for (j = 0; j < frontier && nodes[0][j]; j++) { - /* Only k >> 2 affects the future adaptive state, therefore testing - * small steps that don't change k >> 2 is useless, the orignal - * value from encode_low is better than them. Since we step k - * in steps of 4, make sure range is a multiple of 4, so that - * we don't miss the original value from encode_low. */ - int range = j < frontier/2 ? 4 : 0; - struct TrellisNode *cur_node = nodes[0][j]; - - int ilow = encode_low(&cur_node->state, xlow); - - for (k = ilow - range; k <= ilow + range && k <= 63; k += 4) { - int decoded, dec_diff, pos; - uint32_t ssd; - struct TrellisNode* node; - - if (k < 0) - continue; - - decoded = av_clip((cur_node->state.scale_factor * - low_inv_quant6[k] >> 10) - + cur_node->state.s_predictor, -16384, 16383); - dec_diff = xlow - decoded; - -#define STORE_NODE(index, UPDATE, VALUE)\ - ssd = cur_node->ssd + dec_diff*dec_diff;\ - /* Check for wraparound. Using 64 bit ssd counters would \ - * be simpler, but is slower on x86 32 bit. */\ - if (ssd < cur_node->ssd)\ - continue;\ - if (heap_pos[index] < frontier) {\ - pos = heap_pos[index]++;\ - assert(pathn[index] < FREEZE_INTERVAL * frontier);\ - node = nodes_next[index][pos] = next[index]++;\ - node->path = pathn[index]++;\ - } else {\ - /* Try to replace one of the leaf nodes with the new \ - * one, but not always testing the same leaf position */\ - pos = (frontier>>1) + (heap_pos[index] & ((frontier>>1) - 1));\ - if (ssd >= nodes_next[index][pos]->ssd)\ - continue;\ - heap_pos[index]++;\ - node = nodes_next[index][pos];\ - }\ - node->ssd = ssd;\ - node->state = cur_node->state;\ - UPDATE;\ - c->paths[index][node->path].value = VALUE;\ - c->paths[index][node->path].prev = cur_node->path;\ - /* Sift the newly inserted node up in the heap to restore \ - * the heap property */\ - while (pos > 0) {\ - int parent = (pos - 1) >> 1;\ - if (nodes_next[index][parent]->ssd <= ssd)\ - break;\ - FFSWAP(struct TrellisNode*, nodes_next[index][parent],\ - nodes_next[index][pos]);\ - pos = parent;\ - } - STORE_NODE(0, update_low_predictor(&node->state, k >> 2), k); - } - } - - for (j = 0; j < frontier && nodes[1][j]; j++) { - int ihigh; - struct TrellisNode *cur_node = nodes[1][j]; - - /* We don't try to get any initial guess for ihigh via - * encode_high - since there's only 4 possible values, test - * them all. Testing all of these gives a much, much larger - * gain than testing a larger range around ilow. */ - for (ihigh = 0; ihigh < 4; ihigh++) { - int dhigh, decoded, dec_diff, pos; - uint32_t ssd; - struct TrellisNode* node; - - dhigh = cur_node->state.scale_factor * - high_inv_quant[ihigh] >> 10; - decoded = av_clip(dhigh + cur_node->state.s_predictor, - -16384, 16383); - dec_diff = xhigh - decoded; - - STORE_NODE(1, update_high_predictor(&node->state, dhigh, ihigh), ihigh); - } - } - - for (j = 0; j < 2; j++) { - FFSWAP(struct TrellisNode**, nodes[j], nodes_next[j]); - - if (nodes[j][0]->ssd > (1 << 16)) { - for (k = 1; k < frontier && nodes[j][k]; k++) - nodes[j][k]->ssd -= nodes[j][0]->ssd; - nodes[j][0]->ssd = 0; - } - } - - if (i == froze + FREEZE_INTERVAL) { - p[0] = &c->paths[0][nodes[0][0]->path]; - p[1] = &c->paths[1][nodes[1][0]->path]; - for (j = i; j > froze; j--) { - dst[j] = p[1]->value << 6 | p[0]->value; - p[0] = &c->paths[0][p[0]->prev]; - p[1] = &c->paths[1][p[1]->prev]; - } - froze = i; - pathn[0] = pathn[1] = 0; - memset(nodes[0] + 1, 0, (frontier - 1)*sizeof(**nodes)); - memset(nodes[1] + 1, 0, (frontier - 1)*sizeof(**nodes)); - } - } - - p[0] = &c->paths[0][nodes[0][0]->path]; - p[1] = &c->paths[1][nodes[1][0]->path]; - for (j = i; j > froze; j--) { - dst[j] = p[1]->value << 6 | p[0]->value; - p[0] = &c->paths[0][p[0]->prev]; - p[1] = &c->paths[1][p[1]->prev]; - } - c->band[0] = nodes[0][0]->state; - c->band[1] = nodes[1][0]->state; - - return i; -} - -static int g722_encode_frame(AVCodecContext *avctx, - uint8_t *dst, int buf_size, void *data) -{ - G722Context *c = avctx->priv_data; - const int16_t *samples = data; - int i; - - if (avctx->trellis) - return g722_encode_trellis(avctx, dst, buf_size, data); - - for (i = 0; i < buf_size >> 1; i++) { - int xlow, xhigh, ihigh, ilow; - filter_samples(c, &samples[2*i], &xlow, &xhigh); - ihigh = encode_high(&c->band[1], xhigh); - ilow = encode_low(&c->band[0], xlow); - update_high_predictor(&c->band[1], c->band[1].scale_factor * - high_inv_quant[ihigh] >> 10, ihigh); - update_low_predictor(&c->band[0], ilow >> 2); - *dst++ = ihigh << 6 | ilow; - } - return i; -} - -AVCodec ff_adpcm_g722_encoder = { - .name = "g722", - .type = AVMEDIA_TYPE_AUDIO, - .id = CODEC_ID_ADPCM_G722, - .priv_data_size = sizeof(G722Context), - .init = g722_init, - .close = g722_close, - .encode = g722_encode_frame, - .long_name = NULL_IF_CONFIG_SMALL("G.722 ADPCM"), - .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, -}; -#endif - diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/g722dec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/g722dec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/g722dec.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/g722dec.c 2011-11-04 12:38:26.000000000 +0000 @@ -0,0 +1,143 @@ +/* + * Copyright (c) CMU 1993 Computer Science, Speech Group + * Chengxiang Lu and Alex Hauptmann + * Copyright (c) 2005 Steve Underwood + * Copyright (c) 2009 Kenan Gillet + * Copyright (c) 2010 Martin Storsjo + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * G.722 ADPCM audio decoder + * + * This G.722 decoder is a bit-exact implementation of the ITU G.722 + * specification for all three specified bitrates - 64000bps, 56000bps + * and 48000bps. It passes the ITU tests. + * + * @note For the 56000bps and 48000bps bitrates, the lowest 1 or 2 bits + * respectively of each byte are ignored. + */ + +#include "avcodec.h" +#include "get_bits.h" +#include "g722.h" + +static av_cold int g722_decode_init(AVCodecContext * avctx) +{ + G722Context *c = avctx->priv_data; + + if (avctx->channels != 1) { + av_log(avctx, AV_LOG_ERROR, "Only mono tracks are allowed.\n"); + return AVERROR_INVALIDDATA; + } + avctx->sample_fmt = AV_SAMPLE_FMT_S16; + + switch (avctx->bits_per_coded_sample) { + case 8: + case 7: + case 6: + break; + default: + av_log(avctx, AV_LOG_WARNING, "Unsupported bits_per_coded_sample [%d], " + "assuming 8\n", + avctx->bits_per_coded_sample); + case 0: + avctx->bits_per_coded_sample = 8; + break; + } + + c->band[0].scale_factor = 8; + c->band[1].scale_factor = 2; + c->prev_samples_pos = 22; + + return 0; +} + +static const int16_t low_inv_quant5[32] = { + -35, -35, -2919, -2195, -1765, -1458, -1219, -1023, + -858, -714, -587, -473, -370, -276, -190, -110, + 2919, 2195, 1765, 1458, 1219, 1023, 858, 714, + 587, 473, 370, 276, 190, 110, 35, -35 +}; + +static const int16_t *low_inv_quants[3] = { ff_g722_low_inv_quant6, + low_inv_quant5, + ff_g722_low_inv_quant4 }; + +static int g722_decode_frame(AVCodecContext *avctx, void *data, + int *data_size, AVPacket *avpkt) +{ + G722Context *c = avctx->priv_data; + int16_t *out_buf = data; + int j, out_len; + const int skip = 8 - avctx->bits_per_coded_sample; + const int16_t *quantizer_table = low_inv_quants[skip]; + GetBitContext gb; + + out_len = avpkt->size * 2 * av_get_bytes_per_sample(avctx->sample_fmt); + if (*data_size < out_len) { + av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); + return AVERROR(EINVAL); + } + + init_get_bits(&gb, avpkt->data, avpkt->size * 8); + + for (j = 0; j < avpkt->size; j++) { + int ilow, ihigh, rlow, rhigh, dhigh; + int xout1, xout2; + + ihigh = get_bits(&gb, 2); + ilow = get_bits(&gb, 6 - skip); + skip_bits(&gb, skip); + + rlow = av_clip((c->band[0].scale_factor * quantizer_table[ilow] >> 10) + + c->band[0].s_predictor, -16384, 16383); + + ff_g722_update_low_predictor(&c->band[0], ilow >> (2 - skip)); + + dhigh = c->band[1].scale_factor * ff_g722_high_inv_quant[ihigh] >> 10; + rhigh = av_clip(dhigh + c->band[1].s_predictor, -16384, 16383); + + ff_g722_update_high_predictor(&c->band[1], dhigh, ihigh); + + c->prev_samples[c->prev_samples_pos++] = rlow + rhigh; + c->prev_samples[c->prev_samples_pos++] = rlow - rhigh; + ff_g722_apply_qmf(c->prev_samples + c->prev_samples_pos - 24, + &xout1, &xout2); + *out_buf++ = av_clip_int16(xout1 >> 12); + *out_buf++ = av_clip_int16(xout2 >> 12); + if (c->prev_samples_pos >= PREV_SAMPLES_BUF_SIZE) { + memmove(c->prev_samples, c->prev_samples + c->prev_samples_pos - 22, + 22 * sizeof(c->prev_samples[0])); + c->prev_samples_pos = 22; + } + } + *data_size = out_len; + return avpkt->size; +} + +AVCodec ff_adpcm_g722_decoder = { + .name = "g722", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_ADPCM_G722, + .priv_data_size = sizeof(G722Context), + .init = g722_decode_init, + .decode = g722_decode_frame, + .long_name = NULL_IF_CONFIG_SMALL("G.722 ADPCM"), +}; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/g722enc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/g722enc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/g722enc.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/g722enc.c 2011-11-04 12:38:26.000000000 +0000 @@ -0,0 +1,311 @@ +/* + * Copyright (c) CMU 1993 Computer Science, Speech Group + * Chengxiang Lu and Alex Hauptmann + * Copyright (c) 2005 Steve Underwood + * Copyright (c) 2009 Kenan Gillet + * Copyright (c) 2010 Martin Storsjo + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * G.722 ADPCM audio encoder + */ + +#include "avcodec.h" +#include "g722.h" + +#define FREEZE_INTERVAL 128 + +static av_cold int g722_encode_init(AVCodecContext * avctx) +{ + G722Context *c = avctx->priv_data; + + if (avctx->channels != 1) { + av_log(avctx, AV_LOG_ERROR, "Only mono tracks are allowed.\n"); + return AVERROR_INVALIDDATA; + } + + c->band[0].scale_factor = 8; + c->band[1].scale_factor = 2; + c->prev_samples_pos = 22; + + if (avctx->trellis) { + int frontier = 1 << avctx->trellis; + int max_paths = frontier * FREEZE_INTERVAL; + int i; + for (i = 0; i < 2; i++) { + c->paths[i] = av_mallocz(max_paths * sizeof(**c->paths)); + c->node_buf[i] = av_mallocz(2 * frontier * sizeof(**c->node_buf)); + c->nodep_buf[i] = av_mallocz(2 * frontier * sizeof(**c->nodep_buf)); + } + } + + return 0; +} + +static av_cold int g722_encode_close(AVCodecContext *avctx) +{ + G722Context *c = avctx->priv_data; + int i; + for (i = 0; i < 2; i++) { + av_freep(&c->paths[i]); + av_freep(&c->node_buf[i]); + av_freep(&c->nodep_buf[i]); + } + return 0; +} + +static const int16_t low_quant[33] = { + 35, 72, 110, 150, 190, 233, 276, 323, + 370, 422, 473, 530, 587, 650, 714, 786, + 858, 940, 1023, 1121, 1219, 1339, 1458, 1612, + 1765, 1980, 2195, 2557, 2919 +}; + +static inline void filter_samples(G722Context *c, const int16_t *samples, + int *xlow, int *xhigh) +{ + int xout1, xout2; + c->prev_samples[c->prev_samples_pos++] = samples[0]; + c->prev_samples[c->prev_samples_pos++] = samples[1]; + ff_g722_apply_qmf(c->prev_samples + c->prev_samples_pos - 24, &xout1, &xout2); + *xlow = xout1 + xout2 >> 13; + *xhigh = xout1 - xout2 >> 13; + if (c->prev_samples_pos >= PREV_SAMPLES_BUF_SIZE) { + memmove(c->prev_samples, + c->prev_samples + c->prev_samples_pos - 22, + 22 * sizeof(c->prev_samples[0])); + c->prev_samples_pos = 22; + } +} + +static inline int encode_high(const struct G722Band *state, int xhigh) +{ + int diff = av_clip_int16(xhigh - state->s_predictor); + int pred = 141 * state->scale_factor >> 8; + /* = diff >= 0 ? (diff < pred) + 2 : diff >= -pred */ + return ((diff ^ (diff >> (sizeof(diff)*8-1))) < pred) + 2*(diff >= 0); +} + +static inline int encode_low(const struct G722Band* state, int xlow) +{ + int diff = av_clip_int16(xlow - state->s_predictor); + /* = diff >= 0 ? diff : -(diff + 1) */ + int limit = diff ^ (diff >> (sizeof(diff)*8-1)); + int i = 0; + limit = limit + 1 << 10; + if (limit > low_quant[8] * state->scale_factor) + i = 9; + while (i < 29 && limit > low_quant[i] * state->scale_factor) + i++; + return (diff < 0 ? (i < 2 ? 63 : 33) : 61) - i; +} + +static int g722_encode_trellis(AVCodecContext *avctx, + uint8_t *dst, int buf_size, void *data) +{ + G722Context *c = avctx->priv_data; + const int16_t *samples = data; + int i, j, k; + int frontier = 1 << avctx->trellis; + struct TrellisNode **nodes[2]; + struct TrellisNode **nodes_next[2]; + int pathn[2] = {0, 0}, froze = -1; + struct TrellisPath *p[2]; + + for (i = 0; i < 2; i++) { + nodes[i] = c->nodep_buf[i]; + nodes_next[i] = c->nodep_buf[i] + frontier; + memset(c->nodep_buf[i], 0, 2 * frontier * sizeof(*c->nodep_buf)); + nodes[i][0] = c->node_buf[i] + frontier; + nodes[i][0]->ssd = 0; + nodes[i][0]->path = 0; + nodes[i][0]->state = c->band[i]; + } + + for (i = 0; i < buf_size >> 1; i++) { + int xlow, xhigh; + struct TrellisNode *next[2]; + int heap_pos[2] = {0, 0}; + + for (j = 0; j < 2; j++) { + next[j] = c->node_buf[j] + frontier*(i & 1); + memset(nodes_next[j], 0, frontier * sizeof(**nodes_next)); + } + + filter_samples(c, &samples[2*i], &xlow, &xhigh); + + for (j = 0; j < frontier && nodes[0][j]; j++) { + /* Only k >> 2 affects the future adaptive state, therefore testing + * small steps that don't change k >> 2 is useless, the orignal + * value from encode_low is better than them. Since we step k + * in steps of 4, make sure range is a multiple of 4, so that + * we don't miss the original value from encode_low. */ + int range = j < frontier/2 ? 4 : 0; + struct TrellisNode *cur_node = nodes[0][j]; + + int ilow = encode_low(&cur_node->state, xlow); + + for (k = ilow - range; k <= ilow + range && k <= 63; k += 4) { + int decoded, dec_diff, pos; + uint32_t ssd; + struct TrellisNode* node; + + if (k < 0) + continue; + + decoded = av_clip((cur_node->state.scale_factor * + ff_g722_low_inv_quant6[k] >> 10) + + cur_node->state.s_predictor, -16384, 16383); + dec_diff = xlow - decoded; + +#define STORE_NODE(index, UPDATE, VALUE)\ + ssd = cur_node->ssd + dec_diff*dec_diff;\ + /* Check for wraparound. Using 64 bit ssd counters would \ + * be simpler, but is slower on x86 32 bit. */\ + if (ssd < cur_node->ssd)\ + continue;\ + if (heap_pos[index] < frontier) {\ + pos = heap_pos[index]++;\ + assert(pathn[index] < FREEZE_INTERVAL * frontier);\ + node = nodes_next[index][pos] = next[index]++;\ + node->path = pathn[index]++;\ + } else {\ + /* Try to replace one of the leaf nodes with the new \ + * one, but not always testing the same leaf position */\ + pos = (frontier>>1) + (heap_pos[index] & ((frontier>>1) - 1));\ + if (ssd >= nodes_next[index][pos]->ssd)\ + continue;\ + heap_pos[index]++;\ + node = nodes_next[index][pos];\ + }\ + node->ssd = ssd;\ + node->state = cur_node->state;\ + UPDATE;\ + c->paths[index][node->path].value = VALUE;\ + c->paths[index][node->path].prev = cur_node->path;\ + /* Sift the newly inserted node up in the heap to restore \ + * the heap property */\ + while (pos > 0) {\ + int parent = (pos - 1) >> 1;\ + if (nodes_next[index][parent]->ssd <= ssd)\ + break;\ + FFSWAP(struct TrellisNode*, nodes_next[index][parent],\ + nodes_next[index][pos]);\ + pos = parent;\ + } + STORE_NODE(0, ff_g722_update_low_predictor(&node->state, k >> 2), k); + } + } + + for (j = 0; j < frontier && nodes[1][j]; j++) { + int ihigh; + struct TrellisNode *cur_node = nodes[1][j]; + + /* We don't try to get any initial guess for ihigh via + * encode_high - since there's only 4 possible values, test + * them all. Testing all of these gives a much, much larger + * gain than testing a larger range around ilow. */ + for (ihigh = 0; ihigh < 4; ihigh++) { + int dhigh, decoded, dec_diff, pos; + uint32_t ssd; + struct TrellisNode* node; + + dhigh = cur_node->state.scale_factor * + ff_g722_high_inv_quant[ihigh] >> 10; + decoded = av_clip(dhigh + cur_node->state.s_predictor, + -16384, 16383); + dec_diff = xhigh - decoded; + + STORE_NODE(1, ff_g722_update_high_predictor(&node->state, dhigh, ihigh), ihigh); + } + } + + for (j = 0; j < 2; j++) { + FFSWAP(struct TrellisNode**, nodes[j], nodes_next[j]); + + if (nodes[j][0]->ssd > (1 << 16)) { + for (k = 1; k < frontier && nodes[j][k]; k++) + nodes[j][k]->ssd -= nodes[j][0]->ssd; + nodes[j][0]->ssd = 0; + } + } + + if (i == froze + FREEZE_INTERVAL) { + p[0] = &c->paths[0][nodes[0][0]->path]; + p[1] = &c->paths[1][nodes[1][0]->path]; + for (j = i; j > froze; j--) { + dst[j] = p[1]->value << 6 | p[0]->value; + p[0] = &c->paths[0][p[0]->prev]; + p[1] = &c->paths[1][p[1]->prev]; + } + froze = i; + pathn[0] = pathn[1] = 0; + memset(nodes[0] + 1, 0, (frontier - 1)*sizeof(**nodes)); + memset(nodes[1] + 1, 0, (frontier - 1)*sizeof(**nodes)); + } + } + + p[0] = &c->paths[0][nodes[0][0]->path]; + p[1] = &c->paths[1][nodes[1][0]->path]; + for (j = i; j > froze; j--) { + dst[j] = p[1]->value << 6 | p[0]->value; + p[0] = &c->paths[0][p[0]->prev]; + p[1] = &c->paths[1][p[1]->prev]; + } + c->band[0] = nodes[0][0]->state; + c->band[1] = nodes[1][0]->state; + + return i; +} + +static int g722_encode_frame(AVCodecContext *avctx, + uint8_t *dst, int buf_size, void *data) +{ + G722Context *c = avctx->priv_data; + const int16_t *samples = data; + int i; + + if (avctx->trellis) + return g722_encode_trellis(avctx, dst, buf_size, data); + + for (i = 0; i < buf_size >> 1; i++) { + int xlow, xhigh, ihigh, ilow; + filter_samples(c, &samples[2*i], &xlow, &xhigh); + ihigh = encode_high(&c->band[1], xhigh); + ilow = encode_low(&c->band[0], xlow); + ff_g722_update_high_predictor(&c->band[1], c->band[1].scale_factor * + ff_g722_high_inv_quant[ihigh] >> 10, ihigh); + ff_g722_update_low_predictor(&c->band[0], ilow >> 2); + *dst++ = ihigh << 6 | ilow; + } + return i; +} + +AVCodec ff_adpcm_g722_encoder = { + .name = "g722", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_ADPCM_G722, + .priv_data_size = sizeof(G722Context), + .init = g722_encode_init, + .close = g722_encode_close, + .encode = g722_encode_frame, + .long_name = NULL_IF_CONFIG_SMALL("G.722 ADPCM"), + .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, +}; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/g722.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/g722.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/g722.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/g722.h 2011-11-04 12:38:26.000000000 +0000 @@ -0,0 +1,74 @@ +/* + * Copyright (c) CMU 1993 Computer Science, Speech Group + * Chengxiang Lu and Alex Hauptmann + * Copyright (c) 2005 Steve Underwood + * Copyright (c) 2009 Kenan Gillet + * Copyright (c) 2010 Martin Storsjo + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_G722_H +#define AVCODEC_G722_H + +#include + +#define PREV_SAMPLES_BUF_SIZE 1024 + +typedef struct { + int16_t prev_samples[PREV_SAMPLES_BUF_SIZE]; ///< memory of past decoded samples + int prev_samples_pos; ///< the number of values in prev_samples + + /** + * The band[0] and band[1] correspond respectively to the lower band and higher band. + */ + struct G722Band { + int16_t s_predictor; ///< predictor output value + int32_t s_zero; ///< previous output signal from zero predictor + int8_t part_reconst_mem[2]; ///< signs of previous partially reconstructed signals + int16_t prev_qtzd_reconst; ///< previous quantized reconstructed signal (internal value, using low_inv_quant4) + int16_t pole_mem[2]; ///< second-order pole section coefficient buffer + int32_t diff_mem[6]; ///< quantizer difference signal memory + int16_t zero_mem[6]; ///< Seventh-order zero section coefficient buffer + int16_t log_factor; ///< delayed 2-logarithmic quantizer factor + int16_t scale_factor; ///< delayed quantizer scale factor + } band[2]; + + struct TrellisNode { + struct G722Band state; + uint32_t ssd; + int path; + } *node_buf[2], **nodep_buf[2]; + + struct TrellisPath { + int value; + int prev; + } *paths[2]; +} G722Context; + +extern const int16_t ff_g722_high_inv_quant[4]; +extern const int16_t ff_g722_low_inv_quant4[16]; +extern const int16_t ff_g722_low_inv_quant6[64]; + +void ff_g722_update_low_predictor(struct G722Band *band, const int ilow); + +void ff_g722_update_high_predictor(struct G722Band *band, const int dhigh, + const int ihigh); + +void ff_g722_apply_qmf(const int16_t *prev_samples, int *xout1, int *xout2); + +#endif /* AVCODEC_G722_H */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/g723_1.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/g723_1.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/g723_1.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/g723_1.c 2011-11-04 12:38:26.000000000 +0000 @@ -59,6 +59,17 @@ int reflection_coef; int pf_gain; ///< formant postfilter ///< gain scaling unit memory + + int16_t prev_data[HALF_FRAME_LEN]; + int16_t prev_weight_sig[PITCH_MAX]; + + + int16_t hpf_fir_mem; ///< highpass filter fir + int hpf_iir_mem; ///< and iir memories + int16_t perf_fir_mem[LPC_ORDER]; ///< perceptual filter fir + int16_t perf_iir_mem[LPC_ORDER]; ///< and iir memories + + int16_t harmonic_mem[PITCH_MAX]; } G723_1_Context; static av_cold int g723_1_decode_init(AVCodecContext *avctx) @@ -221,6 +232,10 @@ return i; } +#define normalize_bits_int16(num) normalize_bits(num, 0) +#define normalize_bits_int32(num) normalize_bits(num, 1) +#define dot_product(a,b,c,d) (ff_dot_product(a,b,c)<<(d)) + /** * Scale vector contents based on the largest of their absolutes. */ @@ -1068,3 +1083,1134 @@ .long_name = NULL_IF_CONFIG_SMALL("G.723.1"), .capabilities = CODEC_CAP_SUBFRAMES, }; + +#if CONFIG_G723_1_ENCODER +#define BITSTREAM_WRITER_LE +#include "put_bits.h" + +static av_cold int g723_1_encode_init(AVCodecContext *avctx) +{ + G723_1_Context *p = avctx->priv_data; + + if (avctx->sample_rate != 8000) { + av_log(avctx, AV_LOG_ERROR, "Only 8000Hz sample rate supported\n"); + return -1; + } + + if (avctx->channels != 1) { + av_log(avctx, AV_LOG_ERROR, "Only mono supported\n"); + return AVERROR(EINVAL); + } + + if (avctx->bit_rate == 6300) { + p->cur_rate = Rate6k3; + } else if (avctx->bit_rate == 5300) { + av_log(avctx, AV_LOG_ERROR, "Bitrate not supported yet, use 6.3k\n"); + return AVERROR_PATCHWELCOME; + } else { + av_log(avctx, AV_LOG_ERROR, + "Bitrate not supported, use 6.3k\n"); + return AVERROR(EINVAL); + } + avctx->frame_size = 240; + memcpy(p->prev_lsp, dc_lsp, LPC_ORDER * sizeof(int16_t)); + + return 0; +} + +/** + * Remove DC component from the input signal. + * + * @param buf input signal + * @param fir zero memory + * @param iir pole memory + */ +static void highpass_filter(int16_t *buf, int16_t *fir, int *iir) +{ + int i; + for (i = 0; i < FRAME_LEN; i++) { + *iir = (buf[i] << 15) + ((-*fir) << 15) + MULL2(*iir, 0x7f00); + *fir = buf[i]; + buf[i] = av_clipl_int32((int64_t)*iir + (1 << 15)) >> 16; + } +} + +/** + * Estimate autocorrelation of the input vector. + * + * @param buf input buffer + * @param autocorr autocorrelation coefficients vector + */ +static void comp_autocorr(int16_t *buf, int16_t *autocorr) +{ + int i, scale, temp; + int16_t vector[LPC_FRAME]; + + memcpy(vector, buf, LPC_FRAME * sizeof(int16_t)); + scale_vector(vector, LPC_FRAME); + + /* Apply the Hamming window */ + for (i = 0; i < LPC_FRAME; i++) + vector[i] = (vector[i] * hamming_window[i] + (1 << 14)) >> 15; + + /* Compute the first autocorrelation coefficient */ + temp = dot_product(vector, vector, LPC_FRAME, 0); + + /* Apply a white noise correlation factor of (1025/1024) */ + temp += temp >> 10; + + /* Normalize */ + scale = normalize_bits_int32(temp); + autocorr[0] = av_clipl_int32((int64_t)(temp << scale) + + (1 << 15)) >> 16; + + /* Compute the remaining coefficients */ + if (!autocorr[0]) { + memset(autocorr + 1, 0, LPC_ORDER * sizeof(int16_t)); + } else { + for (i = 1; i <= LPC_ORDER; i++) { + temp = dot_product(vector, vector + i, LPC_FRAME - i, 0); + temp = MULL2((temp << scale), binomial_window[i - 1]); + autocorr[i] = av_clipl_int32((int64_t)temp + (1 << 15)) >> 16; + } + } +} + +/** + * Use Levinson-Durbin recursion to compute LPC coefficients from + * autocorrelation values. + * + * @param lpc LPC coefficients vector + * @param autocorr autocorrelation coefficients vector + * @param error prediction error + */ +static void levinson_durbin(int16_t *lpc, int16_t *autocorr, int16_t error) +{ + int16_t vector[LPC_ORDER]; + int16_t partial_corr; + int i, j, temp; + + memset(lpc, 0, LPC_ORDER * sizeof(int16_t)); + + for (i = 0; i < LPC_ORDER; i++) { + /* Compute the partial correlation coefficient */ + temp = 0; + for (j = 0; j < i; j++) + temp -= lpc[j] * autocorr[i - j - 1]; + temp = ((autocorr[i] << 13) + temp) << 3; + + if (FFABS(temp) >= (error << 16)) + break; + + partial_corr = temp / (error << 1); + + lpc[i] = av_clipl_int32((int64_t)(partial_corr << 14) + + (1 << 15)) >> 16; + + /* Update the prediction error */ + temp = MULL2(temp, partial_corr); + error = av_clipl_int32((int64_t)(error << 16) - temp + + (1 << 15)) >> 16; + + memcpy(vector, lpc, i * sizeof(int16_t)); + for (j = 0; j < i; j++) { + temp = partial_corr * vector[i - j - 1] << 1; + lpc[j] = av_clipl_int32((int64_t)(lpc[j] << 16) - temp + + (1 << 15)) >> 16; + } + } +} + +/** + * Calculate LPC coefficients for the current frame. + * + * @param buf current frame + * @param prev_data 2 trailing subframes of the previous frame + * @param lpc LPC coefficients vector + */ +static void comp_lpc_coeff(int16_t *buf, int16_t *lpc) +{ + int16_t autocorr[(LPC_ORDER + 1) * SUBFRAMES]; + int16_t *autocorr_ptr = autocorr; + int16_t *lpc_ptr = lpc; + int i, j; + + for (i = 0, j = 0; j < SUBFRAMES; i += SUBFRAME_LEN, j++) { + comp_autocorr(buf + i, autocorr_ptr); + levinson_durbin(lpc_ptr, autocorr_ptr + 1, autocorr_ptr[0]); + + lpc_ptr += LPC_ORDER; + autocorr_ptr += LPC_ORDER + 1; + } +} + +static void lpc2lsp(int16_t *lpc, int16_t *prev_lsp, int16_t *lsp) +{ + int f[LPC_ORDER + 2]; ///< coefficients of the sum and difference + ///< polynomials (F1, F2) ordered as + ///< f1[0], f2[0], ...., f1[5], f2[5] + + int max, shift, cur_val, prev_val, count, p; + int i, j; + int64_t temp; + + /* Initialize f1[0] and f2[0] to 1 in Q25 */ + for (i = 0; i < LPC_ORDER; i++) + lsp[i] = (lpc[i] * bandwidth_expand[i] + (1 << 14)) >> 15; + + /* Apply bandwidth expansion on the LPC coefficients */ + f[0] = f[1] = 1 << 25; + + /* Compute the remaining coefficients */ + for (i = 0; i < LPC_ORDER / 2; i++) { + /* f1 */ + f[2 * i + 2] = -f[2 * i] - ((lsp[i] + lsp[LPC_ORDER - 1 - i]) << 12); + /* f2 */ + f[2 * i + 3] = f[2 * i + 1] - ((lsp[i] - lsp[LPC_ORDER - 1 - i]) << 12); + } + + /* Divide f1[5] and f2[5] by 2 for use in polynomial evaluation */ + f[LPC_ORDER] >>= 1; + f[LPC_ORDER + 1] >>= 1; + + /* Normalize and shorten */ + max = FFABS(f[0]); + for (i = 1; i < LPC_ORDER + 2; i++) + max = FFMAX(max, FFABS(f[i])); + + shift = normalize_bits_int32(max); + + for (i = 0; i < LPC_ORDER + 2; i++) + f[i] = av_clipl_int32((int64_t)(f[i] << shift) + (1 << 15)) >> 16; + + /** + * Evaluate F1 and F2 at uniform intervals of pi/256 along the + * unit circle and check for zero crossings. + */ + p = 0; + temp = 0; + for (i = 0; i <= LPC_ORDER / 2; i++) + temp += f[2 * i] * cos_tab[0]; + prev_val = av_clipl_int32(temp << 1); + count = 0; + for ( i = 1; i < COS_TBL_SIZE / 2; i++) { + /* Evaluate */ + temp = 0; + for (j = 0; j <= LPC_ORDER / 2; j++) + temp += f[LPC_ORDER - 2 * j + p] * cos_tab[i * j % COS_TBL_SIZE]; + cur_val = av_clipl_int32(temp << 1); + + /* Check for sign change, indicating a zero crossing */ + if ((cur_val ^ prev_val) < 0) { + int abs_cur = FFABS(cur_val); + int abs_prev = FFABS(prev_val); + int sum = abs_cur + abs_prev; + + shift = normalize_bits_int32(sum); + sum <<= shift; + abs_prev = abs_prev << shift >> 8; + lsp[count++] = ((i - 1) << 7) + (abs_prev >> 1) / (sum >> 16); + + if (count == LPC_ORDER) + break; + + /* Switch between sum and difference polynomials */ + p ^= 1; + + /* Evaluate */ + temp = 0; + for (j = 0; j <= LPC_ORDER / 2; j++){ + temp += f[LPC_ORDER - 2 * j + p] * + cos_tab[i * j % COS_TBL_SIZE]; + } + cur_val = av_clipl_int32(temp<<1); + } + prev_val = cur_val; + } + + if (count != LPC_ORDER) + memcpy(lsp, prev_lsp, LPC_ORDER * sizeof(int16_t)); +} + +/** + * Quantize the current LSP subvector. + * + * @param num band number + * @param offset offset of the current subvector in an LPC_ORDER vector + * @param size size of the current subvector + */ +#define get_index(num, offset, size) \ +{\ + int error, max = -1;\ + int16_t temp[4];\ + int i, j;\ + for (i = 0; i < LSP_CB_SIZE; i++) {\ + for (j = 0; j < size; j++){\ + temp[j] = (weight[j + (offset)] * lsp_band##num[i][j] +\ + (1 << 14)) >> 15;\ + }\ + error = dot_product(lsp + (offset), temp, size, 1) << 1;\ + error -= dot_product(lsp_band##num[i], temp, size, 1);\ + if (error > max) {\ + max = error;\ + lsp_index[num] = i;\ + }\ + }\ +} + +/** + * Vector quantize the LSP frequencies. + * + * @param lsp the current lsp vector + * @param prev_lsp the previous lsp vector + */ +static void lsp_quantize(uint8_t *lsp_index, int16_t *lsp, int16_t *prev_lsp) +{ + int16_t weight[LPC_ORDER]; + int16_t min, max; + int shift, i; + + /* Calculate the VQ weighting vector */ + weight[0] = (1 << 20) / (lsp[1] - lsp[0]); + weight[LPC_ORDER - 1] = (1 << 20) / + (lsp[LPC_ORDER - 1] - lsp[LPC_ORDER - 2]); + + for (i = 1; i < LPC_ORDER - 1; i++) { + min = FFMIN(lsp[i] - lsp[i - 1], lsp[i + 1] - lsp[i]); + if (min > 0x20) + weight[i] = (1 << 20) / min; + else + weight[i] = INT16_MAX; + } + + /* Normalize */ + max = 0; + for (i = 0; i < LPC_ORDER; i++) + max = FFMAX(weight[i], max); + + shift = normalize_bits_int16(max); + for (i = 0; i < LPC_ORDER; i++) { + weight[i] <<= shift; + } + + /* Compute the VQ target vector */ + for (i = 0; i < LPC_ORDER; i++) { + lsp[i] -= dc_lsp[i] + + (((prev_lsp[i] - dc_lsp[i]) * 12288 + (1 << 14)) >> 15); + } + + get_index(0, 0, 3); + get_index(1, 3, 3); + get_index(2, 6, 4); +} + +/** + * Apply the formant perceptual weighting filter. + * + * @param flt_coef filter coefficients + * @param unq_lpc unquantized lpc vector + */ +static void perceptual_filter(G723_1_Context *p, int16_t *flt_coef, + int16_t *unq_lpc, int16_t *buf) +{ + int16_t vector[FRAME_LEN + LPC_ORDER]; + int i, j, k, l = 0; + + memcpy(buf, p->iir_mem, sizeof(int16_t) * LPC_ORDER); + memcpy(vector, p->fir_mem, sizeof(int16_t) * LPC_ORDER); + memcpy(vector + LPC_ORDER, buf + LPC_ORDER, sizeof(int16_t) * FRAME_LEN); + + for (i = LPC_ORDER, j = 0; j < SUBFRAMES; i += SUBFRAME_LEN, j++) { + for (k = 0; k < LPC_ORDER; k++) { + flt_coef[k + 2 * l] = (unq_lpc[k + l] * percept_flt_tbl[0][k] + + (1 << 14)) >> 15; + flt_coef[k + 2 * l + LPC_ORDER] = (unq_lpc[k + l] * + percept_flt_tbl[1][k] + + (1 << 14)) >> 15; + } + iir_filter(flt_coef + 2 * l, flt_coef + 2 * l + LPC_ORDER, vector + i, + buf + i, 0); + l += LPC_ORDER; + } + memcpy(p->iir_mem, buf + FRAME_LEN, sizeof(int16_t) * LPC_ORDER); + memcpy(p->fir_mem, vector + FRAME_LEN, sizeof(int16_t) * LPC_ORDER); +} + +/** + * Estimate the open loop pitch period. + * + * @param buf perceptually weighted speech + * @param start estimation is carried out from this position + */ +static int estimate_pitch(int16_t *buf, int start) +{ + int max_exp = 32; + int max_ccr = 0x4000; + int max_eng = 0x7fff; + int index = PITCH_MIN; + int offset = start - PITCH_MIN + 1; + + int ccr, eng, orig_eng, ccr_eng, exp; + int diff, temp; + + int i; + + orig_eng = dot_product(buf + offset, buf + offset, HALF_FRAME_LEN, 0); + + for (i = PITCH_MIN; i <= PITCH_MAX - 3; i++) { + offset--; + + /* Update energy and compute correlation */ + orig_eng += buf[offset] * buf[offset] - + buf[offset + HALF_FRAME_LEN] * buf[offset + HALF_FRAME_LEN]; + ccr = dot_product(buf + start, buf + offset, HALF_FRAME_LEN, 0); + if (ccr <= 0) + continue; + + /* Split into mantissa and exponent to maintain precision */ + exp = normalize_bits_int32(ccr); + ccr = av_clipl_int32((int64_t)(ccr << exp) + (1 << 15)) >> 16; + exp <<= 1; + ccr *= ccr; + temp = normalize_bits_int32(ccr); + ccr = ccr << temp >> 16; + exp += temp; + + temp = normalize_bits_int32(orig_eng); + eng = av_clipl_int32((int64_t)(orig_eng << temp) + (1 << 15)) >> 16; + exp -= temp; + + if (ccr >= eng) { + exp--; + ccr >>= 1; + } + if (exp > max_exp) + continue; + + if (exp + 1 < max_exp) + goto update; + + /* Equalize exponents before comparison */ + if (exp + 1 == max_exp) + temp = max_ccr >> 1; + else + temp = max_ccr; + ccr_eng = ccr * max_eng; + diff = ccr_eng - eng * temp; + if (diff > 0 && (i - index < PITCH_MIN || diff > ccr_eng >> 2)) { +update: + index = i; + max_exp = exp; + max_ccr = ccr; + max_eng = eng; + } + } + return index; +} + +/** + * Compute harmonic noise filter parameters. + * + * @param buf perceptually weighted speech + * @param pitch_lag open loop pitch period + * @param hf harmonic filter parameters + */ +static void comp_harmonic_coeff(int16_t *buf, int16_t pitch_lag, HFParam *hf) +{ + int ccr, eng, max_ccr, max_eng; + int exp, max, diff; + int energy[15]; + int i, j; + + for (i = 0, j = pitch_lag - 3; j <= pitch_lag + 3; i++, j++) { + /* Compute residual energy */ + energy[i << 1] = dot_product(buf - j, buf - j, SUBFRAME_LEN, 0); + /* Compute correlation */ + energy[(i << 1) + 1] = dot_product(buf, buf - j, SUBFRAME_LEN, 0); + } + + /* Compute target energy */ + energy[14] = dot_product(buf, buf, SUBFRAME_LEN, 0); + + /* Normalize */ + max = 0; + for (i = 0; i < 15; i++) + max = FFMAX(max, FFABS(energy[i])); + + exp = normalize_bits_int32(max); + for (i = 0; i < 15; i++) { + energy[i] = av_clipl_int32((int64_t)(energy[i] << exp) + + (1 << 15)) >> 16; + } + + hf->index = -1; + hf->gain = 0; + max_ccr = 1; + max_eng = 0x7fff; + + for (i = 0; i <= 6; i++) { + eng = energy[i << 1]; + ccr = energy[(i << 1) + 1]; + + if (ccr <= 0) + continue; + + ccr = (ccr * ccr + (1 << 14)) >> 15; + diff = ccr * max_eng - eng * max_ccr; + if (diff > 0) { + max_ccr = ccr; + max_eng = eng; + hf->index = i; + } + } + + if (hf->index == -1) { + hf->index = pitch_lag; + return; + } + + eng = energy[14] * max_eng; + eng = (eng >> 2) + (eng >> 3); + ccr = energy[(hf->index << 1) + 1] * energy[(hf->index << 1) + 1]; + if (eng < ccr) { + eng = energy[(hf->index << 1) + 1]; + + if (eng >= max_eng) + hf->gain = 0x2800; + else + hf->gain = ((eng << 15) / max_eng * 0x2800 + (1 << 14)) >> 15; + } + hf->index += pitch_lag - 3; +} + +/** + * Apply the harmonic noise shaping filter. + * + * @param hf filter parameters + */ +static void harmonic_filter(HFParam *hf, int16_t *src, int16_t *dest) +{ + int i; + + for (i = 0; i < SUBFRAME_LEN; i++) { + int64_t temp = hf->gain * src[i - hf->index] << 1; + dest[i] = av_clipl_int32((src[i] << 16) - temp + (1 << 15)) >> 16; + } +} + +static void harmonic_noise_sub(HFParam *hf, int16_t *src, int16_t *dest) +{ + int i; + for (i = 0; i < SUBFRAME_LEN; i++) { + int64_t temp = hf->gain * src[i - hf->index] << 1; + dest[i] = av_clipl_int32(((dest[i] - src[i]) << 16) + temp + + (1 << 15)) >> 16; + + } +} + +/** + * Combined synthesis and formant perceptual weighting filer. + * + * @param qnt_lpc quantized lpc coefficients + * @param perf_lpc perceptual filter coefficients + * @param perf_fir perceptual filter fir memory + * @param perf_iir perceptual filter iir memory + * @param scale the filter output will be scaled by 2^scale + */ +static void synth_percept_filter(int16_t *qnt_lpc, int16_t *perf_lpc, + int16_t *perf_fir, int16_t *perf_iir, + int16_t *src, int16_t *dest, int scale) +{ + int i, j; + int16_t buf_16[SUBFRAME_LEN + LPC_ORDER]; + int64_t buf[SUBFRAME_LEN]; + + int16_t *bptr_16 = buf_16 + LPC_ORDER; + + memcpy(buf_16, perf_fir, sizeof(int16_t) * LPC_ORDER); + memcpy(dest - LPC_ORDER, perf_iir, sizeof(int16_t) * LPC_ORDER); + + for (i = 0; i < SUBFRAME_LEN; i++) { + int64_t temp = 0; + for (j = 1; j <= LPC_ORDER; j++) + temp -= qnt_lpc[j - 1] * bptr_16[i - j]; + + buf[i] = (src[i] << 15) + (temp << 3); + bptr_16[i] = av_clipl_int32(buf[i] + (1 << 15)) >> 16; + } + + for (i = 0; i < SUBFRAME_LEN; i++) { + int64_t fir = 0, iir = 0; + for (j = 1; j <= LPC_ORDER; j++) { + fir -= perf_lpc[j - 1] * bptr_16[i - j]; + iir += perf_lpc[j + LPC_ORDER - 1] * dest[i - j]; + } + dest[i] = av_clipl_int32(((buf[i] + (fir << 3)) << scale) + (iir << 3) + + (1 << 15)) >> 16; + } + memcpy(perf_fir, buf_16 + SUBFRAME_LEN, sizeof(int16_t) * LPC_ORDER); + memcpy(perf_iir, dest + SUBFRAME_LEN - LPC_ORDER, + sizeof(int16_t) * LPC_ORDER); +} + +/** + * Compute the adaptive codebook contribution. + * + * @param buf input signal + * @param index the current subframe index + */ +static void acb_search(G723_1_Context *p, int16_t *residual, + int16_t *impulse_resp, int16_t *buf, + int index) +{ + + int16_t flt_buf[PITCH_ORDER][SUBFRAME_LEN]; + + const int16_t *cb_tbl = adaptive_cb_gain85; + + int ccr_buf[PITCH_ORDER * SUBFRAMES << 2]; + + int pitch_lag = p->pitch_lag[index >> 1]; + int acb_lag = 1; + int acb_gain = 0; + int odd_frame = index & 1; + int iter = 3 + odd_frame; + int count = 0; + int tbl_size = 85; + + int i, j, k, l, max; + int64_t temp; + + if (!odd_frame) { + if (pitch_lag == PITCH_MIN) + pitch_lag++; + else + pitch_lag = FFMIN(pitch_lag, PITCH_MAX - 5); + } + + for (i = 0; i < iter; i++) { + get_residual(residual, p->prev_excitation, pitch_lag + i - 1); + + for (j = 0; j < SUBFRAME_LEN; j++) { + temp = 0; + for (k = 0; k <= j; k++) + temp += residual[PITCH_ORDER - 1 + k] * impulse_resp[j - k]; + flt_buf[PITCH_ORDER - 1][j] = av_clipl_int32((temp << 1) + + (1 << 15)) >> 16; + } + + for (j = PITCH_ORDER - 2; j >= 0; j--) { + flt_buf[j][0] = ((residual[j] << 13) + (1 << 14)) >> 15; + for (k = 1; k < SUBFRAME_LEN; k++) { + temp = (flt_buf[j + 1][k - 1] << 15) + + residual[j] * impulse_resp[k]; + flt_buf[j][k] = av_clipl_int32((temp << 1) + (1 << 15)) >> 16; + } + } + + /* Compute crosscorrelation with the signal */ + for (j = 0; j < PITCH_ORDER; j++) { + temp = dot_product(buf, flt_buf[j], SUBFRAME_LEN, 0); + ccr_buf[count++] = av_clipl_int32(temp << 1); + } + + /* Compute energies */ + for (j = 0; j < PITCH_ORDER; j++) { + ccr_buf[count++] = dot_product(flt_buf[j], flt_buf[j], + SUBFRAME_LEN, 1); + } + + for (j = 1; j < PITCH_ORDER; j++) { + for (k = 0; k < j; k++) { + temp = dot_product(flt_buf[j], flt_buf[k], SUBFRAME_LEN, 0); + ccr_buf[count++] = av_clipl_int32(temp<<2); + } + } + } + + /* Normalize and shorten */ + max = 0; + for (i = 0; i < 20 * iter; i++) + max = FFMAX(max, FFABS(ccr_buf[i])); + + temp = normalize_bits_int32(max); + + for (i = 0; i < 20 * iter; i++){ + ccr_buf[i] = av_clipl_int32((int64_t)(ccr_buf[i] << temp) + + (1 << 15)) >> 16; + } + + max = 0; + for (i = 0; i < iter; i++) { + /* Select quantization table */ + if (!odd_frame && pitch_lag + i - 1 >= SUBFRAME_LEN - 2 || + odd_frame && pitch_lag >= SUBFRAME_LEN - 2) { + cb_tbl = adaptive_cb_gain170; + tbl_size = 170; + } + + for (j = 0, k = 0; j < tbl_size; j++, k += 20) { + temp = 0; + for (l = 0; l < 20; l++) + temp += ccr_buf[20 * i + l] * cb_tbl[k + l]; + temp = av_clipl_int32(temp); + + if (temp > max) { + max = temp; + acb_gain = j; + acb_lag = i; + } + } + } + + if (!odd_frame) { + pitch_lag += acb_lag - 1; + acb_lag = 1; + } + + p->pitch_lag[index >> 1] = pitch_lag; + p->subframe[index].ad_cb_lag = acb_lag; + p->subframe[index].ad_cb_gain = acb_gain; +} + +/** + * Subtract the adaptive codebook contribution from the input + * to obtain the residual. + * + * @param buf target vector + */ +static void sub_acb_contrib(int16_t *residual, int16_t *impulse_resp, + int16_t *buf) +{ + int i, j; + /* Subtract adaptive CB contribution to obtain the residual */ + for (i = 0; i < SUBFRAME_LEN; i++) { + int64_t temp = buf[i] << 14; + for (j = 0; j <= i; j++) + temp -= residual[j] * impulse_resp[i - j]; + + buf[i] = av_clipl_int32((temp << 2) + (1 << 15)) >> 16; + } +} + +/** + * Quantize the residual signal using the fixed codebook (MP-MLQ). + * + * @param optim optimized fixed codebook parameters + * @param buf excitation vector + */ +static void get_fcb_param(FCBParam *optim, int16_t *impulse_resp, + int16_t *buf, int pulse_cnt, int pitch_lag) +{ + FCBParam param; + int16_t impulse_r[SUBFRAME_LEN]; + int16_t temp_corr[SUBFRAME_LEN]; + int16_t impulse_corr[SUBFRAME_LEN]; + + int ccr1[SUBFRAME_LEN]; + int ccr2[SUBFRAME_LEN]; + int amp, err, max, max_amp_index, min, scale, i, j, k, l; + + int64_t temp; + + /* Update impulse response */ + memcpy(impulse_r, impulse_resp, sizeof(int16_t) * SUBFRAME_LEN); + param.dirac_train = 0; + if (pitch_lag < SUBFRAME_LEN - 2) { + param.dirac_train = 1; + gen_dirac_train(impulse_r, pitch_lag); + } + + for (i = 0; i < SUBFRAME_LEN; i++) + temp_corr[i] = impulse_r[i] >> 1; + + /* Compute impulse response autocorrelation */ + temp = dot_product(temp_corr, temp_corr, SUBFRAME_LEN, 1); + + scale = normalize_bits_int32(temp); + impulse_corr[0] = av_clipl_int32((temp << scale) + (1 << 15)) >> 16; + + for (i = 1; i < SUBFRAME_LEN; i++) { + temp = dot_product(temp_corr + i, temp_corr, SUBFRAME_LEN - i, 1); + impulse_corr[i] = av_clipl_int32((temp << scale) + (1 << 15)) >> 16; + } + + /* Compute crosscorrelation of impulse response with residual signal */ + scale -= 4; + for (i = 0; i < SUBFRAME_LEN; i++){ + temp = dot_product(buf + i, impulse_r, SUBFRAME_LEN - i, 1); + if (scale < 0) + ccr1[i] = temp >> -scale; + else + ccr1[i] = av_clipl_int32(temp << scale); + } + + /* Search loop */ + for (i = 0; i < GRID_SIZE; i++) { + /* Maximize the crosscorrelation */ + max = 0; + for (j = i; j < SUBFRAME_LEN; j += GRID_SIZE) { + temp = FFABS(ccr1[j]); + if (temp >= max) { + max = temp; + param.pulse_pos[0] = j; + } + } + + /* Quantize the gain (max crosscorrelation/impulse_corr[0]) */ + amp = max; + min = 1 << 30; + max_amp_index = GAIN_LEVELS - 2; + for (j = max_amp_index; j >= 2; j--) { + temp = av_clipl_int32((int64_t)fixed_cb_gain[j] * + impulse_corr[0] << 1); + temp = FFABS(temp - amp); + if (temp < min) { + min = temp; + max_amp_index = j; + } + } + + max_amp_index--; + /* Select additional gain values */ + for (j = 1; j < 5; j++) { + for (k = i; k < SUBFRAME_LEN; k += GRID_SIZE) { + temp_corr[k] = 0; + ccr2[k] = ccr1[k]; + } + param.amp_index = max_amp_index + j - 2; + amp = fixed_cb_gain[param.amp_index]; + + param.pulse_sign[0] = (ccr2[param.pulse_pos[0]] < 0) ? -amp : amp; + temp_corr[param.pulse_pos[0]] = 1; + + for (k = 1; k < pulse_cnt; k++) { + max = -1 << 30; + for (l = i; l < SUBFRAME_LEN; l += GRID_SIZE) { + if (temp_corr[l]) + continue; + temp = impulse_corr[FFABS(l - param.pulse_pos[k - 1])]; + temp = av_clipl_int32((int64_t)temp * + param.pulse_sign[k - 1] << 1); + ccr2[l] -= temp; + temp = FFABS(ccr2[l]); + if (temp > max) { + max = temp; + param.pulse_pos[k] = l; + } + } + + param.pulse_sign[k] = (ccr2[param.pulse_pos[k]] < 0) ? + -amp : amp; + temp_corr[param.pulse_pos[k]] = 1; + } + + /* Create the error vector */ + memset(temp_corr, 0, sizeof(int16_t) * SUBFRAME_LEN); + + for (k = 0; k < pulse_cnt; k++) + temp_corr[param.pulse_pos[k]] = param.pulse_sign[k]; + + for (k = SUBFRAME_LEN - 1; k >= 0; k--) { + temp = 0; + for (l = 0; l <= k; l++) { + int prod = av_clipl_int32((int64_t)temp_corr[l] * + impulse_r[k - l] << 1); + temp = av_clipl_int32(temp + prod); + } + temp_corr[k] = temp << 2 >> 16; + } + + /* Compute square of error */ + err = 0; + for (k = 0; k < SUBFRAME_LEN; k++) { + int64_t prod; + prod = av_clipl_int32((int64_t)buf[k] * temp_corr[k] << 1); + err = av_clipl_int32(err - prod); + prod = av_clipl_int32((int64_t)temp_corr[k] * temp_corr[k]); + err = av_clipl_int32(err + prod); + } + + /* Minimize */ + if (err < optim->min_err) { + optim->min_err = err; + optim->grid_index = i; + optim->amp_index = param.amp_index; + optim->dirac_train = param.dirac_train; + + for (k = 0; k < pulse_cnt; k++) { + optim->pulse_sign[k] = param.pulse_sign[k]; + optim->pulse_pos[k] = param.pulse_pos[k]; + } + } + } + } +} + +/** + * Encode the pulse position and gain of the current subframe. + * + * @param optim optimized fixed CB parameters + * @param buf excitation vector + */ +static void pack_fcb_param(G723_1_Subframe *subfrm, FCBParam *optim, + int16_t *buf, int pulse_cnt) +{ + int i, j; + + j = PULSE_MAX - pulse_cnt; + + subfrm->pulse_sign = 0; + subfrm->pulse_pos = 0; + + for (i = 0; i < SUBFRAME_LEN >> 1; i++) { + int val = buf[optim->grid_index + (i << 1)]; + if (!val) { + subfrm->pulse_pos += combinatorial_table[j][i]; + } else { + subfrm->pulse_sign <<= 1; + if (val < 0) subfrm->pulse_sign++; + j++; + + if (j == PULSE_MAX) break; + } + } + subfrm->amp_index = optim->amp_index; + subfrm->grid_index = optim->grid_index; + subfrm->dirac_train = optim->dirac_train; +} + +/** + * Compute the fixed codebook excitation. + * + * @param buf target vector + * @param impulse_resp impulse response of the combined filter + */ +static void fcb_search(G723_1_Context *p, int16_t *impulse_resp, + int16_t *buf, int index) +{ + FCBParam optim; + int pulse_cnt = pulses[index]; + int i; + + optim.min_err = 1 << 30; + get_fcb_param(&optim, impulse_resp, buf, pulse_cnt, SUBFRAME_LEN); + + if (p->pitch_lag[index >> 1] < SUBFRAME_LEN - 2) { + get_fcb_param(&optim, impulse_resp, buf, pulse_cnt, + p->pitch_lag[index >> 1]); + } + + /* Reconstruct the excitation */ + memset(buf, 0, sizeof(int16_t) * SUBFRAME_LEN); + for (i = 0; i < pulse_cnt; i++) + buf[optim.pulse_pos[i]] = optim.pulse_sign[i]; + + pack_fcb_param(&p->subframe[index], &optim, buf, pulse_cnt); + + if (optim.dirac_train) + gen_dirac_train(buf, p->pitch_lag[index >> 1]); +} + +/** + * Pack the frame parameters into output bitstream. + * + * @param frame output buffer + * @param size size of the buffer + */ +static int pack_bitstream(G723_1_Context *p, unsigned char *frame, int size) +{ + PutBitContext pb; + int info_bits, i, temp; + + init_put_bits(&pb, frame, size); + + if (p->cur_rate == Rate6k3) { + info_bits = 0; + put_bits(&pb, 2, info_bits); + } + + put_bits(&pb, 8, p->lsp_index[2]); + put_bits(&pb, 8, p->lsp_index[1]); + put_bits(&pb, 8, p->lsp_index[0]); + + put_bits(&pb, 7, p->pitch_lag[0] - PITCH_MIN); + put_bits(&pb, 2, p->subframe[1].ad_cb_lag); + put_bits(&pb, 7, p->pitch_lag[1] - PITCH_MIN); + put_bits(&pb, 2, p->subframe[3].ad_cb_lag); + + /* Write 12 bit combined gain */ + for (i = 0; i < SUBFRAMES; i++) { + temp = p->subframe[i].ad_cb_gain * GAIN_LEVELS + + p->subframe[i].amp_index; + if (p->cur_rate == Rate6k3) + temp += p->subframe[i].dirac_train << 11; + put_bits(&pb, 12, temp); + } + + put_bits(&pb, 1, p->subframe[0].grid_index); + put_bits(&pb, 1, p->subframe[1].grid_index); + put_bits(&pb, 1, p->subframe[2].grid_index); + put_bits(&pb, 1, p->subframe[3].grid_index); + + if (p->cur_rate == Rate6k3) { + skip_put_bits(&pb, 1); /* reserved bit */ + + /* Write 13 bit combined position index */ + temp = (p->subframe[0].pulse_pos >> 16) * 810 + + (p->subframe[1].pulse_pos >> 14) * 90 + + (p->subframe[2].pulse_pos >> 16) * 9 + + (p->subframe[3].pulse_pos >> 14); + put_bits(&pb, 13, temp); + + put_bits(&pb, 16, p->subframe[0].pulse_pos & 0xffff); + put_bits(&pb, 14, p->subframe[1].pulse_pos & 0x3fff); + put_bits(&pb, 16, p->subframe[2].pulse_pos & 0xffff); + put_bits(&pb, 14, p->subframe[3].pulse_pos & 0x3fff); + + put_bits(&pb, 6, p->subframe[0].pulse_sign); + put_bits(&pb, 5, p->subframe[1].pulse_sign); + put_bits(&pb, 6, p->subframe[2].pulse_sign); + put_bits(&pb, 5, p->subframe[3].pulse_sign); + } + + flush_put_bits(&pb); + return frame_size[info_bits]; +} + +static int g723_1_encode_frame(AVCodecContext *avctx, unsigned char *buf, + int buf_size, void *data) +{ + G723_1_Context *p = avctx->priv_data; + int16_t unq_lpc[LPC_ORDER * SUBFRAMES]; + int16_t qnt_lpc[LPC_ORDER * SUBFRAMES]; + int16_t cur_lsp[LPC_ORDER]; + int16_t weighted_lpc[LPC_ORDER * SUBFRAMES << 1]; + int16_t vector[FRAME_LEN + PITCH_MAX]; + int offset; + int16_t *in = data; + + HFParam hf[4]; + int i, j; + + highpass_filter(in, &p->hpf_fir_mem, &p->hpf_iir_mem); + + memcpy(vector, p->prev_data, HALF_FRAME_LEN * sizeof(int16_t)); + memcpy(vector + HALF_FRAME_LEN, in, FRAME_LEN * sizeof(int16_t)); + + comp_lpc_coeff(vector, unq_lpc); + lpc2lsp(&unq_lpc[LPC_ORDER * 3], p->prev_lsp, cur_lsp); + lsp_quantize(p->lsp_index, cur_lsp, p->prev_lsp); + + /* Update memory */ + memcpy(vector + LPC_ORDER, p->prev_data + SUBFRAME_LEN, + sizeof(int16_t) * SUBFRAME_LEN); + memcpy(vector + LPC_ORDER + SUBFRAME_LEN, in, + sizeof(int16_t) * (HALF_FRAME_LEN + SUBFRAME_LEN)); + memcpy(p->prev_data, in + HALF_FRAME_LEN, + sizeof(int16_t) * HALF_FRAME_LEN); + memcpy(in, vector + LPC_ORDER, sizeof(int16_t) * FRAME_LEN); + + perceptual_filter(p, weighted_lpc, unq_lpc, vector); + + memcpy(in, vector + LPC_ORDER, sizeof(int16_t) * FRAME_LEN); + memcpy(vector, p->prev_weight_sig, sizeof(int16_t) * PITCH_MAX); + memcpy(vector + PITCH_MAX, in, sizeof(int16_t) * FRAME_LEN); + + scale_vector(vector, FRAME_LEN + PITCH_MAX); + + p->pitch_lag[0] = estimate_pitch(vector, PITCH_MAX); + p->pitch_lag[1] = estimate_pitch(vector, PITCH_MAX + HALF_FRAME_LEN); + + for (i = PITCH_MAX, j = 0; j < SUBFRAMES; i += SUBFRAME_LEN, j++) + comp_harmonic_coeff(vector + i, p->pitch_lag[j >> 1], hf + j); + + memcpy(vector, p->prev_weight_sig, sizeof(int16_t) * PITCH_MAX); + memcpy(vector + PITCH_MAX, in, sizeof(int16_t) * FRAME_LEN); + memcpy(p->prev_weight_sig, vector + FRAME_LEN, sizeof(int16_t) * PITCH_MAX); + + for (i = 0, j = 0; j < SUBFRAMES; i += SUBFRAME_LEN, j++) + harmonic_filter(hf + j, vector + PITCH_MAX + i, in + i); + + inverse_quant(cur_lsp, p->prev_lsp, p->lsp_index, 0); + lsp_interpolate(qnt_lpc, cur_lsp, p->prev_lsp); + + memcpy(p->prev_lsp, cur_lsp, sizeof(int16_t) * LPC_ORDER); + + offset = 0; + for (i = 0; i < SUBFRAMES; i++) { + int16_t impulse_resp[SUBFRAME_LEN]; + int16_t residual[SUBFRAME_LEN + PITCH_ORDER - 1]; + int16_t flt_in[SUBFRAME_LEN]; + int16_t zero[LPC_ORDER], fir[LPC_ORDER], iir[LPC_ORDER]; + + /** + * Compute the combined impulse response of the synthesis filter, + * formant perceptual weighting filter and harmonic noise shaping filter + */ + memset(zero, 0, sizeof(int16_t) * LPC_ORDER); + memset(vector, 0, sizeof(int16_t) * PITCH_MAX); + memset(flt_in, 0, sizeof(int16_t) * SUBFRAME_LEN); + + flt_in[0] = 1 << 13; /* Unit impulse */ + synth_percept_filter(qnt_lpc + offset, weighted_lpc + (offset << 1), + zero, zero, flt_in, vector + PITCH_MAX, 1); + harmonic_filter(hf + i, vector + PITCH_MAX, impulse_resp); + + /* Compute the combined zero input response */ + flt_in[0] = 0; + memcpy(fir, p->perf_fir_mem, sizeof(int16_t) * LPC_ORDER); + memcpy(iir, p->perf_iir_mem, sizeof(int16_t) * LPC_ORDER); + + synth_percept_filter(qnt_lpc + offset, weighted_lpc + (offset << 1), + fir, iir, flt_in, vector + PITCH_MAX, 0); + memcpy(vector, p->harmonic_mem, sizeof(int16_t) * PITCH_MAX); + harmonic_noise_sub(hf + i, vector + PITCH_MAX, in); + + acb_search(p, residual, impulse_resp, in, i); + gen_acb_excitation(residual, p->prev_excitation,p->pitch_lag[i >> 1], + p->subframe[i], p->cur_rate); + sub_acb_contrib(residual, impulse_resp, in); + + fcb_search(p, impulse_resp, in, i); + + /* Reconstruct the excitation */ + gen_acb_excitation(impulse_resp, p->prev_excitation, p->pitch_lag[i >> 1], + p->subframe[i], Rate6k3); + + memmove(p->prev_excitation, p->prev_excitation + SUBFRAME_LEN, + sizeof(int16_t) * (PITCH_MAX - SUBFRAME_LEN)); + for (j = 0; j < SUBFRAME_LEN; j++) + in[j] = av_clip_int16((in[j] << 1) + impulse_resp[j]); + memcpy(p->prev_excitation + PITCH_MAX - SUBFRAME_LEN, in, + sizeof(int16_t) * SUBFRAME_LEN); + + /* Update filter memories */ + synth_percept_filter(qnt_lpc + offset, weighted_lpc + (offset << 1), + p->perf_fir_mem, p->perf_iir_mem, + in, vector + PITCH_MAX, 0); + memmove(p->harmonic_mem, p->harmonic_mem + SUBFRAME_LEN, + sizeof(int16_t) * (PITCH_MAX - SUBFRAME_LEN)); + memcpy(p->harmonic_mem + PITCH_MAX - SUBFRAME_LEN, vector + PITCH_MAX, + sizeof(int16_t) * SUBFRAME_LEN); + + in += SUBFRAME_LEN; + offset += LPC_ORDER; + } + + return pack_bitstream(p, buf, buf_size); +} + +AVCodec ff_g723_1_encoder = { + .name = "g723_1", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_G723_1, + .priv_data_size = sizeof(G723_1_Context), + .init = g723_1_encode_init, + .encode = g723_1_encode_frame, + .long_name = NULL_IF_CONFIG_SMALL("G.723.1"), + .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16, + SAMPLE_FMT_NONE}, +}; +#endif diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/g723_1_data.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/g723_1_data.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/g723_1_data.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/g723_1_data.h 2011-11-04 12:38:26.000000000 +0000 @@ -28,6 +28,8 @@ #define SUBFRAMES 4 #define SUBFRAME_LEN 60 #define FRAME_LEN (SUBFRAME_LEN << 2) +#define HALF_FRAME_LEN (FRAME_LEN / 2) +#define LPC_FRAME (HALF_FRAME_LEN + SUBFRAME_LEN) #define LPC_ORDER 10 #define LSP_BANDS 3 #define LSP_CB_SIZE 256 @@ -78,6 +80,26 @@ } PPFParam; /** + * Harmonic filter parameters + */ +typedef struct { + int index; + int gain; +} HFParam; + +/** + * Optimized fixed codebook excitation parameters + */ +typedef struct { + int min_err; + int amp_index; + int grid_index; + int dirac_train; + int pulse_pos[PULSE_MAX]; + int pulse_sign[PULSE_MAX]; +} FCBParam; + +/** * Postfilter gain weighting factors scaled by 2^15 */ static const int16_t ppf_gain_weight[2] = {0x1800, 0x2000}; @@ -1243,3 +1265,51 @@ /* Pole */ {24576, 18432, 13824, 10368, 7776, 5832, 4374, 3281, 2460, 1845} }; + +/** + * Hamming window coefficients scaled by 2^15 + */ +static const int16_t hamming_window[LPC_FRAME] = { + 2621, 2631, 2659, 2705, 2770, 2853, 2955, 3074, 3212, 3367, + 3541, 3731, 3939, 4164, 4405, 4663, 4937, 5226, 5531, 5851, + 6186, 6534, 6897, 7273, 7661, 8062, 8475, 8899, 9334, 9780, + 10235, 10699, 11172, 11653, 12141, 12636, 13138, 13645, 14157, 14673, + 15193, 15716, 16242, 16769, 17298, 17827, 18356, 18884, 19411, 19935, + 20457, 20975, 21489, 21999, 22503, 23002, 23494, 23978, 24455, 24924, + 25384, 25834, 26274, 26704, 27122, 27529, 27924, 28306, 28675, 29031, + 29373, 29700, 30012, 30310, 30592, 30857, 31107, 31340, 31557, 31756, + 31938, 32102, 32249, 32377, 32488, 32580, 32654, 32710, 32747, 32766, + 32766, 32747, 32710, 32654, 32580, 32488, 32377, 32249, 32102, 31938, + 31756, 31557, 31340, 31107, 30857, 30592, 30310, 30012, 29700, 29373, + 29031, 28675, 28306, 27924, 27529, 27122, 26704, 26274, 25834, 25384, + 24924, 24455, 23978, 23494, 23002, 22503, 21999, 21489, 20975, 20457, + 19935, 19411, 18884, 18356, 17827, 17298, 16769, 16242, 15716, 15193, + 14673, 14157, 13645, 13138, 12636, 12141, 11653, 11172, 10699, 10235, + 9780, 9334, 8899, 8475, 8062, 7661, 7273, 6897, 6534, 6186, + 5851, 5531, 5226, 4937, 4663, 4405, 4164, 3939, 3731, 3541, + 3367, 3212, 3074, 2955, 2853, 2770, 2705, 2659, 2631, 2621 +}; + +/** + * Binomial window coefficients scaled by 2^15 + */ +static const int16_t binomial_window[LPC_ORDER] = { + 32749, 32695, 32604, 32477, 32315, 32118, 31887, 31622, 31324, 30995 +}; + +/** + * 0.994^i scaled by 2^15 + */ +static const int16_t bandwidth_expand[LPC_ORDER] = { + 32571, 32376, 32182, 31989, 31797, 31606, 31416, 31228, 31040, 30854 +}; + +/** + * 0.5^i scaled by 2^15 + */ +static const int16_t percept_flt_tbl[2][LPC_ORDER] = { + /* Zero part */ + {29491, 26542, 23888, 21499, 19349, 17414, 15673, 14106, 12695, 11425}, + /* Pole part */ + {16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32} +}; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/g726.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/g726.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/g726.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/g726.c 2011-11-04 12:38:26.000000000 +0000 @@ -22,7 +22,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include +#include "libavutil/avassert.h" +#include "libavutil/opt.h" #include "avcodec.h" +#include "internal.h" #include "get_bits.h" #include "put_bits.h" @@ -71,6 +74,7 @@ } G726Tables; typedef struct G726Context { + AVClass *class; G726Tables tbls; /**< static tables needed for computation */ Float11 sr[2]; /**< prev. reconstructed samples */ @@ -266,11 +270,11 @@ return av_clip(re_signal << 2, -0xffff, 0xffff); } -static av_cold int g726_reset(G726Context* c, int index) +static av_cold int g726_reset(G726Context *c) { int i; - c->tbls = G726Tables_pool[index]; + c->tbls = G726Tables_pool[c->code_size - 2]; for (i=0; i<2; i++) { c->sr[i].mant = 1<<5; c->pk[i] = 1; @@ -295,65 +299,59 @@ g726_decode(c, i); return i; } -#endif /* Interfacing to the libavcodec */ -static av_cold int g726_init(AVCodecContext * avctx) +static av_cold int g726_encode_init(AVCodecContext *avctx) { G726Context* c = avctx->priv_data; - unsigned int index; - if (avctx->sample_rate <= 0) { - av_log(avctx, AV_LOG_ERROR, "Samplerate is invalid\n"); - return -1; + if (avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL && + avctx->sample_rate != 8000) { + av_log(avctx, AV_LOG_ERROR, "Sample rates other than 8kHz are not " + "allowed when the compliance level is higher than unofficial. " + "Resample or reduce the compliance level.\n"); + return AVERROR(EINVAL); } + av_assert0(avctx->sample_rate > 0); - index = (avctx->bit_rate + avctx->sample_rate/2) / avctx->sample_rate - 2; - - if (avctx->bit_rate % avctx->sample_rate && avctx->codec->encode) { - av_log(avctx, AV_LOG_ERROR, "Bitrate - Samplerate combination is invalid\n"); - return -1; - } if(avctx->channels != 1){ av_log(avctx, AV_LOG_ERROR, "Only mono is supported\n"); - return -1; - } - if(index>3){ - av_log(avctx, AV_LOG_ERROR, "Unsupported number of bits %d\n", index+2); - return -1; + return AVERROR(EINVAL); } - g726_reset(c, index); - c->code_size = index+2; + + if (avctx->bit_rate) + c->code_size = (avctx->bit_rate + avctx->sample_rate/2) / avctx->sample_rate; + + c->code_size = av_clip(c->code_size, 2, 5); + avctx->bit_rate = c->code_size * avctx->sample_rate; + avctx->bits_per_coded_sample = c->code_size; + + g726_reset(c); avctx->coded_frame = avcodec_alloc_frame(); if (!avctx->coded_frame) return AVERROR(ENOMEM); avctx->coded_frame->key_frame = 1; - if (avctx->codec->decode) - avctx->sample_fmt = AV_SAMPLE_FMT_S16; - /* select a frame size that will end on a byte boundary and have a size of approximately 1024 bytes */ - if (avctx->codec->encode) - avctx->frame_size = ((int[]){ 4096, 2736, 2048, 1640 })[index]; + avctx->frame_size = ((int[]){ 4096, 2736, 2048, 1640 })[c->code_size - 2]; return 0; } -static av_cold int g726_close(AVCodecContext *avctx) +static av_cold int g726_encode_close(AVCodecContext *avctx) { av_freep(&avctx->coded_frame); return 0; } -#if CONFIG_ADPCM_G726_ENCODER static int g726_encode_frame(AVCodecContext *avctx, uint8_t *dst, int buf_size, void *data) { G726Context *c = avctx->priv_data; - const short *samples = data; + const int16_t *samples = data; PutBitContext pb; int i; @@ -366,8 +364,72 @@ return put_bits_count(&pb)>>3; } + +#define OFFSET(x) offsetof(G726Context, x) +#define AE AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM +static const AVOption options[] = { + { "code_size", "Bits per code", OFFSET(code_size), AV_OPT_TYPE_INT, { 4 }, 2, 5, AE }, + { NULL }, +}; + +static const AVClass class = { + .class_name = "g726", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + +static const AVCodecDefault defaults[] = { + { "b", "0" }, + { NULL }, +}; + +AVCodec ff_adpcm_g726_encoder = { + .name = "g726", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_ADPCM_G726, + .priv_data_size = sizeof(G726Context), + .init = g726_encode_init, + .encode = g726_encode_frame, + .close = g726_encode_close, + .capabilities = CODEC_CAP_SMALL_LAST_FRAME, + .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, + .long_name = NULL_IF_CONFIG_SMALL("G.726 ADPCM"), + .priv_class = &class, + .defaults = defaults, +}; #endif +#if CONFIG_ADPCM_G726_DECODER +static av_cold int g726_decode_init(AVCodecContext *avctx) +{ + G726Context* c = avctx->priv_data; + + if (avctx->strict_std_compliance >= FF_COMPLIANCE_STRICT && + avctx->sample_rate != 8000) { + av_log(avctx, AV_LOG_ERROR, "Only 8kHz sample rate is allowed when " + "the compliance level is strict. Reduce the compliance level " + "if you wish to decode the stream anyway.\n"); + return AVERROR(EINVAL); + } + + if(avctx->channels != 1){ + av_log(avctx, AV_LOG_ERROR, "Only mono is supported\n"); + return AVERROR(EINVAL); + } + + c->code_size = avctx->bits_per_coded_sample; + if (c->code_size < 2 || c->code_size > 5) { + av_log(avctx, AV_LOG_ERROR, "Invalid number of bits %d\n", c->code_size); + return AVERROR(EINVAL); + } + g726_reset(c); + + avctx->sample_fmt = AV_SAMPLE_FMT_S16; + + return 0; +} + static int g726_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) @@ -375,43 +437,43 @@ const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; G726Context *c = avctx->priv_data; - short *samples = data; + int16_t *samples = data; GetBitContext gb; + int out_samples, out_size; + + out_samples = buf_size * 8 / c->code_size; + out_size = out_samples * av_get_bytes_per_sample(avctx->sample_fmt); + if (*data_size < out_size) { + av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); + return AVERROR(EINVAL); + } init_get_bits(&gb, buf, buf_size * 8); - while (get_bits_count(&gb) + c->code_size <= buf_size*8) + while (out_samples--) *samples++ = g726_decode(c, get_bits(&gb, c->code_size)); - if(buf_size*8 != get_bits_count(&gb)) + if (get_bits_left(&gb) > 0) av_log(avctx, AV_LOG_ERROR, "Frame invalidly split, missing parser?\n"); - *data_size = (uint8_t*)samples - (uint8_t*)data; + *data_size = out_size; return buf_size; } -#if CONFIG_ADPCM_G726_ENCODER -AVCodec ff_adpcm_g726_encoder = { - .name = "g726", - .type = AVMEDIA_TYPE_AUDIO, - .id = CODEC_ID_ADPCM_G726, - .priv_data_size = sizeof(G726Context), - .init = g726_init, - .encode = g726_encode_frame, - .close = g726_close, - .capabilities = CODEC_CAP_SMALL_LAST_FRAME, - .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, - .long_name = NULL_IF_CONFIG_SMALL("G.726 ADPCM"), -}; -#endif +static void g726_decode_flush(AVCodecContext *avctx) +{ + G726Context *c = avctx->priv_data; + g726_reset(c); +} AVCodec ff_adpcm_g726_decoder = { .name = "g726", .type = AVMEDIA_TYPE_AUDIO, .id = CODEC_ID_ADPCM_G726, .priv_data_size = sizeof(G726Context), - .init = g726_init, - .close = g726_close, + .init = g726_decode_init, .decode = g726_decode_frame, + .flush = g726_decode_flush, .long_name = NULL_IF_CONFIG_SMALL("G.726 ADPCM"), }; +#endif diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/golomb.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/golomb.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/golomb.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/golomb.h 2011-11-04 12:38:26.000000000 +0000 @@ -75,6 +75,20 @@ } } +/** + * Read an unsigned Exp-Golomb code in the range 0 to UINT32_MAX-1. + */ +static inline unsigned get_ue_golomb_long(GetBitContext *gb) +{ + unsigned buf, log; + + buf = show_bits_long(gb, 32); + log = 31 - av_log2(buf); + skip_bits_long(gb, log); + + return get_bits_long(gb, log + 1) - 1; +} + /** * read unsigned exp golomb code, constraint to a max of 31. * the return value is undefined if the stored value exceeds 31. diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/gsmdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/gsmdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/gsmdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/gsmdec.c 2011-11-04 12:38:26.000000000 +0000 @@ -58,13 +58,18 @@ const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; int16_t *samples = data; - int frame_bytes = 2 * avctx->frame_size; + int frame_bytes = avctx->frame_size * + av_get_bytes_per_sample(avctx->sample_fmt); - if (*data_size < frame_bytes) - return -1; - *data_size = 0; - if(buf_size < avctx->block_align) + if (*data_size < frame_bytes) { + av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); + return AVERROR(EINVAL); + } + + if (buf_size < avctx->block_align) { + av_log(avctx, AV_LOG_ERROR, "Packet is too small\n"); return AVERROR_INVALIDDATA; + } switch (avctx->codec_id) { case CODEC_ID_GSM: @@ -84,6 +89,12 @@ return avctx->block_align; } +static void gsm_flush(AVCodecContext *avctx) +{ + GSMContext *s = avctx->priv_data; + memset(s, 0, sizeof(*s)); +} + AVCodec ff_gsm_decoder = { .name = "gsm", .type = AVMEDIA_TYPE_AUDIO, @@ -91,6 +102,7 @@ .priv_data_size = sizeof(GSMContext), .init = gsm_init, .decode = gsm_decode_frame, + .flush = gsm_flush, .long_name = NULL_IF_CONFIG_SMALL("GSM"), }; @@ -101,5 +113,6 @@ .priv_data_size = sizeof(GSMContext), .init = gsm_init, .decode = gsm_decode_frame, + .flush = gsm_flush, .long_name = NULL_IF_CONFIG_SMALL("GSM Microsoft variant"), }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h261dec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h261dec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h261dec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h261dec.c 2011-11-04 12:38:26.000000000 +0000 @@ -136,7 +136,7 @@ if(s->qscale==0) { av_log(s->avctx, AV_LOG_ERROR, "qscale has forbidden 0 value\n"); - if (s->avctx->error_recognition >= FF_ER_COMPLIANT) + if (s->avctx->err_recognition & AV_EF_BITSTREAM) return -1; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h261enc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h261enc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h261enc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h261enc.c 2011-11-04 12:38:26.000000000 +0000 @@ -53,7 +53,7 @@ H261Context * h = (H261Context *) s; int format, temp_ref; - align_put_bits(&s->pb); + avpriv_align_put_bits(&s->pb); /* Update the pointer to last GOB */ s->ptr_lastgob = put_bits_ptr(&s->pb); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h261_parser.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h261_parser.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h261_parser.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h261_parser.c 2011-11-04 12:38:26.000000000 +0000 @@ -86,9 +86,8 @@ } AVCodecParser ff_h261_parser = { - { CODEC_ID_H261 }, - sizeof(ParseContext), - NULL, - h261_parse, - ff_parse_close, + .codec_ids = { CODEC_ID_H261 }, + .priv_data_size = sizeof(ParseContext), + .parser_parse = h261_parse, + .parser_close = ff_parse_close, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h263.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h263.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h263.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h263.c 2011-11-04 12:38:26.000000000 +0000 @@ -1,5 +1,5 @@ /* - * H263/MPEG4 backend for ffmpeg encoder and decoder + * H263/MPEG4 backend for encoder and decoder * Copyright (c) 2000,2001 Fabrice Bellard * H263+ support. * Copyright (c) 2001 Juan J. Sierralta P diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h263dec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h263dec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h263dec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h263dec.c 2011-11-04 12:38:26.000000000 +0000 @@ -732,7 +732,7 @@ av_log(avctx, AV_LOG_DEBUG, "%"PRId64"\n", rdtsc()-time); #endif - return (ret && avctx->error_recognition >= FF_ER_EXPLODE)?ret:get_consumed_bytes(s, buf_size); + return (ret && (avctx->err_recognition & AV_EF_EXPLODE))?ret:get_consumed_bytes(s, buf_size); } AVCodec ff_h263_decoder = { diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h263.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h263.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h263.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h263.h 2011-11-04 12:38:26.000000000 +0000 @@ -200,48 +200,6 @@ return cbp; } -static inline int get_b_cbp(MpegEncContext * s, DCTELEM block[6][64], - int motion_x, int motion_y, int mb_type){ - int cbp=0, i; - - if(s->flags & CODEC_FLAG_CBP_RD){ - int score=0; - const int lambda= s->lambda2 >> (FF_LAMBDA_SHIFT - 6); - - for(i=0; i<6; i++){ - if(s->coded_score[i] < 0){ - score += s->coded_score[i]; - cbp |= 1 << (5 - i); - } - } - - if(cbp){ - int zero_score= -6; - if ((motion_x | motion_y | s->dquant | mb_type) == 0){ - zero_score-= 4; //2*MV + mb_type + cbp bit - } - - zero_score*= lambda; - if(zero_score <= score){ - cbp=0; - } - } - - for (i = 0; i < 6; i++) { - if (s->block_last_index[i] >= 0 && ((cbp >> (5 - i))&1)==0 ){ - s->block_last_index[i]= -1; - s->dsp.clear_block(s->block[i]); - } - } - }else{ - for (i = 0; i < 6; i++) { - if (s->block_last_index[i] >= 0) - cbp |= 1 << (5 - i); - } - } - return cbp; -} - static inline void memsetw(short *tab, int val, int n) { int i; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h263_parser.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h263_parser.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h263_parser.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h263_parser.c 2011-11-04 12:38:26.000000000 +0000 @@ -88,9 +88,8 @@ } AVCodecParser ff_h263_parser = { - { CODEC_ID_H263 }, - sizeof(ParseContext), - NULL, - h263_parse, - ff_parse_close, + .codec_ids = { CODEC_ID_H263 }, + .priv_data_size = sizeof(ParseContext), + .parser_parse = h263_parse, + .parser_close = ff_parse_close, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h264.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h264.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h264.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h264.c 2011-11-04 12:38:26.000000000 +0000 @@ -26,6 +26,7 @@ */ #include "libavutil/imgutils.h" +#include "libavutil/opt.h" #include "internal.h" #include "dsputil.h" #include "avcodec.h" @@ -56,6 +57,7 @@ static const enum PixelFormat hwaccel_pixfmt_list_h264_jpeg_420[] = { PIX_FMT_DXVA2_VLD, PIX_FMT_VAAPI_VLD, + PIX_FMT_VDA_VLD, PIX_FMT_YUVJ420P, PIX_FMT_NONE }; @@ -460,11 +462,14 @@ } #endif -static inline void mc_dir_part(H264Context *h, Picture *pic, int n, int square, int chroma_height, int delta, int list, - uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, - int src_x_offset, int src_y_offset, - qpel_mc_func *qpix_op, h264_chroma_mc_func chroma_op, - int pixel_shift, int chroma444){ +static av_always_inline void +mc_dir_part(H264Context *h, Picture *pic, int n, int square, + int height, int delta, int list, + uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, + int src_x_offset, int src_y_offset, + qpel_mc_func *qpix_op, h264_chroma_mc_func chroma_op, + int pixel_shift, int chroma_idc) +{ MpegEncContext * const s = &h->s; const int mx= h->mv_cache[list][ scan8[n] ][0] + src_x_offset*8; int my= h->mv_cache[list][ scan8[n] ][1] + src_y_offset*8; @@ -479,6 +484,7 @@ const int full_my= my>>2; const int pic_width = 16*s->mb_width; const int pic_height = 16*s->mb_height >> MB_FIELD; + int ysh; if(mx&7) extra_width -= 3; if(my&7) extra_height -= 3; @@ -487,7 +493,8 @@ || full_my < 0-extra_height || full_mx + 16/*FIXME*/ > pic_width + extra_width || full_my + 16/*FIXME*/ > pic_height + extra_height){ - s->dsp.emulated_edge_mc(s->edge_emu_buffer, src_y - (2 << pixel_shift) - 2*h->mb_linesize, h->mb_linesize, 16+5, 16+5/*FIXME*/, full_mx-2, full_my-2, pic_width, pic_height); + s->dsp.emulated_edge_mc(s->edge_emu_buffer, src_y - (2 << pixel_shift) - 2*h->mb_linesize, h->mb_linesize, + 16+5, 16+5/*FIXME*/, full_mx-2, full_my-2, pic_width, pic_height); src_y= s->edge_emu_buffer + (2 << pixel_shift) + 2*h->mb_linesize; emu=1; } @@ -499,7 +506,7 @@ if(CONFIG_GRAY && s->flags&CODEC_FLAG_GRAY) return; - if(chroma444){ + if(chroma_idc == 3 /* yuv444 */){ src_cb = pic->f.data[1] + offset; if(emu){ s->dsp.emulated_edge_mc(s->edge_emu_buffer, src_cb - (2 << pixel_shift) - 2*h->mb_linesize, h->mb_linesize, @@ -524,42 +531,55 @@ return; } - if(MB_FIELD){ + ysh = 3 - (chroma_idc == 2 /* yuv422 */); + if(chroma_idc == 1 /* yuv420 */ && MB_FIELD){ // chroma offset when predicting from a field of opposite parity my += 2 * ((s->mb_y & 1) - (pic->f.reference - 1)); emu |= (my>>3) < 0 || (my>>3) + 8 >= (pic_height>>1); } - src_cb = pic->f.data[1] + ((mx >> 3) << pixel_shift) + (my >> 3) * h->mb_uvlinesize; - src_cr = pic->f.data[2] + ((mx >> 3) << pixel_shift) + (my >> 3) * h->mb_uvlinesize; + + src_cb = pic->f.data[1] + ((mx >> 3) << pixel_shift) + (my >> ysh) * h->mb_uvlinesize; + src_cr = pic->f.data[2] + ((mx >> 3) << pixel_shift) + (my >> ysh) * h->mb_uvlinesize; if(emu){ - s->dsp.emulated_edge_mc(s->edge_emu_buffer, src_cb, h->mb_uvlinesize, 9, 9/*FIXME*/, (mx>>3), (my>>3), pic_width>>1, pic_height>>1); + s->dsp.emulated_edge_mc(s->edge_emu_buffer, src_cb, h->mb_uvlinesize, + 9, 8 * chroma_idc + 1, (mx >> 3), (my >> ysh), + pic_width >> 1, pic_height >> (chroma_idc == 1 /* yuv420 */)); src_cb= s->edge_emu_buffer; } - chroma_op(dest_cb, src_cb, h->mb_uvlinesize, chroma_height, mx&7, my&7); + chroma_op(dest_cb, src_cb, h->mb_uvlinesize, height >> (chroma_idc == 1 /* yuv420 */), + mx&7, (my << (chroma_idc == 2 /* yuv422 */)) &7); if(emu){ - s->dsp.emulated_edge_mc(s->edge_emu_buffer, src_cr, h->mb_uvlinesize, 9, 9/*FIXME*/, (mx>>3), (my>>3), pic_width>>1, pic_height>>1); + s->dsp.emulated_edge_mc(s->edge_emu_buffer, src_cr, h->mb_uvlinesize, + 9, 8 * chroma_idc + 1, (mx >> 3), (my >> ysh), + pic_width >> 1, pic_height >> (chroma_idc == 1 /* yuv420 */)); src_cr= s->edge_emu_buffer; } - chroma_op(dest_cr, src_cr, h->mb_uvlinesize, chroma_height, mx&7, my&7); + chroma_op(dest_cr, src_cr, h->mb_uvlinesize, height >> (chroma_idc == 1 /* yuv420 */), + mx&7, (my << (chroma_idc == 2 /* yuv422 */)) &7); } -static inline void mc_part_std(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, - qpel_mc_func *qpix_avg, h264_chroma_mc_func chroma_avg, - int list0, int list1, int pixel_shift, int chroma444){ +static av_always_inline void +mc_part_std(H264Context *h, int n, int square, int 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, + qpel_mc_func *qpix_avg, h264_chroma_mc_func chroma_avg, + int list0, int list1, int pixel_shift, int chroma_idc) +{ MpegEncContext * const s = &h->s; qpel_mc_func *qpix_op= qpix_put; h264_chroma_mc_func chroma_op= chroma_put; dest_y += (2*x_offset << pixel_shift) + 2*y_offset*h->mb_linesize; - if(chroma444){ + if (chroma_idc == 3 /* yuv444 */) { dest_cb += (2*x_offset << pixel_shift) + 2*y_offset*h->mb_linesize; dest_cr += (2*x_offset << pixel_shift) + 2*y_offset*h->mb_linesize; - }else{ + } else if (chroma_idc == 2 /* yuv422 */) { + dest_cb += ( x_offset << pixel_shift) + 2*y_offset*h->mb_uvlinesize; + dest_cr += ( x_offset << pixel_shift) + 2*y_offset*h->mb_uvlinesize; + } else /* yuv420 */ { dest_cb += ( x_offset << pixel_shift) + y_offset*h->mb_uvlinesize; dest_cr += ( x_offset << pixel_shift) + y_offset*h->mb_uvlinesize; } @@ -568,9 +588,9 @@ if(list0){ Picture *ref= &h->ref_list[0][ h->ref_cache[0][ scan8[n] ] ]; - mc_dir_part(h, ref, n, square, chroma_height, delta, 0, + mc_dir_part(h, ref, n, square, height, delta, 0, dest_y, dest_cb, dest_cr, x_offset, y_offset, - qpix_op, chroma_op, pixel_shift, chroma444); + qpix_op, chroma_op, pixel_shift, chroma_idc); qpix_op= qpix_avg; chroma_op= chroma_avg; @@ -578,28 +598,36 @@ if(list1){ Picture *ref= &h->ref_list[1][ h->ref_cache[1][ scan8[n] ] ]; - mc_dir_part(h, ref, n, square, chroma_height, delta, 1, + mc_dir_part(h, ref, n, square, height, delta, 1, dest_y, dest_cb, dest_cr, x_offset, y_offset, - qpix_op, chroma_op, pixel_shift, chroma444); + qpix_op, chroma_op, pixel_shift, chroma_idc); } } -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, int pixel_shift, int chroma444){ +static av_always_inline void +mc_part_weighted(H264Context *h, int n, int square, int 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, int pixel_shift, int chroma_idc){ MpegEncContext * const s = &h->s; + int chroma_height; dest_y += (2*x_offset << pixel_shift) + 2*y_offset*h->mb_linesize; - if(chroma444){ + if (chroma_idc == 3 /* yuv444 */) { + chroma_height = height; chroma_weight_avg = luma_weight_avg; chroma_weight_op = luma_weight_op; dest_cb += (2*x_offset << pixel_shift) + 2*y_offset*h->mb_linesize; dest_cr += (2*x_offset << pixel_shift) + 2*y_offset*h->mb_linesize; - }else{ + } else if (chroma_idc == 2 /* yuv422 */) { + chroma_height = height; + dest_cb += ( x_offset << pixel_shift) + 2*y_offset*h->mb_uvlinesize; + dest_cr += ( x_offset << pixel_shift) + 2*y_offset*h->mb_uvlinesize; + } else /* yuv420 */ { + chroma_height = height >> 1; dest_cb += ( x_offset << pixel_shift) + y_offset*h->mb_uvlinesize; dest_cr += ( x_offset << pixel_shift) + y_offset*h->mb_uvlinesize; } @@ -615,27 +643,32 @@ 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, + mc_dir_part(h, &h->ref_list[0][refn0], n, square, height, delta, 0, dest_y, dest_cb, dest_cr, - x_offset, y_offset, qpix_put, chroma_put, pixel_shift, chroma444); - mc_dir_part(h, &h->ref_list[1][refn1], n, square, chroma_height, delta, 1, + x_offset, y_offset, qpix_put, chroma_put, + pixel_shift, chroma_idc); + mc_dir_part(h, &h->ref_list[1][refn1], n, square, height, delta, 1, tmp_y, tmp_cb, tmp_cr, - x_offset, y_offset, qpix_put, chroma_put, pixel_shift, chroma444); + x_offset, y_offset, qpix_put, chroma_put, + pixel_shift, chroma_idc); if(h->use_weight == 2){ int weight0 = h->implicit_weight[refn0][refn1][s->mb_y&1]; 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); + luma_weight_avg( dest_y, tmp_y, h-> mb_linesize, + height, 5, weight0, weight1, 0); + chroma_weight_avg(dest_cb, tmp_cb, h->mb_uvlinesize, + chroma_height, 5, weight0, weight1, 0); + chroma_weight_avg(dest_cr, tmp_cr, h->mb_uvlinesize, + chroma_height, 5, weight0, weight1, 0); }else{ - luma_weight_avg(dest_y, tmp_y, h->mb_linesize, h->luma_log2_weight_denom, + luma_weight_avg(dest_y, tmp_y, h->mb_linesize, height, h->luma_log2_weight_denom, h->luma_weight[refn0][0][0] , h->luma_weight[refn1][1][0], h->luma_weight[refn0][0][1] + h->luma_weight[refn1][1][1]); - chroma_weight_avg(dest_cb, tmp_cb, h->mb_uvlinesize, h->chroma_log2_weight_denom, + chroma_weight_avg(dest_cb, tmp_cb, h->mb_uvlinesize, chroma_height, h->chroma_log2_weight_denom, h->chroma_weight[refn0][0][0][0] , h->chroma_weight[refn1][1][0][0], h->chroma_weight[refn0][0][0][1] + h->chroma_weight[refn1][1][0][1]); - chroma_weight_avg(dest_cr, tmp_cr, h->mb_uvlinesize, h->chroma_log2_weight_denom, + chroma_weight_avg(dest_cr, tmp_cr, h->mb_uvlinesize, chroma_height, h->chroma_log2_weight_denom, h->chroma_weight[refn0][0][1][0] , h->chroma_weight[refn1][1][1][0], h->chroma_weight[refn0][0][1][1] + h->chroma_weight[refn1][1][1][1]); } @@ -643,42 +676,46 @@ 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, + mc_dir_part(h, ref, n, square, height, delta, list, dest_y, dest_cb, dest_cr, x_offset, y_offset, - qpix_put, chroma_put, pixel_shift, chroma444); + qpix_put, chroma_put, pixel_shift, chroma_idc); - luma_weight_op(dest_y, h->mb_linesize, h->luma_log2_weight_denom, + luma_weight_op(dest_y, h->mb_linesize, height, h->luma_log2_weight_denom, h->luma_weight[refn][list][0], h->luma_weight[refn][list][1]); if(h->use_weight_chroma){ - chroma_weight_op(dest_cb, h->mb_uvlinesize, h->chroma_log2_weight_denom, + chroma_weight_op(dest_cb, h->mb_uvlinesize, chroma_height, h->chroma_log2_weight_denom, h->chroma_weight[refn][list][0][0], h->chroma_weight[refn][list][0][1]); - chroma_weight_op(dest_cr, h->mb_uvlinesize, h->chroma_log2_weight_denom, + chroma_weight_op(dest_cr, h->mb_uvlinesize, chroma_height, h->chroma_log2_weight_denom, h->chroma_weight[refn][list][1][0], h->chroma_weight[refn][list][1][1]); } } } -static inline void mc_part(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, - qpel_mc_func *qpix_avg, h264_chroma_mc_func chroma_avg, - h264_weight_func *weight_op, h264_biweight_func *weight_avg, - int list0, int list1, int pixel_shift, int chroma444){ +static av_always_inline void +mc_part(H264Context *h, int n, int square, int 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, + qpel_mc_func *qpix_avg, h264_chroma_mc_func chroma_avg, + h264_weight_func *weight_op, h264_biweight_func *weight_avg, + int list0, int list1, int pixel_shift, int chroma_idc) +{ if((h->use_weight==2 && list0 && list1 && (h->implicit_weight[ h->ref_cache[0][scan8[n]] ][ h->ref_cache[1][scan8[n]] ][h->s.mb_y&1] != 32)) || h->use_weight==1) - mc_part_weighted(h, n, square, chroma_height, delta, dest_y, dest_cb, dest_cr, + mc_part_weighted(h, n, square, height, delta, dest_y, dest_cb, dest_cr, x_offset, y_offset, qpix_put, chroma_put, - weight_op[0], weight_op[3], weight_avg[0], - weight_avg[3], list0, list1, pixel_shift, chroma444); + weight_op[0], weight_op[1], weight_avg[0], + weight_avg[1], list0, list1, pixel_shift, chroma_idc); else - mc_part_std(h, n, square, chroma_height, delta, dest_y, dest_cb, dest_cr, + mc_part_std(h, n, square, height, delta, dest_y, dest_cb, dest_cr, x_offset, y_offset, qpix_put, chroma_put, qpix_avg, - chroma_avg, list0, list1, pixel_shift, chroma444); + chroma_avg, list0, list1, pixel_shift, chroma_idc); } -static inline void prefetch_motion(H264Context *h, int list, int pixel_shift, int chroma444){ +static av_always_inline void +prefetch_motion(H264Context *h, int list, int pixel_shift, int chroma_idc) +{ /* fetch pixels for estimated mv 4 macroblocks ahead * optimized for 64byte cache lines */ MpegEncContext * const s = &h->s; @@ -689,7 +726,7 @@ uint8_t **src = h->ref_list[list][refn].f.data; int off= (mx << pixel_shift) + (my + (s->mb_x&3)*4)*h->mb_linesize + (64 << pixel_shift); s->dsp.prefetch(src[0]+off, s->linesize, 4); - if(chroma444){ + if (chroma_idc == 3 /* yuv444 */) { s->dsp.prefetch(src[1]+off, s->linesize, 4); s->dsp.prefetch(src[2]+off, s->linesize, 4); }else{ @@ -703,45 +740,46 @@ qpel_mc_func (*qpix_put)[16], h264_chroma_mc_func (*chroma_put), qpel_mc_func (*qpix_avg)[16], h264_chroma_mc_func (*chroma_avg), h264_weight_func *weight_op, h264_biweight_func *weight_avg, - int pixel_shift, int chroma444){ + int pixel_shift, int chroma_idc) +{ MpegEncContext * const s = &h->s; const int mb_xy= h->mb_xy; const int mb_type = s->current_picture.f.mb_type[mb_xy]; assert(IS_INTER(mb_type)); - if(HAVE_PTHREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) + if(HAVE_THREADS && (s->avctx->active_thread_type & FF_THREAD_FRAME)) await_references(h); - prefetch_motion(h, 0, pixel_shift, chroma444); + prefetch_motion(h, 0, pixel_shift, chroma_idc); if(IS_16X16(mb_type)){ - mc_part(h, 0, 1, 8, 0, dest_y, dest_cb, dest_cr, 0, 0, + mc_part(h, 0, 1, 16, 0, dest_y, dest_cb, dest_cr, 0, 0, qpix_put[0], chroma_put[0], qpix_avg[0], chroma_avg[0], weight_op, weight_avg, IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1), - pixel_shift, chroma444); + pixel_shift, chroma_idc); }else if(IS_16X8(mb_type)){ - mc_part(h, 0, 0, 4, 8 << pixel_shift, dest_y, dest_cb, dest_cr, 0, 0, + mc_part(h, 0, 0, 8, 8 << pixel_shift, dest_y, dest_cb, dest_cr, 0, 0, qpix_put[1], chroma_put[0], qpix_avg[1], chroma_avg[0], - &weight_op[1], &weight_avg[1], + weight_op, weight_avg, IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1), - pixel_shift, chroma444); - mc_part(h, 8, 0, 4, 8 << pixel_shift, dest_y, dest_cb, dest_cr, 0, 4, + pixel_shift, chroma_idc); + mc_part(h, 8, 0, 8, 8 << pixel_shift, dest_y, dest_cb, dest_cr, 0, 4, qpix_put[1], chroma_put[0], qpix_avg[1], chroma_avg[0], - &weight_op[1], &weight_avg[1], + weight_op, weight_avg, IS_DIR(mb_type, 1, 0), IS_DIR(mb_type, 1, 1), - pixel_shift, chroma444); + pixel_shift, chroma_idc); }else if(IS_8X16(mb_type)){ - mc_part(h, 0, 0, 8, 8*h->mb_linesize, dest_y, dest_cb, dest_cr, 0, 0, + mc_part(h, 0, 0, 16, 8*h->mb_linesize, dest_y, dest_cb, dest_cr, 0, 0, qpix_put[1], chroma_put[1], qpix_avg[1], chroma_avg[1], - &weight_op[2], &weight_avg[2], + &weight_op[1], &weight_avg[1], IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1), - pixel_shift, chroma444); - mc_part(h, 4, 0, 8, 8*h->mb_linesize, dest_y, dest_cb, dest_cr, 4, 0, + pixel_shift, chroma_idc); + mc_part(h, 4, 0, 16, 8*h->mb_linesize, dest_y, dest_cb, dest_cr, 4, 0, qpix_put[1], chroma_put[1], qpix_avg[1], chroma_avg[1], - &weight_op[2], &weight_avg[2], + &weight_op[1], &weight_avg[1], IS_DIR(mb_type, 1, 0), IS_DIR(mb_type, 1, 1), - pixel_shift, chroma444); + pixel_shift, chroma_idc); }else{ int i; @@ -754,50 +792,72 @@ int y_offset= (i&2)<<1; if(IS_SUB_8X8(sub_mb_type)){ - mc_part(h, n, 1, 4, 0, dest_y, dest_cb, dest_cr, x_offset, y_offset, + mc_part(h, n, 1, 8, 0, dest_y, dest_cb, dest_cr, x_offset, y_offset, qpix_put[1], chroma_put[1], qpix_avg[1], chroma_avg[1], - &weight_op[3], &weight_avg[3], + &weight_op[1], &weight_avg[1], IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1), - pixel_shift, chroma444); + pixel_shift, chroma_idc); }else if(IS_SUB_8X4(sub_mb_type)){ - mc_part(h, n , 0, 2, 4 << pixel_shift, dest_y, dest_cb, dest_cr, x_offset, y_offset, + mc_part(h, n , 0, 4, 4 << pixel_shift, dest_y, dest_cb, dest_cr, x_offset, y_offset, qpix_put[2], chroma_put[1], qpix_avg[2], chroma_avg[1], - &weight_op[4], &weight_avg[4], + &weight_op[1], &weight_avg[1], IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1), - pixel_shift, chroma444); - mc_part(h, n+2, 0, 2, 4 << pixel_shift, dest_y, dest_cb, dest_cr, x_offset, y_offset+2, + pixel_shift, chroma_idc); + mc_part(h, n+2, 0, 4, 4 << pixel_shift, dest_y, dest_cb, dest_cr, x_offset, y_offset+2, qpix_put[2], chroma_put[1], qpix_avg[2], chroma_avg[1], - &weight_op[4], &weight_avg[4], + &weight_op[1], &weight_avg[1], IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1), - pixel_shift, chroma444); + pixel_shift, chroma_idc); }else if(IS_SUB_4X8(sub_mb_type)){ - mc_part(h, n , 0, 4, 4*h->mb_linesize, dest_y, dest_cb, dest_cr, x_offset, y_offset, + mc_part(h, n , 0, 8, 4*h->mb_linesize, dest_y, dest_cb, dest_cr, x_offset, y_offset, qpix_put[2], chroma_put[2], qpix_avg[2], chroma_avg[2], - &weight_op[5], &weight_avg[5], + &weight_op[2], &weight_avg[2], IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1), - pixel_shift, chroma444); - mc_part(h, n+1, 0, 4, 4*h->mb_linesize, dest_y, dest_cb, dest_cr, x_offset+2, y_offset, + pixel_shift, chroma_idc); + mc_part(h, n+1, 0, 8, 4*h->mb_linesize, dest_y, dest_cb, dest_cr, x_offset+2, y_offset, qpix_put[2], chroma_put[2], qpix_avg[2], chroma_avg[2], - &weight_op[5], &weight_avg[5], + &weight_op[2], &weight_avg[2], IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1), - pixel_shift, chroma444); + pixel_shift, chroma_idc); }else{ int j; assert(IS_SUB_4X4(sub_mb_type)); for(j=0; j<4; j++){ int sub_x_offset= x_offset + 2*(j&1); int sub_y_offset= y_offset + (j&2); - mc_part(h, n+j, 1, 2, 0, dest_y, dest_cb, dest_cr, sub_x_offset, sub_y_offset, + mc_part(h, n+j, 1, 4, 0, dest_y, dest_cb, dest_cr, sub_x_offset, sub_y_offset, qpix_put[2], chroma_put[2], qpix_avg[2], chroma_avg[2], - &weight_op[6], &weight_avg[6], + &weight_op[2], &weight_avg[2], IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1), - pixel_shift, chroma444); + pixel_shift, chroma_idc); } } } } - prefetch_motion(h, 1, pixel_shift, chroma444); + prefetch_motion(h, 1, pixel_shift, chroma_idc); +} + +static av_always_inline void +hl_motion_420(H264Context *h, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, + qpel_mc_func (*qpix_put)[16], h264_chroma_mc_func (*chroma_put), + qpel_mc_func (*qpix_avg)[16], h264_chroma_mc_func (*chroma_avg), + h264_weight_func *weight_op, h264_biweight_func *weight_avg, + int pixel_shift) +{ + hl_motion(h, dest_y, dest_cb, dest_cr, qpix_put, chroma_put, + qpix_avg, chroma_avg, weight_op, weight_avg, pixel_shift, 1); +} + +static av_always_inline void +hl_motion_422(H264Context *h, uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, + qpel_mc_func (*qpix_put)[16], h264_chroma_mc_func (*chroma_put), + qpel_mc_func (*qpix_avg)[16], h264_chroma_mc_func (*chroma_avg), + h264_weight_func *weight_op, h264_biweight_func *weight_avg, + int pixel_shift) +{ + hl_motion(h, dest_y, dest_cb, dest_cr, qpix_put, chroma_put, + qpix_avg, chroma_avg, weight_op, weight_avg, pixel_shift, 2); } static void free_tables(H264Context *h, int free_rbsp){ @@ -1002,7 +1062,6 @@ h->dequant_coeff_pps= -1; s->unrestricted_mv=1; - s->decode=1; //FIXME s->dsp.dct_bits = 16; dsputil_init(&s->dsp, s->avctx); // needed so that idct permutation is known early @@ -1468,7 +1527,10 @@ ff_thread_finish_setup(s->avctx); } -static av_always_inline void backup_mb_border(H264Context *h, uint8_t *src_y, uint8_t *src_cb, uint8_t *src_cr, int linesize, int uvlinesize, int simple){ +static av_always_inline void backup_mb_border(H264Context *h, uint8_t *src_y, + uint8_t *src_cb, uint8_t *src_cr, + int linesize, int uvlinesize, int simple) +{ MpegEncContext * const s = &h->s; uint8_t *top_border; int top_idx = 1; @@ -1722,7 +1784,7 @@ tr_high= ((uint16_t*)ptr)[3 - linesize/2]*0x0001000100010001ULL; topright= (uint8_t*) &tr_high; } else { - tr= ptr[3 - linesize]*0x01010101; + tr= ptr[3 - linesize]*0x01010101u; topright= (uint8_t*) &tr; } }else @@ -1755,7 +1817,7 @@ static const uint8_t dc_mapping[16] = { 0*16, 1*16, 4*16, 5*16, 2*16, 3*16, 6*16, 7*16, 8*16, 9*16,12*16,13*16,10*16,11*16,14*16,15*16}; for(i = 0; i < 16; i++) - dctcoef_set(h->mb+p*256, pixel_shift, dc_mapping[i], dctcoef_get(h->mb_luma_dc[p], pixel_shift, i)); + dctcoef_set(h->mb+(p*256 << pixel_shift), pixel_shift, dc_mapping[i], dctcoef_get(h->mb_luma_dc[p], pixel_shift, i)); } } }else @@ -1813,7 +1875,8 @@ } } -static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, int pixel_shift){ +static av_always_inline void hl_decode_mb_internal(H264Context *h, int simple, int pixel_shift) +{ MpegEncContext * const s = &h->s; const int mb_x= s->mb_x; const int mb_y= s->mb_y; @@ -1827,7 +1890,8 @@ /* is_h264 should always be true if SVQ3 is disabled. */ const int is_h264 = !CONFIG_SVQ3_DECODER || simple || s->codec_id == CODEC_ID_H264; void (*idct_add)(uint8_t *dst, DCTELEM *block, int stride); - const int block_h = 16>>s->chroma_y_shift; + const int block_h = 16 >> s->chroma_y_shift; + const int chroma422 = CHROMA422; dest_y = s->current_picture.f.data[0] + ((mb_x << pixel_shift) + mb_y * s->linesize ) * 16; dest_cb = s->current_picture.f.data[1] + (mb_x << pixel_shift)*8 + mb_y * s->uvlinesize * block_h; @@ -1844,8 +1908,8 @@ block_offset = &h->block_offset[48]; if(mb_y&1){ //FIXME move out of this function? dest_y -= s->linesize*15; - dest_cb-= s->uvlinesize*(block_h-1); - dest_cr-= s->uvlinesize*(block_h-1); + dest_cb-= s->uvlinesize * (block_h - 1); + dest_cr-= s->uvlinesize * (block_h - 1); } if(FRAME_MBAFF) { int list; @@ -1884,7 +1948,7 @@ } if(simple || !CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){ if (!h->sps.chroma_format_idc) { - for (i = 0; i < 8; i++) { + for (i = 0; i < block_h; i++) { uint16_t *tmp_cb = (uint16_t*)(dest_cb + i*uvlinesize); uint16_t *tmp_cr = (uint16_t*)(dest_cr + i*uvlinesize); for (j = 0; j < 8; j++) { @@ -1911,13 +1975,13 @@ if(simple || !CONFIG_GRAY || !(s->flags&CODEC_FLAG_GRAY)){ if (!h->sps.chroma_format_idc) { for (i=0; i<8; i++) { - memset(dest_cb+ i*uvlinesize, 1 << (bit_depth - 1), 8); - memset(dest_cr+ i*uvlinesize, 1 << (bit_depth - 1), 8); + memset(dest_cb + i*uvlinesize, 1 << (bit_depth - 1), 8); + memset(dest_cr + i*uvlinesize, 1 << (bit_depth - 1), 8); } } else { for (i=0; imb + 128 + i*4, 8); - memcpy(dest_cr+ i*uvlinesize, h->mb + 160 + i*4, 8); + memcpy(dest_cb + i*uvlinesize, h->mb + 128 + i*4, 8); + memcpy(dest_cr + i*uvlinesize, h->mb + 160 + i*4, 8); } } } @@ -1937,11 +2001,21 @@ if(h->deblocking_filter) xchg_mb_border(h, dest_y, dest_cb, dest_cr, linesize, uvlinesize, 0, 0, simple, pixel_shift); }else if(is_h264){ - hl_motion(h, dest_y, dest_cb, dest_cr, - s->me.qpel_put, s->dsp.put_h264_chroma_pixels_tab, - s->me.qpel_avg, s->dsp.avg_h264_chroma_pixels_tab, - h->h264dsp.weight_h264_pixels_tab, - h->h264dsp.biweight_h264_pixels_tab, pixel_shift, 0); + if (chroma422) { + hl_motion_422(h, dest_y, dest_cb, dest_cr, + s->me.qpel_put, s->dsp.put_h264_chroma_pixels_tab, + s->me.qpel_avg, s->dsp.avg_h264_chroma_pixels_tab, + h->h264dsp.weight_h264_pixels_tab, + h->h264dsp.biweight_h264_pixels_tab, + pixel_shift); + } else { + hl_motion_420(h, dest_y, dest_cb, dest_cr, + s->me.qpel_put, s->dsp.put_h264_chroma_pixels_tab, + s->me.qpel_avg, s->dsp.avg_h264_chroma_pixels_tab, + h->h264dsp.weight_h264_pixels_tab, + h->h264dsp.biweight_h264_pixels_tab, + pixel_shift); + } } hl_decode_mb_idct_luma(h, mb_type, is_h264, simple, transform_bypass, pixel_shift, block_offset, linesize, dest_y, 0); @@ -1959,14 +2033,20 @@ if(h->non_zero_count_cache[ scan8[i] ] || dctcoef_get(h->mb, pixel_shift, i*16)) idct_add (dest[j-1] + block_offset[i], h->mb + (i*16 << pixel_shift), uvlinesize); } + if (chroma422) { + for(i=j*16+4; inon_zero_count_cache[ scan8[i+4] ] || dctcoef_get(h->mb, pixel_shift, i*16)) + idct_add (dest[j-1] + block_offset[i+4], h->mb + (i*16 << pixel_shift), uvlinesize); + } + } } } }else{ if(is_h264){ int qp[2]; - if (CHROMA422) { - qp[0] = h->chroma_qp[0]+3; - qp[1] = h->chroma_qp[1]+3; + if (chroma422) { + qp[0] = h->chroma_qp[0] + 3; + qp[1] = h->chroma_qp[1] + 3; } else { qp[0] = h->chroma_qp[0]; qp[1] = h->chroma_qp[1]; @@ -2086,7 +2166,7 @@ s->me.qpel_put, s->dsp.put_h264_chroma_pixels_tab, s->me.qpel_avg, s->dsp.avg_h264_chroma_pixels_tab, h->h264dsp.weight_h264_pixels_tab, - h->h264dsp.biweight_h264_pixels_tab, pixel_shift, 1); + h->h264dsp.biweight_h264_pixels_tab, pixel_shift, 3); } for (p = 0; p < plane_count; p++) @@ -2554,7 +2634,7 @@ s->me.qpel_avg= s->dsp.avg_h264_qpel_pixels_tab; } - first_mb_in_slice= get_ue_golomb(&s->gb); + first_mb_in_slice= get_ue_golomb_long(&s->gb); if(first_mb_in_slice == 0){ //FIXME better field boundary detection if(h0->current_slice && FIELD_PICTURE){ @@ -2627,7 +2707,7 @@ s->height= 16*s->mb_height - (2<chroma_y_shift)*FFMIN(h->sps.crop_bottom, (16>>s->chroma_y_shift)-1); if (s->context_initialized - && ( s->width != s->avctx->width || s->height != s->avctx->height + && ( s->width != s->avctx->coded_width || s->height != s->avctx->coded_height || s->avctx->bits_per_raw_sample != h->sps.bit_depth_luma || h->cur_chroma_format_idc != h->sps.chroma_format_idc || av_cmp_q(h->sps.sar, s->avctx->sample_aspect_ratio))) { @@ -2663,14 +2743,14 @@ s->dsp.dct_bits = h->sps.bit_depth_luma > 8 ? 32 : 16; dsputil_init(&s->dsp, s->avctx); } else { - av_log(s->avctx, AV_LOG_DEBUG, "Unsupported bit depth: %d chroma_idc: %d\n", + av_log(s->avctx, AV_LOG_ERROR, "Unsupported bit depth: %d chroma_idc: %d\n", h->sps.bit_depth_luma, h->sps.chroma_format_idc); return -1; } } if(h->sps.video_signal_type_present_flag){ - s->avctx->color_range = h->sps.full_range ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG; + s->avctx->color_range = h->sps.full_range>0 ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG; if(h->sps.colour_description_present_flag){ s->avctx->color_primaries = h->sps.color_primaries; s->avctx->color_trc = h->sps.color_trc; @@ -2690,6 +2770,8 @@ case 9 : if (CHROMA444) s->avctx->pix_fmt = PIX_FMT_YUV444P9; + else if (CHROMA422) + s->avctx->pix_fmt = PIX_FMT_YUV422P9; else s->avctx->pix_fmt = PIX_FMT_YUV420P9; break; @@ -2704,7 +2786,13 @@ default: if (CHROMA444){ s->avctx->pix_fmt = s->avctx->color_range == AVCOL_RANGE_JPEG ? PIX_FMT_YUVJ444P : PIX_FMT_YUV444P; - }else if (CHROMA422) { + if (s->avctx->colorspace == AVCOL_SPC_RGB) { + s->avctx->pix_fmt = PIX_FMT_GBR24P; + av_log(h->s.avctx, AV_LOG_DEBUG, "Detected GBR colorspace.\n"); + } else if (s->avctx->colorspace == AVCOL_SPC_YCGCO) { + av_log(h->s.avctx, AV_LOG_WARNING, "Detected unsupported YCgCo colorspace.\n"); + } + } else if (CHROMA422) { s->avctx->pix_fmt = s->avctx->color_range == AVCOL_RANGE_JPEG ? PIX_FMT_YUVJ422P : PIX_FMT_YUV422P; }else{ s->avctx->pix_fmt = s->avctx->get_format(s->avctx, @@ -2766,6 +2854,10 @@ if(h->sps.frame_mbs_only_flag){ s->picture_structure= PICT_FRAME; }else{ + if(!h->sps.direct_8x8_inference_flag && slice_type == AV_PICTURE_TYPE_B){ + av_log(h->s.avctx, AV_LOG_ERROR, "This stream was generated by a broken encoder, invalid 8x8 inference\n"); + return -1; + } if(get_bits1(&s->gb)) { //field_pic_flag s->picture_structure= PICT_TOP_FIELD + get_bits1(&s->gb); //bottom_field_flag } else { @@ -2804,7 +2896,7 @@ ff_thread_report_progress((AVFrame*)s->current_picture_ptr, INT_MAX, 1); ff_generate_sliding_window_mmcos(h); if (ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index) < 0 && - s->avctx->error_recognition >= FF_ER_EXPLODE) + (s->avctx->err_recognition & AV_EF_EXPLODE)) return AVERROR_INVALIDDATA; /* Error concealment: if a ref is missing, copy the previous ref in its place. * FIXME: avoiding a memcpy would be nice, but ref handling makes many assumptions @@ -2983,7 +3075,7 @@ } if(h->nal_ref_idc && ff_h264_decode_ref_pic_marking(h0, &s->gb) < 0 && - s->avctx->error_recognition >= FF_ER_EXPLODE) + (s->avctx->err_recognition & AV_EF_EXPLODE)) return AVERROR_INVALIDDATA; if(FRAME_MBAFF){ @@ -3376,7 +3468,7 @@ const int end_mb_y= s->mb_y + FRAME_MBAFF; const int old_slice_type= h->slice_type; const int pixel_shift = h->pixel_shift; - const int block_h = 16>>s->chroma_y_shift; + const int block_h = 16 >> s->chroma_y_shift; if(h->deblocking_filter) { for(mb_x= start_x; mb_xmb_x= mb_x; s->mb_y= mb_y; dest_y = s->current_picture.f.data[0] + ((mb_x << pixel_shift) + mb_y * s->linesize ) * 16; - dest_cb = s->current_picture.f.data[1] + (mb_x << pixel_shift)*(8<uvlinesize * block_h; - dest_cr = s->current_picture.f.data[2] + (mb_x << pixel_shift)*(8<uvlinesize * block_h; + dest_cb = s->current_picture.f.data[1] + (mb_x << pixel_shift) * (8 << CHROMA444) + mb_y * s->uvlinesize * block_h; + dest_cr = s->current_picture.f.data[2] + (mb_x << pixel_shift) * (8 << CHROMA444) + mb_y * s->uvlinesize * block_h; //FIXME simplify above if (MB_FIELD) { @@ -3402,8 +3494,8 @@ uvlinesize = h->mb_uvlinesize = s->uvlinesize * 2; if(mb_y&1){ //FIXME move out of this function? dest_y -= s->linesize*15; - dest_cb-= s->uvlinesize*(block_h-1); - dest_cr-= s->uvlinesize*(block_h-1); + dest_cb-= s->uvlinesize * (block_h - 1); + dest_cr-= s->uvlinesize * (block_h - 1); } } else { linesize = h->mb_linesize = s->linesize; @@ -3747,7 +3839,7 @@ case NAL_IDR_SLICE: case NAL_SLICE: init_get_bits(&hx->s.gb, ptr, bit_length); - if(!get_ue_golomb(&hx->s.gb)) + if (!get_ue_golomb(&hx->s.gb)) nals_needed = nal_index; } continue; @@ -3775,7 +3867,8 @@ if((err = decode_slice_header(hx, h))) break; - if (h->sei_recovery_frame_cnt >= 0 && h->recovery_frame < 0) { + if ( h->sei_recovery_frame_cnt >= 0 + && ((h->recovery_frame - h->frame_num) & ((1 << h->sps.log2_max_frame_num)-1)) > h->sei_recovery_frame_cnt) { h->recovery_frame = (h->frame_num + h->sei_recovery_frame_cnt) % (1 << h->sps.log2_max_frame_num); } @@ -3853,9 +3946,10 @@ break; case NAL_SPS: init_get_bits(&s->gb, ptr, bit_length); - if(ff_h264_decode_seq_parameter_set(h) < 0 && h->is_avc && (nalsize != consumed) && nalsize){ + if(ff_h264_decode_seq_parameter_set(h) < 0 && (h->is_avc ? (nalsize != consumed) && nalsize : 1)){ av_log(h->s.avctx, AV_LOG_DEBUG, "SPS decoding failure, trying alternative mode\n"); - init_get_bits(&s->gb, &buf[buf_index + 1 - consumed], 8*nalsize); + if(h->is_avc) av_assert0(next_avc - buf_index + consumed == nalsize); + init_get_bits(&s->gb, &buf[buf_index + 1 - consumed], 8*(next_avc - buf_index + consumed)); ff_h264_decode_seq_parameter_set(h); } @@ -4138,6 +4232,26 @@ { FF_PROFILE_UNKNOWN }, }; +static const AVOption h264_options[] = { + {"is_avc", "is avc", offsetof(H264Context, is_avc), FF_OPT_TYPE_INT, {.dbl = 0}, 0, 1, 0}, + {"nal_length_size", "nal_length_size", offsetof(H264Context, nal_length_size), FF_OPT_TYPE_INT, {.dbl = 0}, 0, 4, 0}, + {NULL} +}; + +static const AVClass h264_class = { + "H264 Decoder", + av_default_item_name, + h264_options, + LIBAVUTIL_VERSION_INT, +}; + +static const AVClass h264_vdpau_class = { + "H264 VDPAU Decoder", + av_default_item_name, + h264_options, + LIBAVUTIL_VERSION_INT, +}; + AVCodec ff_h264_decoder = { .name = "h264", .type = AVMEDIA_TYPE_VIDEO, @@ -4153,6 +4267,7 @@ .init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy), .update_thread_context = ONLY_IF_THREADS_ENABLED(decode_update_thread_context), .profiles = NULL_IF_CONFIG_SMALL(profiles), + .priv_class = &h264_class, }; #if CONFIG_H264_VDPAU_DECODER @@ -4169,5 +4284,6 @@ .long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (VDPAU acceleration)"), .pix_fmts = (const enum PixelFormat[]){PIX_FMT_VDPAU_H264, PIX_FMT_NONE}, .profiles = NULL_IF_CONFIG_SMALL(profiles), + .priv_class = &h264_vdpau_class, }; #endif diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h264_cabac.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h264_cabac.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h264_cabac.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h264_cabac.c 2011-11-04 12:38:26.000000000 +0000 @@ -1565,7 +1565,12 @@ 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8 }; -static av_always_inline void decode_cabac_residual_internal( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff, int is_dc ) { +static av_always_inline void +decode_cabac_residual_internal(H264Context *h, DCTELEM *block, + int cat, int n, const uint8_t *scantable, + const uint32_t *qmul, int max_coeff, + int is_dc, int chroma422) +{ static const int significant_coeff_flag_offset[2][14] = { { 105+0, 105+15, 105+29, 105+44, 105+47, 402, 484+0, 484+15, 484+29, 660, 528+0, 528+15, 528+29, 718 }, { 277+0, 277+15, 277+29, 277+44, 277+47, 436, 776+0, 776+15, 776+29, 675, 820+0, 820+15, 820+29, 733 } @@ -1593,7 +1598,10 @@ * map node ctx => cabac ctx for level=1 */ static const uint8_t coeff_abs_level1_ctx[8] = { 1, 2, 3, 4, 0, 0, 0, 0 }; /* map node ctx => cabac ctx for level>1 */ - static const uint8_t coeff_abs_levelgt1_ctx[8] = { 5, 5, 5, 5, 6, 7, 8, 9 }; + static const uint8_t coeff_abs_levelgt1_ctx[2][8] = { + { 5, 5, 5, 5, 6, 7, 8, 9 }, + { 5, 5, 5, 5, 6, 7, 8, 8 }, // 422/dc case + }; static const uint8_t coeff_abs_level_transition[2][8] = { /* update node ctx after decoding a level=1 */ { 1, 2, 3, 3, 4, 5, 6, 7 }, @@ -1652,7 +1660,7 @@ coeff_count= decode_significance_8x8_x86(CC, significant_coeff_ctx_base, index, last_coeff_ctx_base, sig_off); } else { - if (is_dc && max_coeff == 8) { // dc 422 + if (is_dc && chroma422) { // dc 422 DECODE_SIGNIFICANCE(7, sig_coeff_offset_dc[last], sig_coeff_offset_dc[last]); } else { coeff_count= decode_significance_x86(CC, max_coeff, significant_coeff_ctx_base, index, @@ -1661,7 +1669,7 @@ #else DECODE_SIGNIFICANCE( 63, sig_off[last], last_coeff_flag_offset_8x8[last] ); } else { - if (is_dc && max_coeff == 8) { // dc 422 + if (is_dc && chroma422) { // dc 422 DECODE_SIGNIFICANCE(7, sig_coeff_offset_dc[last], sig_coeff_offset_dc[last]); } else { DECODE_SIGNIFICANCE(max_coeff - 1, last, last); @@ -1701,9 +1709,7 @@ } \ } else { \ int coeff_abs = 2; \ - if (is_dc && max_coeff == 8) \ - node_ctx = FFMIN(node_ctx, 6); \ - ctx = coeff_abs_levelgt1_ctx[node_ctx] + abs_level_m1_ctx_base; \ + ctx = coeff_abs_levelgt1_ctx[is_dc && chroma422][node_ctx] + abs_level_m1_ctx_base; \ node_ctx = coeff_abs_level_transition[1][node_ctx]; \ \ while( coeff_abs < 15 && get_cabac( CC, ctx ) ) { \ @@ -1745,11 +1751,18 @@ } static void decode_cabac_residual_dc_internal( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, int max_coeff ) { - decode_cabac_residual_internal(h, block, cat, n, scantable, NULL, max_coeff, 1); + decode_cabac_residual_internal(h, block, cat, n, scantable, NULL, max_coeff, 1, 0); +} + +static void decode_cabac_residual_dc_internal_422(H264Context *h, DCTELEM *block, + int cat, int n, const uint8_t *scantable, + int max_coeff) +{ + decode_cabac_residual_internal(h, block, cat, n, scantable, NULL, max_coeff, 1, 1); } static void decode_cabac_residual_nondc_internal( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff ) { - decode_cabac_residual_internal(h, block, cat, n, scantable, qmul, max_coeff, 0); + decode_cabac_residual_internal(h, block, cat, n, scantable, qmul, max_coeff, 0, 0); } /* cat: 0-> DC 16x16 n = 0 @@ -1773,6 +1786,19 @@ decode_cabac_residual_dc_internal( h, block, cat, n, scantable, max_coeff ); } +static av_always_inline void +decode_cabac_residual_dc_422(H264Context *h, DCTELEM *block, + int cat, int n, const uint8_t *scantable, + int max_coeff) +{ + /* read coded block flag */ + if (get_cabac(&h->cabac, &h->cabac_state[get_cabac_cbf_ctx(h, cat, n, max_coeff, 1)]) == 0) { + h->non_zero_count_cache[scan8[n]] = 0; + return; + } + decode_cabac_residual_dc_internal_422(h, block, cat, n, scantable, max_coeff); +} + static av_always_inline void decode_cabac_residual_nondc( H264Context *h, DCTELEM *block, int cat, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff ) { /* read coded block flag */ if( (cat != 5 || CHROMA444) && get_cabac( &h->cabac, &h->cabac_state[get_cabac_cbf_ctx( h, cat, n, max_coeff, 0 ) ] ) == 0 ) { @@ -2325,17 +2351,14 @@ if(CHROMA444){ decode_cabac_luma_residual(h, scan, scan8x8, pixel_shift, mb_type, cbp, 1); decode_cabac_luma_residual(h, scan, scan8x8, pixel_shift, mb_type, cbp, 2); - } else { - const int num_c8x8 = h->sps.chroma_format_idc; - + } else if (CHROMA422) { if( cbp&0x30 ){ int c; for( c = 0; c < 2; c++ ) { //av_log( s->avctx, AV_LOG_ERROR, "INTRA C%d-DC\n",c ); - decode_cabac_residual_dc(h, h->mb + ((256 + 16*16*c) << pixel_shift), 3, - CHROMA_DC_BLOCK_INDEX+c, - CHROMA422 ? chroma422_dc_scan : chroma_dc_scan, - 4*num_c8x8); + decode_cabac_residual_dc_422(h, h->mb + ((256 + 16*16*c) << pixel_shift), 3, + CHROMA_DC_BLOCK_INDEX + c, + chroma422_dc_scan, 8); } } @@ -2344,7 +2367,7 @@ for( c = 0; c < 2; c++ ) { DCTELEM *mb = h->mb + (16*(16 + 16*c) << pixel_shift); qmul = h->dequant4_coeff[c+1+(IS_INTRA( mb_type ) ? 0:3)][h->chroma_qp[c]]; - for (i8x8 = 0; i8x8 < num_c8x8; i8x8++) { + for (i8x8 = 0; i8x8 < 2; i8x8++) { for (i = 0; i < 4; i++) { const int index = 16 + 16 * c + 8*i8x8 + i; //av_log(s->avctx, AV_LOG_ERROR, "INTRA C%d-AC %d\n",c, index - 16); @@ -2357,6 +2380,29 @@ fill_rectangle(&h->non_zero_count_cache[scan8[16]], 4, 4, 8, 0, 1); fill_rectangle(&h->non_zero_count_cache[scan8[32]], 4, 4, 8, 0, 1); } + } else /* yuv420 */ { + if( cbp&0x30 ){ + int c; + for( c = 0; c < 2; c++ ) { + //av_log( s->avctx, AV_LOG_ERROR, "INTRA C%d-DC\n",c ); + decode_cabac_residual_dc(h, h->mb + ((256 + 16*16*c) << pixel_shift), 3, CHROMA_DC_BLOCK_INDEX+c, chroma_dc_scan, 4); + } + } + + if( cbp&0x20 ) { + int c, i; + for( c = 0; c < 2; c++ ) { + qmul = h->dequant4_coeff[c+1+(IS_INTRA( mb_type ) ? 0:3)][h->chroma_qp[c]]; + for( i = 0; i < 4; i++ ) { + const int index = 16 + 16 * c + i; + //av_log( s->avctx, AV_LOG_ERROR, "INTRA C%d-AC %d\n",c, index - 16 ); + decode_cabac_residual_nondc(h, h->mb + (16*index << pixel_shift), 4, index, scan + 1, qmul, 15); + } + } + } else { + fill_rectangle(&h->non_zero_count_cache[scan8[16]], 4, 4, 8, 0, 1); + fill_rectangle(&h->non_zero_count_cache[scan8[32]], 4, 4, 8, 0, 1); + } } } else { fill_rectangle(&h->non_zero_count_cache[scan8[ 0]], 4, 4, 8, 0, 1); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h264_cavlc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h264_cavlc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h264_cavlc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h264_cavlc.c 2011-11-04 12:38:26.000000000 +0000 @@ -298,17 +298,18 @@ } static av_cold void init_cavlc_level_tab(void){ - int suffix_length, mask; + int suffix_length; unsigned int i; for(suffix_length=0; suffix_length<7; suffix_length++){ for(i=0; i<(1<>(LEVEL_TAB_BITS-prefix-1-suffix_length)) - (1<>1) ^ mask) - mask; if(prefix + 1 + suffix_length <= LEVEL_TAB_BITS){ + int level_code = (prefix << suffix_length) + + (i >> (av_log2(i) - suffix_length)) - (1 << suffix_length); + int mask = -(level_code&1); + level_code = (((2 + level_code) >> 1) ^ mask) - mask; cavlc_level_tab[suffix_length][i][0]= level_code; cavlc_level_tab[suffix_length][i][1]= prefix + 1 + suffix_length; }else if(prefix + 1 <= LEVEL_TAB_BITS){ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h264_direct.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h264_direct.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h264_direct.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h264_direct.c 2011-11-04 12:38:26.000000000 +0000 @@ -148,7 +148,7 @@ int ref_field_picture = ref->field_picture; int ref_height = 16*h->s.mb_height >> ref_field_picture; - if(!HAVE_PTHREADS || !(h->s.avctx->active_thread_type&FF_THREAD_FRAME)) + if(!HAVE_THREADS || !(h->s.avctx->active_thread_type&FF_THREAD_FRAME)) return; //FIXME it can be safe to access mb stuff diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h264dsp.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h264dsp.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h264dsp.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h264dsp.c 2011-11-04 12:38:26.000000000 +0000 @@ -64,26 +64,14 @@ else\ c->h264_chroma_dc_dequant_idct= FUNC(ff_h264_chroma422_dc_dequant_idct, depth);\ \ - c->weight_h264_pixels_tab[0]= FUNC(weight_h264_pixels16x16, depth);\ - c->weight_h264_pixels_tab[1]= FUNC(weight_h264_pixels16x8, depth);\ - c->weight_h264_pixels_tab[2]= FUNC(weight_h264_pixels8x16, depth);\ - c->weight_h264_pixels_tab[3]= FUNC(weight_h264_pixels8x8, depth);\ - c->weight_h264_pixels_tab[4]= FUNC(weight_h264_pixels8x4, depth);\ - c->weight_h264_pixels_tab[5]= FUNC(weight_h264_pixels4x8, depth);\ - c->weight_h264_pixels_tab[6]= FUNC(weight_h264_pixels4x4, depth);\ - c->weight_h264_pixels_tab[7]= FUNC(weight_h264_pixels4x2, depth);\ - c->weight_h264_pixels_tab[8]= FUNC(weight_h264_pixels2x4, depth);\ - c->weight_h264_pixels_tab[9]= FUNC(weight_h264_pixels2x2, depth);\ - c->biweight_h264_pixels_tab[0]= FUNC(biweight_h264_pixels16x16, depth);\ - c->biweight_h264_pixels_tab[1]= FUNC(biweight_h264_pixels16x8, depth);\ - c->biweight_h264_pixels_tab[2]= FUNC(biweight_h264_pixels8x16, depth);\ - c->biweight_h264_pixels_tab[3]= FUNC(biweight_h264_pixels8x8, depth);\ - c->biweight_h264_pixels_tab[4]= FUNC(biweight_h264_pixels8x4, depth);\ - c->biweight_h264_pixels_tab[5]= FUNC(biweight_h264_pixels4x8, depth);\ - c->biweight_h264_pixels_tab[6]= FUNC(biweight_h264_pixels4x4, depth);\ - c->biweight_h264_pixels_tab[7]= FUNC(biweight_h264_pixels4x2, depth);\ - c->biweight_h264_pixels_tab[8]= FUNC(biweight_h264_pixels2x4, depth);\ - c->biweight_h264_pixels_tab[9]= FUNC(biweight_h264_pixels2x2, depth);\ + c->weight_h264_pixels_tab[0]= FUNC(weight_h264_pixels16, depth);\ + c->weight_h264_pixels_tab[1]= FUNC(weight_h264_pixels8, depth);\ + c->weight_h264_pixels_tab[2]= FUNC(weight_h264_pixels4, depth);\ + c->weight_h264_pixels_tab[3]= FUNC(weight_h264_pixels2, depth);\ + c->biweight_h264_pixels_tab[0]= FUNC(biweight_h264_pixels16, depth);\ + c->biweight_h264_pixels_tab[1]= FUNC(biweight_h264_pixels8, depth);\ + c->biweight_h264_pixels_tab[2]= FUNC(biweight_h264_pixels4, depth);\ + c->biweight_h264_pixels_tab[3]= FUNC(biweight_h264_pixels2, depth);\ \ c->h264_v_loop_filter_luma= FUNC(h264_v_loop_filter_luma, depth);\ c->h264_h_loop_filter_luma= FUNC(h264_h_loop_filter_luma, depth);\ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h264dsp.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h264dsp.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h264dsp.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h264dsp.h 2011-11-04 12:38:26.000000000 +0000 @@ -31,16 +31,18 @@ #include "dsputil.h" //typedef void (*h264_chroma_mc_func)(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int srcStride, int h, int x, int y); -typedef void (*h264_weight_func)(uint8_t *block, int stride, int log2_denom, int weight, int offset); -typedef void (*h264_biweight_func)(uint8_t *dst, uint8_t *src, int stride, int log2_denom, int weightd, int weights, int offset); +typedef void (*h264_weight_func)(uint8_t *block, int stride, int height, + int log2_denom, int weight, int offset); +typedef void (*h264_biweight_func)(uint8_t *dst, uint8_t *src, int stride, int height, + int log2_denom, int weightd, int weights, int offset); /** * Context for storing H.264 DSP functions */ typedef struct H264DSPContext{ /* weighted MC */ - h264_weight_func weight_h264_pixels_tab[10]; - h264_biweight_func biweight_h264_pixels_tab[10]; + h264_weight_func weight_h264_pixels_tab[4]; + h264_biweight_func biweight_h264_pixels_tab[4]; /* loop filter */ void (*h264_v_loop_filter_luma)(uint8_t *pix/*align 16*/, int stride, int alpha, int beta, int8_t *tc0); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h264dsp_template.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h264dsp_template.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h264dsp_template.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h264dsp_template.c 2011-11-04 12:38:26.000000000 +0000 @@ -29,14 +29,16 @@ #define op_scale1(x) block[x] = av_clip_pixel( (block[x]*weight + offset) >> log2_denom ) #define op_scale2(x) dst[x] = av_clip_pixel( (src[x]*weights + dst[x]*weightd + offset) >> (log2_denom+1)) -#define H264_WEIGHT(W,H) \ -static void FUNCC(weight_h264_pixels ## W ## x ## H)(uint8_t *p_block, int stride, int log2_denom, int weight, int offset){ \ +#define H264_WEIGHT(W) \ +static void FUNCC(weight_h264_pixels ## W)(uint8_t *_block, int stride, int height, \ + int log2_denom, int weight, int offset) \ +{ \ int y; \ - pixel *block = (pixel*)p_block; \ + pixel *block = (pixel*)_block; \ stride >>= sizeof(pixel)-1; \ offset <<= (log2_denom + (BIT_DEPTH-8)); \ if(log2_denom) offset += 1<<(log2_denom-1); \ - for(y=0; y>= sizeof(pixel)-1; \ offset <<= (BIT_DEPTH-8); \ offset = ((offset + 1) | 1) << log2_denom; \ - for(y=0; y> 8; block[stride*3+offset]= ((z0 - z3)*qmul + 128) >> 8; } - -#if 0 - av_log(NULL, AV_LOG_INFO, "after chroma dc\n"); - for (int i = 0; i < 256; i++) { - av_log(NULL, AV_LOG_INFO, "%5d ", block[i]); - if (!((i+1) % 16)) - av_log(NULL, AV_LOG_INFO, "\n"); - } -#endif } -void FUNCC(ff_h264_chroma_dc_dequant_idct)(DCTELEM *p_block, int qmul){ +void FUNCC(ff_h264_chroma_dc_dequant_idct)(DCTELEM *_block, int qmul){ const int stride= 16*2; const int xStride= 16; int a,b,c,d,e; - dctcoef *block = (dctcoef*)p_block; + dctcoef *block = (dctcoef*)_block; a= block[stride*0 + xStride*0]; b= block[stride*0 + xStride*1]; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h264_mvpred.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h264_mvpred.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h264_mvpred.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h264_mvpred.h 2011-11-04 12:38:26.000000000 +0000 @@ -593,7 +593,7 @@ ref_cache[3 - 1*8]= ref[4*top_xy + 3]; }else{ AV_ZERO128(mv_cache[0 - 1*8]); - AV_WN32A(&ref_cache[0 - 1*8], ((top_type ? LIST_NOT_USED : PART_NOT_AVAILABLE)&0xFF)*0x01010101); + AV_WN32A(&ref_cache[0 - 1*8], ((top_type ? LIST_NOT_USED : PART_NOT_AVAILABLE)&0xFF)*0x01010101u); } if(mb_type & (MB_TYPE_16x8|MB_TYPE_8x8)){ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h264_parser.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h264_parser.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h264_parser.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h264_parser.c 2011-11-04 12:38:26.000000000 +0000 @@ -93,17 +93,28 @@ goto found; } }else if(v==1 || v==2 || v==5){ + state+=8; + continue; + } + state= 7; + }else{ + h->parse_history[h->parse_history_count++]= buf[i]; + if(h->parse_history_count>3){ + unsigned int mb, last_mb= h->parse_last_mb; + GetBitContext gb; + + init_get_bits(&gb, h->parse_history, 8*h->parse_history_count); + h->parse_history_count=0; + mb= get_ue_golomb_long(&gb); + last_mb= h->parse_last_mb; + h->parse_last_mb= mb; if(pc->frame_start_found){ - state+=8; - continue; + if(mb <= last_mb) + goto found; }else pc->frame_start_found = 1; + state= 7; } - state= 7; - }else{ - if(buf[i] & 0x80) - goto found; - state= 7; } } pc->state= state; @@ -116,7 +127,7 @@ pc->frame_start_found= 0; if(h->is_avc) return next_avc; - return i-(state&5); + return i-(state&5) - 3*(state>7); } /** @@ -153,7 +164,7 @@ for(;;) { int src_length, dst_length, consumed; - buf = ff_find_start_code(buf, buf_end, &state); + buf = avpriv_mpv_find_start_code(buf, buf_end, &state); if(buf >= buf_end) break; --buf; @@ -185,7 +196,7 @@ s->key_frame = 1; /* fall through */ case NAL_SLICE: - get_ue_golomb(&h->s.gb); // skip first_mb_in_slice + get_ue_golomb_long(&h->s.gb); // skip first_mb_in_slice slice_type = get_ue_golomb_31(&h->s.gb); s->pict_type = golomb_to_pict_type[slice_type % 5]; if (h->sei_recovery_frame_cnt >= 0) { @@ -364,10 +375,10 @@ } AVCodecParser ff_h264_parser = { - { CODEC_ID_H264 }, - sizeof(H264Context), - init, - h264_parse, - close, - h264_split, + .codec_ids = { CODEC_ID_H264 }, + .priv_data_size = sizeof(H264Context), + .parser_init = init, + .parser_parse = h264_parse, + .parser_close = close, + .split = h264_split, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h264pred.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h264pred.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h264pred.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h264pred.c 2011-11-04 12:38:26.000000000 +0000 @@ -40,7 +40,7 @@ #undef BIT_DEPTH static void pred4x4_vertical_vp8_c(uint8_t *src, const uint8_t *topright, int stride){ - const int lt= src[-1-1*stride]; + const unsigned lt = src[-1-1*stride]; LOAD_TOP_EDGE LOAD_TOP_RIGHT_EDGE uint32_t v = PACK_4U8((lt + 2*t0 + t1 + 2) >> 2, @@ -55,7 +55,7 @@ } static void pred4x4_horizontal_vp8_c(uint8_t *src, const uint8_t *topright, int stride){ - const int lt= src[-1-1*stride]; + const unsigned lt = src[-1-1*stride]; LOAD_LEFT_EDGE AV_WN32A(src+0*stride, ((lt + 2*l0 + l1 + 2) >> 2)*0x01010101); @@ -67,8 +67,6 @@ static void pred4x4_down_left_svq3_c(uint8_t *src, const uint8_t *topright, int stride){ LOAD_TOP_EDGE LOAD_LEFT_EDGE - const av_unused int unu0= t0; - const av_unused int unu1= l0; src[0+0*stride]=(l1 + t1)>>1; src[1+0*stride]= @@ -292,7 +290,7 @@ static void pred8x8_left_dc_rv40_c(uint8_t *src, int stride){ int i; - int dc0; + unsigned dc0; dc0=0; for(i=0;i<8; i++) @@ -307,7 +305,7 @@ static void pred8x8_top_dc_rv40_c(uint8_t *src, int stride){ int i; - int dc0; + unsigned dc0; dc0=0; for(i=0;i<8; i++) @@ -322,7 +320,7 @@ static void pred8x8_dc_rv40_c(uint8_t *src, int stride){ int i; - int dc0=0; + unsigned dc0 = 0; for(i=0;i<4; i++){ dc0+= src[-1+i*stride] + src[i-stride]; @@ -464,10 +462,10 @@ h->pred8x8[DC_PRED8x8 ]= FUNCC(pred8x16_dc , depth);\ h->pred8x8[LEFT_DC_PRED8x8]= FUNCC(pred8x16_left_dc , depth);\ h->pred8x8[TOP_DC_PRED8x8 ]= FUNCC(pred8x16_top_dc , depth);\ - h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_l0t, depth);\ - h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_0lt, depth);\ - h->pred8x8[ALZHEIMER_DC_L00_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_l00, depth);\ - h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8 ]= FUNC(pred8x8_mad_cow_dc_0l0, depth);\ + h->pred8x8[ALZHEIMER_DC_L0T_PRED8x8 ]= FUNC(pred8x16_mad_cow_dc_l0t, depth);\ + h->pred8x8[ALZHEIMER_DC_0LT_PRED8x8 ]= FUNC(pred8x16_mad_cow_dc_0lt, depth);\ + h->pred8x8[ALZHEIMER_DC_L00_PRED8x8 ]= FUNC(pred8x16_mad_cow_dc_l00, depth);\ + h->pred8x8[ALZHEIMER_DC_0L0_PRED8x8 ]= FUNC(pred8x16_mad_cow_dc_0l0, depth);\ }\ }else{\ h->pred8x8[DC_PRED8x8 ]= FUNCD(pred8x8_dc_rv40);\ @@ -512,8 +510,13 @@ h->pred4x4_add [ HOR_PRED ]= FUNCC(pred4x4_horizontal_add , depth);\ h->pred8x8l_add [VERT_PRED ]= FUNCC(pred8x8l_vertical_add , depth);\ h->pred8x8l_add [ HOR_PRED ]= FUNCC(pred8x8l_horizontal_add , depth);\ + if (chroma_format_idc == 1) {\ h->pred8x8_add [VERT_PRED8x8]= FUNCC(pred8x8_vertical_add , depth);\ h->pred8x8_add [ HOR_PRED8x8]= FUNCC(pred8x8_horizontal_add , depth);\ + } else {\ + h->pred8x8_add [VERT_PRED8x8]= FUNCC(pred8x16_vertical_add , depth);\ + h->pred8x8_add [ HOR_PRED8x8]= FUNCC(pred8x16_horizontal_add , depth);\ + }\ h->pred16x16_add[VERT_PRED8x8]= FUNCC(pred16x16_vertical_add , depth);\ h->pred16x16_add[ HOR_PRED8x8]= FUNCC(pred16x16_horizontal_add , depth);\ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h264pred_template.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h264pred_template.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h264pred_template.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h264pred_template.c 2011-11-04 12:38:26.000000000 +0000 @@ -121,28 +121,28 @@ #define LOAD_TOP_RIGHT_EDGE\ - const int av_unused t4= topright[0];\ - const int av_unused t5= topright[1];\ - const int av_unused t6= topright[2];\ - const int av_unused t7= topright[3];\ + const unsigned av_unused t4 = topright[0];\ + const unsigned av_unused t5 = topright[1];\ + const unsigned av_unused t6 = topright[2];\ + const unsigned av_unused t7 = topright[3];\ #define LOAD_DOWN_LEFT_EDGE\ - const int av_unused l4= src[-1+4*stride];\ - const int av_unused l5= src[-1+5*stride];\ - const int av_unused l6= src[-1+6*stride];\ - const int av_unused l7= src[-1+7*stride];\ + const unsigned av_unused l4 = src[-1+4*stride];\ + const unsigned av_unused l5 = src[-1+5*stride];\ + const unsigned av_unused l6 = src[-1+6*stride];\ + const unsigned av_unused l7 = src[-1+7*stride];\ #define LOAD_LEFT_EDGE\ - const int av_unused l0= src[-1+0*stride];\ - const int av_unused l1= src[-1+1*stride];\ - const int av_unused l2= src[-1+2*stride];\ - const int av_unused l3= src[-1+3*stride];\ + const unsigned av_unused l0 = src[-1+0*stride];\ + const unsigned av_unused l1 = src[-1+1*stride];\ + const unsigned av_unused l2 = src[-1+2*stride];\ + const unsigned av_unused l3 = src[-1+3*stride];\ #define LOAD_TOP_EDGE\ - const int av_unused t0= src[ 0-1*stride];\ - const int av_unused t1= src[ 1-1*stride];\ - const int av_unused t2= src[ 2-1*stride];\ - const int av_unused t3= src[ 3-1*stride];\ + const unsigned av_unused t0 = src[ 0-1*stride];\ + const unsigned av_unused t1 = src[ 1-1*stride];\ + const unsigned av_unused t2 = src[ 2-1*stride];\ + const unsigned av_unused t3 = src[ 3-1*stride];\ static void FUNCC(pred4x4_down_right)(uint8_t *_src, const uint8_t *topright, int _stride){ pixel *src = (pixel*)_src; @@ -663,23 +663,45 @@ FUNCC(pred4x4_dc)(src, NULL, stride); } +static void FUNC(pred8x16_mad_cow_dc_l0t)(uint8_t *src, int stride){ + FUNCC(pred8x16_top_dc)(src, stride); + FUNCC(pred4x4_dc)(src, NULL, stride); +} + static void FUNC(pred8x8_mad_cow_dc_0lt)(uint8_t *src, int stride){ FUNCC(pred8x8_dc)(src, stride); FUNCC(pred4x4_top_dc)(src, NULL, stride); } +static void FUNC(pred8x16_mad_cow_dc_0lt)(uint8_t *src, int stride){ + FUNCC(pred8x16_dc)(src, stride); + FUNCC(pred4x4_top_dc)(src, NULL, stride); +} + static void FUNC(pred8x8_mad_cow_dc_l00)(uint8_t *src, int stride){ FUNCC(pred8x8_left_dc)(src, stride); FUNCC(pred4x4_128_dc)(src + 4*stride , NULL, stride); FUNCC(pred4x4_128_dc)(src + 4*stride + 4*sizeof(pixel), NULL, stride); } +static void FUNC(pred8x16_mad_cow_dc_l00)(uint8_t *src, int stride){ + FUNCC(pred8x16_left_dc)(src, stride); + FUNCC(pred4x4_128_dc)(src + 4*stride , NULL, stride); + FUNCC(pred4x4_128_dc)(src + 4*stride + 4*sizeof(pixel), NULL, stride); +} + static void FUNC(pred8x8_mad_cow_dc_0l0)(uint8_t *src, int stride){ FUNCC(pred8x8_left_dc)(src, stride); FUNCC(pred4x4_128_dc)(src , NULL, stride); FUNCC(pred4x4_128_dc)(src + 4*sizeof(pixel), NULL, stride); } +static void FUNC(pred8x16_mad_cow_dc_0l0)(uint8_t *src, int stride){ + FUNCC(pred8x16_left_dc)(src, stride); + FUNCC(pred4x4_128_dc)(src , NULL, stride); + FUNCC(pred4x4_128_dc)(src + 4*sizeof(pixel), NULL, stride); +} + static void FUNCC(pred8x8_plane)(uint8_t *_src, int _stride){ int j, k; int a; @@ -1126,8 +1148,24 @@ FUNCC(pred4x4_vertical_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride); } +static void FUNCC(pred8x16_vertical_add)(uint8_t *pix, const int *block_offset, const DCTELEM *block, int stride){ + int i; + for(i=0; i<4; i++) + FUNCC(pred4x4_vertical_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride); + for(i=4; i<8; i++) + FUNCC(pred4x4_vertical_add)(pix + block_offset[i+4], block + i*16*sizeof(pixel), stride); +} + static void FUNCC(pred8x8_horizontal_add)(uint8_t *pix, const int *block_offset, const DCTELEM *block, int stride){ int i; for(i=0; i<4; i++) FUNCC(pred4x4_horizontal_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride); } + +static void FUNCC(pred8x16_horizontal_add)(uint8_t *pix, const int *block_offset, const DCTELEM *block, int stride){ + int i; + for(i=0; i<4; i++) + FUNCC(pred4x4_horizontal_add)(pix + block_offset[i], block + i*16*sizeof(pixel), stride); + for(i=4; i<8; i++) + FUNCC(pred4x4_horizontal_add)(pix + block_offset[i+4], block + i*16*sizeof(pixel), stride); +} diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h264_ps.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h264_ps.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h264_ps.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h264_ps.c 2011-11-04 12:38:26.000000000 +0000 @@ -143,8 +143,8 @@ get_bits(&s->gb, 4); /* bit_rate_scale */ get_bits(&s->gb, 4); /* cpb_size_scale */ for(i=0; igb); /* bit_rate_value_minus1 */ - get_ue_golomb(&s->gb); /* cpb_size_value_minus1 */ + get_ue_golomb_long(&s->gb); /* bit_rate_value_minus1 */ + get_ue_golomb_long(&s->gb); /* cpb_size_value_minus1 */ get_bits1(&s->gb); /* cbr_flag */ } sps->initial_cpb_removal_delay_length = get_bits(&s->gb, 5) + 1; @@ -240,7 +240,7 @@ sps->num_reorder_frames= get_ue_golomb(&s->gb); get_ue_golomb(&s->gb); /*max_dec_frame_buffering*/ - if(s->gb.size_in_bits < get_bits_count(&s->gb)){ + if(get_bits_left(&s->gb) < 0){ sps->num_reorder_frames=0; sps->bitstream_restriction_flag= 0; } @@ -250,8 +250,8 @@ return -1; } } - if(s->gb.size_in_bits < get_bits_count(&s->gb)){ - av_log(h->s.avctx, AV_LOG_ERROR, "Overread VUI by %d bits\n", get_bits_count(&s->gb) - s->gb.size_in_bits); + if(get_bits_left(&s->gb) < 0){ + av_log(h->s.avctx, AV_LOG_ERROR, "Overread VUI by %d bits\n", -get_bits_left(&s->gb)); return -1; } @@ -338,10 +338,12 @@ sps->profile_idc= profile_idc; sps->constraint_set_flags = constraint_set_flags; sps->level_idc= level_idc; + sps->full_range = -1; memset(sps->scaling_matrix4, 16, sizeof(sps->scaling_matrix4)); memset(sps->scaling_matrix8, 16, sizeof(sps->scaling_matrix8)); sps->scaling_matrix_present = 0; + sps->colorspace = 2; //AVCOL_SPC_UNSPECIFIED if(sps->profile_idc >= 100){ //high profile sps->chroma_format_idc= get_ue_golomb_31(&s->gb); @@ -406,10 +408,6 @@ sps->mb_aff= 0; sps->direct_8x8_inference_flag= get_bits1(&s->gb); - if(!sps->frame_mbs_only_flag && !sps->direct_8x8_inference_flag){ - av_log(h->s.avctx, AV_LOG_ERROR, "This stream was generated by a broken encoder, invalid 8x8 inference\n"); - goto fail; - } #ifndef ALLOW_INTERLACE if(sps->mb_aff) @@ -417,7 +415,7 @@ #endif sps->crop= get_bits1(&s->gb); if(sps->crop){ - int crop_vertical_limit = sps->chroma_format_idc & 2 ? 16 : 8; + int crop_vertical_limit = sps->chroma_format_idc & 2 ? 16 : 8; int crop_horizontal_limit = sps->chroma_format_idc == 3 ? 16 : 8; sps->crop_left = get_ue_golomb(&s->gb); sps->crop_right = get_ue_golomb(&s->gb); @@ -492,6 +490,7 @@ unsigned int pps_id= get_ue_golomb(&s->gb); PPS *pps; const int qp_bd_offset = 6*(h->sps.bit_depth_luma-8); + int bits_left; if(pps_id >= MAX_PPS_COUNT) { av_log(h->s.avctx, AV_LOG_ERROR, "pps_id (%d) out of range\n", pps_id); @@ -568,7 +567,8 @@ memcpy(pps->scaling_matrix4, h->sps_buffers[pps->sps_id]->scaling_matrix4, sizeof(pps->scaling_matrix4)); memcpy(pps->scaling_matrix8, h->sps_buffers[pps->sps_id]->scaling_matrix8, sizeof(pps->scaling_matrix8)); - if(get_bits_count(&s->gb) < bit_length){ + bits_left = bit_length - get_bits_count(&s->gb); + if(bits_left > 0){ pps->transform_8x8_mode= get_bits1(&s->gb); decode_scaling_matrices(h, h->sps_buffers[pps->sps_id], pps, 0, pps->scaling_matrix4, pps->scaling_matrix8); pps->chroma_qp_index_offset[1]= get_se_golomb(&s->gb); //second_chroma_qp_index_offset diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h264_refs.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h264_refs.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/h264_refs.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/h264_refs.c 2011-11-04 12:38:26.000000000 +0000 @@ -654,7 +654,13 @@ print_short_term(h); print_long_term(h); - return h->s.avctx->error_recognition >= FF_ER_EXPLODE ? err : 0; + + if(err >= 0 && h->long_ref_count==0 && h->short_ref_count<=2 && h->pps.ref_count[0]<=1 && s->current_picture_ptr->f.pict_type == AV_PICTURE_TYPE_I){ + h->sync |= 1; + s->current_picture_ptr->sync |= h->sync; + } + + return (h->s.avctx->err_recognition & AV_EF_EXPLODE) ? err : 0; } int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb){ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/idcinvideo.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/idcinvideo.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/idcinvideo.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/idcinvideo.c 2011-11-04 12:38:26.000000000 +0000 @@ -36,7 +36,7 @@ * a little more compression by exploiting the fact that adjacent pixels * tend to be similar. * - * Note that this decoder could use ffmpeg's optimized VLC facilities + * Note that this decoder could use libavcodec's optimized VLC facilities * rather than naive, tree-based Huffman decoding. However, there are 256 * Huffman tables. Plus, the VLC bit coding order is right -> left instead * or left -> right, so all of the bits would have to be reversed. Further, diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/imc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/imc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/imc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/imc.c 2011-11-04 12:38:26.000000000 +0000 @@ -104,10 +104,15 @@ static av_cold int imc_decode_init(AVCodecContext * avctx) { - int i, j; + int i, j, ret; IMCContext *q = avctx->priv_data; double r1, r2; + if (avctx->channels != 1) { + av_log_ask_for_sample(avctx, "Number of channels is not supported\n"); + return AVERROR_PATCHWELCOME; + } + q->decoder_reset = 1; for(i = 0; i < BANDS; i++) @@ -156,10 +161,13 @@ } q->one_div_log2 = 1/log(2); - ff_fft_init(&q->fft, 7, 1); + if ((ret = ff_fft_init(&q->fft, 7, 1))) { + av_log(avctx, AV_LOG_INFO, "FFT init failed\n"); + return ret; + } dsputil_init(&q->dsp, avctx); avctx->sample_fmt = AV_SAMPLE_FMT_FLT; - avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO; + avctx->channel_layout = AV_CH_LAYOUT_MONO; return 0; } @@ -336,7 +344,7 @@ indx = 2; if (indx == -1) - return -1; + return AVERROR_INVALIDDATA; q->flcoeffs4[i] = q->flcoeffs4[i] + xTab[(indx*2 + (q->flcoeffs1[i] < highest)) * 2 + flag]; } @@ -595,7 +603,7 @@ middle_value = max_size >> 1; if (q->codewords[j] >= max_size || q->codewords[j] < 0) - return -1; + return AVERROR_INVALIDDATA; if (cw_len >= 4){ quantizer = imc_quantizer2[(stream_format_code & 2) >> 1]; @@ -628,7 +636,7 @@ if (get_bits_count(&q->gb) + cw_len > 512){ //av_log(NULL,0,"Band %i coeff %i cw_len %i\n",i,j,cw_len); - return -1; + return AVERROR_INVALIDDATA; } if(cw_len && (!q->bandFlagsBuf[i] || !q->skipFlags[j])) @@ -651,18 +659,24 @@ IMCContext *q = avctx->priv_data; int stream_format_code; - int imc_hdr, i, j; + int imc_hdr, i, j, out_size, ret; int flag; int bits, summer; int counter, bitscount; - uint16_t buf16[IMC_BLOCK_SIZE / 2]; + LOCAL_ALIGNED_16(uint16_t, buf16, [IMC_BLOCK_SIZE / 2]); if (buf_size < IMC_BLOCK_SIZE) { av_log(avctx, AV_LOG_ERROR, "imc frame too small!\n"); - return -1; + return AVERROR_INVALIDDATA; } - for(i = 0; i < IMC_BLOCK_SIZE / 2; i++) - buf16[i] = av_bswap16(((const uint16_t*)buf)[i]); + + out_size = COEFFS * av_get_bytes_per_sample(avctx->sample_fmt); + if (*data_size < out_size) { + av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); + return AVERROR(EINVAL); + } + + q->dsp.bswap16_buf(buf16, (const uint16_t*)buf, IMC_BLOCK_SIZE / 2); q->out_samples = data; init_get_bits(&q->gb, (const uint8_t*)buf16, IMC_BLOCK_SIZE * 8); @@ -672,13 +686,13 @@ if (imc_hdr != IMC_FRAME_ID) { av_log(avctx, AV_LOG_ERROR, "imc frame header check failed!\n"); av_log(avctx, AV_LOG_ERROR, "got %x instead of 0x21.\n", imc_hdr); - return -1; + return AVERROR_INVALIDDATA; } stream_format_code = get_bits(&q->gb, 3); if(stream_format_code & 1){ av_log(avctx, AV_LOG_ERROR, "Stream code format %X is not supported\n", stream_format_code); - return -1; + return AVERROR_INVALIDDATA; } // av_log(avctx, AV_LOG_DEBUG, "stream_format_code = %d\n", stream_format_code); @@ -738,10 +752,11 @@ } } - if(bit_allocation (q, stream_format_code, 512 - bitscount - get_bits_count(&q->gb), flag) < 0) { + if((ret = bit_allocation (q, stream_format_code, + 512 - bitscount - get_bits_count(&q->gb), flag)) < 0) { av_log(avctx, AV_LOG_ERROR, "Bit allocations failed\n"); q->decoder_reset = 1; - return -1; + return ret; } for(i = 0; i < BANDS; i++) { @@ -795,20 +810,20 @@ if(imc_get_coeffs(q) < 0) { av_log(avctx, AV_LOG_ERROR, "Read coefficients failed\n"); q->decoder_reset = 1; - return 0; + return AVERROR_INVALIDDATA; } if(inverse_quant_coeff(q, stream_format_code) < 0) { av_log(avctx, AV_LOG_ERROR, "Inverse quantization of coefficients failed\n"); q->decoder_reset = 1; - return 0; + return AVERROR_INVALIDDATA; } memset(q->skipFlags, 0, sizeof(q->skipFlags)); imc_imdct256(q); - *data_size = COEFFS * sizeof(float); + *data_size = out_size; return IMC_BLOCK_SIZE; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/imgconvert.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/imgconvert.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/imgconvert.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/imgconvert.c 2011-11-04 12:38:26.000000000 +0000 @@ -337,6 +337,16 @@ } } + switch (pix_fmt) { + case PIX_FMT_RGB8: + case PIX_FMT_BGR8: + case PIX_FMT_RGB4_BYTE: + case PIX_FMT_BGR4_BYTE: + case PIX_FMT_GRAY8: + // do not include palette for these pseudo-paletted formats + return size; + } + if (desc->flags & PIX_FMT_PAL) memcpy((unsigned char *)(((size_t)dest + 3) & ~3), src->data[1], 256 * 4); @@ -737,6 +747,7 @@ return 0; } +#if FF_API_GET_ALPHA_INFO /* NOTE: we scan all the pixels to have an exact information */ static int get_alpha_info_pal8(const AVPicture *src, int width, int height) { @@ -783,6 +794,7 @@ } return ret; } +#endif #if !(HAVE_MMX && HAVE_YASM) /* filter parameters: [-1 4 2 4 -1] // 8 */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/indeo3.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/indeo3.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/indeo3.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/indeo3.c 2011-11-04 12:38:26.000000000 +0000 @@ -1,4 +1,7 @@ /* + * Indeo Video v3 compatible decoder + * Copyright (c) 2009 - 2011 Maxim Poliakovski + * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or @@ -18,1130 +21,1036 @@ /** * @file - * Intel Indeo 3 (IV31, IV32, etc.) video decoder for FFmpeg - * written, produced, and directed by Alan Smithee + * This is a decoder for Intel Indeo Video v3. + * It is based on vector quantization, run-length coding and motion compensation. + * Known container formats: .avi and .mov + * Known FOURCCs: 'IV31', 'IV32' * - * For some documentation see: - * http://wiki.multimedia.cx/index.php?title=Indeo_3 + * @see http://wiki.multimedia.cx/index.php?title=Indeo_3 */ #include "libavutil/imgutils.h" +#include "libavutil/intreadwrite.h" #include "avcodec.h" #include "dsputil.h" #include "bytestream.h" +#include "get_bits.h" #include "indeo3data.h" -typedef struct -{ - uint8_t *Ybuf; - uint8_t *Ubuf; - uint8_t *Vbuf; - unsigned short y_w, y_h; - unsigned short uv_w, uv_h; -} YUVBufs; +/* RLE opcodes. */ +enum { + RLE_ESC_F9 = 249, ///< same as RLE_ESC_FA + do the same with next block + RLE_ESC_FA = 250, ///< INTRA: skip block, INTER: copy data from reference + RLE_ESC_FB = 251, ///< apply null delta to N blocks / skip N blocks + RLE_ESC_FC = 252, ///< same as RLE_ESC_FD + do the same with next block + RLE_ESC_FD = 253, ///< apply null delta to all remaining lines of this block + RLE_ESC_FE = 254, ///< apply null delta to all lines up to the 3rd line + RLE_ESC_FF = 255 ///< apply null delta to all lines up to the 2nd line +}; + + +/* Some constants for parsing frame bitstream flags. */ +#define BS_8BIT_PEL (1 << 1) ///< 8bit pixel bitdepth indicator +#define BS_KEYFRAME (1 << 2) ///< intra frame indicator +#define BS_MV_Y_HALF (1 << 4) ///< vertical mv halfpel resolution indicator +#define BS_MV_X_HALF (1 << 5) ///< horizontal mv halfpel resolution indicator +#define BS_NONREF (1 << 8) ///< nonref (discardable) frame indicator +#define BS_BUFFER 9 ///< indicates which of two frame buffers should be used + + +typedef struct Plane { + uint8_t *buffers[2]; + uint8_t *pixels[2]; ///< pointer to the actual pixel data of the buffers above + uint32_t width; + uint32_t height; + uint32_t pitch; +} Plane; + +#define CELL_STACK_MAX 20 + +typedef struct Cell { + int16_t xpos; ///< cell coordinates in 4x4 blocks + int16_t ypos; + int16_t width; ///< cell width in 4x4 blocks + int16_t height; ///< cell height in 4x4 blocks + uint8_t tree; ///< tree id: 0- MC tree, 1 - VQ tree + const int8_t *mv_ptr; ///< ptr to the motion vector if any +} Cell; typedef struct Indeo3DecodeContext { AVCodecContext *avctx; - int width, height; - AVFrame frame; - - uint8_t *buf; - YUVBufs iv_frame[2]; - YUVBufs *cur_frame; - YUVBufs *ref_frame; + AVFrame frame; + DSPContext dsp; - uint8_t *ModPred; - uint8_t *corrector_type; + GetBitContext gb; + int need_resync; + int skip_bits; + const uint8_t *next_cell_data; + const uint8_t *last_byte; + const int8_t *mc_vectors; + + int16_t width, height; + uint32_t frame_num; ///< current frame number (zero-based) + uint32_t data_size; ///< size of the frame data in bytes + uint16_t frame_flags; ///< frame properties + uint8_t cb_offset; ///< needed for selecting VQ tables + uint8_t buf_sel; ///< active frame buffer: 0 - primary, 1 -secondary + const uint8_t *y_data_ptr; + const uint8_t *v_data_ptr; + const uint8_t *u_data_ptr; + int32_t y_data_size; + int32_t v_data_size; + int32_t u_data_size; + const uint8_t *alt_quant; ///< secondary VQ table set for the modes 1 and 4 + Plane planes[3]; } Indeo3DecodeContext; -static const uint8_t corrector_type_0[24] = { - 195, 159, 133, 115, 101, 93, 87, 77, - 195, 159, 133, 115, 101, 93, 87, 77, - 128, 79, 79, 79, 79, 79, 79, 79 -}; -static const uint8_t corrector_type_2[8] = { 9, 7, 6, 8, 5, 4, 3, 2 }; +static uint8_t requant_tab[8][128]; -static av_cold int build_modpred(Indeo3DecodeContext *s) +/* + * Build the static requantization table. + * This table is used to remap pixel values according to a specific + * quant index and thus avoid overflows while adding deltas. + */ +static av_cold void build_requant_tab(void) { - int i, j; + static int8_t offsets[8] = { 1, 1, 2, -3, -3, 3, 4, 4 }; + static int8_t deltas [8] = { 0, 1, 0, 4, 4, 1, 0, 1 }; - if (!(s->ModPred = av_malloc(8 * 128))) - return AVERROR(ENOMEM); + int i, j, step; - for (i=0; i < 128; ++i) { - s->ModPred[i+0*128] = i > 126 ? 254 : 2*(i + 1 - ((i + 1) % 2)); - s->ModPred[i+1*128] = i == 7 ? 20 : - i == 119 || - i == 120 ? 236 : 2*(i + 2 - ((i + 1) % 3)); - s->ModPred[i+2*128] = i > 125 ? 248 : 2*(i + 2 - ((i + 2) % 4)); - s->ModPred[i+3*128] = 2*(i + 1 - ((i - 3) % 5)); - s->ModPred[i+4*128] = i == 8 ? 20 : 2*(i + 1 - ((i - 3) % 6)); - s->ModPred[i+5*128] = 2*(i + 4 - ((i + 3) % 7)); - s->ModPred[i+6*128] = i > 123 ? 240 : 2*(i + 4 - ((i + 4) % 8)); - s->ModPred[i+7*128] = 2*(i + 5 - ((i + 4) % 9)); - } - - if (!(s->corrector_type = av_malloc(24 * 256))) - return AVERROR(ENOMEM); - - for (i=0; i < 24; ++i) { - for (j=0; j < 256; ++j) { - s->corrector_type[i*256+j] = j < corrector_type_0[i] ? 1 : - j < 248 || (i == 16 && j == 248) ? 0 : - corrector_type_2[j - 248]; - } + for (i = 0; i < 8; i++) { + step = i + 2; + for (j = 0; j < 128; j++) + requant_tab[i][j] = (j + offsets[i]) / step * step + deltas[i]; } - return 0; + /* some last elements calculated above will have values >= 128 */ + /* pixel values shall never exceed 127 so set them to non-overflowing values */ + /* according with the quantization step of the respective section */ + requant_tab[0][127] = 126; + requant_tab[1][119] = 118; + requant_tab[1][120] = 118; + requant_tab[2][126] = 124; + requant_tab[2][127] = 124; + requant_tab[6][124] = 120; + requant_tab[6][125] = 120; + requant_tab[6][126] = 120; + requant_tab[6][127] = 120; + + /* Patch for compatibility with the Intel's binary decoders */ + requant_tab[1][7] = 10; + requant_tab[4][8] = 10; } -static av_cold int iv_alloc_frames(Indeo3DecodeContext *s) + +static av_cold int allocate_frame_buffers(Indeo3DecodeContext *ctx, + AVCodecContext *avctx) { - int luma_width = (s->width + 3) & ~3, - luma_height = (s->height + 3) & ~3, - chroma_width = ((luma_width >> 2) + 3) & ~3, - chroma_height = ((luma_height >> 2) + 3) & ~3, - luma_pixels = luma_width * luma_height, - chroma_pixels = chroma_width * chroma_height, - i; - unsigned int bufsize = luma_pixels * 2 + luma_width * 3 + - (chroma_pixels + chroma_width) * 4; - - av_freep(&s->buf); - if(!(s->buf = av_malloc(bufsize))) - return AVERROR(ENOMEM); - s->iv_frame[0].y_w = s->iv_frame[1].y_w = luma_width; - s->iv_frame[0].y_h = s->iv_frame[1].y_h = luma_height; - s->iv_frame[0].uv_w = s->iv_frame[1].uv_w = chroma_width; - s->iv_frame[0].uv_h = s->iv_frame[1].uv_h = chroma_height; - - s->iv_frame[0].Ybuf = s->buf + luma_width; - i = luma_pixels + luma_width * 2; - s->iv_frame[1].Ybuf = s->buf + i; - i += (luma_pixels + luma_width); - s->iv_frame[0].Ubuf = s->buf + i; - i += (chroma_pixels + chroma_width); - s->iv_frame[1].Ubuf = s->buf + i; - i += (chroma_pixels + chroma_width); - s->iv_frame[0].Vbuf = s->buf + i; - i += (chroma_pixels + chroma_width); - s->iv_frame[1].Vbuf = s->buf + i; - - for(i = 1; i <= luma_width; i++) - s->iv_frame[0].Ybuf[-i] = s->iv_frame[1].Ybuf[-i] = - s->iv_frame[0].Ubuf[-i] = 0x80; - - for(i = 1; i <= chroma_width; i++) { - s->iv_frame[1].Ubuf[-i] = 0x80; - s->iv_frame[0].Vbuf[-i] = 0x80; - s->iv_frame[1].Vbuf[-i] = 0x80; - s->iv_frame[1].Vbuf[chroma_pixels+i-1] = 0x80; + int p, luma_width, luma_height, chroma_width, chroma_height; + int luma_pitch, chroma_pitch, luma_size, chroma_size; + + luma_width = ctx->width; + luma_height = ctx->height; + + if (luma_width < 16 || luma_width > 640 || + luma_height < 16 || luma_height > 480 || + luma_width & 3 || luma_height & 3) { + av_log(avctx, AV_LOG_ERROR, "Invalid picture dimensions: %d x %d!\n", + luma_width, luma_height); + return AVERROR_INVALIDDATA; + } + + chroma_width = FFALIGN(luma_width >> 2, 4); + chroma_height = FFALIGN(luma_height >> 2, 4); + + luma_pitch = FFALIGN(luma_width, 16); + chroma_pitch = FFALIGN(chroma_width, 16); + + /* Calculate size of the luminance plane. */ + /* Add one line more for INTRA prediction. */ + luma_size = luma_pitch * (luma_height + 1); + + /* Calculate size of a chrominance planes. */ + /* Add one line more for INTRA prediction. */ + chroma_size = chroma_pitch * (chroma_height + 1); + + /* allocate frame buffers */ + for (p = 0; p < 3; p++) { + ctx->planes[p].pitch = !p ? luma_pitch : chroma_pitch; + ctx->planes[p].width = !p ? luma_width : chroma_width; + ctx->planes[p].height = !p ? luma_height : chroma_height; + + ctx->planes[p].buffers[0] = av_malloc(!p ? luma_size : chroma_size); + ctx->planes[p].buffers[1] = av_malloc(!p ? luma_size : chroma_size); + + /* fill the INTRA prediction lines with the middle pixel value = 64 */ + memset(ctx->planes[p].buffers[0], 0x40, ctx->planes[p].pitch); + memset(ctx->planes[p].buffers[1], 0x40, ctx->planes[p].pitch); + + /* set buffer pointers = buf_ptr + pitch and thus skip the INTRA prediction line */ + ctx->planes[p].pixels[0] = ctx->planes[p].buffers[0] + ctx->planes[p].pitch; + ctx->planes[p].pixels[1] = ctx->planes[p].buffers[1] + ctx->planes[p].pitch; } return 0; } -static av_cold void iv_free_func(Indeo3DecodeContext *s) + +static av_cold void free_frame_buffers(Indeo3DecodeContext *ctx) { - av_freep(&s->buf); - av_freep(&s->ModPred); - av_freep(&s->corrector_type); + int p; + + for (p = 0; p < 3; p++) { + av_freep(&ctx->planes[p].buffers[0]); + av_freep(&ctx->planes[p].buffers[1]); + } } -struct ustr { - int xpos; - int ypos; - int width; - int height; - int split_flag; - int split_direction; - int usl7; -}; +/** + * Copy pixels of the cell(x + mv_x, y + mv_y) from the previous frame into + * the cell(x, y) in the current frame. + * + * @param ctx pointer to the decoder context + * @param plane pointer to the plane descriptor + * @param cell pointer to the cell descriptor + */ +static void copy_cell(Indeo3DecodeContext *ctx, Plane *plane, Cell *cell) +{ + int h, w, mv_x, mv_y, offset, offset_dst; + uint8_t *src, *dst; + + /* setup output and reference pointers */ + offset_dst = (cell->ypos << 2) * plane->pitch + (cell->xpos << 2); + dst = plane->pixels[ctx->buf_sel] + offset_dst; + mv_y = cell->mv_ptr[0]; + mv_x = cell->mv_ptr[1]; + offset = offset_dst + mv_y * plane->pitch + mv_x; + src = plane->pixels[ctx->buf_sel ^ 1] + offset; + + h = cell->height << 2; + + for (w = cell->width; w > 0;) { + /* copy using 16xH blocks */ + if (!((cell->xpos << 2) & 15) && w >= 4) { + for (; w >= 4; src += 16, dst += 16, w -= 4) + ctx->dsp.put_no_rnd_pixels_tab[0][0](dst, src, plane->pitch, h); + } -#define LV1_CHECK(buf1,rle_v3,lv1,lp2) \ - if((lv1 & 0x80) != 0) { \ - if(rle_v3 != 0) \ - rle_v3 = 0; \ - else { \ - rle_v3 = 1; \ - buf1 -= 2; \ - } \ - } \ - lp2 = 4; - - -#define RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3) \ - if(rle_v3 == 0) { \ - rle_v2 = *buf1; \ - rle_v1 = 1; \ - if(rle_v2 > 32) { \ - rle_v2 -= 32; \ - rle_v1 = 0; \ - } \ - rle_v3 = 1; \ - } \ - buf1--; - - -#define LP2_CHECK(buf1,rle_v3,lp2) \ - if(lp2 == 0 && rle_v3 != 0) \ - rle_v3 = 0; \ - else { \ - buf1--; \ - rle_v3 = 1; \ + /* copy using 8xH blocks */ + if (!((cell->xpos << 2) & 7) && w >= 2) { + ctx->dsp.put_no_rnd_pixels_tab[1][0](dst, src, plane->pitch, h); + w -= 2; + src += 8; + dst += 8; + } + + if (w >= 1) { + copy_block4(dst, src, plane->pitch, plane->pitch, h); + w--; + src += 4; + dst += 4; + } } +} + + +/* Average 4/8 pixels at once without rounding using SWAR */ +#define AVG_32(dst, src, ref) \ + AV_WN32A(dst, ((AV_RN32A(src) + AV_RN32A(ref)) >> 1) & 0x7F7F7F7FUL) +#define AVG_64(dst, src, ref) \ + AV_WN64A(dst, ((AV_RN64A(src) + AV_RN64A(ref)) >> 1) & 0x7F7F7F7F7F7F7F7FULL) -#define RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2) \ - rle_v2--; \ - if(rle_v2 == 0) { \ - rle_v3 = 0; \ - buf1 += 2; \ - } \ - lp2 = 4; - -static void iv_Decode_Chunk(Indeo3DecodeContext *s, - uint8_t *cur, uint8_t *ref, int width, int height, - const uint8_t *buf1, int cb_offset, const uint8_t *hdr, - const uint8_t *buf2, int min_width_160) + +/* + * Replicate each even pixel as follows: + * ABCDEFGH -> AACCEEGG + */ +static inline uint64_t replicate64(uint64_t a) { +#if HAVE_BIGENDIAN + a &= 0xFF00FF00FF00FF00ULL; + a |= a >> 8; +#else + a &= 0x00FF00FF00FF00FFULL; + a |= a << 8; +#endif + return a; +} + +static inline uint32_t replicate32(uint32_t a) { +#if HAVE_BIGENDIAN + a &= 0xFF00FF00UL; + a |= a >> 8; +#else + a &= 0x00FF00FFUL; + a |= a << 8; +#endif + return a; +} + + +/* Fill n lines with 64bit pixel value pix */ +static inline void fill_64(uint8_t *dst, const uint64_t pix, int32_t n, + int32_t row_offset) { - uint8_t bit_buf; - unsigned int bit_pos, lv, lv1, lv2; - int *width_tbl, width_tbl_arr[10]; - const signed char *ref_vectors; - uint8_t *cur_frm_pos, *ref_frm_pos, *cp, *cp2; - uint8_t *cur_end = cur + width*height + width; - uint32_t *cur_lp, *ref_lp; - const uint32_t *correction_lp[2], *correctionloworder_lp[2], *correctionhighorder_lp[2]; - uint8_t *correction_type_sp[2]; - struct ustr strip_tbl[20], *strip; - int i, j, k, lp1, lp2, flag1, cmd, blks_width, blks_height, region_160_width, - rle_v1, rle_v2, rle_v3; - unsigned short res; - - bit_buf = 0; - ref_vectors = NULL; - - width_tbl = width_tbl_arr + 1; - i = (width < 0 ? width + 3 : width)/4; - for(j = -1; j < 8; j++) - width_tbl[j] = i * j; - - strip = strip_tbl; - - for(region_160_width = 0; region_160_width < (width - min_width_160); region_160_width += min_width_160); - - strip->ypos = strip->xpos = 0; - for(strip->width = min_width_160; width > strip->width; strip->width *= 2); - strip->height = height; - strip->split_direction = 0; - strip->split_flag = 0; - strip->usl7 = 0; - - bit_pos = 0; - - rle_v1 = rle_v2 = rle_v3 = 0; - - while(strip >= strip_tbl) { - if(bit_pos <= 0) { - bit_pos = 8; - bit_buf = *buf1++; - } + for (; n > 0; dst += row_offset, n--) + AV_WN64A(dst, pix); +} - bit_pos -= 2; - cmd = (bit_buf >> bit_pos) & 0x03; - if(cmd == 0) { - strip++; - if(strip >= strip_tbl + FF_ARRAY_ELEMS(strip_tbl)) { - av_log(s->avctx, AV_LOG_WARNING, "out of range strip\n"); - break; - } - memcpy(strip, strip-1, sizeof(*strip)); - strip->split_flag = 1; - strip->split_direction = 0; - strip->height = (strip->height > 8 ? ((strip->height+8)>>4)<<3 : 4); - continue; - } else if(cmd == 1) { - strip++; - if(strip >= strip_tbl + FF_ARRAY_ELEMS(strip_tbl)) { - av_log(s->avctx, AV_LOG_WARNING, "out of range strip\n"); - break; - } - memcpy(strip, strip-1, sizeof(*strip)); - strip->split_flag = 1; - strip->split_direction = 1; - strip->width = (strip->width > 8 ? ((strip->width+8)>>4)<<3 : 4); - continue; - } else if(cmd == 2) { - if(strip->usl7 == 0) { - strip->usl7 = 1; - ref_vectors = NULL; - continue; - } - } else if(cmd == 3) { - if(strip->usl7 == 0) { - strip->usl7 = 1; - ref_vectors = (const signed char*)buf2 + (*buf1 * 2); - buf1++; - continue; - } - } +/* Error codes for cell decoding. */ +enum { + IV3_NOERR = 0, + IV3_BAD_RLE = 1, + IV3_BAD_DATA = 2, + IV3_BAD_COUNTER = 3, + IV3_UNSUPPORTED = 4, + IV3_OUT_OF_DATA = 5 +}; - cur_frm_pos = cur + width * strip->ypos + strip->xpos; - if((blks_width = strip->width) < 0) - blks_width += 3; - blks_width >>= 2; - blks_height = strip->height; - - if(ref_vectors != NULL) { - ref_frm_pos = ref + (ref_vectors[0] + strip->ypos) * width + - ref_vectors[1] + strip->xpos; - } else - ref_frm_pos = cur_frm_pos - width_tbl[4]; +#define BUFFER_PRECHECK \ +if (*data_ptr >= last_ptr) \ + return IV3_OUT_OF_DATA; \ + +#define RLE_BLOCK_COPY \ + if (cell->mv_ptr || !skip_flag) \ + copy_block4(dst, ref, row_offset, row_offset, 4 << v_zoom) + +#define RLE_BLOCK_COPY_8 \ + pix64 = AV_RN64A(ref);\ + if (is_first_row) {/* special prediction case: top line of a cell */\ + pix64 = replicate64(pix64);\ + fill_64(dst + row_offset, pix64, 7, row_offset);\ + AVG_64(dst, ref, dst + row_offset);\ + } else \ + fill_64(dst, pix64, 8, row_offset) + +#define RLE_LINES_COPY \ + copy_block4(dst, ref, row_offset, row_offset, num_lines << v_zoom) + +#define RLE_LINES_COPY_M10 \ + pix64 = AV_RN64A(ref);\ + if (is_top_of_cell) {\ + pix64 = replicate64(pix64);\ + fill_64(dst + row_offset, pix64, (num_lines << 1) - 1, row_offset);\ + AVG_64(dst, ref, dst + row_offset);\ + } else \ + fill_64(dst, pix64, num_lines << 1, row_offset) + +#define APPLY_DELTA_4 \ + AV_WN16A(dst + line_offset , AV_RN16A(ref ) + delta_tab->deltas[dyad1]);\ + AV_WN16A(dst + line_offset + 2, AV_RN16A(ref + 2) + delta_tab->deltas[dyad2]);\ + if (mode >= 3) {\ + if (is_top_of_cell && !cell->ypos) {\ + AV_COPY32(dst, dst + row_offset);\ + } else {\ + AVG_32(dst, ref, dst + row_offset);\ + }\ + } - if(cmd == 2) { - if(bit_pos <= 0) { - bit_pos = 8; - bit_buf = *buf1++; - } +#define APPLY_DELTA_8 \ + /* apply two 32-bit VQ deltas to next even line */\ + if (is_top_of_cell) { \ + AV_WN32A(dst + row_offset , \ + replicate32(AV_RN32A(ref )) + delta_tab->deltas_m10[dyad1]);\ + AV_WN32A(dst + row_offset + 4, \ + replicate32(AV_RN32A(ref + 4)) + delta_tab->deltas_m10[dyad2]);\ + } else { \ + AV_WN32A(dst + row_offset , \ + AV_RN32A(ref ) + delta_tab->deltas_m10[dyad1]);\ + AV_WN32A(dst + row_offset + 4, \ + AV_RN32A(ref + 4) + delta_tab->deltas_m10[dyad2]);\ + } \ + /* odd lines are not coded but rather interpolated/replicated */\ + /* first line of the cell on the top of image? - replicate */\ + /* otherwise - interpolate */\ + if (is_top_of_cell && !cell->ypos) {\ + AV_COPY64(dst, dst + row_offset);\ + } else \ + AVG_64(dst, ref, dst + row_offset); + + +#define APPLY_DELTA_1011_INTER \ + if (mode == 10) { \ + AV_WN32A(dst , \ + AV_RN32A(dst ) + delta_tab->deltas_m10[dyad1]);\ + AV_WN32A(dst + 4 , \ + AV_RN32A(dst + 4 ) + delta_tab->deltas_m10[dyad2]);\ + AV_WN32A(dst + row_offset , \ + AV_RN32A(dst + row_offset ) + delta_tab->deltas_m10[dyad1]);\ + AV_WN32A(dst + row_offset + 4, \ + AV_RN32A(dst + row_offset + 4) + delta_tab->deltas_m10[dyad2]);\ + } else { \ + AV_WN16A(dst , \ + AV_RN16A(dst ) + delta_tab->deltas[dyad1]);\ + AV_WN16A(dst + 2 , \ + AV_RN16A(dst + 2 ) + delta_tab->deltas[dyad2]);\ + AV_WN16A(dst + row_offset , \ + AV_RN16A(dst + row_offset ) + delta_tab->deltas[dyad1]);\ + AV_WN16A(dst + row_offset + 2, \ + AV_RN16A(dst + row_offset + 2) + delta_tab->deltas[dyad2]);\ + } - bit_pos -= 2; - cmd = (bit_buf >> bit_pos) & 0x03; - if(cmd == 0 || ref_vectors != NULL) { - for(lp1 = 0; lp1 < blks_width; lp1++) { - for(i = 0, j = 0; i < blks_height; i++, j += width_tbl[1]) - ((uint32_t *)cur_frm_pos)[j] = ((uint32_t *)ref_frm_pos)[j]; - cur_frm_pos += 4; - ref_frm_pos += 4; - } - } else if(cmd != 1) - return; - } else { - k = *buf1 >> 4; - j = *buf1 & 0x0f; - buf1++; - lv = j + cb_offset; - - if((lv - 8) <= 7 && (k == 0 || k == 3 || k == 10)) { - cp2 = s->ModPred + ((lv - 8) << 7); - cp = ref_frm_pos; - for(i = 0; i < blks_width << 2; i++) { - int v = *cp >> 1; - *(cp++) = cp2[v]; +static int decode_cell_data(Cell *cell, uint8_t *block, uint8_t *ref_block, + int pitch, int h_zoom, int v_zoom, int mode, + const vqEntry *delta[2], int swap_quads[2], + const uint8_t **data_ptr, const uint8_t *last_ptr) +{ + int x, y, line, num_lines; + int rle_blocks = 0; + uint8_t code, *dst, *ref; + const vqEntry *delta_tab; + unsigned int dyad1, dyad2; + uint64_t pix64; + int skip_flag = 0, is_top_of_cell, is_first_row = 1; + int row_offset, blk_row_offset, line_offset; + + row_offset = pitch; + blk_row_offset = (row_offset << (2 + v_zoom)) - (cell->width << 2); + line_offset = v_zoom ? row_offset : 0; + + for (y = 0; y < cell->height; is_first_row = 0, y += 1 + v_zoom) { + for (x = 0; x < cell->width; x += 1 + h_zoom) { + ref = ref_block; + dst = block; + + if (rle_blocks > 0) { + if (mode <= 4) { + RLE_BLOCK_COPY; + } else if (mode == 10 && !cell->mv_ptr) { + RLE_BLOCK_COPY_8; } - } - - if(k == 1 || k == 4) { - lv = (hdr[j] & 0xf) + cb_offset; - correction_type_sp[0] = s->corrector_type + (lv << 8); - correction_lp[0] = correction + (lv << 8); - lv = (hdr[j] >> 4) + cb_offset; - correction_lp[1] = correction + (lv << 8); - correction_type_sp[1] = s->corrector_type + (lv << 8); + rle_blocks--; } else { - correctionloworder_lp[0] = correctionloworder_lp[1] = correctionloworder + (lv << 8); - correctionhighorder_lp[0] = correctionhighorder_lp[1] = correctionhighorder + (lv << 8); - correction_type_sp[0] = correction_type_sp[1] = s->corrector_type + (lv << 8); - correction_lp[0] = correction_lp[1] = correction + (lv << 8); - } - - switch(k) { - case 1: - case 0: /********** CASE 0 **********/ - for( ; blks_height > 0; blks_height -= 4) { - for(lp1 = 0; lp1 < blks_width; lp1++) { - for(lp2 = 0; lp2 < 4; ) { - k = *buf1++; - cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2]; - ref_lp = ((uint32_t *)ref_frm_pos) + width_tbl[lp2]; - if ((uint8_t *)cur_lp >= cur_end-3) - break; - - switch(correction_type_sp[0][k]) { - case 0: - *cur_lp = av_le2ne32(((av_le2ne32(*ref_lp) >> 1) + correction_lp[lp2 & 0x01][k]) << 1); - lp2++; - break; - case 1: - res = ((av_le2ne16(((unsigned short *)(ref_lp))[0]) >> 1) + correction_lp[lp2 & 0x01][*buf1]) << 1; - ((unsigned short *)cur_lp)[0] = av_le2ne16(res); - res = ((av_le2ne16(((unsigned short *)(ref_lp))[1]) >> 1) + correction_lp[lp2 & 0x01][k]) << 1; - ((unsigned short *)cur_lp)[1] = av_le2ne16(res); - buf1++; - lp2++; - break; - case 2: - if(lp2 == 0) { - for(i = 0, j = 0; i < 2; i++, j += width_tbl[1]) - cur_lp[j] = ref_lp[j]; - lp2 += 2; - } - break; - case 3: - if(lp2 < 2) { - for(i = 0, j = 0; i < (3 - lp2); i++, j += width_tbl[1]) - cur_lp[j] = ref_lp[j]; - lp2 = 3; - } - break; - case 8: - if(lp2 == 0) { - RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3) - - if(rle_v1 == 1 || ref_vectors != NULL) { - for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) - cur_lp[j] = ref_lp[j]; - } - - RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2) - break; - } else { - rle_v1 = 1; - rle_v2 = *buf1 - 1; - } - case 5: - LP2_CHECK(buf1,rle_v3,lp2) - case 4: - for(i = 0, j = 0; i < (4 - lp2); i++, j += width_tbl[1]) - cur_lp[j] = ref_lp[j]; - lp2 = 4; - break; - - case 7: - if(rle_v3 != 0) - rle_v3 = 0; - else { - buf1--; - rle_v3 = 1; + for (line = 0; line < 4;) { + num_lines = 1; + is_top_of_cell = is_first_row && !line; + + /* select primary VQ table for odd, secondary for even lines */ + if (mode <= 4) + delta_tab = delta[line & 1]; + else + delta_tab = delta[1]; + BUFFER_PRECHECK; + code = bytestream_get_byte(data_ptr); + if (code < 248) { + if (code < delta_tab->num_dyads) { + BUFFER_PRECHECK; + dyad1 = bytestream_get_byte(data_ptr); + dyad2 = code; + if (dyad1 > delta_tab->num_dyads || dyad1 >= 248) + return IV3_BAD_DATA; + } else { + /* process QUADS */ + code -= delta_tab->num_dyads; + dyad1 = code / delta_tab->quad_exp; + dyad2 = code % delta_tab->quad_exp; + if (swap_quads[line & 1]) + FFSWAP(unsigned int, dyad1, dyad2); + } + if (mode <= 4) { + APPLY_DELTA_4; + } else if (mode == 10 && !cell->mv_ptr) { + APPLY_DELTA_8; + } else { + APPLY_DELTA_1011_INTER; + } + } else { + /* process RLE codes */ + switch (code) { + case RLE_ESC_FC: + skip_flag = 0; + rle_blocks = 1; + code = 253; + /* FALLTHROUGH */ + case RLE_ESC_FF: + case RLE_ESC_FE: + case RLE_ESC_FD: + num_lines = 257 - code - line; + if (num_lines <= 0) + return IV3_BAD_RLE; + if (mode <= 4) { + RLE_LINES_COPY; + } else if (mode == 10 && !cell->mv_ptr) { + RLE_LINES_COPY_M10; + } + break; + case RLE_ESC_FB: + BUFFER_PRECHECK; + code = bytestream_get_byte(data_ptr); + rle_blocks = (code & 0x1F) - 1; /* set block counter */ + if (code >= 64 || rle_blocks < 0) + return IV3_BAD_COUNTER; + skip_flag = code & 0x20; + num_lines = 4 - line; /* enforce next block processing */ + if (mode >= 10 || (cell->mv_ptr || !skip_flag)) { + if (mode <= 4) { + RLE_LINES_COPY; + } else if (mode == 10 && !cell->mv_ptr) { + RLE_LINES_COPY_M10; } - case 6: - if(ref_vectors != NULL) { - for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) - cur_lp[j] = ref_lp[j]; + } + break; + case RLE_ESC_F9: + skip_flag = 1; + rle_blocks = 1; + /* FALLTHROUGH */ + case RLE_ESC_FA: + if (line) + return IV3_BAD_RLE; + num_lines = 4; /* enforce next block processing */ + if (cell->mv_ptr) { + if (mode <= 4) { + RLE_LINES_COPY; + } else if (mode == 10 && !cell->mv_ptr) { + RLE_LINES_COPY_M10; } - lp2 = 4; - break; - - case 9: - lv1 = *buf1++; - lv = (lv1 & 0x7F) << 1; - lv += (lv << 8); - lv += (lv << 16); - for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) - cur_lp[j] = lv; - - LV1_CHECK(buf1,rle_v3,lv1,lp2) - break; - default: - return; } + break; + default: + return IV3_UNSUPPORTED; } - - cur_frm_pos += 4; - ref_frm_pos += 4; } - cur_frm_pos += ((width - blks_width) * 4); - ref_frm_pos += ((width - blks_width) * 4); + line += num_lines; + ref += row_offset * (num_lines << v_zoom); + dst += row_offset * (num_lines << v_zoom); } - break; + } - case 4: - case 3: /********** CASE 3 **********/ - if(ref_vectors != NULL) - return; - flag1 = 1; - - for( ; blks_height > 0; blks_height -= 8) { - for(lp1 = 0; lp1 < blks_width; lp1++) { - for(lp2 = 0; lp2 < 4; ) { - k = *buf1++; - - cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2 * 2]; - ref_lp = ((uint32_t *)cur_frm_pos) + width_tbl[(lp2 * 2) - 1]; - - switch(correction_type_sp[lp2 & 0x01][k]) { - case 0: - cur_lp[width_tbl[1]] = av_le2ne32(((av_le2ne32(*ref_lp) >> 1) + correction_lp[lp2 & 0x01][k]) << 1); - if(lp2 > 0 || flag1 == 0 || strip->ypos != 0) - cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; - else - cur_lp[0] = av_le2ne32(((av_le2ne32(*ref_lp) >> 1) + correction_lp[lp2 & 0x01][k]) << 1); - lp2++; - break; - - case 1: - res = ((av_le2ne16(((unsigned short *)ref_lp)[0]) >> 1) + correction_lp[lp2 & 0x01][*buf1]) << 1; - ((unsigned short *)cur_lp)[width_tbl[2]] = av_le2ne16(res); - res = ((av_le2ne16(((unsigned short *)ref_lp)[1]) >> 1) + correction_lp[lp2 & 0x01][k]) << 1; - ((unsigned short *)cur_lp)[width_tbl[2]+1] = av_le2ne16(res); - - if(lp2 > 0 || flag1 == 0 || strip->ypos != 0) - cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; - else - cur_lp[0] = cur_lp[width_tbl[1]]; - buf1++; - lp2++; - break; - - case 2: - if(lp2 == 0) { - for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) - cur_lp[j] = *ref_lp; - lp2 += 2; - } - break; + /* move to next horizontal block */ + block += 4 << h_zoom; + ref_block += 4 << h_zoom; + } - case 3: - if(lp2 < 2) { - for(i = 0, j = 0; i < 6 - (lp2 * 2); i++, j += width_tbl[1]) - cur_lp[j] = *ref_lp; - lp2 = 3; - } - break; + /* move to next line of blocks */ + ref_block += blk_row_offset; + block += blk_row_offset; + } + return IV3_NOERR; +} - case 6: - lp2 = 4; - break; - - case 7: - if(rle_v3 != 0) - rle_v3 = 0; - else { - buf1--; - rle_v3 = 1; - } - lp2 = 4; - break; - case 8: - if(lp2 == 0) { - RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3) - - if(rle_v1 == 1) { - for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) - cur_lp[j] = ref_lp[j]; - } - - RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2) - break; - } else { - rle_v2 = (*buf1) - 1; - rle_v1 = 1; - } - case 5: - LP2_CHECK(buf1,rle_v3,lp2) - case 4: - for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1]) - cur_lp[j] = *ref_lp; - lp2 = 4; - break; - - case 9: - av_log(s->avctx, AV_LOG_ERROR, "UNTESTED.\n"); - lv1 = *buf1++; - lv = (lv1 & 0x7F) << 1; - lv += (lv << 8); - lv += (lv << 16); +/** + * Decode a vector-quantized cell. + * It consists of several routines, each of which handles one or more "modes" + * with which a cell can be encoded. + * + * @param ctx pointer to the decoder context + * @param avctx ptr to the AVCodecContext + * @param plane pointer to the plane descriptor + * @param cell pointer to the cell descriptor + * @param data_ptr pointer to the compressed data + * @param last_ptr pointer to the last byte to catch reads past end of buffer + * @return number of consumed bytes or negative number in case of error + */ +static int decode_cell(Indeo3DecodeContext *ctx, AVCodecContext *avctx, + Plane *plane, Cell *cell, const uint8_t *data_ptr, + const uint8_t *last_ptr) +{ + int x, mv_x, mv_y, mode, vq_index, prim_indx, second_indx; + int zoom_fac; + int offset, error = 0, swap_quads[2]; + uint8_t code, *block, *ref_block = 0; + const vqEntry *delta[2]; + const uint8_t *data_start = data_ptr; + + /* get coding mode and VQ table index from the VQ descriptor byte */ + code = *data_ptr++; + mode = code >> 4; + vq_index = code & 0xF; + + /* setup output and reference pointers */ + offset = (cell->ypos << 2) * plane->pitch + (cell->xpos << 2); + block = plane->pixels[ctx->buf_sel] + offset; + if (!cell->mv_ptr) { + /* use previous line as reference for INTRA cells */ + ref_block = block - plane->pitch; + } else if (mode >= 10) { + /* for mode 10 and 11 INTER first copy the predicted cell into the current one */ + /* so we don't need to do data copying for each RLE code later */ + copy_cell(ctx, plane, cell); + } else { + /* set the pointer to the reference pixels for modes 0-4 INTER */ + mv_y = cell->mv_ptr[0]; + mv_x = cell->mv_ptr[1]; + offset += mv_y * plane->pitch + mv_x; + ref_block = plane->pixels[ctx->buf_sel ^ 1] + offset; + } - for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) - cur_lp[j] = lv; + /* select VQ tables as follows: */ + /* modes 0 and 3 use only the primary table for all lines in a block */ + /* while modes 1 and 4 switch between primary and secondary tables on alternate lines */ + if (mode == 1 || mode == 4) { + code = ctx->alt_quant[vq_index]; + prim_indx = (code >> 4) + ctx->cb_offset; + second_indx = (code & 0xF) + ctx->cb_offset; + } else { + vq_index += ctx->cb_offset; + prim_indx = second_indx = vq_index; + } - LV1_CHECK(buf1,rle_v3,lv1,lp2) - break; + if (prim_indx >= 24 || second_indx >= 24) { + av_log(avctx, AV_LOG_ERROR, "Invalid VQ table indexes! Primary: %d, secondary: %d!\n", + prim_indx, second_indx); + return AVERROR_INVALIDDATA; + } - default: - return; - } - } + delta[0] = &vq_tab[second_indx]; + delta[1] = &vq_tab[prim_indx]; + swap_quads[0] = second_indx >= 16; + swap_quads[1] = prim_indx >= 16; + + /* requantize the prediction if VQ index of this cell differs from VQ index */ + /* of the predicted cell in order to avoid overflows. */ + if (vq_index >= 8 && ref_block) { + for (x = 0; x < cell->width << 2; x++) + ref_block[x] = requant_tab[vq_index & 7][ref_block[x]]; + } - cur_frm_pos += 4; - } + error = IV3_NOERR; - cur_frm_pos += (((width * 2) - blks_width) * 4); - flag1 = 0; - } - break; + switch (mode) { + case 0: /*------------------ MODES 0 & 1 (4x4 block processing) --------------------*/ + case 1: + case 3: /*------------------ MODES 3 & 4 (4x8 block processing) --------------------*/ + case 4: + if (mode >= 3 && cell->mv_ptr) { + av_log(avctx, AV_LOG_ERROR, "Attempt to apply Mode 3/4 to an INTER cell!\n"); + return AVERROR_INVALIDDATA; + } - case 10: /********** CASE 10 **********/ - if(ref_vectors == NULL) { - flag1 = 1; - - for( ; blks_height > 0; blks_height -= 8) { - for(lp1 = 0; lp1 < blks_width; lp1 += 2) { - for(lp2 = 0; lp2 < 4; ) { - k = *buf1++; - cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2 * 2]; - ref_lp = ((uint32_t *)cur_frm_pos) + width_tbl[(lp2 * 2) - 1]; - lv1 = ref_lp[0]; - lv2 = ref_lp[1]; - if(lp2 == 0 && flag1 != 0) { -#if HAVE_BIGENDIAN - lv1 = lv1 & 0xFF00FF00; - lv1 = (lv1 >> 8) | lv1; - lv2 = lv2 & 0xFF00FF00; - lv2 = (lv2 >> 8) | lv2; -#else - lv1 = lv1 & 0x00FF00FF; - lv1 = (lv1 << 8) | lv1; - lv2 = lv2 & 0x00FF00FF; - lv2 = (lv2 << 8) | lv2; -#endif - } + zoom_fac = mode >= 3; + error = decode_cell_data(cell, block, ref_block, plane->pitch, 0, zoom_fac, + mode, delta, swap_quads, &data_ptr, last_ptr); + break; + case 10: /*-------------------- MODE 10 (8x8 block processing) ---------------------*/ + case 11: /*----------------- MODE 11 (4x8 INTER block processing) ------------------*/ + if (mode == 10 && !cell->mv_ptr) { /* MODE 10 INTRA processing */ + error = decode_cell_data(cell, block, ref_block, plane->pitch, 1, 1, + mode, delta, swap_quads, &data_ptr, last_ptr); + } else { /* mode 10 and 11 INTER processing */ + if (mode == 11 && !cell->mv_ptr) { + av_log(avctx, AV_LOG_ERROR, "Attempt to use Mode 11 for an INTRA cell!\n"); + return AVERROR_INVALIDDATA; + } - switch(correction_type_sp[lp2 & 0x01][k]) { - case 0: - cur_lp[width_tbl[1]] = av_le2ne32(((av_le2ne32(lv1) >> 1) + correctionloworder_lp[lp2 & 0x01][k]) << 1); - cur_lp[width_tbl[1]+1] = av_le2ne32(((av_le2ne32(lv2) >> 1) + correctionhighorder_lp[lp2 & 0x01][k]) << 1); - if(lp2 > 0 || strip->ypos != 0 || flag1 == 0) { - cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; - cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE; - } else { - cur_lp[0] = cur_lp[width_tbl[1]]; - cur_lp[1] = cur_lp[width_tbl[1]+1]; - } - lp2++; - break; - - case 1: - cur_lp[width_tbl[1]] = av_le2ne32(((av_le2ne32(lv1) >> 1) + correctionloworder_lp[lp2 & 0x01][*buf1]) << 1); - cur_lp[width_tbl[1]+1] = av_le2ne32(((av_le2ne32(lv2) >> 1) + correctionloworder_lp[lp2 & 0x01][k]) << 1); - if(lp2 > 0 || strip->ypos != 0 || flag1 == 0) { - cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; - cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE; - } else { - cur_lp[0] = cur_lp[width_tbl[1]]; - cur_lp[1] = cur_lp[width_tbl[1]+1]; - } - buf1++; - lp2++; - break; - - case 2: - if(lp2 == 0) { - if(flag1 != 0) { - for(i = 0, j = width_tbl[1]; i < 3; i++, j += width_tbl[1]) { - cur_lp[j] = lv1; - cur_lp[j+1] = lv2; - } - cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; - cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE; - } else { - for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) { - cur_lp[j] = lv1; - cur_lp[j+1] = lv2; - } - } - lp2 += 2; - } - break; - - case 3: - if(lp2 < 2) { - if(lp2 == 0 && flag1 != 0) { - for(i = 0, j = width_tbl[1]; i < 5; i++, j += width_tbl[1]) { - cur_lp[j] = lv1; - cur_lp[j+1] = lv2; - } - cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; - cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE; - } else { - for(i = 0, j = 0; i < 6 - (lp2 * 2); i++, j += width_tbl[1]) { - cur_lp[j] = lv1; - cur_lp[j+1] = lv2; - } - } - lp2 = 3; - } - break; - - case 8: - if(lp2 == 0) { - RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3) - if(rle_v1 == 1) { - if(flag1 != 0) { - for(i = 0, j = width_tbl[1]; i < 7; i++, j += width_tbl[1]) { - cur_lp[j] = lv1; - cur_lp[j+1] = lv2; - } - cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; - cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE; - } else { - for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) { - cur_lp[j] = lv1; - cur_lp[j+1] = lv2; - } - } - } - RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2) - break; - } else { - rle_v1 = 1; - rle_v2 = (*buf1) - 1; - } - case 5: - LP2_CHECK(buf1,rle_v3,lp2) - case 4: - if(lp2 == 0 && flag1 != 0) { - for(i = 0, j = width_tbl[1]; i < 7; i++, j += width_tbl[1]) { - cur_lp[j] = lv1; - cur_lp[j+1] = lv2; - } - cur_lp[0] = ((cur_lp[-width_tbl[1]] >> 1) + (cur_lp[width_tbl[1]] >> 1)) & 0xFEFEFEFE; - cur_lp[1] = ((cur_lp[-width_tbl[1]+1] >> 1) + (cur_lp[width_tbl[1]+1] >> 1)) & 0xFEFEFEFE; - } else { - for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1]) { - cur_lp[j] = lv1; - cur_lp[j+1] = lv2; - } - } - lp2 = 4; - break; - - case 6: - lp2 = 4; - break; - - case 7: - if(lp2 == 0) { - if(rle_v3 != 0) - rle_v3 = 0; - else { - buf1--; - rle_v3 = 1; - } - lp2 = 4; - } - break; - - case 9: - av_log(s->avctx, AV_LOG_ERROR, "UNTESTED.\n"); - lv1 = *buf1; - lv = (lv1 & 0x7F) << 1; - lv += (lv << 8); - lv += (lv << 16); - for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) - cur_lp[j] = lv; - LV1_CHECK(buf1,rle_v3,lv1,lp2) - break; + zoom_fac = mode == 10; + error = decode_cell_data(cell, block, ref_block, plane->pitch, + zoom_fac, 1, mode, delta, swap_quads, + &data_ptr, last_ptr); + } + break; + default: + av_log(avctx, AV_LOG_ERROR, "Unsupported coding mode: %d\n", mode); + return AVERROR_INVALIDDATA; + }//switch mode + + switch (error) { + case IV3_BAD_RLE: + av_log(avctx, AV_LOG_ERROR, "Mode %d: RLE code %X is not allowed at the current line\n", + mode, data_ptr[-1]); + return AVERROR_INVALIDDATA; + case IV3_BAD_DATA: + av_log(avctx, AV_LOG_ERROR, "Mode %d: invalid VQ data\n", mode); + return AVERROR_INVALIDDATA; + case IV3_BAD_COUNTER: + av_log(avctx, AV_LOG_ERROR, "Mode %d: RLE-FB invalid counter: %d\n", mode, code); + return AVERROR_INVALIDDATA; + case IV3_UNSUPPORTED: + av_log(avctx, AV_LOG_ERROR, "Mode %d: unsupported RLE code: %X\n", mode, data_ptr[-1]); + return AVERROR_INVALIDDATA; + case IV3_OUT_OF_DATA: + av_log(avctx, AV_LOG_ERROR, "Mode %d: attempt to read past end of buffer\n", mode); + return AVERROR_INVALIDDATA; + } - default: - return; - } - } + return data_ptr - data_start; /* report number of bytes consumed from the input buffer */ +} - cur_frm_pos += 8; - } - cur_frm_pos += (((width * 2) - blks_width) * 4); - flag1 = 0; - } - } else { - for( ; blks_height > 0; blks_height -= 8) { - for(lp1 = 0; lp1 < blks_width; lp1 += 2) { - for(lp2 = 0; lp2 < 4; ) { - k = *buf1++; - cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2 * 2]; - ref_lp = ((uint32_t *)ref_frm_pos) + width_tbl[lp2 * 2]; - - switch(correction_type_sp[lp2 & 0x01][k]) { - case 0: - lv1 = correctionloworder_lp[lp2 & 0x01][k]; - lv2 = correctionhighorder_lp[lp2 & 0x01][k]; - cur_lp[0] = av_le2ne32(((av_le2ne32(ref_lp[0]) >> 1) + lv1) << 1); - cur_lp[1] = av_le2ne32(((av_le2ne32(ref_lp[1]) >> 1) + lv2) << 1); - cur_lp[width_tbl[1]] = av_le2ne32(((av_le2ne32(ref_lp[width_tbl[1]]) >> 1) + lv1) << 1); - cur_lp[width_tbl[1]+1] = av_le2ne32(((av_le2ne32(ref_lp[width_tbl[1]+1]) >> 1) + lv2) << 1); - lp2++; - break; - - case 1: - lv1 = correctionloworder_lp[lp2 & 0x01][*buf1++]; - lv2 = correctionloworder_lp[lp2 & 0x01][k]; - cur_lp[0] = av_le2ne32(((av_le2ne32(ref_lp[0]) >> 1) + lv1) << 1); - cur_lp[1] = av_le2ne32(((av_le2ne32(ref_lp[1]) >> 1) + lv2) << 1); - cur_lp[width_tbl[1]] = av_le2ne32(((av_le2ne32(ref_lp[width_tbl[1]]) >> 1) + lv1) << 1); - cur_lp[width_tbl[1]+1] = av_le2ne32(((av_le2ne32(ref_lp[width_tbl[1]+1]) >> 1) + lv2) << 1); - lp2++; - break; - - case 2: - if(lp2 == 0) { - for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) { - cur_lp[j] = ref_lp[j]; - cur_lp[j+1] = ref_lp[j+1]; - } - lp2 += 2; - } - break; - - case 3: - if(lp2 < 2) { - for(i = 0, j = 0; i < 6 - (lp2 * 2); i++, j += width_tbl[1]) { - cur_lp[j] = ref_lp[j]; - cur_lp[j+1] = ref_lp[j+1]; - } - lp2 = 3; - } - break; - - case 8: - if(lp2 == 0) { - RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3) - for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) { - ((uint32_t *)cur_frm_pos)[j] = ((uint32_t *)ref_frm_pos)[j]; - ((uint32_t *)cur_frm_pos)[j+1] = ((uint32_t *)ref_frm_pos)[j+1]; - } - RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2) - break; - } else { - rle_v1 = 1; - rle_v2 = (*buf1) - 1; - } - case 5: - case 7: - LP2_CHECK(buf1,rle_v3,lp2) - case 6: - case 4: - for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1]) { - cur_lp[j] = ref_lp[j]; - cur_lp[j+1] = ref_lp[j+1]; - } - lp2 = 4; - break; - - case 9: - av_log(s->avctx, AV_LOG_ERROR, "UNTESTED.\n"); - lv1 = *buf1; - lv = (lv1 & 0x7F) << 1; - lv += (lv << 8); - lv += (lv << 16); - for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) - ((uint32_t *)cur_frm_pos)[j] = ((uint32_t *)cur_frm_pos)[j+1] = lv; - LV1_CHECK(buf1,rle_v3,lv1,lp2) - break; +/* Binary tree codes. */ +enum { + H_SPLIT = 0, + V_SPLIT = 1, + INTRA_NULL = 2, + INTER_DATA = 3 +}; - default: - return; - } - } - cur_frm_pos += 8; - ref_frm_pos += 8; - } +#define SPLIT_CELL(size, new_size) (new_size) = ((size) > 2) ? ((((size) + 2) >> 2) << 1) : 1 - cur_frm_pos += (((width * 2) - blks_width) * 4); - ref_frm_pos += (((width * 2) - blks_width) * 4); - } - } - break; +#define UPDATE_BITPOS(n) \ + ctx->skip_bits += (n); \ + ctx->need_resync = 1 + +#define RESYNC_BITSTREAM \ + if (ctx->need_resync && !(get_bits_count(&ctx->gb) & 7)) { \ + skip_bits_long(&ctx->gb, ctx->skip_bits); \ + ctx->skip_bits = 0; \ + ctx->need_resync = 0; \ + } - case 11: /********** CASE 11 **********/ - if(ref_vectors == NULL) - return; - - for( ; blks_height > 0; blks_height -= 8) { - for(lp1 = 0; lp1 < blks_width; lp1++) { - for(lp2 = 0; lp2 < 4; ) { - k = *buf1++; - cur_lp = ((uint32_t *)cur_frm_pos) + width_tbl[lp2 * 2]; - ref_lp = ((uint32_t *)ref_frm_pos) + width_tbl[lp2 * 2]; - - switch(correction_type_sp[lp2 & 0x01][k]) { - case 0: - cur_lp[0] = av_le2ne32(((av_le2ne32(*ref_lp) >> 1) + correction_lp[lp2 & 0x01][k]) << 1); - cur_lp[width_tbl[1]] = av_le2ne32(((av_le2ne32(ref_lp[width_tbl[1]]) >> 1) + correction_lp[lp2 & 0x01][k]) << 1); - lp2++; - break; - - case 1: - lv1 = (unsigned short)(correction_lp[lp2 & 0x01][*buf1++]); - lv2 = (unsigned short)(correction_lp[lp2 & 0x01][k]); - res = (unsigned short)(((av_le2ne16(((unsigned short *)ref_lp)[0]) >> 1) + lv1) << 1); - ((unsigned short *)cur_lp)[0] = av_le2ne16(res); - res = (unsigned short)(((av_le2ne16(((unsigned short *)ref_lp)[1]) >> 1) + lv2) << 1); - ((unsigned short *)cur_lp)[1] = av_le2ne16(res); - res = (unsigned short)(((av_le2ne16(((unsigned short *)ref_lp)[width_tbl[2]]) >> 1) + lv1) << 1); - ((unsigned short *)cur_lp)[width_tbl[2]] = av_le2ne16(res); - res = (unsigned short)(((av_le2ne16(((unsigned short *)ref_lp)[width_tbl[2]+1]) >> 1) + lv2) << 1); - ((unsigned short *)cur_lp)[width_tbl[2]+1] = av_le2ne16(res); - lp2++; - break; - - case 2: - if(lp2 == 0) { - for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) - cur_lp[j] = ref_lp[j]; - lp2 += 2; - } - break; +#define CHECK_CELL \ + if (curr_cell.xpos + curr_cell.width > (plane->width >> 2) || \ + curr_cell.ypos + curr_cell.height > (plane->height >> 2)) { \ + av_log(avctx, AV_LOG_ERROR, "Invalid cell: x=%d, y=%d, w=%d, h=%d\n", \ + curr_cell.xpos, curr_cell.ypos, curr_cell.width, curr_cell.height); \ + return AVERROR_INVALIDDATA; \ + } - case 3: - if(lp2 < 2) { - for(i = 0, j = 0; i < 6 - (lp2 * 2); i++, j += width_tbl[1]) - cur_lp[j] = ref_lp[j]; - lp2 = 3; - } - break; - case 8: - if(lp2 == 0) { - RLE_V3_CHECK(buf1,rle_v1,rle_v2,rle_v3) - - for(i = 0, j = 0; i < 8; i++, j += width_tbl[1]) - cur_lp[j] = ref_lp[j]; - - RLE_V2_CHECK(buf1,rle_v2, rle_v3,lp2) - break; - } else { - rle_v1 = 1; - rle_v2 = (*buf1) - 1; - } - case 5: - case 7: - LP2_CHECK(buf1,rle_v3,lp2) - case 4: - case 6: - for(i = 0, j = 0; i < 8 - (lp2 * 2); i++, j += width_tbl[1]) - cur_lp[j] = ref_lp[j]; - lp2 = 4; - break; - - case 9: - av_log(s->avctx, AV_LOG_ERROR, "UNTESTED.\n"); - lv1 = *buf1++; - lv = (lv1 & 0x7F) << 1; - lv += (lv << 8); - lv += (lv << 16); - for(i = 0, j = 0; i < 4; i++, j += width_tbl[1]) - cur_lp[j] = lv; - LV1_CHECK(buf1,rle_v3,lv1,lp2) - break; +static int parse_bintree(Indeo3DecodeContext *ctx, AVCodecContext *avctx, + Plane *plane, int code, Cell *ref_cell, + const int depth, const int strip_width) +{ + Cell curr_cell; + int bytes_used; - default: - return; - } - } + if (depth <= 0) { + av_log(avctx, AV_LOG_ERROR, "Stack overflow (corrupted binary tree)!\n"); + return AVERROR_INVALIDDATA; // unwind recursion + } - cur_frm_pos += 4; - ref_frm_pos += 4; - } + curr_cell = *ref_cell; // clone parent cell + if (code == H_SPLIT) { + SPLIT_CELL(ref_cell->height, curr_cell.height); + ref_cell->ypos += curr_cell.height; + ref_cell->height -= curr_cell.height; + } else if (code == V_SPLIT) { + if (curr_cell.width > strip_width) { + /* split strip */ + curr_cell.width = (curr_cell.width <= (strip_width << 1) ? 1 : 2) * strip_width; + } else + SPLIT_CELL(ref_cell->width, curr_cell.width); + ref_cell->xpos += curr_cell.width; + ref_cell->width -= curr_cell.width; + } - cur_frm_pos += (((width * 2) - blks_width) * 4); - ref_frm_pos += (((width * 2) - blks_width) * 4); + while (1) { /* loop until return */ + RESYNC_BITSTREAM; + switch (code = get_bits(&ctx->gb, 2)) { + case H_SPLIT: + case V_SPLIT: + if (parse_bintree(ctx, avctx, plane, code, &curr_cell, depth - 1, strip_width)) + return AVERROR_INVALIDDATA; + break; + case INTRA_NULL: + if (!curr_cell.tree) { /* MC tree INTRA code */ + curr_cell.mv_ptr = 0; /* mark the current strip as INTRA */ + curr_cell.tree = 1; /* enter the VQ tree */ + } else { /* VQ tree NULL code */ + RESYNC_BITSTREAM; + code = get_bits(&ctx->gb, 2); + if (code >= 2) { + av_log(avctx, AV_LOG_ERROR, "Invalid VQ_NULL code: %d\n", code); + return AVERROR_INVALIDDATA; } - break; + if (code == 1) + av_log(avctx, AV_LOG_ERROR, "SkipCell procedure not implemented yet!\n"); - default: - return; + CHECK_CELL + copy_cell(ctx, plane, &curr_cell); + return 0; } - } - - for( ; strip >= strip_tbl; strip--) { - if(strip->split_flag != 0) { - strip->split_flag = 0; - strip->usl7 = (strip-1)->usl7; - - if(strip->split_direction) { - strip->xpos += strip->width; - strip->width = (strip-1)->width - strip->width; - if(region_160_width <= strip->xpos && width < strip->width + strip->xpos) - strip->width = width - strip->xpos; - } else { - strip->ypos += strip->height; - strip->height = (strip-1)->height - strip->height; - } - break; + break; + case INTER_DATA: + if (!curr_cell.tree) { /* MC tree INTER code */ + /* get motion vector index and setup the pointer to the mv set */ + if (!ctx->need_resync) + ctx->next_cell_data = &ctx->gb.buffer[(get_bits_count(&ctx->gb) + 7) >> 3]; + curr_cell.mv_ptr = &ctx->mc_vectors[*(ctx->next_cell_data++) << 1]; + curr_cell.tree = 1; /* enter the VQ tree */ + UPDATE_BITPOS(8); + } else { /* VQ tree DATA code */ + if (!ctx->need_resync) + ctx->next_cell_data = &ctx->gb.buffer[(get_bits_count(&ctx->gb) + 7) >> 3]; + + CHECK_CELL + bytes_used = decode_cell(ctx, avctx, plane, &curr_cell, + ctx->next_cell_data, ctx->last_byte); + if (bytes_used < 0) + return AVERROR_INVALIDDATA; + + UPDATE_BITPOS(bytes_used << 3); + ctx->next_cell_data += bytes_used; + return 0; } + break; } - } + }//while + + return 0; } -static av_cold int indeo3_decode_init(AVCodecContext *avctx) -{ - Indeo3DecodeContext *s = avctx->priv_data; - int ret = 0; - s->avctx = avctx; - s->width = avctx->width; - s->height = avctx->height; - avctx->pix_fmt = PIX_FMT_YUV410P; - avcodec_get_frame_defaults(&s->frame); +static int decode_plane(Indeo3DecodeContext *ctx, AVCodecContext *avctx, + Plane *plane, const uint8_t *data, int32_t data_size, + int32_t strip_width) +{ + Cell curr_cell; + int num_vectors; - if (!(ret = build_modpred(s))) - ret = iv_alloc_frames(s); - if (ret) - iv_free_func(s); + /* each plane data starts with mc_vector_count field, */ + /* an optional array of motion vectors followed by the vq data */ + num_vectors = bytestream_get_le32(&data); + ctx->mc_vectors = num_vectors ? data : 0; + + /* init the bitreader */ + init_get_bits(&ctx->gb, &data[num_vectors * 2], data_size << 3); + ctx->skip_bits = 0; + ctx->need_resync = 0; + + ctx->last_byte = data + data_size - 1; + + /* initialize the 1st cell and set its dimensions to whole plane */ + curr_cell.xpos = curr_cell.ypos = 0; + curr_cell.width = plane->width >> 2; + curr_cell.height = plane->height >> 2; + curr_cell.tree = 0; // we are in the MC tree now + curr_cell.mv_ptr = 0; // no motion vector = INTRA cell - return ret; + return parse_bintree(ctx, avctx, plane, INTRA_NULL, &curr_cell, CELL_STACK_MAX, strip_width); } -static int iv_decode_frame(AVCodecContext *avctx, - const uint8_t *buf, int buf_size) + +#define OS_HDR_ID MKBETAG('F', 'R', 'M', 'H') + +static int decode_frame_headers(Indeo3DecodeContext *ctx, AVCodecContext *avctx, + const uint8_t *buf, int buf_size) { - Indeo3DecodeContext *s = avctx->priv_data; - unsigned int image_width, image_height, - chroma_width, chroma_height; - unsigned int flags, cb_offset, data_size, - y_offset, v_offset, u_offset, mc_vector_count; - const uint8_t *hdr_pos, *buf_pos; - - buf_pos = buf; - buf_pos += 18; /* skip OS header (16 bytes) and version number */ - - flags = bytestream_get_le16(&buf_pos); - data_size = bytestream_get_le32(&buf_pos); - cb_offset = *buf_pos++; - buf_pos += 3; /* skip reserved byte and checksum */ - image_height = bytestream_get_le16(&buf_pos); - image_width = bytestream_get_le16(&buf_pos); - - if(av_image_check_size(image_width, image_height, 0, avctx)) - return -1; - if (image_width != avctx->width || image_height != avctx->height) { - int ret; - avcodec_set_dimensions(avctx, image_width, image_height); - s->width = avctx->width; - s->height = avctx->height; - ret = iv_alloc_frames(s); - if (ret < 0) { - s->width = s->height = 0; - return ret; - } + const uint8_t *buf_ptr = buf, *bs_hdr; + uint32_t frame_num, word2, check_sum, data_size; + uint32_t y_offset, u_offset, v_offset, starts[3], ends[3]; + uint16_t height, width; + int i, j; + + /* parse and check the OS header */ + frame_num = bytestream_get_le32(&buf_ptr); + word2 = bytestream_get_le32(&buf_ptr); + check_sum = bytestream_get_le32(&buf_ptr); + data_size = bytestream_get_le32(&buf_ptr); + + if ((frame_num ^ word2 ^ data_size ^ OS_HDR_ID) != check_sum) { + av_log(avctx, AV_LOG_ERROR, "OS header checksum mismatch!\n"); + return AVERROR_INVALIDDATA; } - chroma_height = ((image_height >> 2) + 3) & 0x7ffc; - chroma_width = ((image_width >> 2) + 3) & 0x7ffc; - y_offset = bytestream_get_le32(&buf_pos); - v_offset = bytestream_get_le32(&buf_pos); - u_offset = bytestream_get_le32(&buf_pos); - buf_pos += 4; /* reserved */ - hdr_pos = buf_pos; - if(data_size == 0x80) return 4; - - if(FFMAX3(y_offset, v_offset, u_offset) >= buf_size-16) { - av_log(s->avctx, AV_LOG_ERROR, "y/u/v offset outside buffer\n"); - return -1; - } - - if(flags & 0x200) { - s->cur_frame = s->iv_frame + 1; - s->ref_frame = s->iv_frame; - } else { - s->cur_frame = s->iv_frame; - s->ref_frame = s->iv_frame + 1; + /* parse the bitstream header */ + bs_hdr = buf_ptr; + + if (bytestream_get_le16(&buf_ptr) != 32) { + av_log(avctx, AV_LOG_ERROR, "Unsupported codec version!\n"); + return AVERROR_INVALIDDATA; + } + + ctx->frame_num = frame_num; + ctx->frame_flags = bytestream_get_le16(&buf_ptr); + ctx->data_size = (bytestream_get_le32(&buf_ptr) + 7) >> 3; + ctx->cb_offset = *buf_ptr++; + + if (ctx->data_size == 16) + return 4; + if (ctx->data_size > buf_size) + ctx->data_size = buf_size; + + buf_ptr += 3; // skip reserved byte and checksum + + /* check frame dimensions */ + height = bytestream_get_le16(&buf_ptr); + width = bytestream_get_le16(&buf_ptr); + if (av_image_check_size(width, height, 0, avctx)) + return AVERROR_INVALIDDATA; + + if (width != ctx->width || height != ctx->height) { + av_dlog(avctx, "Frame dimensions changed!\n"); + + ctx->width = width; + ctx->height = height; + + free_frame_buffers(ctx); + allocate_frame_buffers(ctx, avctx); + avcodec_set_dimensions(avctx, width, height); + } + + y_offset = bytestream_get_le32(&buf_ptr); + v_offset = bytestream_get_le32(&buf_ptr); + u_offset = bytestream_get_le32(&buf_ptr); + + /* unfortunately there is no common order of planes in the buffer */ + /* so we use that sorting algo for determining planes data sizes */ + starts[0] = y_offset; + starts[1] = v_offset; + starts[2] = u_offset; + + for (j = 0; j < 3; j++) { + ends[j] = ctx->data_size; + for (i = 2; i >= 0; i--) + if (starts[i] < ends[j] && starts[i] > starts[j]) + ends[j] = starts[i]; } - buf_pos = buf + 16 + y_offset; - mc_vector_count = bytestream_get_le32(&buf_pos); - if(2LL*mc_vector_count >= buf_size-16-y_offset) { - av_log(s->avctx, AV_LOG_ERROR, "mc_vector_count too large\n"); - return -1; + ctx->y_data_size = ends[0] - starts[0]; + ctx->v_data_size = ends[1] - starts[1]; + ctx->u_data_size = ends[2] - starts[2]; + if (FFMAX3(y_offset, v_offset, u_offset) >= ctx->data_size - 16 || + FFMIN3(ctx->y_data_size, ctx->v_data_size, ctx->u_data_size) <= 0) { + av_log(avctx, AV_LOG_ERROR, "One of the y/u/v offsets is invalid\n"); + return AVERROR_INVALIDDATA; } - iv_Decode_Chunk(s, s->cur_frame->Ybuf, s->ref_frame->Ybuf, image_width, - image_height, buf_pos + mc_vector_count * 2, cb_offset, hdr_pos, buf_pos, - FFMIN(image_width, 160)); + ctx->y_data_ptr = bs_hdr + y_offset; + ctx->v_data_ptr = bs_hdr + v_offset; + ctx->u_data_ptr = bs_hdr + u_offset; + ctx->alt_quant = buf_ptr + sizeof(uint32_t); + + if (ctx->data_size == 16) { + av_log(avctx, AV_LOG_DEBUG, "Sync frame encountered!\n"); + return 16; + } - if (!(s->avctx->flags & CODEC_FLAG_GRAY)) - { + if (ctx->frame_flags & BS_8BIT_PEL) { + av_log_ask_for_sample(avctx, "8-bit pixel format\n"); + return AVERROR_PATCHWELCOME; + } + + if (ctx->frame_flags & BS_MV_X_HALF || ctx->frame_flags & BS_MV_Y_HALF) { + av_log_ask_for_sample(avctx, "halfpel motion vectors\n"); + return AVERROR_PATCHWELCOME; + } + + return 0; +} - buf_pos = buf + 16 + v_offset; - mc_vector_count = bytestream_get_le32(&buf_pos); - if(2LL*mc_vector_count >= buf_size-16-v_offset) { - av_log(s->avctx, AV_LOG_ERROR, "mc_vector_count too large\n"); - return -1; - } - iv_Decode_Chunk(s, s->cur_frame->Vbuf, s->ref_frame->Vbuf, chroma_width, - chroma_height, buf_pos + mc_vector_count * 2, cb_offset, hdr_pos, buf_pos, - FFMIN(chroma_width, 40)); - - buf_pos = buf + 16 + u_offset; - mc_vector_count = bytestream_get_le32(&buf_pos); - if(2LL*mc_vector_count >= buf_size-16-u_offset) { - av_log(s->avctx, AV_LOG_ERROR, "mc_vector_count too large\n"); - return -1; +/** + * Convert and output the current plane. + * All pixel values will be upsampled by shifting right by one bit. + * + * @param[in] plane pointer to the descriptor of the plane being processed + * @param[in] buf_sel indicates which frame buffer the input data stored in + * @param[out] dst pointer to the buffer receiving converted pixels + * @param[in] dst_pitch pitch for moving to the next y line + */ +static void output_plane(const Plane *plane, int buf_sel, uint8_t *dst, int dst_pitch) +{ + int x,y; + const uint8_t *src = plane->pixels[buf_sel]; + uint32_t pitch = plane->pitch; + + for (y = 0; y < plane->height; y++) { + /* convert four pixels at once using SWAR */ + for (x = 0; x < plane->width >> 2; x++) { + AV_WN32A(dst, (AV_RN32A(src) & 0x7F7F7F7F) << 1); + src += 4; + dst += 4; } - iv_Decode_Chunk(s, s->cur_frame->Ubuf, s->ref_frame->Ubuf, chroma_width, - chroma_height, buf_pos + mc_vector_count * 2, cb_offset, hdr_pos, buf_pos, - FFMIN(chroma_width, 40)); + for (x <<= 2; x < plane->width; x++) + *dst++ = *src++ << 1; + src += pitch - plane->width; + dst += dst_pitch - plane->width; } +} + + +static av_cold int decode_init(AVCodecContext *avctx) +{ + Indeo3DecodeContext *ctx = avctx->priv_data; + + ctx->avctx = avctx; + ctx->width = avctx->width; + ctx->height = avctx->height; + avctx->pix_fmt = PIX_FMT_YUV410P; + avcodec_get_frame_defaults(&ctx->frame); + + build_requant_tab(); - return 8; + dsputil_init(&ctx->dsp, avctx); + + allocate_frame_buffers(ctx, avctx); + + return 0; } -static int indeo3_decode_frame(AVCodecContext *avctx, - void *data, int *data_size, - AVPacket *avpkt) + +static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, + AVPacket *avpkt) { + Indeo3DecodeContext *ctx = avctx->priv_data; const uint8_t *buf = avpkt->data; - int buf_size = avpkt->size; - Indeo3DecodeContext *s=avctx->priv_data; - uint8_t *src, *dest; - int y; - - if (iv_decode_frame(avctx, buf, buf_size) < 0) - return -1; - - if(s->frame.data[0]) - avctx->release_buffer(avctx, &s->frame); - - s->frame.reference = 0; - if(avctx->get_buffer(avctx, &s->frame) < 0) { - av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n"); - return -1; - } - - src = s->cur_frame->Ybuf; - dest = s->frame.data[0]; - for (y = 0; y < s->height; y++) { - memcpy(dest, src, s->cur_frame->y_w); - src += s->cur_frame->y_w; - dest += s->frame.linesize[0]; - } - - if (!(s->avctx->flags & CODEC_FLAG_GRAY)) - { - src = s->cur_frame->Ubuf; - dest = s->frame.data[1]; - for (y = 0; y < s->height / 4; y++) { - memcpy(dest, src, s->cur_frame->uv_w); - src += s->cur_frame->uv_w; - dest += s->frame.linesize[1]; - } + int buf_size = avpkt->size; + int res; - src = s->cur_frame->Vbuf; - dest = s->frame.data[2]; - for (y = 0; y < s->height / 4; y++) { - memcpy(dest, src, s->cur_frame->uv_w); - src += s->cur_frame->uv_w; - dest += s->frame.linesize[2]; - } + res = decode_frame_headers(ctx, avctx, buf, buf_size); + if (res < 0) + return res; + + /* skip sync(null) frames */ + if (res) { + // we have processed 16 bytes but no data was decoded + *data_size = 0; + return buf_size; + } + + /* skip droppable INTER frames if requested */ + if (ctx->frame_flags & BS_NONREF && + (avctx->skip_frame >= AVDISCARD_NONREF)) + return 0; + + /* skip INTER frames if requested */ + if (!(ctx->frame_flags & BS_KEYFRAME) && avctx->skip_frame >= AVDISCARD_NONKEY) + return 0; + + /* use BS_BUFFER flag for buffer switching */ + ctx->buf_sel = (ctx->frame_flags >> BS_BUFFER) & 1; + + /* decode luma plane */ + if ((res = decode_plane(ctx, avctx, ctx->planes, ctx->y_data_ptr, ctx->y_data_size, 40))) + return res; + + /* decode chroma planes */ + if ((res = decode_plane(ctx, avctx, &ctx->planes[1], ctx->u_data_ptr, ctx->u_data_size, 10))) + return res; + + if ((res = decode_plane(ctx, avctx, &ctx->planes[2], ctx->v_data_ptr, ctx->v_data_size, 10))) + return res; + + if (ctx->frame.data[0]) + avctx->release_buffer(avctx, &ctx->frame); + + ctx->frame.reference = 0; + if ((res = avctx->get_buffer(avctx, &ctx->frame)) < 0) { + av_log(ctx->avctx, AV_LOG_ERROR, "get_buffer() failed\n"); + return res; } - *data_size=sizeof(AVFrame); - *(AVFrame*)data= s->frame; + output_plane(&ctx->planes[0], ctx->buf_sel, ctx->frame.data[0], ctx->frame.linesize[0]); + output_plane(&ctx->planes[1], ctx->buf_sel, ctx->frame.data[1], ctx->frame.linesize[1]); + output_plane(&ctx->planes[2], ctx->buf_sel, ctx->frame.data[2], ctx->frame.linesize[2]); + + *data_size = sizeof(AVFrame); + *(AVFrame*)data = ctx->frame; return buf_size; } -static av_cold int indeo3_decode_end(AVCodecContext *avctx) + +static av_cold int decode_close(AVCodecContext *avctx) { - Indeo3DecodeContext *s = avctx->priv_data; + Indeo3DecodeContext *ctx = avctx->priv_data; - iv_free_func(s); + free_frame_buffers(avctx->priv_data); - if (s->frame.data[0]) - avctx->release_buffer(avctx, &s->frame); + if (ctx->frame.data[0]) + avctx->release_buffer(avctx, &ctx->frame); return 0; } @@ -1151,9 +1060,8 @@ .type = AVMEDIA_TYPE_VIDEO, .id = CODEC_ID_INDEO3, .priv_data_size = sizeof(Indeo3DecodeContext), - .init = indeo3_decode_init, - .close = indeo3_decode_end, - .decode = indeo3_decode_frame, - .capabilities = CODEC_CAP_DR1, - .long_name = NULL_IF_CONFIG_SMALL("Intel Indeo 3"), + .init = decode_init, + .close = decode_close, + .decode = decode_frame, + .long_name = NULL_IF_CONFIG_SMALL("Intel Indeo 3"), }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/indeo3data.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/indeo3data.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/indeo3data.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/indeo3data.h 2011-11-04 12:38:26.000000000 +0000 @@ -1,6 +1,6 @@ /* - * Intel Indeo 3 (IV31, IV32, etc.) video decoder for ffmpeg - * written, produced, and directed by Alan Smithee + * Indeo Video v3 compatible decoder + * Copyright (c) 2009 - 2011 Maxim Poliakovski * * This file is part of FFmpeg. * @@ -24,2319 +24,337 @@ #include -static const uint32_t correction[] = { - 0x00000000, 0x00000202, 0xfffffdfe, 0x000002ff, 0xfffffd01, 0xffffff03, 0x000000fd, 0x00000404, - 0xfffffbfc, 0x00000501, 0xfffffaff, 0x00000105, 0xfffffefb, 0x000003fc, 0xfffffc04, 0x000005fe, - 0xfffffa02, 0xfffffe06, 0x000001fa, 0x00000904, 0xfffff6fc, 0x00000409, 0xfffffbf7, 0x00000909, - 0xfffff6f7, 0x00000a01, 0xfffff5ff, 0x0000010a, 0xfffffef6, 0x000007fb, 0xfffff805, 0xfffffb08, - 0x000004f8, 0x00000f09, 0xfffff0f7, 0x0000090f, 0xfffff6f1, 0x00000bfd, 0xfffff403, 0xfffffd0c, - 0x000002f4, 0x00001004, 0xffffeffc, 0x00000410, 0xfffffbf0, 0x00001010, 0xffffeff0, 0x00001200, - 0xffffee00, 0x00000012, 0xffffffee, 0x00000bf4, 0xfffff40c, 0x00000ff7, 0xfffff009, 0xfffff710, - 0x000008f0, 0x00001b0b, 0xffffe4f5, 0x00000b1b, 0xfffff4e5, 0x00001c13, 0xffffe3ed, 0x0000131c, - 0xffffece4, 0x000015fa, 0xffffea06, 0xfffffa16, 0x000005ea, 0x00001d04, 0xffffe2fc, 0x0000041d, - 0xfffffbe3, 0x00001e1e, 0xffffe1e2, 0x000020fe, 0xffffdf02, 0xfffffe21, 0x000001df, 0x000016ee, - 0xffffe912, 0xffffee17, 0x000011e9, 0x00001df1, 0xffffe20f, 0xfffff11e, 0x00000ee2, 0x00002e16, - 0xffffd1ea, 0x0000162e, 0xffffe9d2, 0x00002f0d, 0xffffd0f3, 0x00000d2f, 0xfffff2d1, 0x00003123, - 0xffffcedd, 0x00002331, 0xffffdccf, 0x000028f5, 0xffffd70b, 0xfffff529, 0x00000ad7, 0x00003304, - 0xffffccfc, 0x00000433, 0xfffffbcd, 0x00003636, 0xffffc9ca, 0x000021de, 0xffffde22, 0x000029e3, - 0xffffd61d, 0xffffe32a, 0x00001cd6, 0x00003bfa, 0xffffc406, 0xfffffa3c, 0x000005c4, 0x00004c1b, - 0xffffb3e5, 0x00001b4c, 0xffffe4b4, 0x00004d2b, 0xffffb2d5, 0x00002b4d, 0xffffd4b3, 0x000036e8, - 0xffffc918, 0xffffe837, 0x000017c9, 0x00004f0e, 0xffffb0f2, 0x00000e4f, 0xfffff1b1, 0x0000533f, - 0xffffacc1, 0x00003f53, 0xffffc0ad, 0x000049ec, 0xffffb614, 0xffffec4a, 0x000013b6, 0x00005802, - 0xffffa7fe, 0x00000258, 0xfffffda8, 0x00005d5d, 0xffffa2a3, 0x00003ccc, 0xffffc334, 0xffffcc3d, - 0x000033c3, 0x00007834, 0xffff87cc, 0x00003478, 0xffffcb88, 0x00004ad3, 0xffffb52d, 0xffffd34b, - 0x00002cb5, 0x00007d4b, 0xffff82b5, 0x00004b7d, 0xffffb483, 0x00007a21, 0xffff85df, 0x0000217a, - 0xffffde86, 0x000066f3, 0xffff990d, 0xfffff367, 0x00000c99, 0x00005fd8, 0xffffa028, 0xffffd860, - 0x000027a0, 0x00007ede, 0xffff8122, 0xffffde7f, 0x00002181, 0x000058a7, 0xffffa759, 0x000068b2, - 0xffff974e, 0xffffb269, 0x00004d97, 0x00000c0c, 0xfffff3f4, 0x00001717, 0xffffe8e9, 0x00002a2a, - 0xffffd5d6, 0x00004949, 0xffffb6b7, 0x00000000, 0x02020000, 0xfdfe0000, 0x02ff0000, 0xfd010000, - 0xff030000, 0x00fd0000, 0x00000202, 0x02020202, 0xfdfe0202, 0x02ff0202, 0xfd010202, 0xff030202, - 0x00fd0202, 0xfffffdfe, 0x0201fdfe, 0xfdfdfdfe, 0x02fefdfe, 0xfd00fdfe, 0xff02fdfe, 0x00fcfdfe, - 0x000002ff, 0x020202ff, 0xfdfe02ff, 0x02ff02ff, 0xfd0102ff, 0xff0302ff, 0x00fd02ff, 0xfffffd01, - 0x0201fd01, 0xfdfdfd01, 0x02fefd01, 0xfd00fd01, 0xff02fd01, 0x00fcfd01, 0xffffff03, 0x0201ff03, - 0xfdfdff03, 0x02feff03, 0xfd00ff03, 0xff02ff03, 0x00fcff03, 0x000000fd, 0x020200fd, 0xfdfe00fd, - 0x02ff00fd, 0xfd0100fd, 0xff0300fd, 0x00fd00fd, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000303, 0xfffffcfd, 0x000003ff, 0xfffffc01, 0xffffff04, 0x000000fc, 0x00000707, - 0xfffff8f9, 0x00000802, 0xfffff7fe, 0x00000208, 0xfffffdf8, 0x000008fe, 0xfffff702, 0xfffffe09, - 0x000001f7, 0x000005fa, 0xfffffa06, 0x00000d06, 0xfffff2fa, 0x0000060d, 0xfffff9f3, 0x00000d0d, - 0xfffff2f3, 0x00000e01, 0xfffff1ff, 0x0000010e, 0xfffffef2, 0x00000bf8, 0xfffff408, 0xfffff80c, - 0x000007f4, 0x0000170e, 0xffffe8f2, 0x00000e17, 0xfffff1e9, 0x000011fb, 0xffffee05, 0xfffffb12, - 0x000004ee, 0x00001806, 0xffffe7fa, 0x00000618, 0xfffff9e8, 0x00001818, 0xffffe7e8, 0x00001aff, - 0xffffe501, 0xffffff1b, 0x000000e5, 0x000010ef, 0xffffef11, 0x000016f3, 0xffffe90d, 0xfffff317, - 0x00000ce9, 0x00002810, 0xffffd7f0, 0x00001028, 0xffffefd8, 0x0000291c, 0xffffd6e4, 0x00001c29, - 0xffffe3d7, 0x000020f7, 0xffffdf09, 0xfffff721, 0x000008df, 0x00002b06, 0xffffd4fa, 0x0000062b, - 0xfffff9d5, 0x00002e2e, 0xffffd1d2, 0x000031fc, 0xffffce04, 0xfffffc32, 0x000003ce, 0x000021e5, - 0xffffde1b, 0xffffe522, 0x00001ade, 0x00002cea, 0xffffd316, 0xffffea2d, 0x000015d3, 0x00004522, - 0xffffbade, 0x00002245, 0xffffddbb, 0x00004613, 0xffffb9ed, 0x00001346, 0xffffecba, 0x00004935, - 0xffffb6cb, 0x00003549, 0xffffcab7, 0x00003def, 0xffffc211, 0xffffef3e, 0x000010c2, 0x00004d05, - 0xffffb2fb, 0x0000054d, 0xfffffab3, 0x00005252, 0xffffadae, 0x000032cd, 0xffffcd33, 0x00003fd5, - 0xffffc02b, 0xffffd540, 0x00002ac0, 0x000059f6, 0xffffa60a, 0xfffff65a, 0x000009a6, 0x00007229, - 0xffff8dd7, 0x00002972, 0xffffd68e, 0x00007440, 0xffff8bc0, 0x00004074, 0xffffbf8c, 0x000051db, - 0xffffae25, 0xffffdb52, 0x000024ae, 0x00007716, 0xffff88ea, 0x00001677, 0xffffe989, 0x00007c5f, - 0xffff83a1, 0x00005f7c, 0xffffa084, 0x00006ee2, 0xffff911e, 0xffffe26f, 0x00001d91, 0x00005bb2, - 0xffffa44e, 0xffffb25c, 0x00004da4, 0x000070bc, 0xffff8f44, 0xffffbc71, 0x0000438f, 0x00001212, - 0xffffedee, 0x00002222, 0xffffddde, 0x00003f3f, 0xffffc0c1, 0x00006d6d, 0xffff9293, 0x00000000, - 0x03030000, 0xfcfd0000, 0x03ff0000, 0xfc010000, 0xff040000, 0x00fc0000, 0x07070000, 0xf8f90000, - 0x00000303, 0x03030303, 0xfcfd0303, 0x03ff0303, 0xfc010303, 0xff040303, 0x00fc0303, 0x07070303, - 0xf8f90303, 0xfffffcfd, 0x0302fcfd, 0xfcfcfcfd, 0x03fefcfd, 0xfc00fcfd, 0xff03fcfd, 0x00fbfcfd, - 0x0706fcfd, 0xf8f8fcfd, 0x000003ff, 0x030303ff, 0xfcfd03ff, 0x03ff03ff, 0xfc0103ff, 0xff0403ff, - 0x00fc03ff, 0x070703ff, 0xf8f903ff, 0xfffffc01, 0x0302fc01, 0xfcfcfc01, 0x03fefc01, 0xfc00fc01, - 0xff03fc01, 0x00fbfc01, 0x0706fc01, 0xf8f8fc01, 0xffffff04, 0x0302ff04, 0xfcfcff04, 0x03feff04, - 0xfc00ff04, 0xff03ff04, 0x00fbff04, 0x0706ff04, 0xf8f8ff04, 0x000000fc, 0x030300fc, 0xfcfd00fc, - 0x03ff00fc, 0xfc0100fc, 0xff0400fc, 0x00fc00fc, 0x070700fc, 0xf8f900fc, 0x00000707, 0x03030707, - 0xfcfd0707, 0x03ff0707, 0xfc010707, 0xff040707, 0x00fc0707, 0x07070707, 0xf8f90707, 0xfffff8f9, - 0x0302f8f9, 0xfcfcf8f9, 0x03fef8f9, 0xfc00f8f9, 0xff03f8f9, 0x00fbf8f9, 0x0706f8f9, 0xf8f8f8f9, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000404, 0xfffffbfc, 0x000004ff, 0xfffffb01, 0xffffff05, 0x000000fb, 0x00000a03, - 0xfffff5fd, 0x0000030a, 0xfffffcf6, 0x00000909, 0xfffff6f7, 0x000006f9, 0xfffff907, 0x00000bfd, - 0xfffff403, 0xfffffd0c, 0x000002f4, 0x00001108, 0xffffeef8, 0x00000811, 0xfffff7ef, 0x00001111, - 0xffffeeef, 0x00001301, 0xffffecff, 0x00000113, 0xfffffeed, 0x00000ff5, 0xfffff00b, 0xfffff510, - 0x00000af0, 0x000016fa, 0xffffe906, 0xfffffa17, 0x000005e9, 0x00001f12, 0xffffe0ee, 0x0000121f, - 0xffffede1, 0x00002008, 0xffffdff8, 0x00000820, 0xfffff7e0, 0x00002121, 0xffffdedf, 0x000023ff, - 0xffffdc01, 0xffffff24, 0x000000dc, 0x000016e9, 0xffffe917, 0x00001eef, 0xffffe111, 0xffffef1f, - 0x000010e1, 0x00003615, 0xffffc9eb, 0x00001536, 0xffffeaca, 0x00003725, 0xffffc8db, 0x00002537, - 0xffffdac9, 0x00002bf4, 0xffffd40c, 0xfffff42c, 0x00000bd4, 0x00003908, 0xffffc6f8, 0x00000839, - 0xfffff7c7, 0x00003d3d, 0xffffc2c3, 0x000041fb, 0xffffbe05, 0xfffffb42, 0x000004be, 0x00002cdc, - 0xffffd324, 0xffffdc2d, 0x000023d3, 0x00003be3, 0xffffc41d, 0xffffe33c, 0x00001cc4, 0x00005c2d, - 0xffffa3d3, 0x00002d5c, 0xffffd2a4, 0x00005d19, 0xffffa2e7, 0x0000195d, 0xffffe6a3, 0x00006147, - 0xffff9eb9, 0x00004761, 0xffffb89f, 0x000052ea, 0xffffad16, 0xffffea53, 0x000015ad, 0x00006607, - 0xffff99f9, 0x00000766, 0xfffff89a, 0x00006d6d, 0xffff9293, 0x000043bc, 0xffffbc44, 0x000054c7, - 0xffffab39, 0xffffc755, 0x000038ab, 0x000077f3, 0xffff880d, 0xfffff378, 0x00000c88, 0x00006dcf, - 0xffff9231, 0xffffcf6e, 0x00003092, 0x00007a98, 0xffff8568, 0xffff987b, 0x00006785, 0x00001818, - 0xffffe7e8, 0x00002e2e, 0xffffd1d2, 0x00005454, 0xffffabac, 0x00000000, 0x04040000, 0xfbfc0000, - 0x04ff0000, 0xfb010000, 0xff050000, 0x00fb0000, 0x0a030000, 0xf5fd0000, 0x030a0000, 0x00000404, - 0x04040404, 0xfbfc0404, 0x04ff0404, 0xfb010404, 0xff050404, 0x00fb0404, 0x0a030404, 0xf5fd0404, - 0x030a0404, 0xfffffbfc, 0x0403fbfc, 0xfbfbfbfc, 0x04fefbfc, 0xfb00fbfc, 0xff04fbfc, 0x00fafbfc, - 0x0a02fbfc, 0xf5fcfbfc, 0x0309fbfc, 0x000004ff, 0x040404ff, 0xfbfc04ff, 0x04ff04ff, 0xfb0104ff, - 0xff0504ff, 0x00fb04ff, 0x0a0304ff, 0xf5fd04ff, 0x030a04ff, 0xfffffb01, 0x0403fb01, 0xfbfbfb01, - 0x04fefb01, 0xfb00fb01, 0xff04fb01, 0x00fafb01, 0x0a02fb01, 0xf5fcfb01, 0x0309fb01, 0xffffff05, - 0x0403ff05, 0xfbfbff05, 0x04feff05, 0xfb00ff05, 0xff04ff05, 0x00faff05, 0x0a02ff05, 0xf5fcff05, - 0x0309ff05, 0x000000fb, 0x040400fb, 0xfbfc00fb, 0x04ff00fb, 0xfb0100fb, 0xff0500fb, 0x00fb00fb, - 0x0a0300fb, 0xf5fd00fb, 0x030a00fb, 0x00000a03, 0x04040a03, 0xfbfc0a03, 0x04ff0a03, 0xfb010a03, - 0xff050a03, 0x00fb0a03, 0x0a030a03, 0xf5fd0a03, 0x030a0a03, 0xfffff5fd, 0x0403f5fd, 0xfbfbf5fd, - 0x04fef5fd, 0xfb00f5fd, 0xff04f5fd, 0x00faf5fd, 0x0a02f5fd, 0xf5fcf5fd, 0x0309f5fd, 0x0000030a, - 0x0404030a, 0xfbfc030a, 0x04ff030a, 0xfb01030a, 0xff05030a, 0x00fb030a, 0x0a03030a, 0xf5fd030a, - 0x030a030a, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000505, 0xfffffafb, 0x000006fe, 0xfffff902, 0xfffffe07, 0x000001f9, 0x00000b0b, - 0xfffff4f5, 0x00000d03, 0xfffff2fd, 0x0000030d, 0xfffffcf3, 0x000008f7, 0xfffff709, 0x00000efc, - 0xfffff104, 0xfffffc0f, 0x000003f1, 0x0000160b, 0xffffe9f5, 0x00000b16, 0xfffff4ea, 0x00001515, - 0xffffeaeb, 0x00001802, 0xffffe7fe, 0x00000218, 0xfffffde8, 0x000013f2, 0xffffec0e, 0xfffff214, - 0x00000dec, 0x00002617, 0xffffd9e9, 0x00001726, 0xffffe8da, 0x00001cf8, 0xffffe308, 0xfffff81d, - 0x000007e3, 0x0000270b, 0xffffd8f5, 0x00000b27, 0xfffff4d9, 0x00002929, 0xffffd6d7, 0x00002cff, - 0xffffd301, 0xffffff2d, 0x000000d3, 0x00001ce3, 0xffffe31d, 0x000026ea, 0xffffd916, 0xffffea27, - 0x000015d9, 0x0000431b, 0xffffbce5, 0x00001b43, 0xffffe4bd, 0x0000452f, 0xffffbad1, 0x00002f45, - 0xffffd0bb, 0x000037f1, 0xffffc80f, 0xfffff138, 0x00000ec8, 0x0000470b, 0xffffb8f5, 0x00000b47, - 0xfffff4b9, 0x00004c4c, 0xffffb3b4, 0x000052fa, 0xffffad06, 0xfffffa53, 0x000005ad, 0x000038d3, - 0xffffc72d, 0xffffd339, 0x00002cc7, 0x00004adc, 0xffffb524, 0xffffdc4b, 0x000023b5, 0x00007338, - 0xffff8cc8, 0x00003873, 0xffffc78d, 0x0000751f, 0xffff8ae1, 0x00001f75, 0xffffe08b, 0x00007a58, - 0xffff85a8, 0x0000587a, 0xffffa786, 0x000067e4, 0xffff981c, 0xffffe468, 0x00001b98, 0x000054ab, - 0xffffab55, 0x000069b8, 0xffff9648, 0xffffb86a, 0x00004796, 0x00001e1e, 0xffffe1e2, 0x00003a3a, - 0xffffc5c6, 0x00006969, 0xffff9697, 0x00000000, 0x05050000, 0xfafb0000, 0x06fe0000, 0xf9020000, - 0xfe070000, 0x01f90000, 0x0b0b0000, 0xf4f50000, 0x0d030000, 0xf2fd0000, 0x00000505, 0x05050505, - 0xfafb0505, 0x06fe0505, 0xf9020505, 0xfe070505, 0x01f90505, 0x0b0b0505, 0xf4f50505, 0x0d030505, - 0xf2fd0505, 0xfffffafb, 0x0504fafb, 0xfafafafb, 0x06fdfafb, 0xf901fafb, 0xfe06fafb, 0x01f8fafb, - 0x0b0afafb, 0xf4f4fafb, 0x0d02fafb, 0xf2fcfafb, 0x000006fe, 0x050506fe, 0xfafb06fe, 0x06fe06fe, - 0xf90206fe, 0xfe0706fe, 0x01f906fe, 0x0b0b06fe, 0xf4f506fe, 0x0d0306fe, 0xf2fd06fe, 0xfffff902, - 0x0504f902, 0xfafaf902, 0x06fdf902, 0xf901f902, 0xfe06f902, 0x01f8f902, 0x0b0af902, 0xf4f4f902, - 0x0d02f902, 0xf2fcf902, 0xfffffe07, 0x0504fe07, 0xfafafe07, 0x06fdfe07, 0xf901fe07, 0xfe06fe07, - 0x01f8fe07, 0x0b0afe07, 0xf4f4fe07, 0x0d02fe07, 0xf2fcfe07, 0x000001f9, 0x050501f9, 0xfafb01f9, - 0x06fe01f9, 0xf90201f9, 0xfe0701f9, 0x01f901f9, 0x0b0b01f9, 0xf4f501f9, 0x0d0301f9, 0xf2fd01f9, - 0x00000b0b, 0x05050b0b, 0xfafb0b0b, 0x06fe0b0b, 0xf9020b0b, 0xfe070b0b, 0x01f90b0b, 0x0b0b0b0b, - 0xf4f50b0b, 0x0d030b0b, 0xf2fd0b0b, 0xfffff4f5, 0x0504f4f5, 0xfafaf4f5, 0x06fdf4f5, 0xf901f4f5, - 0xfe06f4f5, 0x01f8f4f5, 0x0b0af4f5, 0xf4f4f4f5, 0x0d02f4f5, 0xf2fcf4f5, 0x00000d03, 0x05050d03, - 0xfafb0d03, 0x06fe0d03, 0xf9020d03, 0xfe070d03, 0x01f90d03, 0x0b0b0d03, 0xf4f50d03, 0x0d030d03, - 0xf2fd0d03, 0xfffff2fd, 0x0504f2fd, 0xfafaf2fd, 0x06fdf2fd, 0xf901f2fd, 0xfe06f2fd, 0x01f8f2fd, - 0x0b0af2fd, 0xf4f4f2fd, 0x0d02f2fd, 0xf2fcf2fd, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000606, 0xfffff9fa, 0x000007fe, 0xfffff802, 0xfffffe08, 0x000001f8, 0x00000d0d, - 0xfffff2f3, 0x00000f04, 0xfffff0fc, 0x0000040f, 0xfffffbf1, 0x00000af5, 0xfffff50b, 0x000011fb, - 0xffffee05, 0xfffffb12, 0x000004ee, 0x00001a0d, 0xffffe5f3, 0x00000d1a, 0xfffff2e6, 0x00001a1a, - 0xffffe5e6, 0x00001d02, 0xffffe2fe, 0x0000021d, 0xfffffde3, 0x000017f0, 0xffffe810, 0xfffff018, - 0x00000fe8, 0x00002e1c, 0xffffd1e4, 0x00001c2e, 0xffffe3d2, 0x000022f7, 0xffffdd09, 0xfffff723, - 0x000008dd, 0x00002f0d, 0xffffd0f3, 0x00000d2f, 0xfffff2d1, 0x00003131, 0xffffcecf, 0x000035ff, - 0xffffca01, 0xffffff36, 0x000000ca, 0x000022dd, 0xffffdd23, 0x00002ee6, 0xffffd11a, 0xffffe62f, - 0x000019d1, 0x00005120, 0xffffaee0, 0x00002051, 0xffffdfaf, 0x00005338, 0xffffacc8, 0x00003853, - 0xffffc7ad, 0x000042ee, 0xffffbd12, 0xffffee43, 0x000011bd, 0x0000560d, 0xffffa9f3, 0x00000d56, - 0xfffff2aa, 0x00005b5b, 0xffffa4a5, 0x000062f9, 0xffff9d07, 0xfffff963, 0x0000069d, 0x000043ca, - 0xffffbc36, 0xffffca44, 0x000035bc, 0x000059d4, 0xffffa62c, 0xffffd45a, 0x00002ba6, 0x00007bdf, - 0xffff8421, 0xffffdf7c, 0x00002084, 0x00006699, 0xffff9967, 0x00007eaa, 0xffff8156, 0xffffaa7f, - 0x00005581, 0x00002525, 0xffffdadb, 0x00004545, 0xffffbabb, 0x00000000, 0x06060000, 0xf9fa0000, - 0x07fe0000, 0xf8020000, 0xfe080000, 0x01f80000, 0x0d0d0000, 0xf2f30000, 0x0f040000, 0xf0fc0000, - 0x040f0000, 0x00000606, 0x06060606, 0xf9fa0606, 0x07fe0606, 0xf8020606, 0xfe080606, 0x01f80606, - 0x0d0d0606, 0xf2f30606, 0x0f040606, 0xf0fc0606, 0x040f0606, 0xfffff9fa, 0x0605f9fa, 0xf9f9f9fa, - 0x07fdf9fa, 0xf801f9fa, 0xfe07f9fa, 0x01f7f9fa, 0x0d0cf9fa, 0xf2f2f9fa, 0x0f03f9fa, 0xf0fbf9fa, - 0x040ef9fa, 0x000007fe, 0x060607fe, 0xf9fa07fe, 0x07fe07fe, 0xf80207fe, 0xfe0807fe, 0x01f807fe, - 0x0d0d07fe, 0xf2f307fe, 0x0f0407fe, 0xf0fc07fe, 0x040f07fe, 0xfffff802, 0x0605f802, 0xf9f9f802, - 0x07fdf802, 0xf801f802, 0xfe07f802, 0x01f7f802, 0x0d0cf802, 0xf2f2f802, 0x0f03f802, 0xf0fbf802, - 0x040ef802, 0xfffffe08, 0x0605fe08, 0xf9f9fe08, 0x07fdfe08, 0xf801fe08, 0xfe07fe08, 0x01f7fe08, - 0x0d0cfe08, 0xf2f2fe08, 0x0f03fe08, 0xf0fbfe08, 0x040efe08, 0x000001f8, 0x060601f8, 0xf9fa01f8, - 0x07fe01f8, 0xf80201f8, 0xfe0801f8, 0x01f801f8, 0x0d0d01f8, 0xf2f301f8, 0x0f0401f8, 0xf0fc01f8, - 0x040f01f8, 0x00000d0d, 0x06060d0d, 0xf9fa0d0d, 0x07fe0d0d, 0xf8020d0d, 0xfe080d0d, 0x01f80d0d, - 0x0d0d0d0d, 0xf2f30d0d, 0x0f040d0d, 0xf0fc0d0d, 0x040f0d0d, 0xfffff2f3, 0x0605f2f3, 0xf9f9f2f3, - 0x07fdf2f3, 0xf801f2f3, 0xfe07f2f3, 0x01f7f2f3, 0x0d0cf2f3, 0xf2f2f2f3, 0x0f03f2f3, 0xf0fbf2f3, - 0x040ef2f3, 0x00000f04, 0x06060f04, 0xf9fa0f04, 0x07fe0f04, 0xf8020f04, 0xfe080f04, 0x01f80f04, - 0x0d0d0f04, 0xf2f30f04, 0x0f040f04, 0xf0fc0f04, 0x040f0f04, 0xfffff0fc, 0x0605f0fc, 0xf9f9f0fc, - 0x07fdf0fc, 0xf801f0fc, 0xfe07f0fc, 0x01f7f0fc, 0x0d0cf0fc, 0xf2f2f0fc, 0x0f03f0fc, 0xf0fbf0fc, - 0x040ef0fc, 0x0000040f, 0x0606040f, 0xf9fa040f, 0x07fe040f, 0xf802040f, 0xfe08040f, 0x01f8040f, - 0x0d0d040f, 0xf2f3040f, 0x0f04040f, 0xf0fc040f, 0x040f040f, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000707, 0xfffff8f9, 0x000009fd, 0xfffff603, 0xfffffd0a, 0x000002f6, 0x00001010, - 0xffffeff0, 0x00001205, 0xffffedfb, 0x00000512, 0xfffffaee, 0x00000cf3, 0xfffff30d, 0x000014fa, - 0xffffeb06, 0xfffffa15, 0x000005eb, 0x00001e0f, 0xffffe1f1, 0x00000f1e, 0xfffff0e2, 0x00001e1e, - 0xffffe1e2, 0x00002202, 0xffffddfe, 0x00000222, 0xfffffdde, 0x00001bed, 0xffffe413, 0xffffed1c, - 0x000012e4, 0x00003620, 0xffffc9e0, 0x00002036, 0xffffdfca, 0x000028f5, 0xffffd70b, 0xfffff529, - 0x00000ad7, 0x0000370f, 0xffffc8f1, 0x00000f37, 0xfffff0c9, 0x00003939, 0xffffc6c7, 0x00003eff, - 0xffffc101, 0xffffff3f, 0x000000c1, 0x000027d8, 0xffffd828, 0x000036e2, 0xffffc91e, 0xffffe237, - 0x00001dc9, 0x00005e25, 0xffffa1db, 0x0000255e, 0xffffdaa2, 0x00006041, 0xffff9fbf, 0x00004160, - 0xffffbea0, 0x00004deb, 0xffffb215, 0xffffeb4e, 0x000014b2, 0x0000640f, 0xffff9bf1, 0x00000f64, - 0xfffff09c, 0x00006a6a, 0xffff9596, 0x000073f8, 0xffff8c08, 0xfffff874, 0x0000078c, 0x00004ec1, - 0xffffb13f, 0xffffc14f, 0x00003eb1, 0x000068cd, 0xffff9733, 0xffffcd69, 0x00003297, 0x00007788, - 0xffff8878, 0x00002b2b, 0xffffd4d5, 0x00005050, 0xffffafb0, 0x00000000, 0x07070000, 0xf8f90000, - 0x09fd0000, 0xf6030000, 0xfd0a0000, 0x02f60000, 0x10100000, 0xeff00000, 0x12050000, 0xedfb0000, - 0x05120000, 0x00000707, 0x07070707, 0xf8f90707, 0x09fd0707, 0xf6030707, 0xfd0a0707, 0x02f60707, - 0x10100707, 0xeff00707, 0x12050707, 0xedfb0707, 0x05120707, 0xfffff8f9, 0x0706f8f9, 0xf8f8f8f9, - 0x09fcf8f9, 0xf602f8f9, 0xfd09f8f9, 0x02f5f8f9, 0x100ff8f9, 0xefeff8f9, 0x1204f8f9, 0xedfaf8f9, - 0x0511f8f9, 0x000009fd, 0x070709fd, 0xf8f909fd, 0x09fd09fd, 0xf60309fd, 0xfd0a09fd, 0x02f609fd, - 0x101009fd, 0xeff009fd, 0x120509fd, 0xedfb09fd, 0x051209fd, 0xfffff603, 0x0706f603, 0xf8f8f603, - 0x09fcf603, 0xf602f603, 0xfd09f603, 0x02f5f603, 0x100ff603, 0xefeff603, 0x1204f603, 0xedfaf603, - 0x0511f603, 0xfffffd0a, 0x0706fd0a, 0xf8f8fd0a, 0x09fcfd0a, 0xf602fd0a, 0xfd09fd0a, 0x02f5fd0a, - 0x100ffd0a, 0xefeffd0a, 0x1204fd0a, 0xedfafd0a, 0x0511fd0a, 0x000002f6, 0x070702f6, 0xf8f902f6, - 0x09fd02f6, 0xf60302f6, 0xfd0a02f6, 0x02f602f6, 0x101002f6, 0xeff002f6, 0x120502f6, 0xedfb02f6, - 0x051202f6, 0x00001010, 0x07071010, 0xf8f91010, 0x09fd1010, 0xf6031010, 0xfd0a1010, 0x02f61010, - 0x10101010, 0xeff01010, 0x12051010, 0xedfb1010, 0x05121010, 0xffffeff0, 0x0706eff0, 0xf8f8eff0, - 0x09fceff0, 0xf602eff0, 0xfd09eff0, 0x02f5eff0, 0x100feff0, 0xefefeff0, 0x1204eff0, 0xedfaeff0, - 0x0511eff0, 0x00001205, 0x07071205, 0xf8f91205, 0x09fd1205, 0xf6031205, 0xfd0a1205, 0x02f61205, - 0x10101205, 0xeff01205, 0x12051205, 0xedfb1205, 0x05121205, 0xffffedfb, 0x0706edfb, 0xf8f8edfb, - 0x09fcedfb, 0xf602edfb, 0xfd09edfb, 0x02f5edfb, 0x100fedfb, 0xefefedfb, 0x1204edfb, 0xedfaedfb, - 0x0511edfb, 0x00000512, 0x07070512, 0xf8f90512, 0x09fd0512, 0xf6030512, 0xfd0a0512, 0x02f60512, - 0x10100512, 0xeff00512, 0x12050512, 0xedfb0512, 0x05120512, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000808, 0xfffff7f8, 0x00000afd, 0xfffff503, 0xfffffd0b, 0x000002f5, 0x00001212, - 0xffffedee, 0x00001405, 0xffffebfb, 0x00000514, 0xfffffaec, 0x00000ef1, 0xfffff10f, 0x000017f9, - 0xffffe807, 0xfffff918, 0x000006e8, 0x00002311, 0xffffdcef, 0x00001123, 0xffffeedd, 0x00002222, - 0xffffddde, 0x00002603, 0xffffd9fd, 0x00000326, 0xfffffcda, 0x00001fea, 0xffffe016, 0xffffea20, - 0x000015e0, 0x00003d25, 0xffffc2db, 0x0000253d, 0xffffdac3, 0x00002ef3, 0xffffd10d, 0xfffff32f, - 0x00000cd1, 0x00003f11, 0xffffc0ef, 0x0000113f, 0xffffeec1, 0x00004141, 0xffffbebf, 0x000047ff, - 0xffffb801, 0xffffff48, 0x000000b8, 0x00002dd2, 0xffffd22e, 0x00003edd, 0xffffc123, 0xffffdd3f, - 0x000022c1, 0x00006b2b, 0xffff94d5, 0x00002b6b, 0xffffd495, 0x00006e4b, 0xffff91b5, 0x00004b6e, - 0xffffb492, 0x000058e8, 0xffffa718, 0xffffe859, 0x000017a7, 0x00007211, 0xffff8def, 0x00001172, - 0xffffee8e, 0x00007979, 0xffff8687, 0x00005ab8, 0xffffa548, 0xffffb85b, 0x000047a5, 0x000077c6, - 0xffff883a, 0xffffc678, 0x00003988, 0x00003131, 0xffffcecf, 0x00005c5c, 0xffffa3a4, 0x00000000, - 0x08080000, 0xf7f80000, 0x0afd0000, 0xf5030000, 0xfd0b0000, 0x02f50000, 0x12120000, 0xedee0000, - 0x14050000, 0xebfb0000, 0x05140000, 0x00000808, 0x08080808, 0xf7f80808, 0x0afd0808, 0xf5030808, - 0xfd0b0808, 0x02f50808, 0x12120808, 0xedee0808, 0x14050808, 0xebfb0808, 0x05140808, 0xfffff7f8, - 0x0807f7f8, 0xf7f7f7f8, 0x0afcf7f8, 0xf502f7f8, 0xfd0af7f8, 0x02f4f7f8, 0x1211f7f8, 0xededf7f8, - 0x1404f7f8, 0xebfaf7f8, 0x0513f7f8, 0x00000afd, 0x08080afd, 0xf7f80afd, 0x0afd0afd, 0xf5030afd, - 0xfd0b0afd, 0x02f50afd, 0x12120afd, 0xedee0afd, 0x14050afd, 0xebfb0afd, 0x05140afd, 0xfffff503, - 0x0807f503, 0xf7f7f503, 0x0afcf503, 0xf502f503, 0xfd0af503, 0x02f4f503, 0x1211f503, 0xededf503, - 0x1404f503, 0xebfaf503, 0x0513f503, 0xfffffd0b, 0x0807fd0b, 0xf7f7fd0b, 0x0afcfd0b, 0xf502fd0b, - 0xfd0afd0b, 0x02f4fd0b, 0x1211fd0b, 0xededfd0b, 0x1404fd0b, 0xebfafd0b, 0x0513fd0b, 0x000002f5, - 0x080802f5, 0xf7f802f5, 0x0afd02f5, 0xf50302f5, 0xfd0b02f5, 0x02f502f5, 0x121202f5, 0xedee02f5, - 0x140502f5, 0xebfb02f5, 0x051402f5, 0x00001212, 0x08081212, 0xf7f81212, 0x0afd1212, 0xf5031212, - 0xfd0b1212, 0x02f51212, 0x12121212, 0xedee1212, 0x14051212, 0xebfb1212, 0x05141212, 0xffffedee, - 0x0807edee, 0xf7f7edee, 0x0afcedee, 0xf502edee, 0xfd0aedee, 0x02f4edee, 0x1211edee, 0xedededee, - 0x1404edee, 0xebfaedee, 0x0513edee, 0x00001405, 0x08081405, 0xf7f81405, 0x0afd1405, 0xf5031405, - 0xfd0b1405, 0x02f51405, 0x12121405, 0xedee1405, 0x14051405, 0xebfb1405, 0x05141405, 0xffffebfb, - 0x0807ebfb, 0xf7f7ebfb, 0x0afcebfb, 0xf502ebfb, 0xfd0aebfb, 0x02f4ebfb, 0x1211ebfb, 0xededebfb, - 0x1404ebfb, 0xebfaebfb, 0x0513ebfb, 0x00000514, 0x08080514, 0xf7f80514, 0x0afd0514, 0xf5030514, - 0xfd0b0514, 0x02f50514, 0x12120514, 0xedee0514, 0x14050514, 0xebfb0514, 0x05140514, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000909, 0xfffff6f7, 0x00000bfd, 0xfffff403, 0xfffffd0c, 0x000002f4, 0x00001414, - 0xffffebec, 0x00001706, 0xffffe8fa, 0x00000617, 0xfffff9e9, 0x000010ef, 0xffffef11, 0x00001af9, - 0xffffe507, 0xfffff91b, 0x000006e5, 0x00002713, 0xffffd8ed, 0x00001327, 0xffffecd9, 0x00002727, - 0xffffd8d9, 0x00002b03, 0xffffd4fd, 0x0000032b, 0xfffffcd5, 0x000023e8, 0xffffdc18, 0xffffe824, - 0x000017dc, 0x0000452a, 0xffffbad6, 0x00002a45, 0xffffd5bb, 0x000034f2, 0xffffcb0e, 0xfffff235, - 0x00000dcb, 0x00004713, 0xffffb8ed, 0x00001347, 0xffffecb9, 0x00004949, 0xffffb6b7, 0x00004ffe, - 0xffffb002, 0xfffffe50, 0x000001b0, 0x000033cc, 0xffffcc34, 0x000045d9, 0xffffba27, 0xffffd946, - 0x000026ba, 0x00007930, 0xffff86d0, 0x00003079, 0xffffcf87, 0x00007c54, 0xffff83ac, 0x0000547c, - 0xffffab84, 0x000063e5, 0xffff9c1b, 0xffffe564, 0x00001a9c, 0x000065af, 0xffff9a51, 0xffffaf66, - 0x0000509a, 0x00003737, 0xffffc8c9, 0x00006868, 0xffff9798, 0x00000000, 0x09090000, 0xf6f70000, - 0x0bfd0000, 0xf4030000, 0xfd0c0000, 0x02f40000, 0x14140000, 0xebec0000, 0x17060000, 0xe8fa0000, - 0x06170000, 0xf9e90000, 0x00000909, 0x09090909, 0xf6f70909, 0x0bfd0909, 0xf4030909, 0xfd0c0909, - 0x02f40909, 0x14140909, 0xebec0909, 0x17060909, 0xe8fa0909, 0x06170909, 0xf9e90909, 0xfffff6f7, - 0x0908f6f7, 0xf6f6f6f7, 0x0bfcf6f7, 0xf402f6f7, 0xfd0bf6f7, 0x02f3f6f7, 0x1413f6f7, 0xebebf6f7, - 0x1705f6f7, 0xe8f9f6f7, 0x0616f6f7, 0xf9e8f6f7, 0x00000bfd, 0x09090bfd, 0xf6f70bfd, 0x0bfd0bfd, - 0xf4030bfd, 0xfd0c0bfd, 0x02f40bfd, 0x14140bfd, 0xebec0bfd, 0x17060bfd, 0xe8fa0bfd, 0x06170bfd, - 0xf9e90bfd, 0xfffff403, 0x0908f403, 0xf6f6f403, 0x0bfcf403, 0xf402f403, 0xfd0bf403, 0x02f3f403, - 0x1413f403, 0xebebf403, 0x1705f403, 0xe8f9f403, 0x0616f403, 0xf9e8f403, 0xfffffd0c, 0x0908fd0c, - 0xf6f6fd0c, 0x0bfcfd0c, 0xf402fd0c, 0xfd0bfd0c, 0x02f3fd0c, 0x1413fd0c, 0xebebfd0c, 0x1705fd0c, - 0xe8f9fd0c, 0x0616fd0c, 0xf9e8fd0c, 0x000002f4, 0x090902f4, 0xf6f702f4, 0x0bfd02f4, 0xf40302f4, - 0xfd0c02f4, 0x02f402f4, 0x141402f4, 0xebec02f4, 0x170602f4, 0xe8fa02f4, 0x061702f4, 0xf9e902f4, - 0x00001414, 0x09091414, 0xf6f71414, 0x0bfd1414, 0xf4031414, 0xfd0c1414, 0x02f41414, 0x14141414, - 0xebec1414, 0x17061414, 0xe8fa1414, 0x06171414, 0xf9e91414, 0xffffebec, 0x0908ebec, 0xf6f6ebec, - 0x0bfcebec, 0xf402ebec, 0xfd0bebec, 0x02f3ebec, 0x1413ebec, 0xebebebec, 0x1705ebec, 0xe8f9ebec, - 0x0616ebec, 0xf9e8ebec, 0x00001706, 0x09091706, 0xf6f71706, 0x0bfd1706, 0xf4031706, 0xfd0c1706, - 0x02f41706, 0x14141706, 0xebec1706, 0x17061706, 0xe8fa1706, 0x06171706, 0xf9e91706, 0xffffe8fa, - 0x0908e8fa, 0xf6f6e8fa, 0x0bfce8fa, 0xf402e8fa, 0xfd0be8fa, 0x02f3e8fa, 0x1413e8fa, 0xebebe8fa, - 0x1705e8fa, 0xe8f9e8fa, 0x0616e8fa, 0xf9e8e8fa, 0x00000617, 0x09090617, 0xf6f70617, 0x0bfd0617, - 0xf4030617, 0xfd0c0617, 0x02f40617, 0x14140617, 0xebec0617, 0x17060617, 0xe8fa0617, 0x06170617, - 0xf9e90617, 0xfffff9e9, 0x0908f9e9, 0xf6f6f9e9, 0x0bfcf9e9, 0xf402f9e9, 0xfd0bf9e9, 0x02f3f9e9, - 0x1413f9e9, 0xebebf9e9, 0x1705f9e9, 0xe8f9f9e9, 0x0616f9e9, 0xf9e8f9e9, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000202, 0xfffffdfe, 0x00000200, 0xfffffe00, 0x00000002, 0xfffffffe, 0x00000404, - 0xfffffbfc, 0x00000400, 0xfffffc00, 0x00000004, 0xfffffffc, 0x000003fc, 0xfffffc04, 0x000005fe, - 0xfffffa02, 0xfffffe06, 0x000001fa, 0x00000804, 0xfffff7fc, 0x00000408, 0xfffffbf8, 0x00000808, - 0xfffff7f8, 0x00000a00, 0xfffff600, 0x0000000a, 0xfffffff6, 0x000007fc, 0xfffff804, 0xfffffc08, - 0x000003f8, 0x00000e08, 0xfffff1f8, 0x0000080e, 0xfffff7f2, 0x00000bfe, 0xfffff402, 0xfffffe0c, - 0x000001f4, 0x00001004, 0xffffeffc, 0x00000410, 0xfffffbf0, 0x00001010, 0xffffeff0, 0x00001200, - 0xffffee00, 0x00000012, 0xffffffee, 0x00000bf4, 0xfffff40c, 0x00000ff8, 0xfffff008, 0xfffff810, - 0x000007f0, 0x00001a0a, 0xffffe5f6, 0x00000a1a, 0xfffff5e6, 0x00001c12, 0xffffe3ee, 0x0000121c, - 0xffffede4, 0x000015fa, 0xffffea06, 0xfffffa16, 0x000005ea, 0x00001c04, 0xffffe3fc, 0x0000041c, - 0xfffffbe4, 0x00001e1e, 0xffffe1e2, 0x00001ffe, 0xffffe002, 0xfffffe20, 0x000001e0, 0x000015ee, - 0xffffea12, 0xffffee16, 0x000011ea, 0x00001df2, 0xffffe20e, 0xfffff21e, 0x00000de2, 0x00002e16, - 0xffffd1ea, 0x0000162e, 0xffffe9d2, 0x00002e0c, 0xffffd1f4, 0x00000c2e, 0xfffff3d2, 0x00003022, - 0xffffcfde, 0x00002230, 0xffffddd0, 0x000027f6, 0xffffd80a, 0xfffff628, 0x000009d8, 0x00003204, - 0xffffcdfc, 0x00000432, 0xfffffbce, 0x00003636, 0xffffc9ca, 0x000021de, 0xffffde22, 0x000029e4, - 0xffffd61c, 0xffffe42a, 0x00001bd6, 0x00003bfa, 0xffffc406, 0xfffffa3c, 0x000005c4, 0x00004c1a, - 0xffffb3e6, 0x00001a4c, 0xffffe5b4, 0x00004c2a, 0xffffb3d6, 0x00002a4c, 0xffffd5b4, 0x000035e8, - 0xffffca18, 0xffffe836, 0x000017ca, 0x00004e0e, 0xffffb1f2, 0x00000e4e, 0xfffff1b2, 0x0000523e, - 0xffffadc2, 0x00003e52, 0xffffc1ae, 0x000049ec, 0xffffb614, 0xffffec4a, 0x000013b6, 0x00005802, - 0xffffa7fe, 0x00000258, 0xfffffda8, 0x00005c5c, 0xffffa3a4, 0x00003bcc, 0xffffc434, 0xffffcc3c, - 0x000033c4, 0x00007634, 0xffff89cc, 0x00003476, 0xffffcb8a, 0x000049d4, 0xffffb62c, 0xffffd44a, - 0x00002bb6, 0x0000764a, 0xffff89b6, 0x00004a76, 0xffffb58a, 0x00007620, 0xffff89e0, 0x00002076, - 0xffffdf8a, 0x000065f4, 0xffff9a0c, 0xfffff466, 0x00000b9a, 0x00005fd8, 0xffffa028, 0xffffd860, - 0x000027a0, 0x000075de, 0xffff8a22, 0xffffde76, 0x0000218a, 0x000057a8, 0xffffa858, 0x000067b2, - 0xffff984e, 0xffffb268, 0x00004d98, 0x00000c0c, 0xfffff3f4, 0x00001616, 0xffffe9ea, 0x00002a2a, - 0xffffd5d6, 0x00004848, 0xffffb7b8, 0x00000000, 0x02020000, 0xfdfe0000, 0x02000000, 0xfe000000, - 0x00020000, 0xfffe0000, 0x00000202, 0x02020202, 0xfdfe0202, 0x02000202, 0xfe000202, 0x00020202, - 0xfffe0202, 0xfffffdfe, 0x0201fdfe, 0xfdfdfdfe, 0x01fffdfe, 0xfdfffdfe, 0x0001fdfe, 0xfffdfdfe, - 0x00000200, 0x02020200, 0xfdfe0200, 0x02000200, 0xfe000200, 0x00020200, 0xfffe0200, 0xfffffe00, - 0x0201fe00, 0xfdfdfe00, 0x01fffe00, 0xfdfffe00, 0x0001fe00, 0xfffdfe00, 0x00000002, 0x02020002, - 0xfdfe0002, 0x02000002, 0xfe000002, 0x00020002, 0xfffe0002, 0xfffffffe, 0x0201fffe, 0xfdfdfffe, - 0x01fffffe, 0xfdfffffe, 0x0001fffe, 0xfffdfffe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000303, 0xfffffcfd, 0x00000300, 0xfffffd00, 0x00000003, 0xfffffffd, 0x00000606, - 0xfffff9fa, 0x00000903, 0xfffff6fd, 0x00000309, 0xfffffcf7, 0x000008fd, 0xfffff703, 0xfffffd09, - 0x000002f7, 0x000005fa, 0xfffffa06, 0x00000c06, 0xfffff3fa, 0x0000060c, 0xfffff9f4, 0x00000c0c, - 0xfffff3f4, 0x00000f00, 0xfffff100, 0x0000000f, 0xfffffff1, 0x00000bf7, 0xfffff409, 0xfffff70c, - 0x000008f4, 0x0000180f, 0xffffe7f1, 0x00000f18, 0xfffff0e8, 0x000011fa, 0xffffee06, 0xfffffa12, - 0x000005ee, 0x00001806, 0xffffe7fa, 0x00000618, 0xfffff9e8, 0x00001818, 0xffffe7e8, 0x00001b00, - 0xffffe500, 0x0000001b, 0xffffffe5, 0x000011ee, 0xffffee12, 0x000017f4, 0xffffe80c, 0xfffff418, - 0x00000be8, 0x0000270f, 0xffffd8f1, 0x00000f27, 0xfffff0d9, 0x00002a1b, 0xffffd5e5, 0x00001b2a, - 0xffffe4d6, 0x000020f7, 0xffffdf09, 0xfffff721, 0x000008df, 0x00002a06, 0xffffd5fa, 0x0000062a, - 0xfffff9d6, 0x00002d2d, 0xffffd2d3, 0x000032fd, 0xffffcd03, 0xfffffd33, 0x000002cd, 0x000020e5, - 0xffffdf1b, 0xffffe521, 0x00001adf, 0x00002ceb, 0xffffd315, 0xffffeb2d, 0x000014d3, 0x00004521, - 0xffffbadf, 0x00002145, 0xffffdebb, 0x00004512, 0xffffbaee, 0x00001245, 0xffffedbb, 0x00004836, - 0xffffb7ca, 0x00003648, 0xffffc9b8, 0x00003eee, 0xffffc112, 0xffffee3f, 0x000011c1, 0x00004e06, - 0xffffb1fa, 0x0000064e, 0xfffff9b2, 0x00005151, 0xffffaeaf, 0x000032cd, 0xffffcd33, 0x00003ed6, - 0xffffc12a, 0xffffd63f, 0x000029c1, 0x000059f7, 0xffffa609, 0xfffff75a, 0x000008a6, 0x0000722a, - 0xffff8dd6, 0x00002a72, 0xffffd58e, 0x0000753f, 0xffff8ac1, 0x00003f75, 0xffffc08b, 0x000050dc, - 0xffffaf24, 0xffffdc51, 0x000023af, 0x00007815, 0xffff87eb, 0x00001578, 0xffffea88, 0x00007b60, - 0xffff84a0, 0x0000607b, 0xffff9f85, 0x00006ee2, 0xffff911e, 0xffffe26f, 0x00001d91, 0x00005cb2, - 0xffffa34e, 0xffffb25d, 0x00004da3, 0x000071bb, 0xffff8e45, 0xffffbb72, 0x0000448e, 0x00001212, - 0xffffedee, 0x00002121, 0xffffdedf, 0x00003f3f, 0xffffc0c1, 0x00006c6c, 0xffff9394, 0x00000000, - 0x03030000, 0xfcfd0000, 0x03000000, 0xfd000000, 0x00030000, 0xfffd0000, 0x06060000, 0xf9fa0000, - 0x00000303, 0x03030303, 0xfcfd0303, 0x03000303, 0xfd000303, 0x00030303, 0xfffd0303, 0x06060303, - 0xf9fa0303, 0xfffffcfd, 0x0302fcfd, 0xfcfcfcfd, 0x02fffcfd, 0xfcfffcfd, 0x0002fcfd, 0xfffcfcfd, - 0x0605fcfd, 0xf9f9fcfd, 0x00000300, 0x03030300, 0xfcfd0300, 0x03000300, 0xfd000300, 0x00030300, - 0xfffd0300, 0x06060300, 0xf9fa0300, 0xfffffd00, 0x0302fd00, 0xfcfcfd00, 0x02fffd00, 0xfcfffd00, - 0x0002fd00, 0xfffcfd00, 0x0605fd00, 0xf9f9fd00, 0x00000003, 0x03030003, 0xfcfd0003, 0x03000003, - 0xfd000003, 0x00030003, 0xfffd0003, 0x06060003, 0xf9fa0003, 0xfffffffd, 0x0302fffd, 0xfcfcfffd, - 0x02fffffd, 0xfcfffffd, 0x0002fffd, 0xfffcfffd, 0x0605fffd, 0xf9f9fffd, 0x00000606, 0x03030606, - 0xfcfd0606, 0x03000606, 0xfd000606, 0x00030606, 0xfffd0606, 0x06060606, 0xf9fa0606, 0xfffff9fa, - 0x0302f9fa, 0xfcfcf9fa, 0x02fff9fa, 0xfcfff9fa, 0x0002f9fa, 0xfffcf9fa, 0x0605f9fa, 0xf9f9f9fa, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000404, 0xfffffbfc, 0x00000400, 0xfffffc00, 0x00000004, 0xfffffffc, 0x00000804, - 0xfffff7fc, 0x00000408, 0xfffffbf8, 0x00000808, 0xfffff7f8, 0x000007f8, 0xfffff808, 0x00000bfc, - 0xfffff404, 0xfffffc0c, 0x000003f4, 0x00001008, 0xffffeff8, 0x00000810, 0xfffff7f0, 0x00001010, - 0xffffeff0, 0x00001400, 0xffffec00, 0x00000014, 0xffffffec, 0x00000ff4, 0xfffff00c, 0xfffff410, - 0x00000bf0, 0x000017fc, 0xffffe804, 0xfffffc18, 0x000003e8, 0x00002010, 0xffffdff0, 0x00001020, - 0xffffefe0, 0x00002008, 0xffffdff8, 0x00000820, 0xfffff7e0, 0x00002020, 0xffffdfe0, 0x00002400, - 0xffffdc00, 0x00000024, 0xffffffdc, 0x000017e8, 0xffffe818, 0x00001ff0, 0xffffe010, 0xfffff020, - 0x00000fe0, 0x00003414, 0xffffcbec, 0x00001434, 0xffffebcc, 0x00003824, 0xffffc7dc, 0x00002438, - 0xffffdbc8, 0x00002bf4, 0xffffd40c, 0xfffff42c, 0x00000bd4, 0x00003808, 0xffffc7f8, 0x00000838, - 0xfffff7c8, 0x00003c3c, 0xffffc3c4, 0x00003ffc, 0xffffc004, 0xfffffc40, 0x000003c0, 0x00002bdc, - 0xffffd424, 0xffffdc2c, 0x000023d4, 0x00003be4, 0xffffc41c, 0xffffe43c, 0x00001bc4, 0x00005c2c, - 0xffffa3d4, 0x00002c5c, 0xffffd3a4, 0x00005c18, 0xffffa3e8, 0x0000185c, 0xffffe7a4, 0x00006048, - 0xffff9fb8, 0x00004860, 0xffffb7a0, 0x000053ec, 0xffffac14, 0xffffec54, 0x000013ac, 0x00006408, - 0xffff9bf8, 0x00000864, 0xfffff79c, 0x00006c6c, 0xffff9394, 0x000043bc, 0xffffbc44, 0x000053c8, - 0xffffac38, 0xffffc854, 0x000037ac, 0x000077f4, 0xffff880c, 0xfffff478, 0x00000b88, 0x00006bd0, - 0xffff9430, 0xffffd06c, 0x00002f94, 0x00007b98, 0xffff8468, 0xffff987c, 0x00006784, 0x00001818, - 0xffffe7e8, 0x00002c2c, 0xffffd3d4, 0x00005454, 0xffffabac, 0x00000000, 0x04040000, 0xfbfc0000, - 0x04000000, 0xfc000000, 0x00040000, 0xfffc0000, 0x08040000, 0xf7fc0000, 0x04080000, 0x00000404, - 0x04040404, 0xfbfc0404, 0x04000404, 0xfc000404, 0x00040404, 0xfffc0404, 0x08040404, 0xf7fc0404, - 0x04080404, 0xfffffbfc, 0x0403fbfc, 0xfbfbfbfc, 0x03fffbfc, 0xfbfffbfc, 0x0003fbfc, 0xfffbfbfc, - 0x0803fbfc, 0xf7fbfbfc, 0x0407fbfc, 0x00000400, 0x04040400, 0xfbfc0400, 0x04000400, 0xfc000400, - 0x00040400, 0xfffc0400, 0x08040400, 0xf7fc0400, 0x04080400, 0xfffffc00, 0x0403fc00, 0xfbfbfc00, - 0x03fffc00, 0xfbfffc00, 0x0003fc00, 0xfffbfc00, 0x0803fc00, 0xf7fbfc00, 0x0407fc00, 0x00000004, - 0x04040004, 0xfbfc0004, 0x04000004, 0xfc000004, 0x00040004, 0xfffc0004, 0x08040004, 0xf7fc0004, - 0x04080004, 0xfffffffc, 0x0403fffc, 0xfbfbfffc, 0x03fffffc, 0xfbfffffc, 0x0003fffc, 0xfffbfffc, - 0x0803fffc, 0xf7fbfffc, 0x0407fffc, 0x00000804, 0x04040804, 0xfbfc0804, 0x04000804, 0xfc000804, - 0x00040804, 0xfffc0804, 0x08040804, 0xf7fc0804, 0x04080804, 0xfffff7fc, 0x0403f7fc, 0xfbfbf7fc, - 0x03fff7fc, 0xfbfff7fc, 0x0003f7fc, 0xfffbf7fc, 0x0803f7fc, 0xf7fbf7fc, 0x0407f7fc, 0x00000408, - 0x04040408, 0xfbfc0408, 0x04000408, 0xfc000408, 0x00040408, 0xfffc0408, 0x08040408, 0xf7fc0408, - 0x04080408, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000505, 0xfffffafb, 0x00000500, 0xfffffb00, 0x00000005, 0xfffffffb, 0x00000a0a, - 0xfffff5f6, 0x00000f05, 0xfffff0fb, 0x0000050f, 0xfffffaf1, 0x000009f6, 0xfffff60a, 0x00000efb, - 0xfffff105, 0xfffffb0f, 0x000004f1, 0x0000140a, 0xffffebf6, 0x00000a14, 0xfffff5ec, 0x00001414, - 0xffffebec, 0x00001900, 0xffffe700, 0x00000019, 0xffffffe7, 0x000013f1, 0xffffec0f, 0xfffff114, - 0x00000eec, 0x00002819, 0xffffd7e7, 0x00001928, 0xffffe6d8, 0x00001df6, 0xffffe20a, 0xfffff61e, - 0x000009e2, 0x0000280a, 0xffffd7f6, 0x00000a28, 0xfffff5d8, 0x00002828, 0xffffd7d8, 0x00002d00, - 0xffffd300, 0x0000002d, 0xffffffd3, 0x00001de2, 0xffffe21e, 0x000027ec, 0xffffd814, 0xffffec28, - 0x000013d8, 0x00004119, 0xffffbee7, 0x00001941, 0xffffe6bf, 0x0000462d, 0xffffb9d3, 0x00002d46, - 0xffffd2ba, 0x000036f1, 0xffffc90f, 0xfffff137, 0x00000ec9, 0x0000460a, 0xffffb9f6, 0x00000a46, - 0xfffff5ba, 0x00004b4b, 0xffffb4b5, 0x000054fb, 0xffffab05, 0xfffffb55, 0x000004ab, 0x000036d3, - 0xffffc92d, 0xffffd337, 0x00002cc9, 0x00004add, 0xffffb523, 0xffffdd4b, 0x000022b5, 0x00007337, - 0xffff8cc9, 0x00003773, 0xffffc88d, 0x0000731e, 0xffff8ce2, 0x00001e73, 0xffffe18d, 0x0000785a, - 0xffff87a6, 0x00005a78, 0xffffa588, 0x000068e2, 0xffff971e, 0xffffe269, 0x00001d97, 0x000054ab, - 0xffffab55, 0x000068ba, 0xffff9746, 0xffffba69, 0x00004597, 0x00001e1e, 0xffffe1e2, 0x00003c3c, - 0xffffc3c4, 0x00006969, 0xffff9697, 0x00000000, 0x05050000, 0xfafb0000, 0x05000000, 0xfb000000, - 0x00050000, 0xfffb0000, 0x0a0a0000, 0xf5f60000, 0x0f050000, 0xf0fb0000, 0x00000505, 0x05050505, - 0xfafb0505, 0x05000505, 0xfb000505, 0x00050505, 0xfffb0505, 0x0a0a0505, 0xf5f60505, 0x0f050505, - 0xf0fb0505, 0xfffffafb, 0x0504fafb, 0xfafafafb, 0x04fffafb, 0xfafffafb, 0x0004fafb, 0xfffafafb, - 0x0a09fafb, 0xf5f5fafb, 0x0f04fafb, 0xf0fafafb, 0x00000500, 0x05050500, 0xfafb0500, 0x05000500, - 0xfb000500, 0x00050500, 0xfffb0500, 0x0a0a0500, 0xf5f60500, 0x0f050500, 0xf0fb0500, 0xfffffb00, - 0x0504fb00, 0xfafafb00, 0x04fffb00, 0xfafffb00, 0x0004fb00, 0xfffafb00, 0x0a09fb00, 0xf5f5fb00, - 0x0f04fb00, 0xf0fafb00, 0x00000005, 0x05050005, 0xfafb0005, 0x05000005, 0xfb000005, 0x00050005, - 0xfffb0005, 0x0a0a0005, 0xf5f60005, 0x0f050005, 0xf0fb0005, 0xfffffffb, 0x0504fffb, 0xfafafffb, - 0x04fffffb, 0xfafffffb, 0x0004fffb, 0xfffafffb, 0x0a09fffb, 0xf5f5fffb, 0x0f04fffb, 0xf0fafffb, - 0x00000a0a, 0x05050a0a, 0xfafb0a0a, 0x05000a0a, 0xfb000a0a, 0x00050a0a, 0xfffb0a0a, 0x0a0a0a0a, - 0xf5f60a0a, 0x0f050a0a, 0xf0fb0a0a, 0xfffff5f6, 0x0504f5f6, 0xfafaf5f6, 0x04fff5f6, 0xfafff5f6, - 0x0004f5f6, 0xfffaf5f6, 0x0a09f5f6, 0xf5f5f5f6, 0x0f04f5f6, 0xf0faf5f6, 0x00000f05, 0x05050f05, - 0xfafb0f05, 0x05000f05, 0xfb000f05, 0x00050f05, 0xfffb0f05, 0x0a0a0f05, 0xf5f60f05, 0x0f050f05, - 0xf0fb0f05, 0xfffff0fb, 0x0504f0fb, 0xfafaf0fb, 0x04fff0fb, 0xfafff0fb, 0x0004f0fb, 0xfffaf0fb, - 0x0a09f0fb, 0xf5f5f0fb, 0x0f04f0fb, 0xf0faf0fb, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000606, 0xfffff9fa, 0x00000600, 0xfffffa00, 0x00000006, 0xfffffffa, 0x00000c0c, - 0xfffff3f4, 0x00000c06, 0xfffff3fa, 0x0000060c, 0xfffff9f4, 0x00000bf4, 0xfffff40c, 0x000011fa, - 0xffffee06, 0xfffffa12, 0x000005ee, 0x0000180c, 0xffffe7f4, 0x00000c18, 0xfffff3e8, 0x00001818, - 0xffffe7e8, 0x00001e00, 0xffffe200, 0x0000001e, 0xffffffe2, 0x000017ee, 0xffffe812, 0xffffee18, - 0x000011e8, 0x0000301e, 0xffffcfe2, 0x00001e30, 0xffffe1d0, 0x000023fa, 0xffffdc06, 0xfffffa24, - 0x000005dc, 0x0000300c, 0xffffcff4, 0x00000c30, 0xfffff3d0, 0x00003030, 0xffffcfd0, 0x00003600, - 0xffffca00, 0x00000036, 0xffffffca, 0x000023dc, 0xffffdc24, 0x00002fe8, 0xffffd018, 0xffffe830, - 0x000017d0, 0x00004e1e, 0xffffb1e2, 0x00001e4e, 0xffffe1b2, 0x00005436, 0xffffabca, 0x00003654, - 0xffffc9ac, 0x000041ee, 0xffffbe12, 0xffffee42, 0x000011be, 0x0000540c, 0xffffabf4, 0x00000c54, - 0xfffff3ac, 0x00005a5a, 0xffffa5a6, 0x00005ffa, 0xffffa006, 0xfffffa60, 0x000005a0, 0x000041ca, - 0xffffbe36, 0xffffca42, 0x000035be, 0x000059d6, 0xffffa62a, 0xffffd65a, 0x000029a6, 0x00007de2, - 0xffff821e, 0xffffe27e, 0x00001d82, 0x0000659a, 0xffff9a66, 0x00007dac, 0xffff8254, 0xffffac7e, - 0x00005382, 0x00002424, 0xffffdbdc, 0x00004242, 0xffffbdbe, 0x00000000, 0x06060000, 0xf9fa0000, - 0x06000000, 0xfa000000, 0x00060000, 0xfffa0000, 0x0c0c0000, 0xf3f40000, 0x0c060000, 0xf3fa0000, - 0x060c0000, 0x00000606, 0x06060606, 0xf9fa0606, 0x06000606, 0xfa000606, 0x00060606, 0xfffa0606, - 0x0c0c0606, 0xf3f40606, 0x0c060606, 0xf3fa0606, 0x060c0606, 0xfffff9fa, 0x0605f9fa, 0xf9f9f9fa, - 0x05fff9fa, 0xf9fff9fa, 0x0005f9fa, 0xfff9f9fa, 0x0c0bf9fa, 0xf3f3f9fa, 0x0c05f9fa, 0xf3f9f9fa, - 0x060bf9fa, 0x00000600, 0x06060600, 0xf9fa0600, 0x06000600, 0xfa000600, 0x00060600, 0xfffa0600, - 0x0c0c0600, 0xf3f40600, 0x0c060600, 0xf3fa0600, 0x060c0600, 0xfffffa00, 0x0605fa00, 0xf9f9fa00, - 0x05fffa00, 0xf9fffa00, 0x0005fa00, 0xfff9fa00, 0x0c0bfa00, 0xf3f3fa00, 0x0c05fa00, 0xf3f9fa00, - 0x060bfa00, 0x00000006, 0x06060006, 0xf9fa0006, 0x06000006, 0xfa000006, 0x00060006, 0xfffa0006, - 0x0c0c0006, 0xf3f40006, 0x0c060006, 0xf3fa0006, 0x060c0006, 0xfffffffa, 0x0605fffa, 0xf9f9fffa, - 0x05fffffa, 0xf9fffffa, 0x0005fffa, 0xfff9fffa, 0x0c0bfffa, 0xf3f3fffa, 0x0c05fffa, 0xf3f9fffa, - 0x060bfffa, 0x00000c0c, 0x06060c0c, 0xf9fa0c0c, 0x06000c0c, 0xfa000c0c, 0x00060c0c, 0xfffa0c0c, - 0x0c0c0c0c, 0xf3f40c0c, 0x0c060c0c, 0xf3fa0c0c, 0x060c0c0c, 0xfffff3f4, 0x0605f3f4, 0xf9f9f3f4, - 0x05fff3f4, 0xf9fff3f4, 0x0005f3f4, 0xfff9f3f4, 0x0c0bf3f4, 0xf3f3f3f4, 0x0c05f3f4, 0xf3f9f3f4, - 0x060bf3f4, 0x00000c06, 0x06060c06, 0xf9fa0c06, 0x06000c06, 0xfa000c06, 0x00060c06, 0xfffa0c06, - 0x0c0c0c06, 0xf3f40c06, 0x0c060c06, 0xf3fa0c06, 0x060c0c06, 0xfffff3fa, 0x0605f3fa, 0xf9f9f3fa, - 0x05fff3fa, 0xf9fff3fa, 0x0005f3fa, 0xfff9f3fa, 0x0c0bf3fa, 0xf3f3f3fa, 0x0c05f3fa, 0xf3f9f3fa, - 0x060bf3fa, 0x0000060c, 0x0606060c, 0xf9fa060c, 0x0600060c, 0xfa00060c, 0x0006060c, 0xfffa060c, - 0x0c0c060c, 0xf3f4060c, 0x0c06060c, 0xf3fa060c, 0x060c060c, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000707, 0xfffff8f9, 0x00000700, 0xfffff900, 0x00000007, 0xfffffff9, 0x00000e0e, - 0xfffff1f2, 0x00001507, 0xffffeaf9, 0x00000715, 0xfffff8eb, 0x00000df2, 0xfffff20e, 0x000014f9, - 0xffffeb07, 0xfffff915, 0x000006eb, 0x00001c0e, 0xffffe3f2, 0x00000e1c, 0xfffff1e4, 0x00001c1c, - 0xffffe3e4, 0x00002300, 0xffffdd00, 0x00000023, 0xffffffdd, 0x00001beb, 0xffffe415, 0xffffeb1c, - 0x000014e4, 0x00003823, 0xffffc7dd, 0x00002338, 0xffffdcc8, 0x000029f2, 0xffffd60e, 0xfffff22a, - 0x00000dd6, 0x0000380e, 0xffffc7f2, 0x00000e38, 0xfffff1c8, 0x00003838, 0xffffc7c8, 0x00003f00, - 0xffffc100, 0x0000003f, 0xffffffc1, 0x000029d6, 0xffffd62a, 0x000037e4, 0xffffc81c, 0xffffe438, - 0x00001bc8, 0x00005b23, 0xffffa4dd, 0x0000235b, 0xffffdca5, 0x0000623f, 0xffff9dc1, 0x00003f62, - 0xffffc09e, 0x00004ceb, 0xffffb315, 0xffffeb4d, 0x000014b3, 0x0000620e, 0xffff9df2, 0x00000e62, - 0xfffff19e, 0x00006969, 0xffff9697, 0x000076f9, 0xffff8907, 0xfffff977, 0x00000689, 0x00004cc1, - 0xffffb33f, 0xffffc14d, 0x00003eb3, 0x000068cf, 0xffff9731, 0xffffcf69, 0x00003097, 0x00007689, - 0xffff8977, 0x00002a2a, 0xffffd5d6, 0x00004d4d, 0xffffb2b3, 0x00000000, 0x07070000, 0xf8f90000, - 0x07000000, 0xf9000000, 0x00070000, 0xfff90000, 0x0e0e0000, 0xf1f20000, 0x15070000, 0xeaf90000, - 0x07150000, 0x00000707, 0x07070707, 0xf8f90707, 0x07000707, 0xf9000707, 0x00070707, 0xfff90707, - 0x0e0e0707, 0xf1f20707, 0x15070707, 0xeaf90707, 0x07150707, 0xfffff8f9, 0x0706f8f9, 0xf8f8f8f9, - 0x06fff8f9, 0xf8fff8f9, 0x0006f8f9, 0xfff8f8f9, 0x0e0df8f9, 0xf1f1f8f9, 0x1506f8f9, 0xeaf8f8f9, - 0x0714f8f9, 0x00000700, 0x07070700, 0xf8f90700, 0x07000700, 0xf9000700, 0x00070700, 0xfff90700, - 0x0e0e0700, 0xf1f20700, 0x15070700, 0xeaf90700, 0x07150700, 0xfffff900, 0x0706f900, 0xf8f8f900, - 0x06fff900, 0xf8fff900, 0x0006f900, 0xfff8f900, 0x0e0df900, 0xf1f1f900, 0x1506f900, 0xeaf8f900, - 0x0714f900, 0x00000007, 0x07070007, 0xf8f90007, 0x07000007, 0xf9000007, 0x00070007, 0xfff90007, - 0x0e0e0007, 0xf1f20007, 0x15070007, 0xeaf90007, 0x07150007, 0xfffffff9, 0x0706fff9, 0xf8f8fff9, - 0x06fffff9, 0xf8fffff9, 0x0006fff9, 0xfff8fff9, 0x0e0dfff9, 0xf1f1fff9, 0x1506fff9, 0xeaf8fff9, - 0x0714fff9, 0x00000e0e, 0x07070e0e, 0xf8f90e0e, 0x07000e0e, 0xf9000e0e, 0x00070e0e, 0xfff90e0e, - 0x0e0e0e0e, 0xf1f20e0e, 0x15070e0e, 0xeaf90e0e, 0x07150e0e, 0xfffff1f2, 0x0706f1f2, 0xf8f8f1f2, - 0x06fff1f2, 0xf8fff1f2, 0x0006f1f2, 0xfff8f1f2, 0x0e0df1f2, 0xf1f1f1f2, 0x1506f1f2, 0xeaf8f1f2, - 0x0714f1f2, 0x00001507, 0x07071507, 0xf8f91507, 0x07001507, 0xf9001507, 0x00071507, 0xfff91507, - 0x0e0e1507, 0xf1f21507, 0x15071507, 0xeaf91507, 0x07151507, 0xffffeaf9, 0x0706eaf9, 0xf8f8eaf9, - 0x06ffeaf9, 0xf8ffeaf9, 0x0006eaf9, 0xfff8eaf9, 0x0e0deaf9, 0xf1f1eaf9, 0x1506eaf9, 0xeaf8eaf9, - 0x0714eaf9, 0x00000715, 0x07070715, 0xf8f90715, 0x07000715, 0xf9000715, 0x00070715, 0xfff90715, - 0x0e0e0715, 0xf1f20715, 0x15070715, 0xeaf90715, 0x07150715, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000808, 0xfffff7f8, 0x00000800, 0xfffff800, 0x00000008, 0xfffffff8, 0x00001010, - 0xffffeff0, 0x00001008, 0xffffeff8, 0x00000810, 0xfffff7f0, 0x00000ff0, 0xfffff010, 0x000017f8, - 0xffffe808, 0xfffff818, 0x000007e8, 0x00002010, 0xffffdff0, 0x00001020, 0xffffefe0, 0x00002020, - 0xffffdfe0, 0x00002800, 0xffffd800, 0x00000028, 0xffffffd8, 0x00001fe8, 0xffffe018, 0xffffe820, - 0x000017e0, 0x00004028, 0xffffbfd8, 0x00002840, 0xffffd7c0, 0x00002ff0, 0xffffd010, 0xfffff030, - 0x00000fd0, 0x00004010, 0xffffbff0, 0x00001040, 0xffffefc0, 0x00004040, 0xffffbfc0, 0x00004800, - 0xffffb800, 0x00000048, 0xffffffb8, 0x00002fd0, 0xffffd030, 0x00003fe0, 0xffffc020, 0xffffe040, - 0x00001fc0, 0x00006828, 0xffff97d8, 0x00002868, 0xffffd798, 0x00007048, 0xffff8fb8, 0x00004870, - 0xffffb790, 0x000057e8, 0xffffa818, 0xffffe858, 0x000017a8, 0x00007010, 0xffff8ff0, 0x00001070, - 0xffffef90, 0x00007878, 0xffff8788, 0x000057b8, 0xffffa848, 0xffffb858, 0x000047a8, 0x000077c8, - 0xffff8838, 0xffffc878, 0x00003788, 0x00003030, 0xffffcfd0, 0x00005858, 0xffffa7a8, 0x00000000, - 0x08080000, 0xf7f80000, 0x08000000, 0xf8000000, 0x00080000, 0xfff80000, 0x10100000, 0xeff00000, - 0x10080000, 0xeff80000, 0x08100000, 0x00000808, 0x08080808, 0xf7f80808, 0x08000808, 0xf8000808, - 0x00080808, 0xfff80808, 0x10100808, 0xeff00808, 0x10080808, 0xeff80808, 0x08100808, 0xfffff7f8, - 0x0807f7f8, 0xf7f7f7f8, 0x07fff7f8, 0xf7fff7f8, 0x0007f7f8, 0xfff7f7f8, 0x100ff7f8, 0xefeff7f8, - 0x1007f7f8, 0xeff7f7f8, 0x080ff7f8, 0x00000800, 0x08080800, 0xf7f80800, 0x08000800, 0xf8000800, - 0x00080800, 0xfff80800, 0x10100800, 0xeff00800, 0x10080800, 0xeff80800, 0x08100800, 0xfffff800, - 0x0807f800, 0xf7f7f800, 0x07fff800, 0xf7fff800, 0x0007f800, 0xfff7f800, 0x100ff800, 0xefeff800, - 0x1007f800, 0xeff7f800, 0x080ff800, 0x00000008, 0x08080008, 0xf7f80008, 0x08000008, 0xf8000008, - 0x00080008, 0xfff80008, 0x10100008, 0xeff00008, 0x10080008, 0xeff80008, 0x08100008, 0xfffffff8, - 0x0807fff8, 0xf7f7fff8, 0x07fffff8, 0xf7fffff8, 0x0007fff8, 0xfff7fff8, 0x100ffff8, 0xefeffff8, - 0x1007fff8, 0xeff7fff8, 0x080ffff8, 0x00001010, 0x08081010, 0xf7f81010, 0x08001010, 0xf8001010, - 0x00081010, 0xfff81010, 0x10101010, 0xeff01010, 0x10081010, 0xeff81010, 0x08101010, 0xffffeff0, - 0x0807eff0, 0xf7f7eff0, 0x07ffeff0, 0xf7ffeff0, 0x0007eff0, 0xfff7eff0, 0x100feff0, 0xefefeff0, - 0x1007eff0, 0xeff7eff0, 0x080feff0, 0x00001008, 0x08081008, 0xf7f81008, 0x08001008, 0xf8001008, - 0x00081008, 0xfff81008, 0x10101008, 0xeff01008, 0x10081008, 0xeff81008, 0x08101008, 0xffffeff8, - 0x0807eff8, 0xf7f7eff8, 0x07ffeff8, 0xf7ffeff8, 0x0007eff8, 0xfff7eff8, 0x100feff8, 0xefefeff8, - 0x1007eff8, 0xeff7eff8, 0x080feff8, 0x00000810, 0x08080810, 0xf7f80810, 0x08000810, 0xf8000810, - 0x00080810, 0xfff80810, 0x10100810, 0xeff00810, 0x10080810, 0xeff80810, 0x08100810, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000909, 0xfffff6f7, 0x00000900, 0xfffff700, 0x00000009, 0xfffffff7, 0x00001212, - 0xffffedee, 0x00001b09, 0xffffe4f7, 0x0000091b, 0xfffff6e5, 0x000011ee, 0xffffee12, 0x00001af7, - 0xffffe509, 0xfffff71b, 0x000008e5, 0x00002412, 0xffffdbee, 0x00001224, 0xffffeddc, 0x00002424, - 0xffffdbdc, 0x00002d00, 0xffffd300, 0x0000002d, 0xffffffd3, 0x000023e5, 0xffffdc1b, 0xffffe524, - 0x00001adc, 0x0000482d, 0xffffb7d3, 0x00002d48, 0xffffd2b8, 0x000035ee, 0xffffca12, 0xffffee36, - 0x000011ca, 0x00004812, 0xffffb7ee, 0x00001248, 0xffffedb8, 0x00004848, 0xffffb7b8, 0x00005100, - 0xffffaf00, 0x00000051, 0xffffffaf, 0x000035ca, 0xffffca36, 0x000047dc, 0xffffb824, 0xffffdc48, - 0x000023b8, 0x0000752d, 0xffff8ad3, 0x00002d75, 0xffffd28b, 0x00007e51, 0xffff81af, 0x0000517e, - 0xffffae82, 0x000062e5, 0xffff9d1b, 0xffffe563, 0x00001a9d, 0x000062af, 0xffff9d51, 0xffffaf63, - 0x0000509d, 0x00003636, 0xffffc9ca, 0x00006c6c, 0xffff9394, 0x00000000, 0x09090000, 0xf6f70000, - 0x09000000, 0xf7000000, 0x00090000, 0xfff70000, 0x12120000, 0xedee0000, 0x1b090000, 0xe4f70000, - 0x091b0000, 0xf6e50000, 0x00000909, 0x09090909, 0xf6f70909, 0x09000909, 0xf7000909, 0x00090909, - 0xfff70909, 0x12120909, 0xedee0909, 0x1b090909, 0xe4f70909, 0x091b0909, 0xf6e50909, 0xfffff6f7, - 0x0908f6f7, 0xf6f6f6f7, 0x08fff6f7, 0xf6fff6f7, 0x0008f6f7, 0xfff6f6f7, 0x1211f6f7, 0xededf6f7, - 0x1b08f6f7, 0xe4f6f6f7, 0x091af6f7, 0xf6e4f6f7, 0x00000900, 0x09090900, 0xf6f70900, 0x09000900, - 0xf7000900, 0x00090900, 0xfff70900, 0x12120900, 0xedee0900, 0x1b090900, 0xe4f70900, 0x091b0900, - 0xf6e50900, 0xfffff700, 0x0908f700, 0xf6f6f700, 0x08fff700, 0xf6fff700, 0x0008f700, 0xfff6f700, - 0x1211f700, 0xededf700, 0x1b08f700, 0xe4f6f700, 0x091af700, 0xf6e4f700, 0x00000009, 0x09090009, - 0xf6f70009, 0x09000009, 0xf7000009, 0x00090009, 0xfff70009, 0x12120009, 0xedee0009, 0x1b090009, - 0xe4f70009, 0x091b0009, 0xf6e50009, 0xfffffff7, 0x0908fff7, 0xf6f6fff7, 0x08fffff7, 0xf6fffff7, - 0x0008fff7, 0xfff6fff7, 0x1211fff7, 0xededfff7, 0x1b08fff7, 0xe4f6fff7, 0x091afff7, 0xf6e4fff7, - 0x00001212, 0x09091212, 0xf6f71212, 0x09001212, 0xf7001212, 0x00091212, 0xfff71212, 0x12121212, - 0xedee1212, 0x1b091212, 0xe4f71212, 0x091b1212, 0xf6e51212, 0xffffedee, 0x0908edee, 0xf6f6edee, - 0x08ffedee, 0xf6ffedee, 0x0008edee, 0xfff6edee, 0x1211edee, 0xedededee, 0x1b08edee, 0xe4f6edee, - 0x091aedee, 0xf6e4edee, 0x00001b09, 0x09091b09, 0xf6f71b09, 0x09001b09, 0xf7001b09, 0x00091b09, - 0xfff71b09, 0x12121b09, 0xedee1b09, 0x1b091b09, 0xe4f71b09, 0x091b1b09, 0xf6e51b09, 0xffffe4f7, - 0x0908e4f7, 0xf6f6e4f7, 0x08ffe4f7, 0xf6ffe4f7, 0x0008e4f7, 0xfff6e4f7, 0x1211e4f7, 0xedede4f7, - 0x1b08e4f7, 0xe4f6e4f7, 0x091ae4f7, 0xf6e4e4f7, 0x0000091b, 0x0909091b, 0xf6f7091b, 0x0900091b, - 0xf700091b, 0x0009091b, 0xfff7091b, 0x1212091b, 0xedee091b, 0x1b09091b, 0xe4f7091b, 0x091b091b, - 0xf6e5091b, 0xfffff6e5, 0x0908f6e5, 0xf6f6f6e5, 0x08fff6e5, 0xf6fff6e5, 0x0008f6e5, 0xfff6f6e5, - 0x1211f6e5, 0xededf6e5, 0x1b08f6e5, 0xe4f6f6e5, 0x091af6e5, 0xf6e4f6e5, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000202, 0xfffffdfe, 0x00000300, 0xfffffd00, 0x00000003, 0xfffffffd, 0x00000606, - 0xfffff9fa, 0x00000700, 0xfffff900, 0x00000007, 0xfffffff9, 0x000004fb, 0xfffffb05, 0xfffffb05, - 0x000004fb, 0x00000b06, 0xfffff4fa, 0x0000060b, 0xfffff9f5, 0x00000800, 0xfffff800, 0x00000008, - 0xfffffff8, 0x00000b0b, 0xfffff4f5, 0x00000c00, 0xfffff400, 0x0000000c, 0xfffffff4, 0x0000110c, - 0xffffeef4, 0x00000c11, 0xfffff3ef, 0x00001111, 0xffffeeef, 0x00001206, 0xffffedfa, 0x00000612, - 0xfffff9ee, 0x00000af8, 0xfffff508, 0xfffff80b, 0x000007f5, 0x00000f00, 0xfffff100, 0x0000000f, - 0xfffffff1, 0x00001400, 0xffffec00, 0x00000014, 0xffffffec, 0x00001912, 0xffffe6ee, 0x00001219, - 0xffffede7, 0x0000190b, 0xffffe6f5, 0x00000b19, 0xfffff4e7, 0x00001919, 0xffffe6e7, 0x00000df2, - 0xfffff20e, 0xfffff20e, 0x00000df2, 0x00001a00, 0xffffe600, 0x0000001a, 0xffffffe6, 0x000011f5, - 0xffffee0b, 0xfffff512, 0x00000aee, 0x000015f9, 0xffffea07, 0xfffff916, 0x000006ea, 0x0000221a, - 0xffffdde6, 0x00001a22, 0xffffe5de, 0x00002212, 0xffffddee, 0x00001222, 0xffffedde, 0x00002222, - 0xffffddde, 0x0000230b, 0xffffdcf5, 0x00000b23, 0xfffff4dd, 0x00001d00, 0xffffe300, 0x0000001d, - 0xffffffe3, 0x000015ed, 0xffffea13, 0xffffed16, 0x000012ea, 0x000019f1, 0xffffe60f, 0xfffff11a, - 0x00000ee6, 0x00002500, 0xffffdb00, 0x00000025, 0xffffffdb, 0x00002c1b, 0xffffd3e5, 0x00001b2c, - 0xffffe4d4, 0x00002c24, 0xffffd3dc, 0x0000242c, 0xffffdbd4, 0x00002c12, 0xffffd3ee, 0x0000122c, - 0xffffedd4, 0x000020f6, 0xffffdf0a, 0xfffff621, 0x000009df, 0x00002d2d, 0xffffd2d3, 0x00000000, - 0x00000000, 0x00000202, 0xfffffdfe, 0x00000300, 0xfffffd00, 0x00000003, 0xfffffffd, 0x00000606, - 0xfffff9fa, 0x00000700, 0xfffff900, 0x02020000, 0x02020202, 0x0201fdfe, 0x02020300, 0x0201fd00, - 0x02020003, 0x0201fffd, 0x02020606, 0x0201f9fa, 0x02020700, 0x0201f900, 0xfdfe0000, 0xfdfe0202, - 0xfdfdfdfe, 0xfdfe0300, 0xfdfdfd00, 0xfdfe0003, 0xfdfdfffd, 0xfdfe0606, 0xfdfdf9fa, 0xfdfe0700, - 0xfdfdf900, 0x03000000, 0x03000202, 0x02fffdfe, 0x03000300, 0x02fffd00, 0x03000003, 0x02fffffd, - 0x03000606, 0x02fff9fa, 0x03000700, 0x02fff900, 0xfd000000, 0xfd000202, 0xfcfffdfe, 0xfd000300, - 0xfcfffd00, 0xfd000003, 0xfcfffffd, 0xfd000606, 0xfcfff9fa, 0xfd000700, 0xfcfff900, 0x00030000, - 0x00030202, 0x0002fdfe, 0x00030300, 0x0002fd00, 0x00030003, 0x0002fffd, 0x00030606, 0x0002f9fa, - 0x00030700, 0x0002f900, 0xfffd0000, 0xfffd0202, 0xfffcfdfe, 0xfffd0300, 0xfffcfd00, 0xfffd0003, - 0xfffcfffd, 0xfffd0606, 0xfffcf9fa, 0xfffd0700, 0xfffcf900, 0x06060000, 0x06060202, 0x0605fdfe, - 0x06060300, 0x0605fd00, 0x06060003, 0x0605fffd, 0x06060606, 0x0605f9fa, 0x06060700, 0x0605f900, - 0xf9fa0000, 0xf9fa0202, 0xf9f9fdfe, 0xf9fa0300, 0xf9f9fd00, 0xf9fa0003, 0xf9f9fffd, 0xf9fa0606, - 0xf9f9f9fa, 0xf9fa0700, 0xf9f9f900, 0x07000000, 0x07000202, 0x06fffdfe, 0x07000300, 0x06fffd00, - 0x07000003, 0x06fffffd, 0x07000606, 0x06fff9fa, 0x07000700, 0x06fff900, 0xf9000000, 0xf9000202, - 0xf8fffdfe, 0xf9000300, 0xf8fffd00, 0xf9000003, 0xf8fffffd, 0xf9000606, 0xf8fff9fa, 0xf9000700, - 0xf8fff900, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000200, 0xfffffe00, 0x00000002, 0xfffffffe, 0x00000202, 0xfffffdfe, 0x00000606, - 0xfffff9fa, 0x00000600, 0xfffffa00, 0x00000006, 0xfffffffa, 0x000003fc, 0xfffffc04, 0xfffffa0a, - 0x000005f6, 0xfffff400, 0x00000c00, 0xfffff3fa, 0xfffff406, 0x00000bfa, 0x00000c06, 0xfffffff2, - 0x0000000e, 0x00000c0c, 0xfffff3f4, 0xffffee00, 0x00001200, 0xfffff40e, 0x00000bf2, 0xfffff9ee, - 0xfffffa12, 0x000005ee, 0x00000612, 0xffffedf6, 0xffffee0a, 0x000011f6, 0x0000120a, 0xffffffea, - 0x00000016, 0xffffe800, 0x00001800, 0xfffff3ea, 0xfffff416, 0x00000bea, 0x00000c16, 0xffffe7f8, - 0xffffe808, 0x000017f8, 0x00001808, 0xfffff9e6, 0xfffffa1a, 0x000005e6, 0x0000061a, 0xffffffe4, - 0x0000001c, 0x00001414, 0xffffebec, 0xffffe5f2, 0x00001a0e, 0xfffff3e2, 0x00000c1e, 0xffffdff6, - 0x0000200a, 0xffffdfee, 0x00002012, 0xffffe5e6, 0x00001a1a, 0xffffebde, 0x00001422, 0xfffff3da, - 0x00000c26, 0xffffdfe0, 0x00002020, 0x00002020, 0xffffd7ea, 0xffffddde, 0x00002222, 0x00000000, - 0x00000200, 0xfffffe00, 0x00000002, 0xfffffffe, 0x00000202, 0xfffffdfe, 0x00000606, 0xfffff9fa, - 0x00000600, 0xfffffa00, 0x00000006, 0xfffffffa, 0x02000000, 0x02000200, 0x01fffe00, 0x02000002, - 0x01fffffe, 0x02000202, 0x01fffdfe, 0x02000606, 0x01fff9fa, 0x02000600, 0x01fffa00, 0x02000006, - 0x01fffffa, 0xfe000000, 0xfe000200, 0xfdfffe00, 0xfe000002, 0xfdfffffe, 0xfe000202, 0xfdfffdfe, - 0xfe000606, 0xfdfff9fa, 0xfe000600, 0xfdfffa00, 0xfe000006, 0xfdfffffa, 0x00020000, 0x00020200, - 0x0001fe00, 0x00020002, 0x0001fffe, 0x00020202, 0x0001fdfe, 0x00020606, 0x0001f9fa, 0x00020600, - 0x0001fa00, 0x00020006, 0x0001fffa, 0xfffe0000, 0xfffe0200, 0xfffdfe00, 0xfffe0002, 0xfffdfffe, - 0xfffe0202, 0xfffdfdfe, 0xfffe0606, 0xfffdf9fa, 0xfffe0600, 0xfffdfa00, 0xfffe0006, 0xfffdfffa, - 0x02020000, 0x02020200, 0x0201fe00, 0x02020002, 0x0201fffe, 0x02020202, 0x0201fdfe, 0x02020606, - 0x0201f9fa, 0x02020600, 0x0201fa00, 0x02020006, 0x0201fffa, 0xfdfe0000, 0xfdfe0200, 0xfdfdfe00, - 0xfdfe0002, 0xfdfdfffe, 0xfdfe0202, 0xfdfdfdfe, 0xfdfe0606, 0xfdfdf9fa, 0xfdfe0600, 0xfdfdfa00, - 0xfdfe0006, 0xfdfdfffa, 0x06060000, 0x06060200, 0x0605fe00, 0x06060002, 0x0605fffe, 0x06060202, - 0x0605fdfe, 0x06060606, 0x0605f9fa, 0x06060600, 0x0605fa00, 0x06060006, 0x0605fffa, 0xf9fa0000, - 0xf9fa0200, 0xf9f9fe00, 0xf9fa0002, 0xf9f9fffe, 0xf9fa0202, 0xf9f9fdfe, 0xf9fa0606, 0xf9f9f9fa, - 0xf9fa0600, 0xf9f9fa00, 0xf9fa0006, 0xf9f9fffa, 0x06000000, 0x06000200, 0x05fffe00, 0x06000002, - 0x05fffffe, 0x06000202, 0x05fffdfe, 0x06000606, 0x05fff9fa, 0x06000600, 0x05fffa00, 0x06000006, - 0x05fffffa, 0xfa000000, 0xfa000200, 0xf9fffe00, 0xfa000002, 0xf9fffffe, 0xfa000202, 0xf9fffdfe, - 0xfa000606, 0xf9fff9fa, 0xfa000600, 0xf9fffa00, 0xfa000006, 0xf9fffffa, 0x00060000, 0x00060200, - 0x0005fe00, 0x00060002, 0x0005fffe, 0x00060202, 0x0005fdfe, 0x00060606, 0x0005f9fa, 0x00060600, - 0x0005fa00, 0x00060006, 0x0005fffa, 0xfffa0000, 0xfffa0200, 0xfff9fe00, 0xfffa0002, 0xfff9fffe, - 0xfffa0202, 0xfff9fdfe, 0xfffa0606, 0xfff9f9fa, 0xfffa0600, 0xfff9fa00, 0xfffa0006, 0xfff9fffa, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000200, 0xfffffe00, 0x00000002, 0xfffffffe, 0x00000404, 0xfffffbfc, 0x00000a0a, - 0xfffff5f6, 0x00000a00, 0xfffff600, 0x0000000a, 0xfffffff6, 0x000005fa, 0xfffffa06, 0xfffff80e, - 0x000007f2, 0xffffffee, 0x00000012, 0xfffff00a, 0x00000ff6, 0xffffe800, 0x00001800, 0xfffff7e8, - 0xfffff818, 0x000007e8, 0x00000818, 0x00001212, 0xffffedee, 0xfffff014, 0x00000fec, 0xffffe5f2, - 0xffffe60e, 0x000019f2, 0x00001a0e, 0xffffffe2, 0x0000001e, 0xffffde00, 0x00002200, 0xfffff7de, - 0xfffff822, 0x000007de, 0x00000822, 0xffffede2, 0xffffee1e, 0x000011e2, 0x0000121e, 0xffffddf6, - 0xffffde0a, 0x000021f6, 0x0000220a, 0xffffddec, 0x00002214, 0xffffffd8, 0x00000028, 0x00001e1e, - 0xffffe1e2, 0xffffedd8, 0x00001228, 0xffffd400, 0x00002c00, 0xffffd3f0, 0x00002c10, 0xffffdbdc, - 0xffffdbdc, 0x00002424, 0xffffd3e6, 0x00002c1a, 0xffffe5d2, 0x00001a2e, 0xffffedcc, 0x00001234, - 0xffffc9ec, 0xffffd3d4, 0x00002c2c, 0xffffc9e0, 0xffffd1d2, 0xffffd1d2, 0x00002e2e, 0x00000000, - 0x00000200, 0xfffffe00, 0x00000002, 0xfffffffe, 0x00000404, 0xfffffbfc, 0x00000a0a, 0xfffff5f6, - 0x00000a00, 0xfffff600, 0x0000000a, 0xfffffff6, 0x02000000, 0x02000200, 0x01fffe00, 0x02000002, - 0x01fffffe, 0x02000404, 0x01fffbfc, 0x02000a0a, 0x01fff5f6, 0x02000a00, 0x01fff600, 0x0200000a, - 0x01fffff6, 0xfe000000, 0xfe000200, 0xfdfffe00, 0xfe000002, 0xfdfffffe, 0xfe000404, 0xfdfffbfc, - 0xfe000a0a, 0xfdfff5f6, 0xfe000a00, 0xfdfff600, 0xfe00000a, 0xfdfffff6, 0x00020000, 0x00020200, - 0x0001fe00, 0x00020002, 0x0001fffe, 0x00020404, 0x0001fbfc, 0x00020a0a, 0x0001f5f6, 0x00020a00, - 0x0001f600, 0x0002000a, 0x0001fff6, 0xfffe0000, 0xfffe0200, 0xfffdfe00, 0xfffe0002, 0xfffdfffe, - 0xfffe0404, 0xfffdfbfc, 0xfffe0a0a, 0xfffdf5f6, 0xfffe0a00, 0xfffdf600, 0xfffe000a, 0xfffdfff6, - 0x04040000, 0x04040200, 0x0403fe00, 0x04040002, 0x0403fffe, 0x04040404, 0x0403fbfc, 0x04040a0a, - 0x0403f5f6, 0x04040a00, 0x0403f600, 0x0404000a, 0x0403fff6, 0xfbfc0000, 0xfbfc0200, 0xfbfbfe00, - 0xfbfc0002, 0xfbfbfffe, 0xfbfc0404, 0xfbfbfbfc, 0xfbfc0a0a, 0xfbfbf5f6, 0xfbfc0a00, 0xfbfbf600, - 0xfbfc000a, 0xfbfbfff6, 0x0a0a0000, 0x0a0a0200, 0x0a09fe00, 0x0a0a0002, 0x0a09fffe, 0x0a0a0404, - 0x0a09fbfc, 0x0a0a0a0a, 0x0a09f5f6, 0x0a0a0a00, 0x0a09f600, 0x0a0a000a, 0x0a09fff6, 0xf5f60000, - 0xf5f60200, 0xf5f5fe00, 0xf5f60002, 0xf5f5fffe, 0xf5f60404, 0xf5f5fbfc, 0xf5f60a0a, 0xf5f5f5f6, - 0xf5f60a00, 0xf5f5f600, 0xf5f6000a, 0xf5f5fff6, 0x0a000000, 0x0a000200, 0x09fffe00, 0x0a000002, - 0x09fffffe, 0x0a000404, 0x09fffbfc, 0x0a000a0a, 0x09fff5f6, 0x0a000a00, 0x09fff600, 0x0a00000a, - 0x09fffff6, 0xf6000000, 0xf6000200, 0xf5fffe00, 0xf6000002, 0xf5fffffe, 0xf6000404, 0xf5fffbfc, - 0xf6000a0a, 0xf5fff5f6, 0xf6000a00, 0xf5fff600, 0xf600000a, 0xf5fffff6, 0x000a0000, 0x000a0200, - 0x0009fe00, 0x000a0002, 0x0009fffe, 0x000a0404, 0x0009fbfc, 0x000a0a0a, 0x0009f5f6, 0x000a0a00, - 0x0009f600, 0x000a000a, 0x0009fff6, 0xfff60000, 0xfff60200, 0xfff5fe00, 0xfff60002, 0xfff5fffe, - 0xfff60404, 0xfff5fbfc, 0xfff60a0a, 0xfff5f5f6, 0xfff60a00, 0xfff5f600, 0xfff6000a, 0xfff5fff6, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000400, 0xfffffc00, 0x00000004, 0xfffffffc, 0x00000404, 0xfffffbfc, 0x00000c0c, - 0xfffff3f4, 0x00000c00, 0xfffff400, 0x0000000c, 0xfffffff4, 0x000007f8, 0xfffff808, 0xfffff008, - 0x00000ff8, 0xffffe800, 0x00001800, 0xfffff7e8, 0xfffff818, 0x000007e8, 0x00000818, 0xfffff014, - 0x00000fec, 0xffffffe4, 0x0000001c, 0xffffe7f0, 0xffffe810, 0x000017f0, 0x00001810, 0xffffe000, - 0x00002000, 0xffffefe4, 0xfffff01c, 0x00000fe4, 0x0000101c, 0xffffdff8, 0xffffe008, 0xfffff7e0, - 0xfffff820, 0x000007e0, 0x00000820, 0x00001ff8, 0x00002008, 0x00001818, 0xffffe7e8, 0xffffe818, - 0x000017e8, 0xffffdfec, 0x00002014, 0xffffffd8, 0x00000028, 0xffffefd8, 0x00001028, 0xffffd400, - 0xffffd400, 0xffffffd4, 0x0000002c, 0x00002c00, 0x00002c00, 0xffffdfe0, 0x00002020, 0xffffd3f0, - 0x00002c10, 0xffffd3e8, 0xffffe7d4, 0x0000182c, 0x00002c18, 0xffffefd0, 0x00001030, 0xffffdbdc, - 0xffffdbdc, 0x00002424, 0x00002424, 0xffffcbec, 0x00002828, 0xffffd7d8, 0xffffcbe0, 0x00000000, - 0x00000400, 0xfffffc00, 0x00000004, 0xfffffffc, 0x00000404, 0xfffffbfc, 0x00000c0c, 0xfffff3f4, - 0x00000c00, 0xfffff400, 0x0000000c, 0xfffffff4, 0x04000000, 0x04000400, 0x03fffc00, 0x04000004, - 0x03fffffc, 0x04000404, 0x03fffbfc, 0x04000c0c, 0x03fff3f4, 0x04000c00, 0x03fff400, 0x0400000c, - 0x03fffff4, 0xfc000000, 0xfc000400, 0xfbfffc00, 0xfc000004, 0xfbfffffc, 0xfc000404, 0xfbfffbfc, - 0xfc000c0c, 0xfbfff3f4, 0xfc000c00, 0xfbfff400, 0xfc00000c, 0xfbfffff4, 0x00040000, 0x00040400, - 0x0003fc00, 0x00040004, 0x0003fffc, 0x00040404, 0x0003fbfc, 0x00040c0c, 0x0003f3f4, 0x00040c00, - 0x0003f400, 0x0004000c, 0x0003fff4, 0xfffc0000, 0xfffc0400, 0xfffbfc00, 0xfffc0004, 0xfffbfffc, - 0xfffc0404, 0xfffbfbfc, 0xfffc0c0c, 0xfffbf3f4, 0xfffc0c00, 0xfffbf400, 0xfffc000c, 0xfffbfff4, - 0x04040000, 0x04040400, 0x0403fc00, 0x04040004, 0x0403fffc, 0x04040404, 0x0403fbfc, 0x04040c0c, - 0x0403f3f4, 0x04040c00, 0x0403f400, 0x0404000c, 0x0403fff4, 0xfbfc0000, 0xfbfc0400, 0xfbfbfc00, - 0xfbfc0004, 0xfbfbfffc, 0xfbfc0404, 0xfbfbfbfc, 0xfbfc0c0c, 0xfbfbf3f4, 0xfbfc0c00, 0xfbfbf400, - 0xfbfc000c, 0xfbfbfff4, 0x0c0c0000, 0x0c0c0400, 0x0c0bfc00, 0x0c0c0004, 0x0c0bfffc, 0x0c0c0404, - 0x0c0bfbfc, 0x0c0c0c0c, 0x0c0bf3f4, 0x0c0c0c00, 0x0c0bf400, 0x0c0c000c, 0x0c0bfff4, 0xf3f40000, - 0xf3f40400, 0xf3f3fc00, 0xf3f40004, 0xf3f3fffc, 0xf3f40404, 0xf3f3fbfc, 0xf3f40c0c, 0xf3f3f3f4, - 0xf3f40c00, 0xf3f3f400, 0xf3f4000c, 0xf3f3fff4, 0x0c000000, 0x0c000400, 0x0bfffc00, 0x0c000004, - 0x0bfffffc, 0x0c000404, 0x0bfffbfc, 0x0c000c0c, 0x0bfff3f4, 0x0c000c00, 0x0bfff400, 0x0c00000c, - 0x0bfffff4, 0xf4000000, 0xf4000400, 0xf3fffc00, 0xf4000004, 0xf3fffffc, 0xf4000404, 0xf3fffbfc, - 0xf4000c0c, 0xf3fff3f4, 0xf4000c00, 0xf3fff400, 0xf400000c, 0xf3fffff4, 0x000c0000, 0x000c0400, - 0x000bfc00, 0x000c0004, 0x000bfffc, 0x000c0404, 0x000bfbfc, 0x000c0c0c, 0x000bf3f4, 0x000c0c00, - 0x000bf400, 0x000c000c, 0x000bfff4, 0xfff40000, 0xfff40400, 0xfff3fc00, 0xfff40004, 0xfff3fffc, - 0xfff40404, 0xfff3fbfc, 0xfff40c0c, 0xfff3f3f4, 0xfff40c00, 0xfff3f400, 0xfff4000c, 0xfff3fff4, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000202, 0xfffffdfe, 0x00000606, 0xfffff9fa, 0x00000c0c, 0xfffff3f4, 0x00001414, - 0xffffebec, 0x00002020, 0xffffdfe0, 0x00002e2e, 0xffffd1d2, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000202, 0xfffffdfe, 0x00000606, 0xfffff9fa, 0x00000c0c, 0xfffff3f4, 0x00001414, 0xffffebec, - 0x00002020, 0xffffdfe0, 0x00002e2e, 0xffffd1d2, 0x02020000, 0x02020202, 0x0201fdfe, 0x02020606, - 0x0201f9fa, 0x02020c0c, 0x0201f3f4, 0x02021414, 0x0201ebec, 0x02022020, 0x0201dfe0, 0x02022e2e, - 0x0201d1d2, 0xfdfe0000, 0xfdfe0202, 0xfdfdfdfe, 0xfdfe0606, 0xfdfdf9fa, 0xfdfe0c0c, 0xfdfdf3f4, - 0xfdfe1414, 0xfdfdebec, 0xfdfe2020, 0xfdfddfe0, 0xfdfe2e2e, 0xfdfdd1d2, 0x06060000, 0x06060202, - 0x0605fdfe, 0x06060606, 0x0605f9fa, 0x06060c0c, 0x0605f3f4, 0x06061414, 0x0605ebec, 0x06062020, - 0x0605dfe0, 0x06062e2e, 0x0605d1d2, 0xf9fa0000, 0xf9fa0202, 0xf9f9fdfe, 0xf9fa0606, 0xf9f9f9fa, - 0xf9fa0c0c, 0xf9f9f3f4, 0xf9fa1414, 0xf9f9ebec, 0xf9fa2020, 0xf9f9dfe0, 0xf9fa2e2e, 0xf9f9d1d2, - 0x0c0c0000, 0x0c0c0202, 0x0c0bfdfe, 0x0c0c0606, 0x0c0bf9fa, 0x0c0c0c0c, 0x0c0bf3f4, 0x0c0c1414, - 0x0c0bebec, 0x0c0c2020, 0x0c0bdfe0, 0x0c0c2e2e, 0x0c0bd1d2, 0xf3f40000, 0xf3f40202, 0xf3f3fdfe, - 0xf3f40606, 0xf3f3f9fa, 0xf3f40c0c, 0xf3f3f3f4, 0xf3f41414, 0xf3f3ebec, 0xf3f42020, 0xf3f3dfe0, - 0xf3f42e2e, 0xf3f3d1d2, 0x14140000, 0x14140202, 0x1413fdfe, 0x14140606, 0x1413f9fa, 0x14140c0c, - 0x1413f3f4, 0x14141414, 0x1413ebec, 0x14142020, 0x1413dfe0, 0x14142e2e, 0x1413d1d2, 0xebec0000, - 0xebec0202, 0xebebfdfe, 0xebec0606, 0xebebf9fa, 0xebec0c0c, 0xebebf3f4, 0xebec1414, 0xebebebec, - 0xebec2020, 0xebebdfe0, 0xebec2e2e, 0xebebd1d2, 0x20200000, 0x20200202, 0x201ffdfe, 0x20200606, - 0x201ff9fa, 0x20200c0c, 0x201ff3f4, 0x20201414, 0x201febec, 0x20202020, 0x201fdfe0, 0x20202e2e, - 0x201fd1d2, 0xdfe00000, 0xdfe00202, 0xdfdffdfe, 0xdfe00606, 0xdfdff9fa, 0xdfe00c0c, 0xdfdff3f4, - 0xdfe01414, 0xdfdfebec, 0xdfe02020, 0xdfdfdfe0, 0xdfe02e2e, 0xdfdfd1d2, 0x2e2e0000, 0x2e2e0202, - 0x2e2dfdfe, 0x2e2e0606, 0x2e2df9fa, 0x2e2e0c0c, 0x2e2df3f4, 0x2e2e1414, 0x2e2debec, 0x2e2e2020, - 0x2e2ddfe0, 0x2e2e2e2e, 0x2e2dd1d2, 0xd1d20000, 0xd1d20202, 0xd1d1fdfe, 0xd1d20606, 0xd1d1f9fa, - 0xd1d20c0c, 0xd1d1f3f4, 0xd1d21414, 0xd1d1ebec, 0xd1d22020, 0xd1d1dfe0, 0xd1d22e2e, 0xd1d1d1d2, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000202, 0xfffffdfe, 0x00000606, 0xfffff9fa, 0x00000c0c, 0xfffff3f4, 0x00001414, - 0xffffebec, 0x00002020, 0xffffdfe0, 0x00002e2e, 0xffffd1d2, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000202, 0xfffffdfe, 0x00000606, 0xfffff9fa, 0x00000c0c, 0xfffff3f4, 0x00001414, 0xffffebec, - 0x00002020, 0xffffdfe0, 0x00002e2e, 0xffffd1d2, 0x02020000, 0x02020202, 0x0201fdfe, 0x02020606, - 0x0201f9fa, 0x02020c0c, 0x0201f3f4, 0x02021414, 0x0201ebec, 0x02022020, 0x0201dfe0, 0x02022e2e, - 0x0201d1d2, 0xfdfe0000, 0xfdfe0202, 0xfdfdfdfe, 0xfdfe0606, 0xfdfdf9fa, 0xfdfe0c0c, 0xfdfdf3f4, - 0xfdfe1414, 0xfdfdebec, 0xfdfe2020, 0xfdfddfe0, 0xfdfe2e2e, 0xfdfdd1d2, 0x06060000, 0x06060202, - 0x0605fdfe, 0x06060606, 0x0605f9fa, 0x06060c0c, 0x0605f3f4, 0x06061414, 0x0605ebec, 0x06062020, - 0x0605dfe0, 0x06062e2e, 0x0605d1d2, 0xf9fa0000, 0xf9fa0202, 0xf9f9fdfe, 0xf9fa0606, 0xf9f9f9fa, - 0xf9fa0c0c, 0xf9f9f3f4, 0xf9fa1414, 0xf9f9ebec, 0xf9fa2020, 0xf9f9dfe0, 0xf9fa2e2e, 0xf9f9d1d2, - 0x0c0c0000, 0x0c0c0202, 0x0c0bfdfe, 0x0c0c0606, 0x0c0bf9fa, 0x0c0c0c0c, 0x0c0bf3f4, 0x0c0c1414, - 0x0c0bebec, 0x0c0c2020, 0x0c0bdfe0, 0x0c0c2e2e, 0x0c0bd1d2, 0xf3f40000, 0xf3f40202, 0xf3f3fdfe, - 0xf3f40606, 0xf3f3f9fa, 0xf3f40c0c, 0xf3f3f3f4, 0xf3f41414, 0xf3f3ebec, 0xf3f42020, 0xf3f3dfe0, - 0xf3f42e2e, 0xf3f3d1d2, 0x14140000, 0x14140202, 0x1413fdfe, 0x14140606, 0x1413f9fa, 0x14140c0c, - 0x1413f3f4, 0x14141414, 0x1413ebec, 0x14142020, 0x1413dfe0, 0x14142e2e, 0x1413d1d2, 0xebec0000, - 0xebec0202, 0xebebfdfe, 0xebec0606, 0xebebf9fa, 0xebec0c0c, 0xebebf3f4, 0xebec1414, 0xebebebec, - 0xebec2020, 0xebebdfe0, 0xebec2e2e, 0xebebd1d2, 0x20200000, 0x20200202, 0x201ffdfe, 0x20200606, - 0x201ff9fa, 0x20200c0c, 0x201ff3f4, 0x20201414, 0x201febec, 0x20202020, 0x201fdfe0, 0x20202e2e, - 0x201fd1d2, 0xdfe00000, 0xdfe00202, 0xdfdffdfe, 0xdfe00606, 0xdfdff9fa, 0xdfe00c0c, 0xdfdff3f4, - 0xdfe01414, 0xdfdfebec, 0xdfe02020, 0xdfdfdfe0, 0xdfe02e2e, 0xdfdfd1d2, 0x2e2e0000, 0x2e2e0202, - 0x2e2dfdfe, 0x2e2e0606, 0x2e2df9fa, 0x2e2e0c0c, 0x2e2df3f4, 0x2e2e1414, 0x2e2debec, 0x2e2e2020, - 0x2e2ddfe0, 0x2e2e2e2e, 0x2e2dd1d2, 0xd1d20000, 0xd1d20202, 0xd1d1fdfe, 0xd1d20606, 0xd1d1f9fa, - 0xd1d20c0c, 0xd1d1f3f4, 0xd1d21414, 0xd1d1ebec, 0xd1d22020, 0xd1d1dfe0, 0xd1d22e2e, 0xd1d1d1d2, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000202, 0xfffffdfe, 0x00000606, 0xfffff9fa, 0x00000c0c, 0xfffff3f4, 0x00001414, - 0xffffebec, 0x00002020, 0xffffdfe0, 0x00002e2e, 0xffffd1d2, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000202, 0xfffffdfe, 0x00000606, 0xfffff9fa, 0x00000c0c, 0xfffff3f4, 0x00001414, 0xffffebec, - 0x00002020, 0xffffdfe0, 0x00002e2e, 0xffffd1d2, 0x02020000, 0x02020202, 0x0201fdfe, 0x02020606, - 0x0201f9fa, 0x02020c0c, 0x0201f3f4, 0x02021414, 0x0201ebec, 0x02022020, 0x0201dfe0, 0x02022e2e, - 0x0201d1d2, 0xfdfe0000, 0xfdfe0202, 0xfdfdfdfe, 0xfdfe0606, 0xfdfdf9fa, 0xfdfe0c0c, 0xfdfdf3f4, - 0xfdfe1414, 0xfdfdebec, 0xfdfe2020, 0xfdfddfe0, 0xfdfe2e2e, 0xfdfdd1d2, 0x06060000, 0x06060202, - 0x0605fdfe, 0x06060606, 0x0605f9fa, 0x06060c0c, 0x0605f3f4, 0x06061414, 0x0605ebec, 0x06062020, - 0x0605dfe0, 0x06062e2e, 0x0605d1d2, 0xf9fa0000, 0xf9fa0202, 0xf9f9fdfe, 0xf9fa0606, 0xf9f9f9fa, - 0xf9fa0c0c, 0xf9f9f3f4, 0xf9fa1414, 0xf9f9ebec, 0xf9fa2020, 0xf9f9dfe0, 0xf9fa2e2e, 0xf9f9d1d2, - 0x0c0c0000, 0x0c0c0202, 0x0c0bfdfe, 0x0c0c0606, 0x0c0bf9fa, 0x0c0c0c0c, 0x0c0bf3f4, 0x0c0c1414, - 0x0c0bebec, 0x0c0c2020, 0x0c0bdfe0, 0x0c0c2e2e, 0x0c0bd1d2, 0xf3f40000, 0xf3f40202, 0xf3f3fdfe, - 0xf3f40606, 0xf3f3f9fa, 0xf3f40c0c, 0xf3f3f3f4, 0xf3f41414, 0xf3f3ebec, 0xf3f42020, 0xf3f3dfe0, - 0xf3f42e2e, 0xf3f3d1d2, 0x14140000, 0x14140202, 0x1413fdfe, 0x14140606, 0x1413f9fa, 0x14140c0c, - 0x1413f3f4, 0x14141414, 0x1413ebec, 0x14142020, 0x1413dfe0, 0x14142e2e, 0x1413d1d2, 0xebec0000, - 0xebec0202, 0xebebfdfe, 0xebec0606, 0xebebf9fa, 0xebec0c0c, 0xebebf3f4, 0xebec1414, 0xebebebec, - 0xebec2020, 0xebebdfe0, 0xebec2e2e, 0xebebd1d2, 0x20200000, 0x20200202, 0x201ffdfe, 0x20200606, - 0x201ff9fa, 0x20200c0c, 0x201ff3f4, 0x20201414, 0x201febec, 0x20202020, 0x201fdfe0, 0x20202e2e, - 0x201fd1d2, 0xdfe00000, 0xdfe00202, 0xdfdffdfe, 0xdfe00606, 0xdfdff9fa, 0xdfe00c0c, 0xdfdff3f4, - 0xdfe01414, 0xdfdfebec, 0xdfe02020, 0xdfdfdfe0, 0xdfe02e2e, 0xdfdfd1d2, 0x2e2e0000, 0x2e2e0202, - 0x2e2dfdfe, 0x2e2e0606, 0x2e2df9fa, 0x2e2e0c0c, 0x2e2df3f4, 0x2e2e1414, 0x2e2debec, 0x2e2e2020, - 0x2e2ddfe0, 0x2e2e2e2e, 0x2e2dd1d2, 0xd1d20000, 0xd1d20202, 0xd1d1fdfe, 0xd1d20606, 0xd1d1f9fa, - 0xd1d20c0c, 0xd1d1f3f4, 0xd1d21414, 0xd1d1ebec, 0xd1d22020, 0xd1d1dfe0, 0xd1d22e2e, 0xd1d1d1d2, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000202, 0xfffffdfe, 0x00000606, 0xfffff9fa, 0x00000c0c, 0xfffff3f4, 0x00001414, - 0xffffebec, 0x00002020, 0xffffdfe0, 0x00002e2e, 0xffffd1d2, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000202, 0xfffffdfe, 0x00000606, 0xfffff9fa, 0x00000c0c, 0xfffff3f4, 0x00001414, 0xffffebec, - 0x00002020, 0xffffdfe0, 0x00002e2e, 0xffffd1d2, 0x02020000, 0x02020202, 0x0201fdfe, 0x02020606, - 0x0201f9fa, 0x02020c0c, 0x0201f3f4, 0x02021414, 0x0201ebec, 0x02022020, 0x0201dfe0, 0x02022e2e, - 0x0201d1d2, 0xfdfe0000, 0xfdfe0202, 0xfdfdfdfe, 0xfdfe0606, 0xfdfdf9fa, 0xfdfe0c0c, 0xfdfdf3f4, - 0xfdfe1414, 0xfdfdebec, 0xfdfe2020, 0xfdfddfe0, 0xfdfe2e2e, 0xfdfdd1d2, 0x06060000, 0x06060202, - 0x0605fdfe, 0x06060606, 0x0605f9fa, 0x06060c0c, 0x0605f3f4, 0x06061414, 0x0605ebec, 0x06062020, - 0x0605dfe0, 0x06062e2e, 0x0605d1d2, 0xf9fa0000, 0xf9fa0202, 0xf9f9fdfe, 0xf9fa0606, 0xf9f9f9fa, - 0xf9fa0c0c, 0xf9f9f3f4, 0xf9fa1414, 0xf9f9ebec, 0xf9fa2020, 0xf9f9dfe0, 0xf9fa2e2e, 0xf9f9d1d2, - 0x0c0c0000, 0x0c0c0202, 0x0c0bfdfe, 0x0c0c0606, 0x0c0bf9fa, 0x0c0c0c0c, 0x0c0bf3f4, 0x0c0c1414, - 0x0c0bebec, 0x0c0c2020, 0x0c0bdfe0, 0x0c0c2e2e, 0x0c0bd1d2, 0xf3f40000, 0xf3f40202, 0xf3f3fdfe, - 0xf3f40606, 0xf3f3f9fa, 0xf3f40c0c, 0xf3f3f3f4, 0xf3f41414, 0xf3f3ebec, 0xf3f42020, 0xf3f3dfe0, - 0xf3f42e2e, 0xf3f3d1d2, 0x14140000, 0x14140202, 0x1413fdfe, 0x14140606, 0x1413f9fa, 0x14140c0c, - 0x1413f3f4, 0x14141414, 0x1413ebec, 0x14142020, 0x1413dfe0, 0x14142e2e, 0x1413d1d2, 0xebec0000, - 0xebec0202, 0xebebfdfe, 0xebec0606, 0xebebf9fa, 0xebec0c0c, 0xebebf3f4, 0xebec1414, 0xebebebec, - 0xebec2020, 0xebebdfe0, 0xebec2e2e, 0xebebd1d2, 0x20200000, 0x20200202, 0x201ffdfe, 0x20200606, - 0x201ff9fa, 0x20200c0c, 0x201ff3f4, 0x20201414, 0x201febec, 0x20202020, 0x201fdfe0, 0x20202e2e, - 0x201fd1d2, 0xdfe00000, 0xdfe00202, 0xdfdffdfe, 0xdfe00606, 0xdfdff9fa, 0xdfe00c0c, 0xdfdff3f4, - 0xdfe01414, 0xdfdfebec, 0xdfe02020, 0xdfdfdfe0, 0xdfe02e2e, 0xdfdfd1d2, 0x2e2e0000, 0x2e2e0202, - 0x2e2dfdfe, 0x2e2e0606, 0x2e2df9fa, 0x2e2e0c0c, 0x2e2df3f4, 0x2e2e1414, 0x2e2debec, 0x2e2e2020, - 0x2e2ddfe0, 0x2e2e2e2e, 0x2e2dd1d2, 0xd1d20000, 0xd1d20202, 0xd1d1fdfe, 0xd1d20606, 0xd1d1f9fa, - 0xd1d20c0c, 0xd1d1f3f4, 0xd1d21414, 0xd1d1ebec, 0xd1d22020, 0xd1d1dfe0, 0xd1d22e2e, 0xd1d1d1d2, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 -}; +/* + * Define compressed VQ tables. + */ +#define TAB_1_1 \ + PD( 0, 0), E2( 2, 2), E4( -1, 3), E2( 4, 4), E4( 1, 5),\ + E2( -4, 4), E4( -2, 6), E4( 4, 9), E2( 9, 9), E4( 1, 10),\ + E4( -5, 8), E4( 9, 15), E4( -3, 12), E4( 4, 16), E2( 16, 16),\ + E4( 0, 18), E2( -12, 12), E4( -9, 16), E4( 11, 27), E4( 19, 28),\ + E4( -6, 22), E4( 4, 29), E2( 30, 30), E4( -2, 33), E4( -18, 23),\ + E4( -15, 30), E4( 22, 46), E4( 13, 47), E4( 35, 49), E4( -11, 41),\ + E4( 4, 51), E2( 54, 54), E2( -34, 34), E4( -29, 42), E4( -6, 60),\ + E4( 27, 76), E4( 43, 77), E4( -24, 55), E4( 14, 79), E4( 63, 83),\ + E4( -20, 74), E4( 2, 88), E2( 93, 93), E4( -52, 61), E4( 52, 120),\ + E4( -45, 75), E4( 75, 125), E4( 33, 122), E4( -13, 103), E4( -40, 96),\ + E4( -34, 127), E2( -89, 89), E4( -78, 105), E2( 12, 12), E2( 23, 23),\ + E2( 42, 42), E2( 73, 73) -static const uint32_t correctionloworder[] = { - 0x00000000, 0x02020202, 0xfdfdfdfe, 0x0302feff, 0xfcfd0101, 0xfeff0303, 0x0100fcfd, 0x04040404, - 0xfbfbfbfc, 0x05050101, 0xfafafeff, 0x01010505, 0xfefefafb, 0x0403fbfc, 0xfbfc0404, 0x0605fdfe, - 0xf9fa0202, 0xfdfe0606, 0x0201f9fa, 0x09090404, 0xf6f6fbfc, 0x04040909, 0xfbfbf6f7, 0x09090909, - 0xf6f6f6f7, 0x0a0a0101, 0xf5f5feff, 0x01010a0a, 0xfefef5f6, 0x0807fafb, 0xf7f80505, 0xfafb0808, - 0x0504f7f8, 0x0f0f0909, 0xf0f0f6f7, 0x09090f0f, 0xf6f6f0f1, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, - 0x0302f3f4, 0x10100404, 0xefeffbfc, 0x04041010, 0xfbfbeff0, 0x10101010, 0xefefeff0, 0x12120000, - 0xedee0000, 0x00001212, 0xffffedee, 0x0c0bf3f4, 0xf3f40c0c, 0x100ff6f7, 0xeff00909, 0xf6f71010, - 0x0908eff0, 0x1b1b0b0b, 0xe4e4f4f5, 0x0b0b1b1b, 0xf4f4e4e5, 0x1c1c1313, 0xe3e3eced, 0x13131c1c, - 0xecece3e4, 0x1615f9fa, 0xe9ea0606, 0xf9fa1616, 0x0605e9ea, 0x1d1d0404, 0xe2e2fbfc, 0x04041d1d, - 0xfbfbe2e3, 0x1e1e1e1e, 0xe1e1e1e2, 0x2120fdfe, 0xdedf0202, 0xfdfe2121, 0x0201dedf, 0x1716edee, - 0xe8e91212, 0xedee1717, 0x1211e8e9, 0x1e1df0f1, 0xe1e20f0f, 0xf0f11e1e, 0x0f0ee1e2, 0x2e2e1616, - 0xd1d1e9ea, 0x16162e2e, 0xe9e9d1d2, 0x2f2f0d0d, 0xd0d0f2f3, 0x0d0d2f2f, 0xf2f2d0d1, 0x31312323, - 0xcecedcdd, 0x23233131, 0xdcdccecf, 0x2928f4f5, 0xd6d70b0b, 0xf4f52929, 0x0b0ad6d7, 0x33330404, - 0xccccfbfc, 0x04043333, 0xfbfbcccd, 0x36363636, 0xc9c9c9ca, 0x2221ddde, 0xddde2222, 0x2a29e2e3, - 0xd5d61d1d, 0xe2e32a2a, 0x1d1cd5d6, 0x3c3bf9fa, 0xc3c40606, 0xf9fa3c3c, 0x0605c3c4, 0x4c4c1b1b, - 0xb3b3e4e5, 0x1b1b4c4c, 0xe4e4b3b4, 0x4d4d2b2b, 0xb2b2d4d5, 0x2b2b4d4d, 0xd4d4b2b3, 0x3736e7e8, - 0xc8c91818, 0xe7e83737, 0x1817c8c9, 0x4f4f0e0e, 0xb0b0f1f2, 0x0e0e4f4f, 0xf1f1b0b1, 0x53533f3f, - 0xacacc0c1, 0x3f3f5353, 0xc0c0acad, 0x4a49ebec, 0xb5b61414, 0xebec4a4a, 0x1413b5b6, 0x58580202, - 0xa7a7fdfe, 0x02025858, 0xfdfda7a8, 0x5d5d5d5d, 0xa2a2a2a3, 0x3d3ccbcc, 0xc2c33434, 0xcbcc3d3d, - 0x3433c2c3, 0x78783434, 0x8787cbcc, 0x34347878, 0xcbcb8788, 0x4b4ad2d3, 0xb4b52d2d, 0xd2d34b4b, - 0x2d2cb4b5, 0x7d7d4b4b, 0x8282b4b5, 0x4b4b7d7d, 0xb4b48283, 0x7a7a2121, 0x8585dedf, 0x21217a7a, - 0xdede8586, 0x6766f2f3, 0x98990d0d, 0xf2f36767, 0x0d0c9899, 0x605fd7d8, 0x9fa02828, 0xd7d86060, - 0x28279fa0, 0x7f7eddde, 0x80812222, 0xddde7f7f, 0x22218081, 0x5958a6a7, 0xa6a75959, 0x6968b1b2, - 0x96974e4e, 0xb1b26969, 0x4e4d9697, 0x0c0c0c0c, 0xf3f3f3f4, 0x17171717, 0xe8e8e8e9, 0x2a2a2a2a, - 0xd5d5d5d6, 0x49494949, 0xb6b6b6b7, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, - 0x02020202, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, - 0x0302feff, 0x0302feff, 0x0302feff, 0x0302feff, 0x0302feff, 0x0302feff, 0x0302feff, 0xfcfd0101, - 0xfcfd0101, 0xfcfd0101, 0xfcfd0101, 0xfcfd0101, 0xfcfd0101, 0xfcfd0101, 0xfeff0303, 0xfeff0303, - 0xfeff0303, 0xfeff0303, 0xfeff0303, 0xfeff0303, 0xfeff0303, 0x0100fcfd, 0x0100fcfd, 0x0100fcfd, - 0x0100fcfd, 0x0100fcfd, 0x0100fcfd, 0x0100fcfd, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x03030303, 0xfcfcfcfd, 0x0403feff, 0xfbfc0101, 0xfeff0404, 0x0100fbfc, 0x07070707, - 0xf8f8f8f9, 0x08080202, 0xf7f7fdfe, 0x02020808, 0xfdfdf7f8, 0x0908fdfe, 0xf6f70202, 0xfdfe0909, - 0x0201f6f7, 0x0605f9fa, 0xf9fa0606, 0x0d0d0606, 0xf2f2f9fa, 0x06060d0d, 0xf9f9f2f3, 0x0d0d0d0d, - 0xf2f2f2f3, 0x0e0e0101, 0xf1f1feff, 0x01010e0e, 0xfefef1f2, 0x0c0bf7f8, 0xf3f40808, 0xf7f80c0c, - 0x0807f3f4, 0x17170e0e, 0xe8e8f1f2, 0x0e0e1717, 0xf1f1e8e9, 0x1211fafb, 0xedee0505, 0xfafb1212, - 0x0504edee, 0x18180606, 0xe7e7f9fa, 0x06061818, 0xf9f9e7e8, 0x18181818, 0xe7e7e7e8, 0x1b1afeff, - 0xe4e50101, 0xfeff1b1b, 0x0100e4e5, 0x1110eeef, 0xeeef1111, 0x1716f2f3, 0xe8e90d0d, 0xf2f31717, - 0x0d0ce8e9, 0x28281010, 0xd7d7eff0, 0x10102828, 0xefefd7d8, 0x29291c1c, 0xd6d6e3e4, 0x1c1c2929, - 0xe3e3d6d7, 0x2120f6f7, 0xdedf0909, 0xf6f72121, 0x0908dedf, 0x2b2b0606, 0xd4d4f9fa, 0x06062b2b, - 0xf9f9d4d5, 0x2e2e2e2e, 0xd1d1d1d2, 0x3231fbfc, 0xcdce0404, 0xfbfc3232, 0x0403cdce, 0x2221e4e5, - 0xddde1b1b, 0xe4e52222, 0x1b1addde, 0x2d2ce9ea, 0xd2d31616, 0xe9ea2d2d, 0x1615d2d3, 0x45452222, - 0xbabaddde, 0x22224545, 0xddddbabb, 0x46461313, 0xb9b9eced, 0x13134646, 0xececb9ba, 0x49493535, - 0xb6b6cacb, 0x35354949, 0xcacab6b7, 0x3e3deeef, 0xc1c21111, 0xeeef3e3e, 0x1110c1c2, 0x4d4d0505, - 0xb2b2fafb, 0x05054d4d, 0xfafab2b3, 0x52525252, 0xadadadae, 0x3332cccd, 0xcccd3333, 0x403fd4d5, - 0xbfc02b2b, 0xd4d54040, 0x2b2abfc0, 0x5a59f5f6, 0xa5a60a0a, 0xf5f65a5a, 0x0a09a5a6, 0x72722929, - 0x8d8dd6d7, 0x29297272, 0xd6d68d8e, 0x74744040, 0x8b8bbfc0, 0x40407474, 0xbfbf8b8c, 0x5251dadb, - 0xadae2525, 0xdadb5252, 0x2524adae, 0x77771616, 0x8888e9ea, 0x16167777, 0xe9e98889, 0x7c7c5f5f, - 0x8383a0a1, 0x5f5f7c7c, 0xa0a08384, 0x6f6ee1e2, 0x90911e1e, 0xe1e26f6f, 0x1e1d9091, 0x5c5bb1b2, - 0xa3a44e4e, 0xb1b25c5c, 0x4e4da3a4, 0x7170bbbc, 0x8e8f4444, 0xbbbc7171, 0x44438e8f, 0x12121212, - 0xedededee, 0x22222222, 0xddddddde, 0x3f3f3f3f, 0xc0c0c0c1, 0x6d6d6d6d, 0x92929293, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x03030303, 0x03030303, 0x03030303, 0x03030303, 0x03030303, 0x03030303, 0x03030303, 0x03030303, - 0x03030303, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, - 0xfcfcfcfd, 0xfcfcfcfd, 0x0403feff, 0x0403feff, 0x0403feff, 0x0403feff, 0x0403feff, 0x0403feff, - 0x0403feff, 0x0403feff, 0x0403feff, 0xfbfc0101, 0xfbfc0101, 0xfbfc0101, 0xfbfc0101, 0xfbfc0101, - 0xfbfc0101, 0xfbfc0101, 0xfbfc0101, 0xfbfc0101, 0xfeff0404, 0xfeff0404, 0xfeff0404, 0xfeff0404, - 0xfeff0404, 0xfeff0404, 0xfeff0404, 0xfeff0404, 0xfeff0404, 0x0100fbfc, 0x0100fbfc, 0x0100fbfc, - 0x0100fbfc, 0x0100fbfc, 0x0100fbfc, 0x0100fbfc, 0x0100fbfc, 0x0100fbfc, 0x07070707, 0x07070707, - 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0xf8f8f8f9, - 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x04040404, 0xfbfbfbfc, 0x0504feff, 0xfafb0101, 0xfeff0505, 0x0100fafb, 0x0a0a0303, - 0xf5f5fcfd, 0x03030a0a, 0xfcfcf5f6, 0x09090909, 0xf6f6f6f7, 0x0706f8f9, 0xf8f90707, 0x0c0bfcfd, - 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x11110808, 0xeeeef7f8, 0x08081111, 0xf7f7eeef, 0x11111111, - 0xeeeeeeef, 0x13130101, 0xececfeff, 0x01011313, 0xfefeeced, 0x100ff4f5, 0xeff00b0b, 0xf4f51010, - 0x0b0aeff0, 0x1716f9fa, 0xe8e90606, 0xf9fa1717, 0x0605e8e9, 0x1f1f1212, 0xe0e0edee, 0x12121f1f, - 0xedede0e1, 0x20200808, 0xdfdff7f8, 0x08082020, 0xf7f7dfe0, 0x21212121, 0xdedededf, 0x2423feff, - 0xdbdc0101, 0xfeff2424, 0x0100dbdc, 0x1716e8e9, 0xe8e91717, 0x1f1eeeef, 0xe0e11111, 0xeeef1f1f, - 0x1110e0e1, 0x36361515, 0xc9c9eaeb, 0x15153636, 0xeaeac9ca, 0x37372525, 0xc8c8dadb, 0x25253737, - 0xdadac8c9, 0x2c2bf3f4, 0xd3d40c0c, 0xf3f42c2c, 0x0c0bd3d4, 0x39390808, 0xc6c6f7f8, 0x08083939, - 0xf7f7c6c7, 0x3d3d3d3d, 0xc2c2c2c3, 0x4241fafb, 0xbdbe0505, 0xfafb4242, 0x0504bdbe, 0x2d2cdbdc, - 0xd2d32424, 0xdbdc2d2d, 0x2423d2d3, 0x3c3be2e3, 0xc3c41d1d, 0xe2e33c3c, 0x1d1cc3c4, 0x5c5c2d2d, - 0xa3a3d2d3, 0x2d2d5c5c, 0xd2d2a3a4, 0x5d5d1919, 0xa2a2e6e7, 0x19195d5d, 0xe6e6a2a3, 0x61614747, - 0x9e9eb8b9, 0x47476161, 0xb8b89e9f, 0x5352e9ea, 0xacad1616, 0xe9ea5353, 0x1615acad, 0x66660707, - 0x9999f8f9, 0x07076666, 0xf8f8999a, 0x6d6d6d6d, 0x92929293, 0x4443bbbc, 0xbbbc4444, 0x5554c6c7, - 0xaaab3939, 0xc6c75555, 0x3938aaab, 0x7877f2f3, 0x87880d0d, 0xf2f37878, 0x0d0c8788, 0x6e6dcecf, - 0x91923131, 0xcecf6e6e, 0x31309192, 0x7b7a9798, 0x84856868, 0x97987b7b, 0x68678485, 0x18181818, - 0xe7e7e7e8, 0x2e2e2e2e, 0xd1d1d1d2, 0x54545454, 0xabababac, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x04040404, - 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, - 0x04040404, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, - 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0x0504feff, 0x0504feff, 0x0504feff, 0x0504feff, 0x0504feff, - 0x0504feff, 0x0504feff, 0x0504feff, 0x0504feff, 0x0504feff, 0xfafb0101, 0xfafb0101, 0xfafb0101, - 0xfafb0101, 0xfafb0101, 0xfafb0101, 0xfafb0101, 0xfafb0101, 0xfafb0101, 0xfafb0101, 0xfeff0505, - 0xfeff0505, 0xfeff0505, 0xfeff0505, 0xfeff0505, 0xfeff0505, 0xfeff0505, 0xfeff0505, 0xfeff0505, - 0xfeff0505, 0x0100fafb, 0x0100fafb, 0x0100fafb, 0x0100fafb, 0x0100fafb, 0x0100fafb, 0x0100fafb, - 0x0100fafb, 0x0100fafb, 0x0100fafb, 0x0a0a0303, 0x0a0a0303, 0x0a0a0303, 0x0a0a0303, 0x0a0a0303, - 0x0a0a0303, 0x0a0a0303, 0x0a0a0303, 0x0a0a0303, 0x0a0a0303, 0xf5f5fcfd, 0xf5f5fcfd, 0xf5f5fcfd, - 0xf5f5fcfd, 0xf5f5fcfd, 0xf5f5fcfd, 0xf5f5fcfd, 0xf5f5fcfd, 0xf5f5fcfd, 0xf5f5fcfd, 0x03030a0a, - 0x03030a0a, 0x03030a0a, 0x03030a0a, 0x03030a0a, 0x03030a0a, 0x03030a0a, 0x03030a0a, 0x03030a0a, - 0x03030a0a, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x05050505, 0xfafafafb, 0x0706fdfe, 0xf8f90202, 0xfdfe0707, 0x0201f8f9, 0x0b0b0b0b, - 0xf4f4f4f5, 0x0d0d0303, 0xf2f2fcfd, 0x03030d0d, 0xfcfcf2f3, 0x0908f6f7, 0xf6f70909, 0x0f0efbfc, - 0xf0f10404, 0xfbfc0f0f, 0x0403f0f1, 0x16160b0b, 0xe9e9f4f5, 0x0b0b1616, 0xf4f4e9ea, 0x15151515, - 0xeaeaeaeb, 0x18180202, 0xe7e7fdfe, 0x02021818, 0xfdfde7e8, 0x1413f1f2, 0xebec0e0e, 0xf1f21414, - 0x0e0debec, 0x26261717, 0xd9d9e8e9, 0x17172626, 0xe8e8d9da, 0x1d1cf7f8, 0xe2e30808, 0xf7f81d1d, - 0x0807e2e3, 0x27270b0b, 0xd8d8f4f5, 0x0b0b2727, 0xf4f4d8d9, 0x29292929, 0xd6d6d6d7, 0x2d2cfeff, - 0xd2d30101, 0xfeff2d2d, 0x0100d2d3, 0x1d1ce2e3, 0xe2e31d1d, 0x2726e9ea, 0xd8d91616, 0xe9ea2727, - 0x1615d8d9, 0x43431b1b, 0xbcbce4e5, 0x1b1b4343, 0xe4e4bcbd, 0x45452f2f, 0xbabad0d1, 0x2f2f4545, - 0xd0d0babb, 0x3837f0f1, 0xc7c80f0f, 0xf0f13838, 0x0f0ec7c8, 0x47470b0b, 0xb8b8f4f5, 0x0b0b4747, - 0xf4f4b8b9, 0x4c4c4c4c, 0xb3b3b3b4, 0x5352f9fa, 0xacad0606, 0xf9fa5353, 0x0605acad, 0x3938d2d3, - 0xc6c72d2d, 0xd2d33939, 0x2d2cc6c7, 0x4b4adbdc, 0xb4b52424, 0xdbdc4b4b, 0x2423b4b5, 0x73733838, - 0x8c8cc7c8, 0x38387373, 0xc7c78c8d, 0x75751f1f, 0x8a8ae0e1, 0x1f1f7575, 0xe0e08a8b, 0x7a7a5858, - 0x8585a7a8, 0x58587a7a, 0xa7a78586, 0x6867e3e4, 0x97981c1c, 0xe3e46868, 0x1c1b9798, 0x5554aaab, - 0xaaab5555, 0x6a69b7b8, 0x95964848, 0xb7b86a6a, 0x48479596, 0x1e1e1e1e, 0xe1e1e1e2, 0x3a3a3a3a, - 0xc5c5c5c6, 0x69696969, 0x96969697, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x05050505, 0x05050505, - 0x05050505, 0x05050505, 0x05050505, 0x05050505, 0x05050505, 0x05050505, 0x05050505, 0x05050505, - 0x05050505, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, - 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0x0706fdfe, 0x0706fdfe, 0x0706fdfe, 0x0706fdfe, - 0x0706fdfe, 0x0706fdfe, 0x0706fdfe, 0x0706fdfe, 0x0706fdfe, 0x0706fdfe, 0x0706fdfe, 0xf8f90202, - 0xf8f90202, 0xf8f90202, 0xf8f90202, 0xf8f90202, 0xf8f90202, 0xf8f90202, 0xf8f90202, 0xf8f90202, - 0xf8f90202, 0xf8f90202, 0xfdfe0707, 0xfdfe0707, 0xfdfe0707, 0xfdfe0707, 0xfdfe0707, 0xfdfe0707, - 0xfdfe0707, 0xfdfe0707, 0xfdfe0707, 0xfdfe0707, 0xfdfe0707, 0x0201f8f9, 0x0201f8f9, 0x0201f8f9, - 0x0201f8f9, 0x0201f8f9, 0x0201f8f9, 0x0201f8f9, 0x0201f8f9, 0x0201f8f9, 0x0201f8f9, 0x0201f8f9, - 0x0b0b0b0b, 0x0b0b0b0b, 0x0b0b0b0b, 0x0b0b0b0b, 0x0b0b0b0b, 0x0b0b0b0b, 0x0b0b0b0b, 0x0b0b0b0b, - 0x0b0b0b0b, 0x0b0b0b0b, 0x0b0b0b0b, 0xf4f4f4f5, 0xf4f4f4f5, 0xf4f4f4f5, 0xf4f4f4f5, 0xf4f4f4f5, - 0xf4f4f4f5, 0xf4f4f4f5, 0xf4f4f4f5, 0xf4f4f4f5, 0xf4f4f4f5, 0xf4f4f4f5, 0x0d0d0303, 0x0d0d0303, - 0x0d0d0303, 0x0d0d0303, 0x0d0d0303, 0x0d0d0303, 0x0d0d0303, 0x0d0d0303, 0x0d0d0303, 0x0d0d0303, - 0x0d0d0303, 0xf2f2fcfd, 0xf2f2fcfd, 0xf2f2fcfd, 0xf2f2fcfd, 0xf2f2fcfd, 0xf2f2fcfd, 0xf2f2fcfd, - 0xf2f2fcfd, 0xf2f2fcfd, 0xf2f2fcfd, 0xf2f2fcfd, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x06060606, 0xf9f9f9fa, 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, 0x0d0d0d0d, - 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, 0x04040f0f, 0xfbfbf0f1, 0x0b0af4f5, 0xf4f50b0b, 0x1211fafb, - 0xedee0505, 0xfafb1212, 0x0504edee, 0x1a1a0d0d, 0xe5e5f2f3, 0x0d0d1a1a, 0xf2f2e5e6, 0x1a1a1a1a, - 0xe5e5e5e6, 0x1d1d0202, 0xe2e2fdfe, 0x02021d1d, 0xfdfde2e3, 0x1817eff0, 0xe7e81010, 0xeff01818, - 0x100fe7e8, 0x2e2e1c1c, 0xd1d1e3e4, 0x1c1c2e2e, 0xe3e3d1d2, 0x2322f6f7, 0xdcdd0909, 0xf6f72323, - 0x0908dcdd, 0x2f2f0d0d, 0xd0d0f2f3, 0x0d0d2f2f, 0xf2f2d0d1, 0x31313131, 0xcecececf, 0x3635feff, - 0xc9ca0101, 0xfeff3636, 0x0100c9ca, 0x2322dcdd, 0xdcdd2323, 0x2f2ee5e6, 0xd0d11a1a, 0xe5e62f2f, - 0x1a19d0d1, 0x51512020, 0xaeaedfe0, 0x20205151, 0xdfdfaeaf, 0x53533838, 0xacacc7c8, 0x38385353, - 0xc7c7acad, 0x4342edee, 0xbcbd1212, 0xedee4343, 0x1211bcbd, 0x56560d0d, 0xa9a9f2f3, 0x0d0d5656, - 0xf2f2a9aa, 0x5b5b5b5b, 0xa4a4a4a5, 0x6362f8f9, 0x9c9d0707, 0xf8f96363, 0x07069c9d, 0x4443c9ca, - 0xbbbc3636, 0xc9ca4444, 0x3635bbbc, 0x5a59d3d4, 0xa5a62c2c, 0xd3d45a5a, 0x2c2ba5a6, 0x7c7bdedf, - 0x83842121, 0xdedf7c7c, 0x21208384, 0x67669899, 0x98996767, 0x7f7ea9aa, 0x80815656, 0xa9aa7f7f, - 0x56558081, 0x25252525, 0xdadadadb, 0x45454545, 0xbabababb, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, - 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, - 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, - 0xf9f9f9fa, 0x0807fdfe, 0x0807fdfe, 0x0807fdfe, 0x0807fdfe, 0x0807fdfe, 0x0807fdfe, 0x0807fdfe, - 0x0807fdfe, 0x0807fdfe, 0x0807fdfe, 0x0807fdfe, 0x0807fdfe, 0xf7f80202, 0xf7f80202, 0xf7f80202, - 0xf7f80202, 0xf7f80202, 0xf7f80202, 0xf7f80202, 0xf7f80202, 0xf7f80202, 0xf7f80202, 0xf7f80202, - 0xf7f80202, 0xfdfe0808, 0xfdfe0808, 0xfdfe0808, 0xfdfe0808, 0xfdfe0808, 0xfdfe0808, 0xfdfe0808, - 0xfdfe0808, 0xfdfe0808, 0xfdfe0808, 0xfdfe0808, 0xfdfe0808, 0x0201f7f8, 0x0201f7f8, 0x0201f7f8, - 0x0201f7f8, 0x0201f7f8, 0x0201f7f8, 0x0201f7f8, 0x0201f7f8, 0x0201f7f8, 0x0201f7f8, 0x0201f7f8, - 0x0201f7f8, 0x0d0d0d0d, 0x0d0d0d0d, 0x0d0d0d0d, 0x0d0d0d0d, 0x0d0d0d0d, 0x0d0d0d0d, 0x0d0d0d0d, - 0x0d0d0d0d, 0x0d0d0d0d, 0x0d0d0d0d, 0x0d0d0d0d, 0x0d0d0d0d, 0xf2f2f2f3, 0xf2f2f2f3, 0xf2f2f2f3, - 0xf2f2f2f3, 0xf2f2f2f3, 0xf2f2f2f3, 0xf2f2f2f3, 0xf2f2f2f3, 0xf2f2f2f3, 0xf2f2f2f3, 0xf2f2f2f3, - 0xf2f2f2f3, 0x0f0f0404, 0x0f0f0404, 0x0f0f0404, 0x0f0f0404, 0x0f0f0404, 0x0f0f0404, 0x0f0f0404, - 0x0f0f0404, 0x0f0f0404, 0x0f0f0404, 0x0f0f0404, 0x0f0f0404, 0xf0f0fbfc, 0xf0f0fbfc, 0xf0f0fbfc, - 0xf0f0fbfc, 0xf0f0fbfc, 0xf0f0fbfc, 0xf0f0fbfc, 0xf0f0fbfc, 0xf0f0fbfc, 0xf0f0fbfc, 0xf0f0fbfc, - 0xf0f0fbfc, 0x04040f0f, 0x04040f0f, 0x04040f0f, 0x04040f0f, 0x04040f0f, 0x04040f0f, 0x04040f0f, - 0x04040f0f, 0x04040f0f, 0x04040f0f, 0x04040f0f, 0x04040f0f, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x07070707, 0xf8f8f8f9, 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, 0x10101010, - 0xefefeff0, 0x12120505, 0xededfafb, 0x05051212, 0xfafaedee, 0x0d0cf2f3, 0xf2f30d0d, 0x1514f9fa, - 0xeaeb0606, 0xf9fa1515, 0x0605eaeb, 0x1e1e0f0f, 0xe1e1f0f1, 0x0f0f1e1e, 0xf0f0e1e2, 0x1e1e1e1e, - 0xe1e1e1e2, 0x22220202, 0xddddfdfe, 0x02022222, 0xfdfdddde, 0x1c1beced, 0xe3e41313, 0xeced1c1c, - 0x1312e3e4, 0x36362020, 0xc9c9dfe0, 0x20203636, 0xdfdfc9ca, 0x2928f4f5, 0xd6d70b0b, 0xf4f52929, - 0x0b0ad6d7, 0x37370f0f, 0xc8c8f0f1, 0x0f0f3737, 0xf0f0c8c9, 0x39393939, 0xc6c6c6c7, 0x3f3efeff, - 0xc0c10101, 0xfeff3f3f, 0x0100c0c1, 0x2827d7d8, 0xd7d82828, 0x3736e1e2, 0xc8c91e1e, 0xe1e23737, - 0x1e1dc8c9, 0x5e5e2525, 0xa1a1dadb, 0x25255e5e, 0xdadaa1a2, 0x60604141, 0x9f9fbebf, 0x41416060, - 0xbebe9fa0, 0x4e4deaeb, 0xb1b21515, 0xeaeb4e4e, 0x1514b1b2, 0x64640f0f, 0x9b9bf0f1, 0x0f0f6464, - 0xf0f09b9c, 0x6a6a6a6a, 0x95959596, 0x7473f7f8, 0x8b8c0808, 0xf7f87474, 0x08078b8c, 0x4f4ec0c1, - 0xb0b13f3f, 0xc0c14f4f, 0x3f3eb0b1, 0x6968cccd, 0x96973333, 0xcccd6969, 0x33329697, 0x78778788, - 0x87887878, 0x2b2b2b2b, 0xd4d4d4d5, 0x50505050, 0xafafafb0, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, - 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, - 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, - 0xf8f8f8f9, 0x0a09fcfd, 0x0a09fcfd, 0x0a09fcfd, 0x0a09fcfd, 0x0a09fcfd, 0x0a09fcfd, 0x0a09fcfd, - 0x0a09fcfd, 0x0a09fcfd, 0x0a09fcfd, 0x0a09fcfd, 0x0a09fcfd, 0xf5f60303, 0xf5f60303, 0xf5f60303, - 0xf5f60303, 0xf5f60303, 0xf5f60303, 0xf5f60303, 0xf5f60303, 0xf5f60303, 0xf5f60303, 0xf5f60303, - 0xf5f60303, 0xfcfd0a0a, 0xfcfd0a0a, 0xfcfd0a0a, 0xfcfd0a0a, 0xfcfd0a0a, 0xfcfd0a0a, 0xfcfd0a0a, - 0xfcfd0a0a, 0xfcfd0a0a, 0xfcfd0a0a, 0xfcfd0a0a, 0xfcfd0a0a, 0x0302f5f6, 0x0302f5f6, 0x0302f5f6, - 0x0302f5f6, 0x0302f5f6, 0x0302f5f6, 0x0302f5f6, 0x0302f5f6, 0x0302f5f6, 0x0302f5f6, 0x0302f5f6, - 0x0302f5f6, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, - 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0xefefeff0, 0xefefeff0, 0xefefeff0, - 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, - 0xefefeff0, 0x12120505, 0x12120505, 0x12120505, 0x12120505, 0x12120505, 0x12120505, 0x12120505, - 0x12120505, 0x12120505, 0x12120505, 0x12120505, 0x12120505, 0xededfafb, 0xededfafb, 0xededfafb, - 0xededfafb, 0xededfafb, 0xededfafb, 0xededfafb, 0xededfafb, 0xededfafb, 0xededfafb, 0xededfafb, - 0xededfafb, 0x05051212, 0x05051212, 0x05051212, 0x05051212, 0x05051212, 0x05051212, 0x05051212, - 0x05051212, 0x05051212, 0x05051212, 0x05051212, 0x05051212, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, 0xfcfd0b0b, 0x0302f4f5, 0x12121212, - 0xedededee, 0x14140505, 0xebebfafb, 0x05051414, 0xfafaebec, 0x0f0ef0f1, 0xf0f10f0f, 0x1817f8f9, - 0xe7e80707, 0xf8f91818, 0x0706e7e8, 0x23231111, 0xdcdceeef, 0x11112323, 0xeeeedcdd, 0x22222222, - 0xddddddde, 0x26260303, 0xd9d9fcfd, 0x03032626, 0xfcfcd9da, 0x201fe9ea, 0xdfe01616, 0xe9ea2020, - 0x1615dfe0, 0x3d3d2525, 0xc2c2dadb, 0x25253d3d, 0xdadac2c3, 0x2f2ef2f3, 0xd0d10d0d, 0xf2f32f2f, - 0x0d0cd0d1, 0x3f3f1111, 0xc0c0eeef, 0x11113f3f, 0xeeeec0c1, 0x41414141, 0xbebebebf, 0x4847feff, - 0xb7b80101, 0xfeff4848, 0x0100b7b8, 0x2e2dd1d2, 0xd1d22e2e, 0x3f3edcdd, 0xc0c12323, 0xdcdd3f3f, - 0x2322c0c1, 0x6b6b2b2b, 0x9494d4d5, 0x2b2b6b6b, 0xd4d49495, 0x6e6e4b4b, 0x9191b4b5, 0x4b4b6e6e, - 0xb4b49192, 0x5958e7e8, 0xa6a71818, 0xe7e85959, 0x1817a6a7, 0x72721111, 0x8d8deeef, 0x11117272, - 0xeeee8d8e, 0x79797979, 0x86868687, 0x5b5ab7b8, 0xa4a54848, 0xb7b85b5b, 0x4847a4a5, 0x7877c5c6, - 0x87883a3a, 0xc5c67878, 0x3a398788, 0x31313131, 0xcecececf, 0x5c5c5c5c, 0xa3a3a3a4, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0x08080808, - 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0xf7f7f7f8, - 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, - 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0x0b0afcfd, 0x0b0afcfd, 0x0b0afcfd, 0x0b0afcfd, 0x0b0afcfd, - 0x0b0afcfd, 0x0b0afcfd, 0x0b0afcfd, 0x0b0afcfd, 0x0b0afcfd, 0x0b0afcfd, 0x0b0afcfd, 0xf4f50303, - 0xf4f50303, 0xf4f50303, 0xf4f50303, 0xf4f50303, 0xf4f50303, 0xf4f50303, 0xf4f50303, 0xf4f50303, - 0xf4f50303, 0xf4f50303, 0xf4f50303, 0xfcfd0b0b, 0xfcfd0b0b, 0xfcfd0b0b, 0xfcfd0b0b, 0xfcfd0b0b, - 0xfcfd0b0b, 0xfcfd0b0b, 0xfcfd0b0b, 0xfcfd0b0b, 0xfcfd0b0b, 0xfcfd0b0b, 0xfcfd0b0b, 0x0302f4f5, - 0x0302f4f5, 0x0302f4f5, 0x0302f4f5, 0x0302f4f5, 0x0302f4f5, 0x0302f4f5, 0x0302f4f5, 0x0302f4f5, - 0x0302f4f5, 0x0302f4f5, 0x0302f4f5, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, - 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0xedededee, - 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, - 0xedededee, 0xedededee, 0xedededee, 0x14140505, 0x14140505, 0x14140505, 0x14140505, 0x14140505, - 0x14140505, 0x14140505, 0x14140505, 0x14140505, 0x14140505, 0x14140505, 0x14140505, 0xebebfafb, - 0xebebfafb, 0xebebfafb, 0xebebfafb, 0xebebfafb, 0xebebfafb, 0xebebfafb, 0xebebfafb, 0xebebfafb, - 0xebebfafb, 0xebebfafb, 0xebebfafb, 0x05051414, 0x05051414, 0x05051414, 0x05051414, 0x05051414, - 0x05051414, 0x05051414, 0x05051414, 0x05051414, 0x05051414, 0x05051414, 0x05051414, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x14141414, - 0xebebebec, 0x17170606, 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, 0x1110eeef, 0xeeef1111, 0x1b1af8f9, - 0xe4e50707, 0xf8f91b1b, 0x0706e4e5, 0x27271313, 0xd8d8eced, 0x13132727, 0xececd8d9, 0x27272727, - 0xd8d8d8d9, 0x2b2b0303, 0xd4d4fcfd, 0x03032b2b, 0xfcfcd4d5, 0x2423e7e8, 0xdbdc1818, 0xe7e82424, - 0x1817dbdc, 0x45452a2a, 0xbabad5d6, 0x2a2a4545, 0xd5d5babb, 0x3534f1f2, 0xcacb0e0e, 0xf1f23535, - 0x0e0dcacb, 0x47471313, 0xb8b8eced, 0x13134747, 0xececb8b9, 0x49494949, 0xb6b6b6b7, 0x504ffdfe, - 0xafb00202, 0xfdfe5050, 0x0201afb0, 0x3433cbcc, 0xcbcc3434, 0x4645d8d9, 0xb9ba2727, 0xd8d94646, - 0x2726b9ba, 0x79793030, 0x8686cfd0, 0x30307979, 0xcfcf8687, 0x7c7c5454, 0x8383abac, 0x54547c7c, - 0xabab8384, 0x6463e4e5, 0x9b9c1b1b, 0xe4e56464, 0x1b1a9b9c, 0x6665aeaf, 0x999a5151, 0xaeaf6666, - 0x5150999a, 0x37373737, 0xc8c8c8c9, 0x68686868, 0x97979798, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, - 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0xf6f6f6f7, - 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, - 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0x0c0bfcfd, 0x0c0bfcfd, 0x0c0bfcfd, 0x0c0bfcfd, - 0x0c0bfcfd, 0x0c0bfcfd, 0x0c0bfcfd, 0x0c0bfcfd, 0x0c0bfcfd, 0x0c0bfcfd, 0x0c0bfcfd, 0x0c0bfcfd, - 0x0c0bfcfd, 0xf3f40303, 0xf3f40303, 0xf3f40303, 0xf3f40303, 0xf3f40303, 0xf3f40303, 0xf3f40303, - 0xf3f40303, 0xf3f40303, 0xf3f40303, 0xf3f40303, 0xf3f40303, 0xf3f40303, 0xfcfd0c0c, 0xfcfd0c0c, - 0xfcfd0c0c, 0xfcfd0c0c, 0xfcfd0c0c, 0xfcfd0c0c, 0xfcfd0c0c, 0xfcfd0c0c, 0xfcfd0c0c, 0xfcfd0c0c, - 0xfcfd0c0c, 0xfcfd0c0c, 0xfcfd0c0c, 0x0302f3f4, 0x0302f3f4, 0x0302f3f4, 0x0302f3f4, 0x0302f3f4, - 0x0302f3f4, 0x0302f3f4, 0x0302f3f4, 0x0302f3f4, 0x0302f3f4, 0x0302f3f4, 0x0302f3f4, 0x0302f3f4, - 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, - 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0xebebebec, 0xebebebec, 0xebebebec, - 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, - 0xebebebec, 0xebebebec, 0x17170606, 0x17170606, 0x17170606, 0x17170606, 0x17170606, 0x17170606, - 0x17170606, 0x17170606, 0x17170606, 0x17170606, 0x17170606, 0x17170606, 0x17170606, 0xe8e8f9fa, - 0xe8e8f9fa, 0xe8e8f9fa, 0xe8e8f9fa, 0xe8e8f9fa, 0xe8e8f9fa, 0xe8e8f9fa, 0xe8e8f9fa, 0xe8e8f9fa, - 0xe8e8f9fa, 0xe8e8f9fa, 0xe8e8f9fa, 0xe8e8f9fa, 0x06061717, 0x06061717, 0x06061717, 0x06061717, - 0x06061717, 0x06061717, 0x06061717, 0x06061717, 0x06061717, 0x06061717, 0x06061717, 0x06061717, - 0x06061717, 0xf9f9e8e9, 0xf9f9e8e9, 0xf9f9e8e9, 0xf9f9e8e9, 0xf9f9e8e9, 0xf9f9e8e9, 0xf9f9e8e9, - 0xf9f9e8e9, 0xf9f9e8e9, 0xf9f9e8e9, 0xf9f9e8e9, 0xf9f9e8e9, 0xf9f9e8e9, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x02020202, 0xfdfdfdfe, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, - 0xfbfbfbfc, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x0403fbfc, 0xfbfc0404, 0x0605fdfe, - 0xf9fa0202, 0xfdfe0606, 0x0201f9fa, 0x08080404, 0xf7f7fbfc, 0x04040808, 0xfbfbf7f8, 0x08080808, - 0xf7f7f7f8, 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x0807fbfc, 0xf7f80404, 0xfbfc0808, - 0x0403f7f8, 0x0e0e0808, 0xf1f1f7f8, 0x08080e0e, 0xf7f7f1f2, 0x0c0bfdfe, 0xf3f40202, 0xfdfe0c0c, - 0x0201f3f4, 0x10100404, 0xefeffbfc, 0x04041010, 0xfbfbeff0, 0x10101010, 0xefefeff0, 0x12120000, - 0xedee0000, 0x00001212, 0xffffedee, 0x0c0bf3f4, 0xf3f40c0c, 0x100ff7f8, 0xeff00808, 0xf7f81010, - 0x0807eff0, 0x1a1a0a0a, 0xe5e5f5f6, 0x0a0a1a1a, 0xf5f5e5e6, 0x1c1c1212, 0xe3e3edee, 0x12121c1c, - 0xedede3e4, 0x1615f9fa, 0xe9ea0606, 0xf9fa1616, 0x0605e9ea, 0x1c1c0404, 0xe3e3fbfc, 0x04041c1c, - 0xfbfbe3e4, 0x1e1e1e1e, 0xe1e1e1e2, 0x201ffdfe, 0xdfe00202, 0xfdfe2020, 0x0201dfe0, 0x1615edee, - 0xe9ea1212, 0xedee1616, 0x1211e9ea, 0x1e1df1f2, 0xe1e20e0e, 0xf1f21e1e, 0x0e0de1e2, 0x2e2e1616, - 0xd1d1e9ea, 0x16162e2e, 0xe9e9d1d2, 0x2e2e0c0c, 0xd1d1f3f4, 0x0c0c2e2e, 0xf3f3d1d2, 0x30302222, - 0xcfcfddde, 0x22223030, 0xddddcfd0, 0x2827f5f6, 0xd7d80a0a, 0xf5f62828, 0x0a09d7d8, 0x32320404, - 0xcdcdfbfc, 0x04043232, 0xfbfbcdce, 0x36363636, 0xc9c9c9ca, 0x2221ddde, 0xddde2222, 0x2a29e3e4, - 0xd5d61c1c, 0xe3e42a2a, 0x1c1bd5d6, 0x3c3bf9fa, 0xc3c40606, 0xf9fa3c3c, 0x0605c3c4, 0x4c4c1a1a, - 0xb3b3e5e6, 0x1a1a4c4c, 0xe5e5b3b4, 0x4c4c2a2a, 0xb3b3d5d6, 0x2a2a4c4c, 0xd5d5b3b4, 0x3635e7e8, - 0xc9ca1818, 0xe7e83636, 0x1817c9ca, 0x4e4e0e0e, 0xb1b1f1f2, 0x0e0e4e4e, 0xf1f1b1b2, 0x52523e3e, - 0xadadc1c2, 0x3e3e5252, 0xc1c1adae, 0x4a49ebec, 0xb5b61414, 0xebec4a4a, 0x1413b5b6, 0x58580202, - 0xa7a7fdfe, 0x02025858, 0xfdfda7a8, 0x5c5c5c5c, 0xa3a3a3a4, 0x3c3bcbcc, 0xc3c43434, 0xcbcc3c3c, - 0x3433c3c4, 0x76763434, 0x8989cbcc, 0x34347676, 0xcbcb898a, 0x4a49d3d4, 0xb5b62c2c, 0xd3d44a4a, - 0x2c2bb5b6, 0x76764a4a, 0x8989b5b6, 0x4a4a7676, 0xb5b5898a, 0x76762020, 0x8989dfe0, 0x20207676, - 0xdfdf898a, 0x6665f3f4, 0x999a0c0c, 0xf3f46666, 0x0c0b999a, 0x605fd7d8, 0x9fa02828, 0xd7d86060, - 0x28279fa0, 0x7675ddde, 0x898a2222, 0xddde7676, 0x2221898a, 0x5857a7a8, 0xa7a85858, 0x6867b1b2, - 0x97984e4e, 0xb1b26868, 0x4e4d9798, 0x0c0c0c0c, 0xf3f3f3f4, 0x16161616, 0xe9e9e9ea, 0x2a2a2a2a, - 0xd5d5d5d6, 0x48484848, 0xb7b7b7b8, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, - 0x02020202, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, - 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0xfdfe0000, - 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0x00000202, 0x00000202, - 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, - 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x03030303, 0xfcfcfcfd, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, - 0xf9f9f9fa, 0x09090303, 0xf6f6fcfd, 0x03030909, 0xfcfcf6f7, 0x0908fcfd, 0xf6f70303, 0xfcfd0909, - 0x0302f6f7, 0x0605f9fa, 0xf9fa0606, 0x0c0c0606, 0xf3f3f9fa, 0x06060c0c, 0xf9f9f3f4, 0x0c0c0c0c, - 0xf3f3f3f4, 0x0f0f0000, 0xf0f10000, 0x00000f0f, 0xfffff0f1, 0x0c0bf6f7, 0xf3f40909, 0xf6f70c0c, - 0x0908f3f4, 0x18180f0f, 0xe7e7f0f1, 0x0f0f1818, 0xf0f0e7e8, 0x1211f9fa, 0xedee0606, 0xf9fa1212, - 0x0605edee, 0x18180606, 0xe7e7f9fa, 0x06061818, 0xf9f9e7e8, 0x18181818, 0xe7e7e7e8, 0x1b1b0000, - 0xe4e50000, 0x00001b1b, 0xffffe4e5, 0x1211edee, 0xedee1212, 0x1817f3f4, 0xe7e80c0c, 0xf3f41818, - 0x0c0be7e8, 0x27270f0f, 0xd8d8f0f1, 0x0f0f2727, 0xf0f0d8d9, 0x2a2a1b1b, 0xd5d5e4e5, 0x1b1b2a2a, - 0xe4e4d5d6, 0x2120f6f7, 0xdedf0909, 0xf6f72121, 0x0908dedf, 0x2a2a0606, 0xd5d5f9fa, 0x06062a2a, - 0xf9f9d5d6, 0x2d2d2d2d, 0xd2d2d2d3, 0x3332fcfd, 0xcccd0303, 0xfcfd3333, 0x0302cccd, 0x2120e4e5, - 0xdedf1b1b, 0xe4e52121, 0x1b1adedf, 0x2d2ceaeb, 0xd2d31515, 0xeaeb2d2d, 0x1514d2d3, 0x45452121, - 0xbabadedf, 0x21214545, 0xdedebabb, 0x45451212, 0xbabaedee, 0x12124545, 0xededbabb, 0x48483636, - 0xb7b7c9ca, 0x36364848, 0xc9c9b7b8, 0x3f3eedee, 0xc0c11212, 0xedee3f3f, 0x1211c0c1, 0x4e4e0606, - 0xb1b1f9fa, 0x06064e4e, 0xf9f9b1b2, 0x51515151, 0xaeaeaeaf, 0x3332cccd, 0xcccd3333, 0x3f3ed5d6, - 0xc0c12a2a, 0xd5d63f3f, 0x2a29c0c1, 0x5a59f6f7, 0xa5a60909, 0xf6f75a5a, 0x0908a5a6, 0x72722a2a, - 0x8d8dd5d6, 0x2a2a7272, 0xd5d58d8e, 0x75753f3f, 0x8a8ac0c1, 0x3f3f7575, 0xc0c08a8b, 0x5150dbdc, - 0xaeaf2424, 0xdbdc5151, 0x2423aeaf, 0x78781515, 0x8787eaeb, 0x15157878, 0xeaea8788, 0x7b7b6060, - 0x84849fa0, 0x60607b7b, 0x9f9f8485, 0x6f6ee1e2, 0x90911e1e, 0xe1e26f6f, 0x1e1d9091, 0x5d5cb1b2, - 0xa2a34e4e, 0xb1b25d5d, 0x4e4da2a3, 0x7271babb, 0x8d8e4545, 0xbabb7272, 0x45448d8e, 0x12121212, - 0xedededee, 0x21212121, 0xdedededf, 0x3f3f3f3f, 0xc0c0c0c1, 0x6c6c6c6c, 0x93939394, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x03030303, 0x03030303, 0x03030303, 0x03030303, 0x03030303, 0x03030303, 0x03030303, 0x03030303, - 0x03030303, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, 0xfcfcfcfd, - 0xfcfcfcfd, 0xfcfcfcfd, 0x03030000, 0x03030000, 0x03030000, 0x03030000, 0x03030000, 0x03030000, - 0x03030000, 0x03030000, 0x03030000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, - 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0x00000303, 0x00000303, 0x00000303, 0x00000303, - 0x00000303, 0x00000303, 0x00000303, 0x00000303, 0x00000303, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, - 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0x06060606, 0x06060606, - 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0xf9f9f9fa, - 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x04040404, 0xfbfbfbfc, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x08080404, - 0xf7f7fbfc, 0x04040808, 0xfbfbf7f8, 0x08080808, 0xf7f7f7f8, 0x0807f7f8, 0xf7f80808, 0x0c0bfbfc, - 0xf3f40404, 0xfbfc0c0c, 0x0403f3f4, 0x10100808, 0xefeff7f8, 0x08081010, 0xf7f7eff0, 0x10101010, - 0xefefeff0, 0x14140000, 0xebec0000, 0x00001414, 0xffffebec, 0x100ff3f4, 0xeff00c0c, 0xf3f41010, - 0x0c0beff0, 0x1817fbfc, 0xe7e80404, 0xfbfc1818, 0x0403e7e8, 0x20201010, 0xdfdfeff0, 0x10102020, - 0xefefdfe0, 0x20200808, 0xdfdff7f8, 0x08082020, 0xf7f7dfe0, 0x20202020, 0xdfdfdfe0, 0x24240000, - 0xdbdc0000, 0x00002424, 0xffffdbdc, 0x1817e7e8, 0xe7e81818, 0x201feff0, 0xdfe01010, 0xeff02020, - 0x100fdfe0, 0x34341414, 0xcbcbebec, 0x14143434, 0xebebcbcc, 0x38382424, 0xc7c7dbdc, 0x24243838, - 0xdbdbc7c8, 0x2c2bf3f4, 0xd3d40c0c, 0xf3f42c2c, 0x0c0bd3d4, 0x38380808, 0xc7c7f7f8, 0x08083838, - 0xf7f7c7c8, 0x3c3c3c3c, 0xc3c3c3c4, 0x403ffbfc, 0xbfc00404, 0xfbfc4040, 0x0403bfc0, 0x2c2bdbdc, - 0xd3d42424, 0xdbdc2c2c, 0x2423d3d4, 0x3c3be3e4, 0xc3c41c1c, 0xe3e43c3c, 0x1c1bc3c4, 0x5c5c2c2c, - 0xa3a3d3d4, 0x2c2c5c5c, 0xd3d3a3a4, 0x5c5c1818, 0xa3a3e7e8, 0x18185c5c, 0xe7e7a3a4, 0x60604848, - 0x9f9fb7b8, 0x48486060, 0xb7b79fa0, 0x5453ebec, 0xabac1414, 0xebec5454, 0x1413abac, 0x64640808, - 0x9b9bf7f8, 0x08086464, 0xf7f79b9c, 0x6c6c6c6c, 0x93939394, 0x4443bbbc, 0xbbbc4444, 0x5453c7c8, - 0xabac3838, 0xc7c85454, 0x3837abac, 0x7877f3f4, 0x87880c0c, 0xf3f47878, 0x0c0b8788, 0x6c6bcfd0, - 0x93943030, 0xcfd06c6c, 0x302f9394, 0x7c7b9798, 0x83846868, 0x97987c7c, 0x68678384, 0x18181818, - 0xe7e7e7e8, 0x2c2c2c2c, 0xd3d3d3d4, 0x54545454, 0xabababac, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x04040404, - 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, - 0x04040404, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, - 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0x04040000, 0x04040000, 0x04040000, 0x04040000, 0x04040000, - 0x04040000, 0x04040000, 0x04040000, 0x04040000, 0x04040000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, - 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0x00000404, - 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0x00000404, - 0x00000404, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, - 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0x08080404, 0x08080404, 0x08080404, 0x08080404, 0x08080404, - 0x08080404, 0x08080404, 0x08080404, 0x08080404, 0x08080404, 0xf7f7fbfc, 0xf7f7fbfc, 0xf7f7fbfc, - 0xf7f7fbfc, 0xf7f7fbfc, 0xf7f7fbfc, 0xf7f7fbfc, 0xf7f7fbfc, 0xf7f7fbfc, 0xf7f7fbfc, 0x04040808, - 0x04040808, 0x04040808, 0x04040808, 0x04040808, 0x04040808, 0x04040808, 0x04040808, 0x04040808, - 0x04040808, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x05050505, 0xfafafafb, 0x05050000, 0xfafb0000, 0x00000505, 0xfffffafb, 0x0a0a0a0a, - 0xf5f5f5f6, 0x0f0f0505, 0xf0f0fafb, 0x05050f0f, 0xfafaf0f1, 0x0a09f5f6, 0xf5f60a0a, 0x0f0efafb, - 0xf0f10505, 0xfafb0f0f, 0x0504f0f1, 0x14140a0a, 0xebebf5f6, 0x0a0a1414, 0xf5f5ebec, 0x14141414, - 0xebebebec, 0x19190000, 0xe6e70000, 0x00001919, 0xffffe6e7, 0x1413f0f1, 0xebec0f0f, 0xf0f11414, - 0x0f0eebec, 0x28281919, 0xd7d7e6e7, 0x19192828, 0xe6e6d7d8, 0x1e1df5f6, 0xe1e20a0a, 0xf5f61e1e, - 0x0a09e1e2, 0x28280a0a, 0xd7d7f5f6, 0x0a0a2828, 0xf5f5d7d8, 0x28282828, 0xd7d7d7d8, 0x2d2d0000, - 0xd2d30000, 0x00002d2d, 0xffffd2d3, 0x1e1de1e2, 0xe1e21e1e, 0x2827ebec, 0xd7d81414, 0xebec2828, - 0x1413d7d8, 0x41411919, 0xbebee6e7, 0x19194141, 0xe6e6bebf, 0x46462d2d, 0xb9b9d2d3, 0x2d2d4646, - 0xd2d2b9ba, 0x3736f0f1, 0xc8c90f0f, 0xf0f13737, 0x0f0ec8c9, 0x46460a0a, 0xb9b9f5f6, 0x0a0a4646, - 0xf5f5b9ba, 0x4b4b4b4b, 0xb4b4b4b5, 0x5554fafb, 0xaaab0505, 0xfafb5555, 0x0504aaab, 0x3736d2d3, - 0xc8c92d2d, 0xd2d33737, 0x2d2cc8c9, 0x4b4adcdd, 0xb4b52323, 0xdcdd4b4b, 0x2322b4b5, 0x73733737, - 0x8c8cc8c9, 0x37377373, 0xc8c88c8d, 0x73731e1e, 0x8c8ce1e2, 0x1e1e7373, 0xe1e18c8d, 0x78785a5a, - 0x8787a5a6, 0x5a5a7878, 0xa5a58788, 0x6968e1e2, 0x96971e1e, 0xe1e26969, 0x1e1d9697, 0x5554aaab, - 0xaaab5555, 0x6968b9ba, 0x96974646, 0xb9ba6969, 0x46459697, 0x1e1e1e1e, 0xe1e1e1e2, 0x3c3c3c3c, - 0xc3c3c3c4, 0x69696969, 0x96969697, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x05050505, 0x05050505, - 0x05050505, 0x05050505, 0x05050505, 0x05050505, 0x05050505, 0x05050505, 0x05050505, 0x05050505, - 0x05050505, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, - 0xfafafafb, 0xfafafafb, 0xfafafafb, 0xfafafafb, 0x05050000, 0x05050000, 0x05050000, 0x05050000, - 0x05050000, 0x05050000, 0x05050000, 0x05050000, 0x05050000, 0x05050000, 0x05050000, 0xfafb0000, - 0xfafb0000, 0xfafb0000, 0xfafb0000, 0xfafb0000, 0xfafb0000, 0xfafb0000, 0xfafb0000, 0xfafb0000, - 0xfafb0000, 0xfafb0000, 0x00000505, 0x00000505, 0x00000505, 0x00000505, 0x00000505, 0x00000505, - 0x00000505, 0x00000505, 0x00000505, 0x00000505, 0x00000505, 0xfffffafb, 0xfffffafb, 0xfffffafb, - 0xfffffafb, 0xfffffafb, 0xfffffafb, 0xfffffafb, 0xfffffafb, 0xfffffafb, 0xfffffafb, 0xfffffafb, - 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, - 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, - 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0x0f0f0505, 0x0f0f0505, - 0x0f0f0505, 0x0f0f0505, 0x0f0f0505, 0x0f0f0505, 0x0f0f0505, 0x0f0f0505, 0x0f0f0505, 0x0f0f0505, - 0x0f0f0505, 0xf0f0fafb, 0xf0f0fafb, 0xf0f0fafb, 0xf0f0fafb, 0xf0f0fafb, 0xf0f0fafb, 0xf0f0fafb, - 0xf0f0fafb, 0xf0f0fafb, 0xf0f0fafb, 0xf0f0fafb, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x0c0c0c0c, - 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, 0x06060c0c, 0xf9f9f3f4, 0x0c0bf3f4, 0xf3f40c0c, 0x1211f9fa, - 0xedee0606, 0xf9fa1212, 0x0605edee, 0x18180c0c, 0xe7e7f3f4, 0x0c0c1818, 0xf3f3e7e8, 0x18181818, - 0xe7e7e7e8, 0x1e1e0000, 0xe1e20000, 0x00001e1e, 0xffffe1e2, 0x1817edee, 0xe7e81212, 0xedee1818, - 0x1211e7e8, 0x30301e1e, 0xcfcfe1e2, 0x1e1e3030, 0xe1e1cfd0, 0x2423f9fa, 0xdbdc0606, 0xf9fa2424, - 0x0605dbdc, 0x30300c0c, 0xcfcff3f4, 0x0c0c3030, 0xf3f3cfd0, 0x30303030, 0xcfcfcfd0, 0x36360000, - 0xc9ca0000, 0x00003636, 0xffffc9ca, 0x2423dbdc, 0xdbdc2424, 0x302fe7e8, 0xcfd01818, 0xe7e83030, - 0x1817cfd0, 0x4e4e1e1e, 0xb1b1e1e2, 0x1e1e4e4e, 0xe1e1b1b2, 0x54543636, 0xababc9ca, 0x36365454, - 0xc9c9abac, 0x4241edee, 0xbdbe1212, 0xedee4242, 0x1211bdbe, 0x54540c0c, 0xababf3f4, 0x0c0c5454, - 0xf3f3abac, 0x5a5a5a5a, 0xa5a5a5a6, 0x605ff9fa, 0x9fa00606, 0xf9fa6060, 0x06059fa0, 0x4241c9ca, - 0xbdbe3636, 0xc9ca4242, 0x3635bdbe, 0x5a59d5d6, 0xa5a62a2a, 0xd5d65a5a, 0x2a29a5a6, 0x7e7de1e2, - 0x81821e1e, 0xe1e27e7e, 0x1e1d8182, 0x6665999a, 0x999a6666, 0x7e7dabac, 0x81825454, 0xabac7e7e, - 0x54538182, 0x24242424, 0xdbdbdbdc, 0x42424242, 0xbdbdbdbe, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, - 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, - 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, - 0xf9f9f9fa, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, - 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, - 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, - 0xf9fa0000, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, - 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, - 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, - 0xfffff9fa, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, - 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, - 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, - 0xf3f3f3f4, 0x0c0c0606, 0x0c0c0606, 0x0c0c0606, 0x0c0c0606, 0x0c0c0606, 0x0c0c0606, 0x0c0c0606, - 0x0c0c0606, 0x0c0c0606, 0x0c0c0606, 0x0c0c0606, 0x0c0c0606, 0xf3f3f9fa, 0xf3f3f9fa, 0xf3f3f9fa, - 0xf3f3f9fa, 0xf3f3f9fa, 0xf3f3f9fa, 0xf3f3f9fa, 0xf3f3f9fa, 0xf3f3f9fa, 0xf3f3f9fa, 0xf3f3f9fa, - 0xf3f3f9fa, 0x06060c0c, 0x06060c0c, 0x06060c0c, 0x06060c0c, 0x06060c0c, 0x06060c0c, 0x06060c0c, - 0x06060c0c, 0x06060c0c, 0x06060c0c, 0x06060c0c, 0x06060c0c, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x07070707, 0xf8f8f8f9, 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, 0x0e0e0e0e, - 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, 0x07071515, 0xf8f8eaeb, 0x0e0df1f2, 0xf1f20e0e, 0x1514f8f9, - 0xeaeb0707, 0xf8f91515, 0x0706eaeb, 0x1c1c0e0e, 0xe3e3f1f2, 0x0e0e1c1c, 0xf1f1e3e4, 0x1c1c1c1c, - 0xe3e3e3e4, 0x23230000, 0xdcdd0000, 0x00002323, 0xffffdcdd, 0x1c1beaeb, 0xe3e41515, 0xeaeb1c1c, - 0x1514e3e4, 0x38382323, 0xc7c7dcdd, 0x23233838, 0xdcdcc7c8, 0x2a29f1f2, 0xd5d60e0e, 0xf1f22a2a, - 0x0e0dd5d6, 0x38380e0e, 0xc7c7f1f2, 0x0e0e3838, 0xf1f1c7c8, 0x38383838, 0xc7c7c7c8, 0x3f3f0000, - 0xc0c10000, 0x00003f3f, 0xffffc0c1, 0x2a29d5d6, 0xd5d62a2a, 0x3837e3e4, 0xc7c81c1c, 0xe3e43838, - 0x1c1bc7c8, 0x5b5b2323, 0xa4a4dcdd, 0x23235b5b, 0xdcdca4a5, 0x62623f3f, 0x9d9dc0c1, 0x3f3f6262, - 0xc0c09d9e, 0x4d4ceaeb, 0xb2b31515, 0xeaeb4d4d, 0x1514b2b3, 0x62620e0e, 0x9d9df1f2, 0x0e0e6262, - 0xf1f19d9e, 0x69696969, 0x96969697, 0x7776f8f9, 0x88890707, 0xf8f97777, 0x07068889, 0x4d4cc0c1, - 0xb2b33f3f, 0xc0c14d4d, 0x3f3eb2b3, 0x6968cecf, 0x96973131, 0xcecf6969, 0x31309697, 0x77768889, - 0x88897777, 0x2a2a2a2a, 0xd5d5d5d6, 0x4d4d4d4d, 0xb2b2b2b3, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, - 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0x07070707, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, - 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, 0xf8f8f8f9, - 0xf8f8f8f9, 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0x07070000, - 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0xf8f90000, 0xf8f90000, 0xf8f90000, - 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, - 0xf8f90000, 0x00000707, 0x00000707, 0x00000707, 0x00000707, 0x00000707, 0x00000707, 0x00000707, - 0x00000707, 0x00000707, 0x00000707, 0x00000707, 0x00000707, 0xfffff8f9, 0xfffff8f9, 0xfffff8f9, - 0xfffff8f9, 0xfffff8f9, 0xfffff8f9, 0xfffff8f9, 0xfffff8f9, 0xfffff8f9, 0xfffff8f9, 0xfffff8f9, - 0xfffff8f9, 0x0e0e0e0e, 0x0e0e0e0e, 0x0e0e0e0e, 0x0e0e0e0e, 0x0e0e0e0e, 0x0e0e0e0e, 0x0e0e0e0e, - 0x0e0e0e0e, 0x0e0e0e0e, 0x0e0e0e0e, 0x0e0e0e0e, 0x0e0e0e0e, 0xf1f1f1f2, 0xf1f1f1f2, 0xf1f1f1f2, - 0xf1f1f1f2, 0xf1f1f1f2, 0xf1f1f1f2, 0xf1f1f1f2, 0xf1f1f1f2, 0xf1f1f1f2, 0xf1f1f1f2, 0xf1f1f1f2, - 0xf1f1f1f2, 0x15150707, 0x15150707, 0x15150707, 0x15150707, 0x15150707, 0x15150707, 0x15150707, - 0x15150707, 0x15150707, 0x15150707, 0x15150707, 0x15150707, 0xeaeaf8f9, 0xeaeaf8f9, 0xeaeaf8f9, - 0xeaeaf8f9, 0xeaeaf8f9, 0xeaeaf8f9, 0xeaeaf8f9, 0xeaeaf8f9, 0xeaeaf8f9, 0xeaeaf8f9, 0xeaeaf8f9, - 0xeaeaf8f9, 0x07071515, 0x07071515, 0x07071515, 0x07071515, 0x07071515, 0x07071515, 0x07071515, - 0x07071515, 0x07071515, 0x07071515, 0x07071515, 0x07071515, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, 0x00000808, 0xfffff7f8, 0x10101010, - 0xefefeff0, 0x10100808, 0xefeff7f8, 0x08081010, 0xf7f7eff0, 0x100feff0, 0xeff01010, 0x1817f7f8, - 0xe7e80808, 0xf7f81818, 0x0807e7e8, 0x20201010, 0xdfdfeff0, 0x10102020, 0xefefdfe0, 0x20202020, - 0xdfdfdfe0, 0x28280000, 0xd7d80000, 0x00002828, 0xffffd7d8, 0x201fe7e8, 0xdfe01818, 0xe7e82020, - 0x1817dfe0, 0x40402828, 0xbfbfd7d8, 0x28284040, 0xd7d7bfc0, 0x302feff0, 0xcfd01010, 0xeff03030, - 0x100fcfd0, 0x40401010, 0xbfbfeff0, 0x10104040, 0xefefbfc0, 0x40404040, 0xbfbfbfc0, 0x48480000, - 0xb7b80000, 0x00004848, 0xffffb7b8, 0x302fcfd0, 0xcfd03030, 0x403fdfe0, 0xbfc02020, 0xdfe04040, - 0x201fbfc0, 0x68682828, 0x9797d7d8, 0x28286868, 0xd7d79798, 0x70704848, 0x8f8fb7b8, 0x48487070, - 0xb7b78f90, 0x5857e7e8, 0xa7a81818, 0xe7e85858, 0x1817a7a8, 0x70701010, 0x8f8feff0, 0x10107070, - 0xefef8f90, 0x78787878, 0x87878788, 0x5857b7b8, 0xa7a84848, 0xb7b85858, 0x4847a7a8, 0x7877c7c8, - 0x87883838, 0xc7c87878, 0x38378788, 0x30303030, 0xcfcfcfd0, 0x58585858, 0xa7a7a7a8, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0x08080808, - 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0x08080808, 0xf7f7f7f8, - 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, - 0xf7f7f7f8, 0xf7f7f7f8, 0xf7f7f7f8, 0x08080000, 0x08080000, 0x08080000, 0x08080000, 0x08080000, - 0x08080000, 0x08080000, 0x08080000, 0x08080000, 0x08080000, 0x08080000, 0x08080000, 0xf7f80000, - 0xf7f80000, 0xf7f80000, 0xf7f80000, 0xf7f80000, 0xf7f80000, 0xf7f80000, 0xf7f80000, 0xf7f80000, - 0xf7f80000, 0xf7f80000, 0xf7f80000, 0x00000808, 0x00000808, 0x00000808, 0x00000808, 0x00000808, - 0x00000808, 0x00000808, 0x00000808, 0x00000808, 0x00000808, 0x00000808, 0x00000808, 0xfffff7f8, - 0xfffff7f8, 0xfffff7f8, 0xfffff7f8, 0xfffff7f8, 0xfffff7f8, 0xfffff7f8, 0xfffff7f8, 0xfffff7f8, - 0xfffff7f8, 0xfffff7f8, 0xfffff7f8, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, - 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0x10101010, 0xefefeff0, - 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, 0xefefeff0, - 0xefefeff0, 0xefefeff0, 0xefefeff0, 0x10100808, 0x10100808, 0x10100808, 0x10100808, 0x10100808, - 0x10100808, 0x10100808, 0x10100808, 0x10100808, 0x10100808, 0x10100808, 0x10100808, 0xefeff7f8, - 0xefeff7f8, 0xefeff7f8, 0xefeff7f8, 0xefeff7f8, 0xefeff7f8, 0xefeff7f8, 0xefeff7f8, 0xefeff7f8, - 0xefeff7f8, 0xefeff7f8, 0xefeff7f8, 0x08081010, 0x08081010, 0x08081010, 0x08081010, 0x08081010, - 0x08081010, 0x08081010, 0x08081010, 0x08081010, 0x08081010, 0x08081010, 0x08081010, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x09090909, 0xf6f6f6f7, 0x09090000, 0xf6f70000, 0x00000909, 0xfffff6f7, 0x12121212, - 0xedededee, 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, 0x1211edee, 0xedee1212, 0x1b1af6f7, - 0xe4e50909, 0xf6f71b1b, 0x0908e4e5, 0x24241212, 0xdbdbedee, 0x12122424, 0xededdbdc, 0x24242424, - 0xdbdbdbdc, 0x2d2d0000, 0xd2d30000, 0x00002d2d, 0xffffd2d3, 0x2423e4e5, 0xdbdc1b1b, 0xe4e52424, - 0x1b1adbdc, 0x48482d2d, 0xb7b7d2d3, 0x2d2d4848, 0xd2d2b7b8, 0x3635edee, 0xc9ca1212, 0xedee3636, - 0x1211c9ca, 0x48481212, 0xb7b7edee, 0x12124848, 0xededb7b8, 0x48484848, 0xb7b7b7b8, 0x51510000, - 0xaeaf0000, 0x00005151, 0xffffaeaf, 0x3635c9ca, 0xc9ca3636, 0x4847dbdc, 0xb7b82424, 0xdbdc4848, - 0x2423b7b8, 0x75752d2d, 0x8a8ad2d3, 0x2d2d7575, 0xd2d28a8b, 0x7e7e5151, 0x8181aeaf, 0x51517e7e, - 0xaeae8182, 0x6362e4e5, 0x9c9d1b1b, 0xe4e56363, 0x1b1a9c9d, 0x6362aeaf, 0x9c9d5151, 0xaeaf6363, - 0x51509c9d, 0x36363636, 0xc9c9c9ca, 0x6c6c6c6c, 0x93939394, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, - 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0x09090909, 0xf6f6f6f7, - 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, - 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0xf6f6f6f7, 0x09090000, 0x09090000, 0x09090000, 0x09090000, - 0x09090000, 0x09090000, 0x09090000, 0x09090000, 0x09090000, 0x09090000, 0x09090000, 0x09090000, - 0x09090000, 0xf6f70000, 0xf6f70000, 0xf6f70000, 0xf6f70000, 0xf6f70000, 0xf6f70000, 0xf6f70000, - 0xf6f70000, 0xf6f70000, 0xf6f70000, 0xf6f70000, 0xf6f70000, 0xf6f70000, 0x00000909, 0x00000909, - 0x00000909, 0x00000909, 0x00000909, 0x00000909, 0x00000909, 0x00000909, 0x00000909, 0x00000909, - 0x00000909, 0x00000909, 0x00000909, 0xfffff6f7, 0xfffff6f7, 0xfffff6f7, 0xfffff6f7, 0xfffff6f7, - 0xfffff6f7, 0xfffff6f7, 0xfffff6f7, 0xfffff6f7, 0xfffff6f7, 0xfffff6f7, 0xfffff6f7, 0xfffff6f7, - 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, - 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0x12121212, 0xedededee, 0xedededee, 0xedededee, - 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, 0xedededee, - 0xedededee, 0xedededee, 0x1b1b0909, 0x1b1b0909, 0x1b1b0909, 0x1b1b0909, 0x1b1b0909, 0x1b1b0909, - 0x1b1b0909, 0x1b1b0909, 0x1b1b0909, 0x1b1b0909, 0x1b1b0909, 0x1b1b0909, 0x1b1b0909, 0xe4e4f6f7, - 0xe4e4f6f7, 0xe4e4f6f7, 0xe4e4f6f7, 0xe4e4f6f7, 0xe4e4f6f7, 0xe4e4f6f7, 0xe4e4f6f7, 0xe4e4f6f7, - 0xe4e4f6f7, 0xe4e4f6f7, 0xe4e4f6f7, 0xe4e4f6f7, 0x09091b1b, 0x09091b1b, 0x09091b1b, 0x09091b1b, - 0x09091b1b, 0x09091b1b, 0x09091b1b, 0x09091b1b, 0x09091b1b, 0x09091b1b, 0x09091b1b, 0x09091b1b, - 0x09091b1b, 0xf6f6e4e5, 0xf6f6e4e5, 0xf6f6e4e5, 0xf6f6e4e5, 0xf6f6e4e5, 0xf6f6e4e5, 0xf6f6e4e5, - 0xf6f6e4e5, 0xf6f6e4e5, 0xf6f6e4e5, 0xf6f6e4e5, 0xf6f6e4e5, 0xf6f6e4e5, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x02020202, 0xfdfdfdfe, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, - 0xf9f9f9fa, 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, 0x0504fafb, 0xfafb0505, 0xfafb0505, - 0x0504fafb, 0x0b0b0606, 0xf4f4f9fa, 0x06060b0b, 0xf9f9f4f5, 0x08080000, 0xf7f80000, 0x00000808, - 0xfffff7f8, 0x0b0b0b0b, 0xf4f4f4f5, 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x11110c0c, - 0xeeeef3f4, 0x0c0c1111, 0xf3f3eeef, 0x11111111, 0xeeeeeeef, 0x12120606, 0xededf9fa, 0x06061212, - 0xf9f9edee, 0x0b0af7f8, 0xf4f50808, 0xf7f80b0b, 0x0807f4f5, 0x0f0f0000, 0xf0f10000, 0x00000f0f, - 0xfffff0f1, 0x14140000, 0xebec0000, 0x00001414, 0xffffebec, 0x19191212, 0xe6e6edee, 0x12121919, - 0xedede6e7, 0x19190b0b, 0xe6e6f4f5, 0x0b0b1919, 0xf4f4e6e7, 0x19191919, 0xe6e6e6e7, 0x0e0df1f2, - 0xf1f20e0e, 0xf1f20e0e, 0x0e0df1f2, 0x1a1a0000, 0xe5e60000, 0x00001a1a, 0xffffe5e6, 0x1211f4f5, - 0xedee0b0b, 0xf4f51212, 0x0b0aedee, 0x1615f8f9, 0xe9ea0707, 0xf8f91616, 0x0706e9ea, 0x22221a1a, - 0xdddde5e6, 0x1a1a2222, 0xe5e5ddde, 0x22221212, 0xddddedee, 0x12122222, 0xededddde, 0x22222222, - 0xddddddde, 0x23230b0b, 0xdcdcf4f5, 0x0b0b2323, 0xf4f4dcdd, 0x1d1d0000, 0xe2e30000, 0x00001d1d, - 0xffffe2e3, 0x1615eced, 0xe9ea1313, 0xeced1616, 0x1312e9ea, 0x1a19f0f1, 0xe5e60f0f, 0xf0f11a1a, - 0x0f0ee5e6, 0x25250000, 0xdadb0000, 0x00002525, 0xffffdadb, 0x2c2c1b1b, 0xd3d3e4e5, 0x1b1b2c2c, - 0xe4e4d3d4, 0x2c2c2424, 0xd3d3dbdc, 0x24242c2c, 0xdbdbd3d4, 0x2c2c1212, 0xd3d3edee, 0x12122c2c, - 0xededd3d4, 0x2120f5f6, 0xdedf0a0a, 0xf5f62121, 0x0a09dedf, 0x2d2d2d2d, 0xd2d2d2d3, 0x00000000, - 0x00000000, 0x02020202, 0xfdfdfdfe, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, - 0xf9f9f9fa, 0x07070000, 0xf8f90000, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x03030000, 0xfcfd0000, - 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x07070000, 0xf8f90000, 0x00000000, 0x02020202, - 0xfdfdfdfe, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x07070000, - 0xf8f90000, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, - 0x06060606, 0xf9f9f9fa, 0x07070000, 0xf8f90000, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x03030000, - 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x07070000, 0xf8f90000, 0x00000000, - 0x02020202, 0xfdfdfdfe, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, - 0x07070000, 0xf8f90000, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x03030000, 0xfcfd0000, 0x00000303, - 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x07070000, 0xf8f90000, 0x00000000, 0x02020202, 0xfdfdfdfe, - 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x07070000, 0xf8f90000, - 0x00000000, 0x02020202, 0xfdfdfdfe, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, - 0xf9f9f9fa, 0x07070000, 0xf8f90000, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x03030000, 0xfcfd0000, - 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x07070000, 0xf8f90000, 0x00000000, 0x02020202, - 0xfdfdfdfe, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x07070000, - 0xf8f90000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x02020202, 0xfdfdfdfe, 0x06060606, - 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x0403fbfc, 0xfbfc0404, 0xf9fa0a0a, - 0x0605f5f6, 0xf3f40000, 0x0c0c0000, 0xf3f3f9fa, 0xf3f40606, 0x0c0bf9fa, 0x0c0c0606, 0xfffff1f2, - 0x00000e0e, 0x0c0c0c0c, 0xf3f3f3f4, 0xedee0000, 0x12120000, 0xf3f40e0e, 0x0c0bf1f2, 0xf9f9edee, - 0xf9fa1212, 0x0605edee, 0x06061212, 0xededf5f6, 0xedee0a0a, 0x1211f5f6, 0x12120a0a, 0xffffe9ea, - 0x00001616, 0xe7e80000, 0x18180000, 0xf3f3e9ea, 0xf3f41616, 0x0c0be9ea, 0x0c0c1616, 0xe7e7f7f8, - 0xe7e80808, 0x1817f7f8, 0x18180808, 0xf9f9e5e6, 0xf9fa1a1a, 0x0605e5e6, 0x06061a1a, 0xffffe3e4, - 0x00001c1c, 0x14141414, 0xebebebec, 0xe5e5f1f2, 0x1a1a0e0e, 0xf3f3e1e2, 0x0c0c1e1e, 0xdfdff5f6, - 0x20200a0a, 0xdfdfedee, 0x20201212, 0xe5e5e5e6, 0x1a1a1a1a, 0xebebddde, 0x14142222, 0xf3f3d9da, - 0x0c0c2626, 0xdfdfdfe0, 0x20202020, 0x20202020, 0xd7d7e9ea, 0xddddddde, 0x22222222, 0x00000000, - 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, - 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, - 0xfffffdfe, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, - 0xfffff9fa, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x02020202, 0xfdfdfdfe, - 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x00000000, 0x02020000, - 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x06060000, - 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, - 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, - 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x02020202, 0xfdfdfdfe, 0x06060606, - 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x00000000, 0x02020000, 0xfdfe0000, - 0x00000202, 0xfffffdfe, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, - 0x00000606, 0xfffff9fa, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x02020202, - 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x00000000, - 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, - 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, - 0xfffffdfe, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, - 0xfffff9fa, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x02020202, 0xfdfdfdfe, - 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x00000000, 0x02020000, - 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x06060000, - 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, - 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, - 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x0605f9fa, 0xf9fa0606, 0xf7f80e0e, - 0x0807f1f2, 0xffffedee, 0x00001212, 0xeff00a0a, 0x100ff5f6, 0xe7e80000, 0x18180000, 0xf7f7e7e8, - 0xf7f81818, 0x0807e7e8, 0x08081818, 0x12121212, 0xedededee, 0xeff01414, 0x100febec, 0xe5e5f1f2, - 0xe5e60e0e, 0x1a19f1f2, 0x1a1a0e0e, 0xffffe1e2, 0x00001e1e, 0xddde0000, 0x22220000, 0xf7f7ddde, - 0xf7f82222, 0x0807ddde, 0x08082222, 0xedede1e2, 0xedee1e1e, 0x1211e1e2, 0x12121e1e, 0xddddf5f6, - 0xddde0a0a, 0x2221f5f6, 0x22220a0a, 0xddddebec, 0x22221414, 0xffffd7d8, 0x00002828, 0x1e1e1e1e, - 0xe1e1e1e2, 0xededd7d8, 0x12122828, 0xd3d40000, 0x2c2c0000, 0xd3d3eff0, 0x2c2c1010, 0xdbdbdbdc, - 0xdbdbdbdc, 0x24242424, 0xd3d3e5e6, 0x2c2c1a1a, 0xe5e5d1d2, 0x1a1a2e2e, 0xededcbcc, 0x12123434, - 0xc9c9ebec, 0xd3d3d3d4, 0x2c2c2c2c, 0xc9c9dfe0, 0xd1d1d1d2, 0xd1d1d1d2, 0x2e2e2e2e, 0x00000000, - 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, - 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, - 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, 0x00000a0a, - 0xfffff5f6, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, - 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x00000000, 0x02020000, - 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, - 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, - 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, - 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, - 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x00000000, 0x02020000, 0xfdfe0000, - 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, - 0x00000a0a, 0xfffff5f6, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, - 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x00000000, - 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, - 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, - 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, 0x00000a0a, - 0xfffff5f6, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, - 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x00000000, 0x02020000, - 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, - 0xf5f60000, 0x00000a0a, 0xfffff5f6, 0x00000000, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, - 0x04040404, 0xfbfbfbfc, 0x0a0a0a0a, 0xf5f5f5f6, 0x0a0a0000, 0xf5f60000, 0x00000a0a, 0xfffff5f6, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, - 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x0807f7f8, 0xf7f80808, 0xeff00808, - 0x100ff7f8, 0xe7e80000, 0x18180000, 0xf7f7e7e8, 0xf7f81818, 0x0807e7e8, 0x08081818, 0xeff01414, - 0x100febec, 0xffffe3e4, 0x00001c1c, 0xe7e7eff0, 0xe7e81010, 0x1817eff0, 0x18181010, 0xdfe00000, - 0x20200000, 0xefefe3e4, 0xeff01c1c, 0x100fe3e4, 0x10101c1c, 0xdfdff7f8, 0xdfe00808, 0xf7f7dfe0, - 0xf7f82020, 0x0807dfe0, 0x08082020, 0x201ff7f8, 0x20200808, 0x18181818, 0xe7e7e7e8, 0xe7e81818, - 0x1817e7e8, 0xdfdfebec, 0x20201414, 0xffffd7d8, 0x00002828, 0xefefd7d8, 0x10102828, 0xd3d40000, - 0xd3d40000, 0xffffd3d4, 0x00002c2c, 0x2c2c0000, 0x2c2c0000, 0xdfdfdfe0, 0x20202020, 0xd3d3eff0, - 0x2c2c1010, 0xd3d3e7e8, 0xe7e7d3d4, 0x18182c2c, 0x2c2c1818, 0xefefcfd0, 0x10103030, 0xdbdbdbdc, - 0xdbdbdbdc, 0x24242424, 0x24242424, 0xcbcbebec, 0x28282828, 0xd7d7d7d8, 0xcbcbdfe0, 0x00000000, - 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, - 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x00000000, 0x04040000, 0xfbfc0000, 0x00000404, - 0xfffffbfc, 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, 0x00000c0c, - 0xfffff3f4, 0x00000000, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x04040404, 0xfbfbfbfc, - 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x00000000, 0x04040000, - 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, - 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x00000000, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, - 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, - 0x00000000, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, - 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x00000000, 0x04040000, 0xfbfc0000, - 0x00000404, 0xfffffbfc, 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, - 0x00000c0c, 0xfffff3f4, 0x00000000, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x04040404, - 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x00000000, - 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, - 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x00000000, 0x04040000, 0xfbfc0000, 0x00000404, - 0xfffffbfc, 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, 0x00000c0c, - 0xfffff3f4, 0x00000000, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x04040404, 0xfbfbfbfc, - 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x00000000, 0x04040000, - 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, - 0xf3f40000, 0x00000c0c, 0xfffff3f4, 0x00000000, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, - 0x04040404, 0xfbfbfbfc, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0000, 0xf3f40000, 0x00000c0c, 0xfffff3f4, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, - 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, - 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, - 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, - 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, - 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, - 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, - 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, - 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, - 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, - 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, - 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, - 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, - 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, - 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, - 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, - 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, - 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, - 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, - 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, - 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, - 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, - 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, - 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, - 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, - 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, - 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, - 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, - 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, - 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, - 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, - 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, - 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, - 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, - 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, - 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, - 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, - 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, - 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, - 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, - 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, - 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, - 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, - 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, - 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, - 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, - 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, - 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, - 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, - 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, - 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, - 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, - 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, - 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, - 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, - 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, - 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, - 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, - 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, - 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, - 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, - 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, - 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, - 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, - 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, - 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, - 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, - 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, - 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, - 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, - 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, - 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, - 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, - 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, - 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, - 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, - 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, - 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, - 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, - 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, - 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, - 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, - 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, - 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x06060606, 0xf9f9f9fa, - 0x0c0c0c0c, 0xf3f3f3f4, 0x14141414, 0xebebebec, 0x20202020, 0xdfdfdfe0, 0x2e2e2e2e, 0xd1d1d1d2, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 -}; +#define TAB_1_2 \ + PD( 0, 0), E2( 3, 3), E4( -1, 4), E2( 7, 7), E4( 2, 8),\ + E4( -2, 9), E2( -6, 6), E4( 6, 13), E2( 13, 13), E4( 1, 14),\ + E4( -8, 12), E4( 14, 23), E4( -5, 18), E4( 6, 24), E2( 24, 24),\ + E4( -1, 27), E2( -17, 17), E4( -13, 23), E4( 16, 40), E4( 28, 41),\ + E4( -9, 33), E4( 6, 43), E2( 46, 46), E4( -4, 50), E4( -27, 34),\ + E4( -22, 45), E4( 34, 69), E4( 19, 70), E4( 53, 73), E4( -17, 62),\ + E4( 5, 77), E2( 82, 82), E2( -51, 51), E4( -43, 64), E4( -10, 90),\ + E4( 41, 114), E4( 64, 116), E4( -37, 82), E4( 22, 119), E4( 95, 124),\ + E4( -30, 111), E4( -78, 92), E4( -68, 113), E2( 18, 18), E2( 34, 34),\ + E2( 63, 63), E2( 109, 109) + +#define TAB_1_3 \ + PD( 0, 0), E2( 4, 4), E4( -1, 5), E4( 3, 10), E2( 9, 9),\ + E2( -7, 7), E4( -3, 12), E4( 8, 17), E2( 17, 17), E4( 1, 19),\ + E4( -11, 16), E4( -6, 23), E4( 18, 31), E4( 8, 32), E2( 33, 33),\ + E4( -1, 36), E2( -23, 23), E4( -17, 31), E4( 21, 54), E4( 37, 55),\ + E4( -12, 44), E4( 8, 57), E2( 61, 61), E4( -5, 66), E4( -36, 45),\ + E4( -29, 60), E4( 45, 92), E4( 25, 93), E4( 71, 97), E4( -22, 83),\ + E4( 7, 102), E2( 109, 109), E2( -68, 68), E4( -57, 85), E4( -13, 120),\ + E4( -49, 110), E4(-104, 123), E2( 24, 24), E2( 46, 46), E2( 84, 84) + +#define TAB_1_4 \ + PD( 0, 0), E2( 5, 5), E4( -2, 7), E2( 11, 11), E4( 3, 13),\ + E2( -9, 9), E4( -4, 15), E4( 11, 22), E2( 21, 21), E4( 2, 24),\ + E4( -14, 20), E4( 23, 38), E4( -8, 29), E4( 11, 39), E2( 41, 41),\ + E4( -1, 45), E2( -29, 29), E4( -22, 39), E4( 27, 67), E4( 47, 69),\ + E4( -15, 56), E4( 11, 71), E2( 76, 76), E4( -6, 83), E4( -45, 57),\ + E4( -36, 75), E4( 56, 115), E4( 31, 117), E4( 88, 122), E4( -28, 104),\ + E2( -85, 85), E4( -72, 106), E2( 30, 30), E2( 58, 58), E2( 105, 105) + +#define TAB_1_5 \ + PD( 0, 0), E2( 6, 6), E4( -2, 8), E2( 13, 13), E4( 4, 15),\ + E2( -11, 11), E4( -5, 18), E4( 13, 26), E2( 26, 26), E4( 2, 29),\ + E4( -16, 24), E4( 28, 46), E4( -9, 35), E4( 13, 47), E2( 49, 49),\ + E4( -1, 54), E2( -35, 35), E4( -26, 47), E4( 32, 81), E4( 56, 83),\ + E4( -18, 67), E4( 13, 86), E2( 91, 91), E4( -7, 99), E4( -54, 68),\ + E4( -44, 90), E4( -33, 124), E2(-103, 103), E4( -86, 127), E2( 37, 37),\ + E2( 69, 69) + +#define TAB_1_6 \ + PD( 0, 0), E2( 7, 7), E4( -3, 10), E2( 16, 16), E4( 5, 18),\ + E2( -13, 13), E4( -6, 21), E4( 15, 30), E2( 30, 30), E4( 2, 34),\ + E4( -19, 28), E4( 32, 54), E4( -11, 41), E4( 15, 55), E2( 57, 57),\ + E4( -1, 63), E2( -40, 40), E4( -30, 55), E4( 37, 94), E4( 65, 96),\ + E4( -21, 78), E4( 15, 100), E2( 106, 106), E4( -8, 116), E4( -63, 79),\ + E4( -51, 105), E2(-120, 120), E2( 43, 43), E2( 80, 80) + +#define TAB_1_7 \ + PD( 0, 0), E2( 8, 8), E4( -3, 11), E2( 18, 18), E4( 5, 20),\ + E2( -15, 15), E4( -7, 24), E4( 17, 35), E2( 34, 34), E4( 3, 38),\ + E4( -22, 32), E4( 37, 61), E4( -13, 47), E4( 17, 63), E2( 65, 65),\ + E4( -1, 72), E2( -46, 46), E4( -35, 63), E4( 43, 107), E4( 75, 110),\ + E4( -24, 89), E4( 17, 114), E2( 121, 121), E4( -72, 91), E4( -58, 120),\ + E2( 49, 49), E2( 92, 92) + +#define TAB_1_8 \ + PD( 0, 0), E2( 9, 9), E4( -3, 12), E2( 20, 20), E4( 6, 23),\ + E2( -17, 17), E4( -7, 27), E4( 19, 39), E2( 39, 39), E4( 3, 43),\ + E4( -24, 36), E4( 42, 69), E4( -14, 53), E4( 19, 71), E2( 73, 73),\ + E4( -2, 80), E2( -52, 52), E4( -39, 70), E4( 48, 121), E4( 84, 124),\ + E4( -27, 100), E4( -81, 102), E2( 55, 55), E2( 104, 104) + +#define TAB_2_1 \ + PD( 0, 0), E2( 2, 2), E4( 0, 2), E2( 4, 4), E4( 0, 4),\ + E2( -4, 4), E4( -2, 6), E4( 4, 8), E2( 8, 8), E4( 0, 10),\ + E4( -4, 8), E4( 8, 14), E4( -2, 12), E4( 4, 16), E2( 16, 16),\ + E4( 0, 18), E2( -12, 12), E4( -8, 16), E4( 10, 26), E4( 18, 28),\ + E4( -6, 22), E4( 4, 28), E2( 30, 30), E4( -2, 32), E4( -18, 22),\ + E4( -14, 30), E4( 22, 46), E4( 12, 46), E4( 34, 48), E4( -10, 40),\ + E4( 4, 50), E2( 54, 54), E2( -34, 34), E4( -28, 42), E4( -6, 60),\ + E4( 26, 76), E4( 42, 76), E4( -24, 54), E4( 14, 78), E4( 62, 82),\ + E4( -20, 74), E4( 2, 88), E2( 92, 92), E4( -52, 60), E4( 52, 118),\ + E4( -44, 74), E4( 74, 118), E4( 32, 118), E4( -12, 102), E4( -40, 96),\ + E4( -34, 118), E2( -88, 88), E4( -78, 104), E2( 12, 12), E2( 22, 22),\ + E2( 42, 42), E2( 72, 72) + +#define TAB_2_2 \ + PD( 0, 0), E2( 3, 3), E4( 0, 3), E2( 6, 6), E4( 3, 9),\ + E4( -3, 9), E2( -6, 6), E4( 6, 12), E2( 12, 12), E4( 0, 15),\ + E4( -9, 12), E4( 15, 24), E4( -6, 18), E4( 6, 24), E2( 24, 24),\ + E4( 0, 27), E2( -18, 18), E4( -12, 24), E4( 15, 39), E4( 27, 42),\ + E4( -9, 33), E4( 6, 42), E2( 45, 45), E4( -3, 51), E4( -27, 33),\ + E4( -21, 45), E4( 33, 69), E4( 18, 69), E4( 54, 72), E4( -18, 63),\ + E4( 6, 78), E2( 81, 81), E2( -51, 51), E4( -42, 63), E4( -9, 90),\ + E4( 42, 114), E4( 63, 117), E4( -36, 81), E4( 21, 120), E4( 96, 123),\ + E4( -30, 111), E4( -78, 93), E4( -69, 114), E2( 18, 18), E2( 33, 33),\ + E2( 63, 63), E2( 108, 108) + +#define TAB_2_3 \ + PD( 0, 0), E2( 4, 4), E4( 0, 4), E4( 4, 8), E2( 8, 8),\ + E2( -8, 8), E4( -4, 12), E4( 8, 16), E2( 16, 16), E4( 0, 20),\ + E4( -12, 16), E4( -4, 24), E4( 16, 32), E4( 8, 32), E2( 32, 32),\ + E4( 0, 36), E2( -24, 24), E4( -16, 32), E4( 20, 52), E4( 36, 56),\ + E4( -12, 44), E4( 8, 56), E2( 60, 60), E4( -4, 64), E4( -36, 44),\ + E4( -28, 60), E4( 44, 92), E4( 24, 92), E4( 72, 96), E4( -20, 84),\ + E4( 8, 100), E2( 108, 108), E2( -68, 68), E4( -56, 84), E4( -12, 120),\ + E4( -48, 108), E4(-104, 124), E2( 24, 24), E2( 44, 44), E2( 84, 84) + +#define TAB_2_4 \ + PD( 0, 0), E2( 5, 5), E4( 0, 5), E2( 10, 10), E4( 5, 15),\ + E2( -10, 10), E4( -5, 15), E4( 10, 20), E2( 20, 20), E4( 0, 25),\ + E4( -15, 20), E4( 25, 40), E4( -10, 30), E4( 10, 40), E2( 40, 40),\ + E4( 0, 45), E2( -30, 30), E4( -20, 40), E4( 25, 65), E4( 45, 70),\ + E4( -15, 55), E4( 10, 70), E2( 75, 75), E4( -5, 85), E4( -45, 55),\ + E4( -35, 75), E4( 55, 115), E4( 30, 115), E4( 90, 120), E4( -30, 105),\ + E2( -85, 85), E4( -70, 105), E2( 30, 30), E2( 60, 60), E2( 105, 105) + +#define TAB_2_5 \ + PD( 0, 0), E2( 6, 6), E4( 0, 6), E2( 12, 12), E4( 6, 12),\ + E2( -12, 12), E4( -6, 18), E4( 12, 24), E2( 24, 24), E4( 0, 30),\ + E4( -18, 24), E4( 30, 48), E4( -6, 36), E4( 12, 48), E2( 48, 48),\ + E4( 0, 54), E2( -36, 36), E4( -24, 48), E4( 30, 78), E4( 54, 84),\ + E4( -18, 66), E4( 12, 84), E2( 90, 90), E4( -6, 96), E4( -54, 66),\ + E4( -42, 90), E4( -30, 126), E2(-102, 102), E4( -84, 126), E2( 36, 36),\ + E2( 66, 66) + +#define TAB_2_6 \ + PD( 0, 0), E2( 7, 7), E4( 0, 7), E2( 14, 14), E4( 7, 21),\ + E2( -14, 14), E4( -7, 21), E4( 14, 28), E2( 28, 28), E4( 0, 35),\ + E4( -21, 28), E4( 35, 56), E4( -14, 42), E4( 14, 56), E2( 56, 56),\ + E4( 0, 63), E2( -42, 42), E4( -28, 56), E4( 35, 91), E4( 63, 98),\ + E4( -21, 77), E4( 14, 98), E2( 105, 105), E4( -7, 119), E4( -63, 77),\ + E4( -49, 105), E2(-119, 119), E2( 42, 42), E2( 77, 77) + +#define TAB_2_7 \ + PD( 0, 0), E2( 8, 8), E4( 0, 8), E2( 16, 16), E4( 8, 16),\ + E2( -16, 16), E4( -8, 24), E4( 16, 32), E2( 32, 32), E4( 0, 40),\ + E4( -24, 32), E4( 40, 64), E4( -16, 48), E4( 16, 64), E2( 64, 64),\ + E4( 0, 72), E2( -48, 48), E4( -32, 64), E4( 40, 104), E4( 72, 112),\ + E4( -24, 88), E4( 16, 112), E2( 120, 120), E4( -72, 88), E4( -56, 120),\ + E2( 48, 48), E2( 88, 88) + +#define TAB_2_8 \ + PD( 0, 0), E2( 9, 9), E4( 0, 9), E2( 18, 18), E4( 9, 27),\ + E2( -18, 18), E4( -9, 27), E4( 18, 36), E2( 36, 36), E4( 0, 45),\ + E4( -27, 36), E4( 45, 72), E4( -18, 54), E4( 18, 72), E2( 72, 72),\ + E4( 0, 81), E2( -54, 54), E4( -36, 72), E4( 45, 117), E4( 81, 126),\ + E4( -27, 99), E4( -81, 99), E2( 54, 54), E2( 108, 108) + +#define TAB_3_1 \ + PD( 0, 0), E2( 2, 2), E4( 0, 3), E2( 6, 6), E4( 0, 7),\ + E2( -5, 5), E2( 5, -5), E4( 6, 11), E4( 0, 8), E2( 11, 11),\ + E4( 0, 12), E4( 12, 17), E2( 17, 17), E4( 6, 18), E4( -8, 11),\ + E4( 0, 15), E4( 0, 20), E4( 18, 25), E4( 11, 25), E2( 25, 25),\ + E2( -14, 14), E2( 14, -14), E4( 0, 26), E4( -11, 18), E4( -7, 22),\ + E4( 26, 34), E4( 18, 34), E2( 34, 34), E4( 11, 35), E4( 0, 29),\ + E4( -19, 22), E4( -15, 26), E4( 0, 37), E4( 27, 44), E4( 36, 44),\ + E4( 18, 44), E4( -10, 33), E2( 45, 45) + +#define TAB_3_2 \ + PD( 0, 0), E4( 0, 2), E2( 2, 2), E2( 6, 6), E4( 0, 6),\ + E2( -4, 4), E2( 10, -6), E2( 0, -12), PD( -6, -12), E2( 6, -12),\ + PD( 6, 12), E2( -14, 0), E2( 12, 12), E2( 0, -18), E2( 14, -12),\ + PD( -18, -6), E2( 18, -6), PD( 18, 6), PD( -10, -18), E2( 10, -18),\ + PD( 10, 18), E2( -22, 0), E2( 0, -24), PD( -22, -12), E2( 22, -12),\ + PD( 22, 12), PD( -8, -24), E2( 8, -24), PD( 8, 24), PD( -26, -6),\ + E2( 26, -6), PD( 26, 6), E2( -28, 0), E2( 20, 20), E2( -14, -26),\ + E2( -30, -12), E2( -10, -32), E2( -18, -32), E2( -26, -26), E2( -34, -20),\ + E2( -38, -12), E2( -32, -32), PD( 32, 32), PD( -22, -40), E2( -34, -34) + +#define TAB_3_3 \ + PD( 0, 0), E4( 0, 2), E2( 4, 4), E2( 10, 10), E4( 0, 10),\ + E2( -6, 6), E2( 14, -8), E2( -18, 0), E2( 10, -16), E2( 0, -24),\ + PD( -24, -8), E2( 24, -8), PD( 24, 8), E2( 18, 18), E2( 20, -16),\ + PD( -14, -26), E2( 14, -26), PD( 14, 26), E2( -30, 0), E2( 0, -34),\ + PD( -34, -8), E2( 34, -8), PD( 34, 8), PD( -30, -18), E2( 30, -18),\ + PD( 30, 18), PD( -10, -34), E2( 10, -34), PD( 10, 34), E2( -20, -34),\ + E2( -40, 0), E2( 30, 30), E2( -40, -18), E2( 0, -44), E2( -16, -44),\ + PD( -36, -36), E2( -36, -36), E2( -26, -44), E2( -46, -26), E2( -52, -18),\ + PD( -20, -54), E2( -44, -44), PD( -32, -54), PD( -46, -46), E2( -46, -46) + +#define TAB_3_4 \ + PD( 0, 0), E4( 0, 4), E2( 4, 4), E2( 12, 12), E4( 0, 12),\ + E2( -8, 8), E2( 8, -16), E2( 0, -24), PD( -24, -8), E2( 24, -8),\ + PD( 24, 8), E2( 20, -16), E2( -28, 0), PD( -16, -24), E2( 16, -24),\ + PD( 16, 24), E2( 0, -32), PD( -28, -16), E2( 28, -16), PD( 28, 16),\ + PD( -8, -32), PD( 8, -32), PD( -32, -8), E2( 32, -8), PD( 32, 8),\ + PD( -8, 32), PD( 8, 32), E2( 24, 24), E2( 24, -24), E2( -20, -32),\ + E2( -40, 0), E2( -40, -16), PD( 0, -44), PD( 0, -44), E2( -44, 0),\ + PD( 0, 44), PD( 0, 44), E2( -32, -32), E2( -16, -44), PD( -24, -44),\ + E2( -44, -24), PD( 24, 44), E2( -48, -16), PD( -36, -36), E2( -36, -36),\ + PD( 36, 36), PD( -20, -52), E2( 40, 40), PD( -32, -52) + +#define TAB_3_5 \ + PD( 0, 0), E2( 2, 2), E2( 6, 6), E2( 12, 12), E2( 20, 20),\ + E2( 32, 32), E2( 46, 46) + + +/** + * Pack two delta values (a,b) into one 16bit word + * according with endianess of the host machine. + */ +#if HAVE_BIGENDIAN +#define PD(a,b) (((a) << 8) + (b)) +#else +#define PD(a,b) (((b) << 8) + (a)) +#endif + +/** + * Expand a pair of delta values (a,b) + * into two/four delta entries. + */ +#define E2(a, b) PD(a, b), PD(-a, -b) +#define E4(a, b) PD(a, b), PD(-a, -b), PD(b, a), PD(-b, -a) + +/* + * VQ tables for 4x4 block modes. + * Let the compiler decompress and build the tables for us. + */ +static const int16_t delta_tab_1_1[195] = { TAB_1_1 }; +static const int16_t delta_tab_1_2[159] = { TAB_1_2 }; +static const int16_t delta_tab_1_3[133] = { TAB_1_3 }; +static const int16_t delta_tab_1_4[115] = { TAB_1_4 }; +static const int16_t delta_tab_1_5[101] = { TAB_1_5 }; +static const int16_t delta_tab_1_6[93] = { TAB_1_6 }; +static const int16_t delta_tab_1_7[87] = { TAB_1_7 }; +static const int16_t delta_tab_1_8[77] = { TAB_1_8 }; + +static const int16_t delta_tab_2_1[195] = { TAB_2_1 }; +static const int16_t delta_tab_2_2[159] = { TAB_2_2 }; +static const int16_t delta_tab_2_3[133] = { TAB_2_3 }; +static const int16_t delta_tab_2_4[115] = { TAB_2_4 }; +static const int16_t delta_tab_2_5[101] = { TAB_2_5 }; +static const int16_t delta_tab_2_6[93] = { TAB_2_6 }; +static const int16_t delta_tab_2_7[87] = { TAB_2_7 }; +static const int16_t delta_tab_2_8[77] = { TAB_2_8 }; + +static const int16_t delta_tab_3_1[128] = { TAB_3_1 }; +static const int16_t delta_tab_3_2[79] = { TAB_3_2 }; +static const int16_t delta_tab_3_3[79] = { TAB_3_3 }; +static const int16_t delta_tab_3_4[79] = { TAB_3_4 }; +static const int16_t delta_tab_3_5[79] = { TAB_3_5 }; + +#undef PD + +/** + * Pack four delta values (a,a,b,b) into one 32bit word + * according with endianess of the host machine. + */ +#if HAVE_BIGENDIAN +#define PD(a,b) (((a) << 24) + ((a) << 16) + ((b) << 8) + (b)) +#else +#define PD(a,b) (((b) << 24) + ((b) << 16) + ((a) << 8) + (a)) +#endif + +/* + * VQ tables for 8x8 block modes. + * Those are based on the same delta tables by using + * each value twice: ABCD --> AABBCCDD. + */ +static const int32_t delta_tab_1_1_m10[195] = { TAB_1_1 }; +static const int32_t delta_tab_1_2_m10[159] = { TAB_1_2 }; +static const int32_t delta_tab_1_3_m10[133] = { TAB_1_3 }; +static const int32_t delta_tab_1_4_m10[115] = { TAB_1_4 }; +static const int32_t delta_tab_1_5_m10[101] = { TAB_1_5 }; +static const int32_t delta_tab_1_6_m10[93] = { TAB_1_6 }; +static const int32_t delta_tab_1_7_m10[87] = { TAB_1_7 }; +static const int32_t delta_tab_1_8_m10[77] = { TAB_1_8 }; + +static const int32_t delta_tab_2_1_m10[195] = { TAB_2_1 }; +static const int32_t delta_tab_2_2_m10[159] = { TAB_2_2 }; +static const int32_t delta_tab_2_3_m10[133] = { TAB_2_3 }; +static const int32_t delta_tab_2_4_m10[115] = { TAB_2_4 }; +static const int32_t delta_tab_2_5_m10[101] = { TAB_2_5 }; +static const int32_t delta_tab_2_6_m10[93] = { TAB_2_6 }; +static const int32_t delta_tab_2_7_m10[87] = { TAB_2_7 }; +static const int32_t delta_tab_2_8_m10[77] = { TAB_2_8 }; + +static const int32_t delta_tab_3_1_m10[128] = { TAB_3_1 }; +static const int32_t delta_tab_3_2_m10[79] = { TAB_3_2 }; +static const int32_t delta_tab_3_3_m10[79] = { TAB_3_3 }; +static const int32_t delta_tab_3_4_m10[79] = { TAB_3_4 }; +static const int32_t delta_tab_3_5_m10[79] = { TAB_3_5 }; + + +typedef struct { + const int16_t *deltas; ///< delta tables for 4x4 block modes + const int32_t *deltas_m10; ///< delta tables for 8x8 block modes + uint8_t num_dyads; ///< number of two-pixel deltas + uint8_t quad_exp; ///< log2 of four-pixel deltas +} vqEntry; + +static const vqEntry vq_tab[24] = { + /* set 1 */ + { delta_tab_1_1, delta_tab_1_1_m10, 195, 7 }, + { delta_tab_1_2, delta_tab_1_2_m10, 159, 9 }, + { delta_tab_1_3, delta_tab_1_3_m10, 133, 10 }, + { delta_tab_1_4, delta_tab_1_4_m10, 115, 11 }, + { delta_tab_1_5, delta_tab_1_5_m10, 101, 12 }, + { delta_tab_1_6, delta_tab_1_6_m10, 93, 12 }, + { delta_tab_1_7, delta_tab_1_7_m10, 87, 12 }, + { delta_tab_1_8, delta_tab_1_8_m10, 77, 13 }, + /* set 2 */ + { delta_tab_2_1, delta_tab_2_1_m10, 195, 7 }, + { delta_tab_2_2, delta_tab_2_2_m10, 159, 9 }, + { delta_tab_2_3, delta_tab_2_3_m10, 133, 10 }, + { delta_tab_2_4, delta_tab_2_4_m10, 115, 11 }, + { delta_tab_2_5, delta_tab_2_5_m10, 101, 12 }, + { delta_tab_2_6, delta_tab_2_6_m10, 93, 12 }, + { delta_tab_2_7, delta_tab_2_7_m10, 87, 12 }, + { delta_tab_2_8, delta_tab_2_8_m10, 77, 13 }, -static const uint32_t correctionhighorder[] = { - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x0302feff, 0xfcfd0101, - 0xfeff0303, 0x0100fcfd, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x0302feff, 0xfcfd0101, 0xfeff0303, - 0x0100fcfd, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x0302feff, 0xfcfd0101, 0xfeff0303, 0x0100fcfd, - 0x00000000, 0x02020202, 0xfdfdfdfe, 0x0302feff, 0xfcfd0101, 0xfeff0303, 0x0100fcfd, 0x00000000, - 0x02020202, 0xfdfdfdfe, 0x0302feff, 0xfcfd0101, 0xfeff0303, 0x0100fcfd, 0x00000000, 0x02020202, - 0xfdfdfdfe, 0x0302feff, 0xfcfd0101, 0xfeff0303, 0x0100fcfd, 0x00000000, 0x02020202, 0xfdfdfdfe, - 0x0302feff, 0xfcfd0101, 0xfeff0303, 0x0100fcfd, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, - 0x03030303, 0xfcfcfcfd, 0x0403feff, 0xfbfc0101, 0xfeff0404, 0x0100fbfc, 0x07070707, 0xf8f8f8f9, - 0x00000000, 0x03030303, 0xfcfcfcfd, 0x0403feff, 0xfbfc0101, 0xfeff0404, 0x0100fbfc, 0x07070707, - 0xf8f8f8f9, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x0403feff, 0xfbfc0101, 0xfeff0404, 0x0100fbfc, - 0x07070707, 0xf8f8f8f9, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x0403feff, 0xfbfc0101, 0xfeff0404, - 0x0100fbfc, 0x07070707, 0xf8f8f8f9, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x0403feff, 0xfbfc0101, - 0xfeff0404, 0x0100fbfc, 0x07070707, 0xf8f8f8f9, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x0403feff, - 0xfbfc0101, 0xfeff0404, 0x0100fbfc, 0x07070707, 0xf8f8f8f9, 0x00000000, 0x03030303, 0xfcfcfcfd, - 0x0403feff, 0xfbfc0101, 0xfeff0404, 0x0100fbfc, 0x07070707, 0xf8f8f8f9, 0x00000000, 0x03030303, - 0xfcfcfcfd, 0x0403feff, 0xfbfc0101, 0xfeff0404, 0x0100fbfc, 0x07070707, 0xf8f8f8f9, 0x00000000, - 0x03030303, 0xfcfcfcfd, 0x0403feff, 0xfbfc0101, 0xfeff0404, 0x0100fbfc, 0x07070707, 0xf8f8f8f9, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x04040404, 0xfbfbfbfc, - 0x0504feff, 0xfafb0101, 0xfeff0505, 0x0100fafb, 0x0a0a0303, 0xf5f5fcfd, 0x03030a0a, 0x00000000, - 0x04040404, 0xfbfbfbfc, 0x0504feff, 0xfafb0101, 0xfeff0505, 0x0100fafb, 0x0a0a0303, 0xf5f5fcfd, - 0x03030a0a, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x0504feff, 0xfafb0101, 0xfeff0505, 0x0100fafb, - 0x0a0a0303, 0xf5f5fcfd, 0x03030a0a, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x0504feff, 0xfafb0101, - 0xfeff0505, 0x0100fafb, 0x0a0a0303, 0xf5f5fcfd, 0x03030a0a, 0x00000000, 0x04040404, 0xfbfbfbfc, - 0x0504feff, 0xfafb0101, 0xfeff0505, 0x0100fafb, 0x0a0a0303, 0xf5f5fcfd, 0x03030a0a, 0x00000000, - 0x04040404, 0xfbfbfbfc, 0x0504feff, 0xfafb0101, 0xfeff0505, 0x0100fafb, 0x0a0a0303, 0xf5f5fcfd, - 0x03030a0a, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x0504feff, 0xfafb0101, 0xfeff0505, 0x0100fafb, - 0x0a0a0303, 0xf5f5fcfd, 0x03030a0a, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x0504feff, 0xfafb0101, - 0xfeff0505, 0x0100fafb, 0x0a0a0303, 0xf5f5fcfd, 0x03030a0a, 0x00000000, 0x04040404, 0xfbfbfbfc, - 0x0504feff, 0xfafb0101, 0xfeff0505, 0x0100fafb, 0x0a0a0303, 0xf5f5fcfd, 0x03030a0a, 0x00000000, - 0x04040404, 0xfbfbfbfc, 0x0504feff, 0xfafb0101, 0xfeff0505, 0x0100fafb, 0x0a0a0303, 0xf5f5fcfd, - 0x03030a0a, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x05050505, 0xfafafafb, 0x0706fdfe, 0xf8f90202, - 0xfdfe0707, 0x0201f8f9, 0x0b0b0b0b, 0xf4f4f4f5, 0x0d0d0303, 0xf2f2fcfd, 0x00000000, 0x05050505, - 0xfafafafb, 0x0706fdfe, 0xf8f90202, 0xfdfe0707, 0x0201f8f9, 0x0b0b0b0b, 0xf4f4f4f5, 0x0d0d0303, - 0xf2f2fcfd, 0x00000000, 0x05050505, 0xfafafafb, 0x0706fdfe, 0xf8f90202, 0xfdfe0707, 0x0201f8f9, - 0x0b0b0b0b, 0xf4f4f4f5, 0x0d0d0303, 0xf2f2fcfd, 0x00000000, 0x05050505, 0xfafafafb, 0x0706fdfe, - 0xf8f90202, 0xfdfe0707, 0x0201f8f9, 0x0b0b0b0b, 0xf4f4f4f5, 0x0d0d0303, 0xf2f2fcfd, 0x00000000, - 0x05050505, 0xfafafafb, 0x0706fdfe, 0xf8f90202, 0xfdfe0707, 0x0201f8f9, 0x0b0b0b0b, 0xf4f4f4f5, - 0x0d0d0303, 0xf2f2fcfd, 0x00000000, 0x05050505, 0xfafafafb, 0x0706fdfe, 0xf8f90202, 0xfdfe0707, - 0x0201f8f9, 0x0b0b0b0b, 0xf4f4f4f5, 0x0d0d0303, 0xf2f2fcfd, 0x00000000, 0x05050505, 0xfafafafb, - 0x0706fdfe, 0xf8f90202, 0xfdfe0707, 0x0201f8f9, 0x0b0b0b0b, 0xf4f4f4f5, 0x0d0d0303, 0xf2f2fcfd, - 0x00000000, 0x05050505, 0xfafafafb, 0x0706fdfe, 0xf8f90202, 0xfdfe0707, 0x0201f8f9, 0x0b0b0b0b, - 0xf4f4f4f5, 0x0d0d0303, 0xf2f2fcfd, 0x00000000, 0x05050505, 0xfafafafb, 0x0706fdfe, 0xf8f90202, - 0xfdfe0707, 0x0201f8f9, 0x0b0b0b0b, 0xf4f4f4f5, 0x0d0d0303, 0xf2f2fcfd, 0x00000000, 0x05050505, - 0xfafafafb, 0x0706fdfe, 0xf8f90202, 0xfdfe0707, 0x0201f8f9, 0x0b0b0b0b, 0xf4f4f4f5, 0x0d0d0303, - 0xf2f2fcfd, 0x00000000, 0x05050505, 0xfafafafb, 0x0706fdfe, 0xf8f90202, 0xfdfe0707, 0x0201f8f9, - 0x0b0b0b0b, 0xf4f4f4f5, 0x0d0d0303, 0xf2f2fcfd, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x06060606, 0xf9f9f9fa, - 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, - 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, - 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, - 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, - 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, - 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, - 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, - 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, - 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, - 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, - 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, - 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, - 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, - 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, - 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, - 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, - 0x04040f0f, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x0807fdfe, 0xf7f80202, 0xfdfe0808, 0x0201f7f8, - 0x0d0d0d0d, 0xf2f2f2f3, 0x0f0f0404, 0xf0f0fbfc, 0x04040f0f, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x07070707, 0xf8f8f8f9, - 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, - 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, - 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, - 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, - 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, - 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, - 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, - 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, - 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, - 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, - 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, - 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, - 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, - 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, - 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, - 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, - 0x05051212, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x0a09fcfd, 0xf5f60303, 0xfcfd0a0a, 0x0302f5f6, - 0x10101010, 0xefefeff0, 0x12120505, 0xededfafb, 0x05051212, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, - 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, - 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, - 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, - 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, - 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, - 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, - 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, - 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, - 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, - 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, - 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, - 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, - 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, - 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, - 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, - 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, - 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x0b0afcfd, 0xf4f50303, - 0xfcfd0b0b, 0x0302f4f5, 0x12121212, 0xedededee, 0x14140505, 0xebebfafb, 0x05051414, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x09090909, 0xf6f6f6f7, - 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x14141414, 0xebebebec, 0x17170606, 0xe8e8f9fa, - 0x06061717, 0xf9f9e8e9, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, - 0x0302f3f4, 0x14141414, 0xebebebec, 0x17170606, 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, 0x00000000, - 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x14141414, 0xebebebec, - 0x17170606, 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, - 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x14141414, 0xebebebec, 0x17170606, 0xe8e8f9fa, 0x06061717, - 0xf9f9e8e9, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, - 0x14141414, 0xebebebec, 0x17170606, 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, 0x00000000, 0x09090909, - 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x14141414, 0xebebebec, 0x17170606, - 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, - 0xfcfd0c0c, 0x0302f3f4, 0x14141414, 0xebebebec, 0x17170606, 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, - 0x00000000, 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x14141414, - 0xebebebec, 0x17170606, 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, 0x00000000, 0x09090909, 0xf6f6f6f7, - 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x14141414, 0xebebebec, 0x17170606, 0xe8e8f9fa, - 0x06061717, 0xf9f9e8e9, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, - 0x0302f3f4, 0x14141414, 0xebebebec, 0x17170606, 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, 0x00000000, - 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x14141414, 0xebebebec, - 0x17170606, 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, - 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, 0x14141414, 0xebebebec, 0x17170606, 0xe8e8f9fa, 0x06061717, - 0xf9f9e8e9, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x0c0bfcfd, 0xf3f40303, 0xfcfd0c0c, 0x0302f3f4, - 0x14141414, 0xebebebec, 0x17170606, 0xe8e8f9fa, 0x06061717, 0xf9f9e8e9, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x02020000, 0xfdfe0000, - 0x00000202, 0xfffffdfe, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x02020000, 0xfdfe0000, 0x00000202, - 0xfffffdfe, 0x00000000, 0x02020202, 0xfdfdfdfe, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, - 0x00000000, 0x02020202, 0xfdfdfdfe, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x00000000, - 0x02020202, 0xfdfdfdfe, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x00000000, 0x02020202, - 0xfdfdfdfe, 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x00000000, 0x02020202, 0xfdfdfdfe, - 0x02020000, 0xfdfe0000, 0x00000202, 0xfffffdfe, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, - 0x03030303, 0xfcfcfcfd, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, - 0x00000000, 0x03030303, 0xfcfcfcfd, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, - 0xf9f9f9fa, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, - 0x06060606, 0xf9f9f9fa, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x03030000, 0xfcfd0000, 0x00000303, - 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x03030000, 0xfcfd0000, - 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x00000000, 0x03030303, 0xfcfcfcfd, 0x03030000, - 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x00000000, 0x03030303, 0xfcfcfcfd, - 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x00000000, 0x03030303, - 0xfcfcfcfd, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, 0x00000000, - 0x03030303, 0xfcfcfcfd, 0x03030000, 0xfcfd0000, 0x00000303, 0xfffffcfd, 0x06060606, 0xf9f9f9fa, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x04040404, 0xfbfbfbfc, - 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x08080404, 0xf7f7fbfc, 0x04040808, 0x00000000, - 0x04040404, 0xfbfbfbfc, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x08080404, 0xf7f7fbfc, - 0x04040808, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, - 0x08080404, 0xf7f7fbfc, 0x04040808, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x04040000, 0xfbfc0000, - 0x00000404, 0xfffffbfc, 0x08080404, 0xf7f7fbfc, 0x04040808, 0x00000000, 0x04040404, 0xfbfbfbfc, - 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x08080404, 0xf7f7fbfc, 0x04040808, 0x00000000, - 0x04040404, 0xfbfbfbfc, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x08080404, 0xf7f7fbfc, - 0x04040808, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, - 0x08080404, 0xf7f7fbfc, 0x04040808, 0x00000000, 0x04040404, 0xfbfbfbfc, 0x04040000, 0xfbfc0000, - 0x00000404, 0xfffffbfc, 0x08080404, 0xf7f7fbfc, 0x04040808, 0x00000000, 0x04040404, 0xfbfbfbfc, - 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x08080404, 0xf7f7fbfc, 0x04040808, 0x00000000, - 0x04040404, 0xfbfbfbfc, 0x04040000, 0xfbfc0000, 0x00000404, 0xfffffbfc, 0x08080404, 0xf7f7fbfc, - 0x04040808, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x05050505, 0xfafafafb, 0x05050000, 0xfafb0000, - 0x00000505, 0xfffffafb, 0x0a0a0a0a, 0xf5f5f5f6, 0x0f0f0505, 0xf0f0fafb, 0x00000000, 0x05050505, - 0xfafafafb, 0x05050000, 0xfafb0000, 0x00000505, 0xfffffafb, 0x0a0a0a0a, 0xf5f5f5f6, 0x0f0f0505, - 0xf0f0fafb, 0x00000000, 0x05050505, 0xfafafafb, 0x05050000, 0xfafb0000, 0x00000505, 0xfffffafb, - 0x0a0a0a0a, 0xf5f5f5f6, 0x0f0f0505, 0xf0f0fafb, 0x00000000, 0x05050505, 0xfafafafb, 0x05050000, - 0xfafb0000, 0x00000505, 0xfffffafb, 0x0a0a0a0a, 0xf5f5f5f6, 0x0f0f0505, 0xf0f0fafb, 0x00000000, - 0x05050505, 0xfafafafb, 0x05050000, 0xfafb0000, 0x00000505, 0xfffffafb, 0x0a0a0a0a, 0xf5f5f5f6, - 0x0f0f0505, 0xf0f0fafb, 0x00000000, 0x05050505, 0xfafafafb, 0x05050000, 0xfafb0000, 0x00000505, - 0xfffffafb, 0x0a0a0a0a, 0xf5f5f5f6, 0x0f0f0505, 0xf0f0fafb, 0x00000000, 0x05050505, 0xfafafafb, - 0x05050000, 0xfafb0000, 0x00000505, 0xfffffafb, 0x0a0a0a0a, 0xf5f5f5f6, 0x0f0f0505, 0xf0f0fafb, - 0x00000000, 0x05050505, 0xfafafafb, 0x05050000, 0xfafb0000, 0x00000505, 0xfffffafb, 0x0a0a0a0a, - 0xf5f5f5f6, 0x0f0f0505, 0xf0f0fafb, 0x00000000, 0x05050505, 0xfafafafb, 0x05050000, 0xfafb0000, - 0x00000505, 0xfffffafb, 0x0a0a0a0a, 0xf5f5f5f6, 0x0f0f0505, 0xf0f0fafb, 0x00000000, 0x05050505, - 0xfafafafb, 0x05050000, 0xfafb0000, 0x00000505, 0xfffffafb, 0x0a0a0a0a, 0xf5f5f5f6, 0x0f0f0505, - 0xf0f0fafb, 0x00000000, 0x05050505, 0xfafafafb, 0x05050000, 0xfafb0000, 0x00000505, 0xfffffafb, - 0x0a0a0a0a, 0xf5f5f5f6, 0x0f0f0505, 0xf0f0fafb, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x06060606, 0xf9f9f9fa, - 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, - 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, - 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, - 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, - 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, - 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, - 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, - 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, - 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, - 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, - 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, - 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, - 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, - 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, - 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, - 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, - 0x06060c0c, 0x00000000, 0x06060606, 0xf9f9f9fa, 0x06060000, 0xf9fa0000, 0x00000606, 0xfffff9fa, - 0x0c0c0c0c, 0xf3f3f3f4, 0x0c0c0606, 0xf3f3f9fa, 0x06060c0c, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x07070707, 0xf8f8f8f9, - 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, - 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, - 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, - 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, - 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, - 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, - 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, - 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, - 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, - 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, - 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, - 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, - 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, - 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, - 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, - 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, - 0x07071515, 0x00000000, 0x07070707, 0xf8f8f8f9, 0x07070000, 0xf8f90000, 0x00000707, 0xfffff8f9, - 0x0e0e0e0e, 0xf1f1f1f2, 0x15150707, 0xeaeaf8f9, 0x07071515, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, - 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, - 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, - 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, - 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, - 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, - 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, - 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, - 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, - 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, - 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, - 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, - 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, - 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, - 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, - 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, - 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, - 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, 0x08080808, 0xf7f7f7f8, 0x08080000, 0xf7f80000, - 0x00000808, 0xfffff7f8, 0x10101010, 0xefefeff0, 0x10100808, 0xefeff7f8, 0x08081010, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, 0x09090909, 0xf6f6f6f7, - 0x09090000, 0xf6f70000, 0x00000909, 0xfffff6f7, 0x12121212, 0xedededee, 0x1b1b0909, 0xe4e4f6f7, - 0x09091b1b, 0xf6f6e4e5, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x09090000, 0xf6f70000, 0x00000909, - 0xfffff6f7, 0x12121212, 0xedededee, 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, 0x00000000, - 0x09090909, 0xf6f6f6f7, 0x09090000, 0xf6f70000, 0x00000909, 0xfffff6f7, 0x12121212, 0xedededee, - 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x09090000, - 0xf6f70000, 0x00000909, 0xfffff6f7, 0x12121212, 0xedededee, 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, - 0xf6f6e4e5, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x09090000, 0xf6f70000, 0x00000909, 0xfffff6f7, - 0x12121212, 0xedededee, 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, 0x00000000, 0x09090909, - 0xf6f6f6f7, 0x09090000, 0xf6f70000, 0x00000909, 0xfffff6f7, 0x12121212, 0xedededee, 0x1b1b0909, - 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x09090000, 0xf6f70000, - 0x00000909, 0xfffff6f7, 0x12121212, 0xedededee, 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, - 0x00000000, 0x09090909, 0xf6f6f6f7, 0x09090000, 0xf6f70000, 0x00000909, 0xfffff6f7, 0x12121212, - 0xedededee, 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, 0x00000000, 0x09090909, 0xf6f6f6f7, - 0x09090000, 0xf6f70000, 0x00000909, 0xfffff6f7, 0x12121212, 0xedededee, 0x1b1b0909, 0xe4e4f6f7, - 0x09091b1b, 0xf6f6e4e5, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x09090000, 0xf6f70000, 0x00000909, - 0xfffff6f7, 0x12121212, 0xedededee, 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, 0x00000000, - 0x09090909, 0xf6f6f6f7, 0x09090000, 0xf6f70000, 0x00000909, 0xfffff6f7, 0x12121212, 0xedededee, - 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x09090000, - 0xf6f70000, 0x00000909, 0xfffff6f7, 0x12121212, 0xedededee, 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, - 0xf6f6e4e5, 0x00000000, 0x09090909, 0xf6f6f6f7, 0x09090000, 0xf6f70000, 0x00000909, 0xfffff6f7, - 0x12121212, 0xedededee, 0x1b1b0909, 0xe4e4f6f7, 0x09091b1b, 0xf6f6e4e5, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, - 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0xfdfdfdfe, 0xfdfdfdfe, - 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, - 0xfdfdfdfe, 0x03030000, 0x03030000, 0x03030000, 0x03030000, 0x03030000, 0x03030000, 0x03030000, - 0x03030000, 0x03030000, 0x03030000, 0x03030000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, - 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0xfcfd0000, 0x00000303, - 0x00000303, 0x00000303, 0x00000303, 0x00000303, 0x00000303, 0x00000303, 0x00000303, 0x00000303, - 0x00000303, 0x00000303, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, - 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0xfffffcfd, 0x06060606, 0x06060606, 0x06060606, - 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, - 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, - 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0x07070000, - 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0x07070000, 0xf8f90000, 0xf8f90000, - 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, 0xf8f90000, - 0xf8f90000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, - 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, - 0x02020000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, - 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0x00000202, 0x00000202, - 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, - 0x00000202, 0x00000202, 0x00000202, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, - 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, - 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, - 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, - 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, - 0xfdfdfdfe, 0xfdfdfdfe, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, - 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0xf9f9f9fa, - 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, - 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0x06060000, 0x06060000, 0x06060000, 0x06060000, - 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, 0x06060000, - 0x06060000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, - 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0xf9fa0000, 0x00000606, 0x00000606, - 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, 0x00000606, - 0x00000606, 0x00000606, 0x00000606, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, - 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, 0xfffff9fa, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, - 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, 0x02020000, - 0x02020000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, - 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0xfdfe0000, 0x00000202, 0x00000202, - 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, 0x00000202, - 0x00000202, 0x00000202, 0x00000202, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, - 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, 0xfffffdfe, - 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, - 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, - 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, - 0xfbfbfbfc, 0xfbfbfbfc, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, - 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0x0a0a0a0a, 0xf5f5f5f6, - 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, - 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0xf5f5f5f6, 0x0a0a0000, 0x0a0a0000, 0x0a0a0000, 0x0a0a0000, - 0x0a0a0000, 0x0a0a0000, 0x0a0a0000, 0x0a0a0000, 0x0a0a0000, 0x0a0a0000, 0x0a0a0000, 0x0a0a0000, - 0x0a0a0000, 0xf5f60000, 0xf5f60000, 0xf5f60000, 0xf5f60000, 0xf5f60000, 0xf5f60000, 0xf5f60000, - 0xf5f60000, 0xf5f60000, 0xf5f60000, 0xf5f60000, 0xf5f60000, 0xf5f60000, 0x00000a0a, 0x00000a0a, - 0x00000a0a, 0x00000a0a, 0x00000a0a, 0x00000a0a, 0x00000a0a, 0x00000a0a, 0x00000a0a, 0x00000a0a, - 0x00000a0a, 0x00000a0a, 0x00000a0a, 0xfffff5f6, 0xfffff5f6, 0xfffff5f6, 0xfffff5f6, 0xfffff5f6, - 0xfffff5f6, 0xfffff5f6, 0xfffff5f6, 0xfffff5f6, 0xfffff5f6, 0xfffff5f6, 0xfffff5f6, 0xfffff5f6, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x04040000, 0x04040000, 0x04040000, 0x04040000, - 0x04040000, 0x04040000, 0x04040000, 0x04040000, 0x04040000, 0x04040000, 0x04040000, 0x04040000, - 0x04040000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, - 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0xfbfc0000, 0x00000404, 0x00000404, - 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0x00000404, 0x00000404, - 0x00000404, 0x00000404, 0x00000404, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, - 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, 0xfffffbfc, - 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, - 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0x04040404, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, - 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, 0xfbfbfbfc, - 0xfbfbfbfc, 0xfbfbfbfc, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, - 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0xf3f3f3f4, - 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, - 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0x0c0c0000, 0x0c0c0000, 0x0c0c0000, 0x0c0c0000, - 0x0c0c0000, 0x0c0c0000, 0x0c0c0000, 0x0c0c0000, 0x0c0c0000, 0x0c0c0000, 0x0c0c0000, 0x0c0c0000, - 0x0c0c0000, 0xf3f40000, 0xf3f40000, 0xf3f40000, 0xf3f40000, 0xf3f40000, 0xf3f40000, 0xf3f40000, - 0xf3f40000, 0xf3f40000, 0xf3f40000, 0xf3f40000, 0xf3f40000, 0xf3f40000, 0x00000c0c, 0x00000c0c, - 0x00000c0c, 0x00000c0c, 0x00000c0c, 0x00000c0c, 0x00000c0c, 0x00000c0c, 0x00000c0c, 0x00000c0c, - 0x00000c0c, 0x00000c0c, 0x00000c0c, 0xfffff3f4, 0xfffff3f4, 0xfffff3f4, 0xfffff3f4, 0xfffff3f4, - 0xfffff3f4, 0xfffff3f4, 0xfffff3f4, 0xfffff3f4, 0xfffff3f4, 0xfffff3f4, 0xfffff3f4, 0xfffff3f4, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0x02020202, 0x02020202, 0x02020202, - 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, - 0x02020202, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, - 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0x06060606, 0x06060606, - 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, - 0x06060606, 0x06060606, 0x06060606, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, - 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, - 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, - 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, - 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, - 0xf3f3f3f4, 0xf3f3f3f4, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, - 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0xebebebec, - 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, - 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0x20202020, 0x20202020, 0x20202020, 0x20202020, - 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, - 0x20202020, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, - 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0x2e2e2e2e, 0x2e2e2e2e, - 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, - 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, - 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0x02020202, 0x02020202, 0x02020202, - 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, - 0x02020202, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, - 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0x06060606, 0x06060606, - 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, - 0x06060606, 0x06060606, 0x06060606, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, - 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, - 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, - 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, - 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, - 0xf3f3f3f4, 0xf3f3f3f4, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, - 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0xebebebec, - 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, - 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0x20202020, 0x20202020, 0x20202020, 0x20202020, - 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, - 0x20202020, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, - 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0x2e2e2e2e, 0x2e2e2e2e, - 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, - 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, - 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0x02020202, 0x02020202, 0x02020202, - 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, - 0x02020202, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, - 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0x06060606, 0x06060606, - 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, - 0x06060606, 0x06060606, 0x06060606, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, - 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, - 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, - 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, - 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, - 0xf3f3f3f4, 0xf3f3f3f4, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, - 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0xebebebec, - 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, - 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0x20202020, 0x20202020, 0x20202020, 0x20202020, - 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, - 0x20202020, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, - 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0x2e2e2e2e, 0x2e2e2e2e, - 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, - 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, - 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, - 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x02020202, 0x02020202, 0x02020202, 0x02020202, - 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, 0x02020202, - 0x02020202, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, - 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0xfdfdfdfe, 0x06060606, 0x06060606, - 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, 0x06060606, - 0x06060606, 0x06060606, 0x06060606, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, - 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, 0xf9f9f9fa, - 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, - 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0x0c0c0c0c, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, - 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, 0xf3f3f3f4, - 0xf3f3f3f4, 0xf3f3f3f4, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, - 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0x14141414, 0xebebebec, - 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, - 0xebebebec, 0xebebebec, 0xebebebec, 0xebebebec, 0x20202020, 0x20202020, 0x20202020, 0x20202020, - 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, 0x20202020, - 0x20202020, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, - 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0xdfdfdfe0, 0x2e2e2e2e, 0x2e2e2e2e, - 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, - 0x2e2e2e2e, 0x2e2e2e2e, 0x2e2e2e2e, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, - 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, 0xd1d1d1d2, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 + /* set 3 */ + { delta_tab_3_1, delta_tab_3_1_m10, 128, 11 }, + { delta_tab_3_2, delta_tab_3_2_m10, 79, 13 }, + { delta_tab_3_3, delta_tab_3_3_m10, 79, 13 }, + { delta_tab_3_4, delta_tab_3_4_m10, 79, 13 }, + { delta_tab_3_5, delta_tab_3_5_m10, 79, 13 }, + { delta_tab_3_5, delta_tab_3_5_m10, 79, 13 }, + { delta_tab_3_5, delta_tab_3_5_m10, 79, 13 }, + { delta_tab_3_5, delta_tab_3_5_m10, 79, 13 } }; #endif /* AVCODEC_INDEO3DATA_H */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/internal.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/internal.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/internal.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/internal.h 2011-11-04 12:38:26.000000000 +0000 @@ -53,7 +53,7 @@ */ int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b); -unsigned int ff_toupper4(unsigned int x); +unsigned int avpriv_toupper4(unsigned int x); /** * does needed setup of pkt_pts/pos and such for (re)get_buffer(); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ituh263dec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ituh263dec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ituh263dec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ituh263dec.c 2011-11-04 12:38:26.000000000 +0000 @@ -271,7 +271,7 @@ int h263_decode_motion(MpegEncContext * s, int pred, int f_code) { - int code, val, sign, shift, l; + int code, val, sign, shift; code = get_vlc2(&s->gb, mv_vlc.table, MV_VLC_BITS, 2); if (code == 0) @@ -293,8 +293,7 @@ /* modulo decoding */ if (!s->h263_long_vectors) { - l = INT_BIT - 5 - f_code; - val = (val<>l; + val = sign_extend(val, 5 + f_code); } else { /* horrible h263 long vector mode */ if (pred < -31 && val < -63) diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ituh263enc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ituh263enc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ituh263enc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ituh263enc.c 2011-11-04 12:38:26.000000000 +0000 @@ -126,7 +126,7 @@ coded_frame_rate= 1800000; coded_frame_rate_base= (1000+best_clock_code)*best_divisor; - align_put_bits(&s->pb); + avpriv_align_put_bits(&s->pb); /* Update the pointer to last GOB */ s->ptr_lastgob = put_bits_ptr(&s->pb); @@ -657,7 +657,7 @@ void ff_h263_encode_motion(MpegEncContext * s, int val, int f_code) { - int range, l, bit_size, sign, code, bits; + int range, bit_size, sign, code, bits; if (val == 0) { /* zero vector */ @@ -667,8 +667,7 @@ bit_size = f_code - 1; range = 1 << bit_size; /* modulo encoding */ - l= INT_BIT - 6 - bit_size; - val = (val<>l; + val = sign_extend(val, 6 + bit_size); sign = val>>31; val= (val^sign)-sign; sign&=1; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/j2kdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/j2kdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/j2kdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/j2kdec.c 2011-11-04 12:38:26.000000000 +0000 @@ -910,6 +910,8 @@ } marker = bytestream_get_be16(&s->buf); + if(s->avctx->debug & FF_DEBUG_STARTCODE) + av_log(s->avctx, AV_LOG_DEBUG, "marker 0x%.4X at pos 0x%x\n", marker, s->buf - s->buf_start - 4); oldbuf = s->buf; if (marker == J2K_SOD){ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/jpeglsenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/jpeglsenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/jpeglsenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/jpeglsenc.c 2011-11-04 12:38:26.000000000 +0000 @@ -357,7 +357,7 @@ put_bits(&pb, 8, v); } } - align_put_bits(&pb); + avpriv_align_put_bits(&pb); av_free(buf2); /* End of image */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/latm_parser.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/latm_parser.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/latm_parser.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/latm_parser.c 2011-11-04 12:38:26.000000000 +0000 @@ -106,9 +106,8 @@ } AVCodecParser ff_aac_latm_parser = { - { CODEC_ID_AAC_LATM }, - sizeof(LATMParseContext), - NULL, - latm_parse, - ff_parse_close + .codec_ids = { CODEC_ID_AAC_LATM }, + .priv_data_size = sizeof(LATMParseContext), + .parser_parse = latm_parse, + .parser_close = ff_parse_close }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libavcodec.v ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libavcodec.v --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libavcodec.v 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libavcodec.v 2011-11-04 12:38:26.000000000 +0000 @@ -1,9 +1,29 @@ LIBAVCODEC_$MAJOR { - global: *; - local: - ff_*_bsf; - ff_*_decoder; - ff_*_encoder; - ff_*_hwaccel; - ff_*_parser; + global: av*; + audio_resample; + audio_resample_close; + #deprecated, remove after next bump + img_get_alpha_info; + dsputil_init; + ff_find_pix_fmt; + ff_framenum_to_drop_timecode; + ff_framenum_to_smtpe_timecode; + ff_raw_pix_fmt_tags; + ff_init_smtpe_timecode; + ff_fft*; + ff_mdct*; + ff_dct*; + ff_rdft*; + ff_prores_idct_put_10_sse2; + ff_simple_idct*; + ff_aanscales; + ff_faan*; + ff_mmx_idct; + ff_fdct*; + fdct_ifast; + j_rev_dct; + ff_mmxext_idct; + ff_idct_xvid*; + ff_jpeg_fdct*; + local: *; }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libcelt_dec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libcelt_dec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libcelt_dec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libcelt_dec.c 2011-11-04 12:38:26.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Xiph CELT / Opus decoder using libcelt + * Xiph CELT decoder using libcelt * Copyright (c) 2011 Nicolas George * * This file is part of FFmpeg. @@ -33,7 +33,7 @@ static int ff_celt_error_to_averror(int err) { - switch(err) { + switch (err) { case CELT_BAD_ARG: return AVERROR(EINVAL); #ifdef CELT_BUFFER_TOO_SMALL case CELT_BUFFER_TOO_SMALL: return AVERROR(ENOBUFS); @@ -82,7 +82,7 @@ } celt->discard *= c->channels * sizeof(int16_t); } - if(c->extradata_size >= 8) { + if (c->extradata_size >= 8) { unsigned version = AV_RL32(c->extradata + 4); unsigned lib_version = ff_celt_bitstream_version_hack(celt->mode); if (version != lib_version) @@ -91,6 +91,7 @@ "improperly decoded by libcelt for version 0x%x.\n", version, lib_version); } + c->sample_fmt = AV_SAMPLE_FMT_S16; return 0; } @@ -132,5 +133,5 @@ .close = libcelt_dec_close, .decode = libcelt_dec_decode, .capabilities = 0, - .long_name = NULL_IF_CONFIG_SMALL("Xiph CELT/Opus decoder using libcelt"), + .long_name = NULL_IF_CONFIG_SMALL("Xiph CELT decoder using libcelt"), }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libdiracdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libdiracdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libdiracdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libdiracdec.c 2011-11-04 12:38:26.000000000 +0000 @@ -37,34 +37,34 @@ #include /** contains a single frame returned from Dirac */ -typedef struct FfmpegDiracDecoderParams { +typedef struct DiracDecoderParams { /** decoder handle */ dirac_decoder_t* p_decoder; /** buffer to hold decoded frame */ unsigned char* p_out_frame_buf; -} FfmpegDiracDecoderParams; +} DiracDecoderParams; /** * returns FFmpeg chroma format */ -static enum PixelFormat GetFfmpegChromaFormat(dirac_chroma_t dirac_pix_fmt) +static enum PixelFormat get_chroma_format(dirac_chroma_t dirac_pix_fmt) { - int num_formats = sizeof(ffmpeg_dirac_pixel_format_map) / - sizeof(ffmpeg_dirac_pixel_format_map[0]); + int num_formats = sizeof(dirac_pixel_format_map) / + sizeof(dirac_pixel_format_map[0]); int idx; for (idx = 0; idx < num_formats; ++idx) - if (ffmpeg_dirac_pixel_format_map[idx].dirac_pix_fmt == dirac_pix_fmt) - return ffmpeg_dirac_pixel_format_map[idx].ff_pix_fmt; + if (dirac_pixel_format_map[idx].dirac_pix_fmt == dirac_pix_fmt) + return dirac_pixel_format_map[idx].ff_pix_fmt; return PIX_FMT_NONE; } static av_cold int libdirac_decode_init(AVCodecContext *avccontext) { - FfmpegDiracDecoderParams *p_dirac_params = avccontext->priv_data; + DiracDecoderParams *p_dirac_params = avccontext->priv_data; p_dirac_params->p_decoder = dirac_decoder_init(avccontext->debug); if (!p_dirac_params->p_decoder) @@ -80,7 +80,7 @@ const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; - FfmpegDiracDecoderParams *p_dirac_params = avccontext->priv_data; + DiracDecoderParams *p_dirac_params = avccontext->priv_data; AVPicture *picture = data; AVPicture pic; int pict_size; @@ -117,7 +117,7 @@ avccontext->height = src_params->height; avccontext->width = src_params->width; - avccontext->pix_fmt = GetFfmpegChromaFormat(src_params->chroma); + avccontext->pix_fmt = get_chroma_format(src_params->chroma); if (avccontext->pix_fmt == PIX_FMT_NONE) { av_log(avccontext, AV_LOG_ERROR, "Dirac chroma format %d not supported currently\n", @@ -174,7 +174,7 @@ static av_cold int libdirac_decode_close(AVCodecContext *avccontext) { - FfmpegDiracDecoderParams *p_dirac_params = avccontext->priv_data; + DiracDecoderParams *p_dirac_params = avccontext->priv_data; dirac_decoder_close(p_dirac_params->p_decoder); av_freep(&p_dirac_params->p_out_frame_buf); @@ -198,7 +198,7 @@ .name = "libdirac", .type = AVMEDIA_TYPE_VIDEO, .id = CODEC_ID_DIRAC, - .priv_data_size = sizeof(FfmpegDiracDecoderParams), + .priv_data_size = sizeof(DiracDecoderParams), .init = libdirac_decode_init, .close = libdirac_decode_close, .decode = libdirac_decode_frame, diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libdiracenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libdiracenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libdiracenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libdiracenc.c 2011-11-04 12:38:26.000000000 +0000 @@ -38,7 +38,7 @@ #include /** Dirac encoder private data */ -typedef struct FfmpegDiracEncoderParams { +typedef struct DiracEncoderParams { /** Dirac encoder context */ dirac_encoder_context_t enc_ctx; @@ -61,27 +61,27 @@ int enc_buf_size; /** queue storing encoded frames */ - FfmpegDiracSchroQueue enc_frame_queue; + DiracSchroQueue enc_frame_queue; /** end of sequence signalled by user, 0 - false, 1 - true */ int eos_signalled; /** end of sequence returned by encoder, 0 - false, 1 - true */ int eos_pulled; -} FfmpegDiracEncoderParams; +} DiracEncoderParams; /** * Works out Dirac-compatible chroma format. */ static dirac_chroma_t GetDiracChromaFormat(enum PixelFormat ff_pix_fmt) { - int num_formats = sizeof(ffmpeg_dirac_pixel_format_map) / - sizeof(ffmpeg_dirac_pixel_format_map[0]); + int num_formats = sizeof(dirac_pixel_format_map) / + sizeof(dirac_pixel_format_map[0]); int idx; for (idx = 0; idx < num_formats; ++idx) - if (ffmpeg_dirac_pixel_format_map[idx].ff_pix_fmt == ff_pix_fmt) - return ffmpeg_dirac_pixel_format_map[idx].dirac_pix_fmt; + if (dirac_pixel_format_map[idx].ff_pix_fmt == ff_pix_fmt) + return dirac_pixel_format_map[idx].dirac_pix_fmt; return formatNK; } @@ -127,7 +127,7 @@ static av_cold int libdirac_encode_init(AVCodecContext *avccontext) { - FfmpegDiracEncoderParams* p_dirac_params = avccontext->priv_data; + DiracEncoderParams* p_dirac_params = avccontext->priv_data; int no_local = 1; int verbose = avccontext->debug; VideoFormat preset; @@ -219,7 +219,7 @@ static void DiracFreeFrame(void *data) { - FfmpegDiracSchroEncodedFrame *enc_frame = data; + DiracSchroEncodedFrame *enc_frame = data; av_freep(&(enc_frame->p_encbuf)); av_free(enc_frame); @@ -231,9 +231,9 @@ { int enc_size = 0; dirac_encoder_state_t state; - FfmpegDiracEncoderParams* p_dirac_params = avccontext->priv_data; - FfmpegDiracSchroEncodedFrame* p_frame_output = NULL; - FfmpegDiracSchroEncodedFrame* p_next_output_frame = NULL; + DiracEncoderParams *p_dirac_params = avccontext->priv_data; + DiracSchroEncodedFrame *p_frame_output = NULL; + DiracSchroEncodedFrame *p_next_output_frame = NULL; int go = 1; int last_frame_in_sequence = 0; @@ -303,7 +303,7 @@ break; /* create output frame */ - p_frame_output = av_mallocz(sizeof(FfmpegDiracSchroEncodedFrame)); + p_frame_output = av_mallocz(sizeof(DiracSchroEncodedFrame)); /* set output data */ p_frame_output->size = p_dirac_params->enc_buf_size; p_frame_output->p_encbuf = p_dirac_params->enc_buf; @@ -371,7 +371,7 @@ static av_cold int libdirac_encode_close(AVCodecContext *avccontext) { - FfmpegDiracEncoderParams* p_dirac_params = avccontext->priv_data; + DiracEncoderParams *p_dirac_params = avccontext->priv_data; /* close the encoder */ dirac_encoder_close(p_dirac_params->p_encoder); @@ -395,7 +395,7 @@ .name = "libdirac", .type = AVMEDIA_TYPE_VIDEO, .id = CODEC_ID_DIRAC, - .priv_data_size = sizeof(FfmpegDiracEncoderParams), + .priv_data_size = sizeof(DiracEncoderParams), .init = libdirac_encode_init, .encode = libdirac_encode_frame, .close = libdirac_encode_close, diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libdirac.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libdirac.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libdirac.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libdirac.h 2011-11-04 12:38:26.000000000 +0000 @@ -35,7 +35,7 @@ static const struct { enum PixelFormat ff_pix_fmt; dirac_chroma_t dirac_pix_fmt; -} ffmpeg_dirac_pixel_format_map[] = { +} dirac_pixel_format_map[] = { { PIX_FMT_YUV420P, format420 }, { PIX_FMT_YUV422P, format422 }, { PIX_FMT_YUV444P, format444 }, diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libdirac_libschro.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libdirac_libschro.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libdirac_libschro.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libdirac_libschro.c 2011-11-04 12:38:26.000000000 +0000 @@ -25,7 +25,7 @@ #include "libdirac_libschro.h" -static const FfmpegDiracSchroVideoFormatInfo ff_dirac_schro_video_format_info[] = { +static const DiracSchroVideoFormatInfo ff_dirac_schro_video_format_info[] = { { 640, 480, 24000, 1001}, { 176, 120, 15000, 1001}, { 176, 144, 25, 2 }, @@ -53,7 +53,7 @@ sizeof(ff_dirac_schro_video_format_info[0]); for (idx = 1; idx < num_formats; ++idx) { - const FfmpegDiracSchroVideoFormatInfo *vf = &ff_dirac_schro_video_format_info[idx]; + const DiracSchroVideoFormatInfo *vf = &ff_dirac_schro_video_format_info[idx]; if (avccontext->width == vf->width && avccontext->height == vf->height) { ret_idx = idx; @@ -65,22 +65,22 @@ return ret_idx; } -void ff_dirac_schro_queue_init(FfmpegDiracSchroQueue *queue) +void ff_dirac_schro_queue_init(DiracSchroQueue *queue) { queue->p_head = queue->p_tail = NULL; queue->size = 0; } -void ff_dirac_schro_queue_free(FfmpegDiracSchroQueue *queue, +void ff_dirac_schro_queue_free(DiracSchroQueue *queue, void (*free_func)(void *)) { while (queue->p_head) free_func(ff_dirac_schro_queue_pop(queue)); } -int ff_dirac_schro_queue_push_back(FfmpegDiracSchroQueue *queue, void *p_data) +int ff_dirac_schro_queue_push_back(DiracSchroQueue *queue, void *p_data) { - FfmpegDiracSchroQueueElement *p_new = av_mallocz(sizeof(FfmpegDiracSchroQueueElement)); + DiracSchroQueueElement *p_new = av_mallocz(sizeof(DiracSchroQueueElement)); if (!p_new) return -1; @@ -97,9 +97,9 @@ return 0; } -void *ff_dirac_schro_queue_pop(FfmpegDiracSchroQueue *queue) +void *ff_dirac_schro_queue_pop(DiracSchroQueue *queue) { - FfmpegDiracSchroQueueElement *top = queue->p_head; + DiracSchroQueueElement *top = queue->p_head; if (top) { void *data = top->data; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libdirac_libschro.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libdirac_libschro.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libdirac_libschro.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libdirac_libschro.h 2011-11-04 12:38:26.000000000 +0000 @@ -33,7 +33,7 @@ uint16_t height; uint16_t frame_rate_num; uint16_t frame_rate_denom; -} FfmpegDiracSchroVideoFormatInfo; +} DiracSchroVideoFormatInfo; /** * Returns the index into the Dirac Schro common video format info table @@ -43,7 +43,7 @@ /** * contains a single encoded frame returned from Dirac or Schroedinger */ -typedef struct FfmpegDiracSchroEncodedFrame { +typedef struct DiracSchroEncodedFrame { /** encoded frame data */ uint8_t *p_encbuf; @@ -55,51 +55,51 @@ /** key frame flag. 1 : is key frame , 0 : in not key frame */ uint16_t key_frame; -} FfmpegDiracSchroEncodedFrame; +} DiracSchroEncodedFrame; /** * queue element */ -typedef struct FfmpegDiracSchroQueueElement { +typedef struct DiracSchroQueueElement { /** Data to be stored in queue*/ void *data; /** Pointer to next element queue */ - struct FfmpegDiracSchroQueueElement *next; -} FfmpegDiracSchroQueueElement; + struct DiracSchroQueueElement *next; +} DiracSchroQueueElement; /** * A simple queue implementation used in libdirac and libschroedinger */ -typedef struct FfmpegDiracSchroQueue { +typedef struct DiracSchroQueue { /** Pointer to head of queue */ - FfmpegDiracSchroQueueElement *p_head; + DiracSchroQueueElement *p_head; /** Pointer to tail of queue */ - FfmpegDiracSchroQueueElement *p_tail; + DiracSchroQueueElement *p_tail; /** Queue size*/ int size; -} FfmpegDiracSchroQueue; +} DiracSchroQueue; /** * Initialise the queue */ -void ff_dirac_schro_queue_init(FfmpegDiracSchroQueue *queue); +void ff_dirac_schro_queue_init(DiracSchroQueue *queue); /** * Add an element to the end of the queue */ -int ff_dirac_schro_queue_push_back(FfmpegDiracSchroQueue *queue, void *p_data); +int ff_dirac_schro_queue_push_back(DiracSchroQueue *queue, void *p_data); /** * Return the first element in the queue */ -void *ff_dirac_schro_queue_pop(FfmpegDiracSchroQueue *queue); +void *ff_dirac_schro_queue_pop(DiracSchroQueue *queue); /** * Free the queue resources. free_func is a function supplied by the caller to * free any resources allocated by the caller. The data field of the queue * element is passed to it. */ -void ff_dirac_schro_queue_free(FfmpegDiracSchroQueue *queue, +void ff_dirac_schro_queue_free(DiracSchroQueue *queue, void (*free_func)(void *)); #endif /* AVCODEC_LIBDIRAC_LIBSCHRO_H */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libgsm.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libgsm.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libgsm.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libgsm.c 2011-11-04 12:38:26.000000000 +0000 @@ -166,23 +166,39 @@ static int libgsm_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { + int i, ret; + struct gsm_state *s = avctx->priv_data; uint8_t *buf = avpkt->data; int buf_size = avpkt->size; - *data_size = 0; /* In case of error */ - if(buf_size < avctx->block_align) return -1; - switch(avctx->codec_id) { - case CODEC_ID_GSM: - if(gsm_decode(avctx->priv_data,buf,data)) return -1; - *data_size = GSM_FRAME_SIZE*sizeof(int16_t); - break; - case CODEC_ID_GSM_MS: - if(gsm_decode(avctx->priv_data,buf,data) || - gsm_decode(avctx->priv_data,buf+33,((int16_t*)data)+GSM_FRAME_SIZE)) return -1; - *data_size = GSM_FRAME_SIZE*sizeof(int16_t)*2; + int16_t *samples = data; + int out_size = avctx->frame_size * av_get_bytes_per_sample(avctx->sample_fmt); + + if (*data_size < out_size) { + av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); + return AVERROR(EINVAL); + } + + if (buf_size < avctx->block_align) { + av_log(avctx, AV_LOG_ERROR, "Packet is too small\n"); + return AVERROR_INVALIDDATA; + } + + for (i = 0; i < avctx->frame_size / GSM_FRAME_SIZE; i++) { + if ((ret = gsm_decode(s, buf, samples)) < 0) + return -1; + buf += GSM_BLOCK_SIZE; + samples += GSM_FRAME_SIZE; } + + *data_size = out_size; return avctx->block_align; } +static void libgsm_flush(AVCodecContext *avctx) { + gsm_destroy(avctx->priv_data); + avctx->priv_data = gsm_create(); +} + AVCodec ff_libgsm_decoder = { .name = "libgsm", .type = AVMEDIA_TYPE_AUDIO, @@ -190,6 +206,7 @@ .init = libgsm_decode_init, .close = libgsm_decode_close, .decode = libgsm_decode_frame, + .flush = libgsm_flush, .long_name = NULL_IF_CONFIG_SMALL("libgsm GSM"), }; @@ -200,5 +217,6 @@ .init = libgsm_decode_init, .close = libgsm_decode_close, .decode = libgsm_decode_frame, + .flush = libgsm_flush, .long_name = NULL_IF_CONFIG_SMALL("libgsm GSM Microsoft variant"), }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libmp3lame.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libmp3lame.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libmp3lame.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libmp3lame.c 2011-11-04 12:38:26.000000000 +0000 @@ -49,8 +49,11 @@ { Mp3AudioContext *s = avctx->priv_data; - if (avctx->channels > 2) - return -1; + if (avctx->channels > 2) { + av_log(avctx, AV_LOG_ERROR, + "Invalid number of channels %d, must be <= 2\n", avctx->channels); + return AVERROR(EINVAL); + } s->stereo = avctx->channels > 1 ? 1 : 0; @@ -277,7 +280,7 @@ #define OFFSET(x) offsetof(Mp3AudioContext, x) #define AE AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { - { "reservoir", "Use bit reservoir.", OFFSET(reservoir), FF_OPT_TYPE_INT, { 1 }, 0, 1, AE }, + { "reservoir", "Use bit reservoir.", OFFSET(reservoir), AV_OPT_TYPE_INT, { 1 }, 0, 1, AE }, { NULL }, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libopencore-amr.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libopencore-amr.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libopencore-amr.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libopencore-amr.c 2011-11-04 12:38:26.000000000 +0000 @@ -79,7 +79,6 @@ typedef struct AMRContext { AVClass *av_class; - int frame_count; void *dec_state; void *enc_state; int enc_bitrate; @@ -88,7 +87,7 @@ } AMRContext; static const AVOption options[] = { - { "dtx", "Allow DTX (generate comfort noise)", offsetof(AMRContext, enc_dtx), FF_OPT_TYPE_INT, { 0 }, 0, 1, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, + { "dtx", "Allow DTX (generate comfort noise)", offsetof(AMRContext, enc_dtx), AV_OPT_TYPE_INT, { 0 }, 0, 1, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, { NULL } }; @@ -100,7 +99,6 @@ { AMRContext *s = avctx->priv_data; - s->frame_count = 0; s->dec_state = Decoder_Interface_init(); if (!s->dec_state) { av_log(avctx, AV_LOG_ERROR, "Decoder_Interface_init error\n"); @@ -133,10 +131,16 @@ AMRContext *s = avctx->priv_data; static const uint8_t block_size[16] = { 12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0 }; enum Mode dec_mode; - int packet_size; + int packet_size, out_size; av_dlog(avctx, "amr_decode_frame buf=%p buf_size=%d frame_count=%d!!\n", - buf, buf_size, s->frame_count); + buf, buf_size, avctx->frame_number); + + out_size = 160 * av_get_bytes_per_sample(avctx->sample_fmt); + if (*data_size < out_size) { + av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n"); + return AVERROR(EINVAL); + } dec_mode = (buf[0] >> 3) & 0x000F; packet_size = block_size[dec_mode] + 1; @@ -147,12 +151,11 @@ return AVERROR_INVALIDDATA; } - s->frame_count++; av_dlog(avctx, "packet_size=%d buf= 0x%X %X %X %X\n", packet_size, buf[0], buf[1], buf[2], buf[3]); /* call decoder */ Decoder_Interface_Decode(s->dec_state, buf, data, 0); - *data_size = 160 * 2; + *data_size = out_size; return packet_size; } @@ -172,8 +175,6 @@ { AMRContext *s = avctx->priv_data; - s->frame_count = 0; - if (avctx->sample_rate != 8000) { av_log(avctx, AV_LOG_ERROR, "Only 8000Hz sample rate supported\n"); return AVERROR(ENOSYS); @@ -276,12 +277,14 @@ int buf_size = avpkt->size; AMRWBContext *s = avctx->priv_data; int mode; - int packet_size; + int packet_size, out_size; static const uint8_t block_size[16] = {18, 24, 33, 37, 41, 47, 51, 59, 61, 6, 6, 0, 0, 0, 1, 1}; - if (!buf_size) - /* nothing to do */ - return 0; + out_size = 320 * av_get_bytes_per_sample(avctx->sample_fmt); + if (*data_size < out_size) { + av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n"); + return AVERROR(EINVAL); + } mode = (buf[0] >> 3) & 0x000F; packet_size = block_size[mode]; @@ -293,7 +296,7 @@ } D_IF_decode(s->state, buf, data, _good_frame); - *data_size = 320 * 2; + *data_size = out_size; return packet_size; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libschroedinger.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libschroedinger.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libschroedinger.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libschroedinger.c 2011-11-04 12:38:26.000000000 +0000 @@ -64,14 +64,14 @@ int ff_get_schro_frame_format (SchroChromaFormat schro_pix_fmt, SchroFrameFormat *schro_frame_fmt) { - unsigned int num_formats = sizeof(ffmpeg_schro_pixel_format_map) / - sizeof(ffmpeg_schro_pixel_format_map[0]); + unsigned int num_formats = sizeof(schro_pixel_format_map) / + sizeof(schro_pixel_format_map[0]); int idx; for (idx = 0; idx < num_formats; ++idx) { - if (ffmpeg_schro_pixel_format_map[idx].schro_pix_fmt == schro_pix_fmt) { - *schro_frame_fmt = ffmpeg_schro_pixel_format_map[idx].schro_frame_fmt; + if (schro_pixel_format_map[idx].schro_pix_fmt == schro_pix_fmt) { + *schro_frame_fmt = schro_pixel_format_map[idx].schro_frame_fmt; return 0; } } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libschroedingerdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libschroedingerdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libschroedingerdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libschroedingerdec.c 2011-11-04 12:38:26.000000000 +0000 @@ -41,7 +41,7 @@ #include /** libschroedinger decoder private data */ -typedef struct FfmpegSchroDecoderParams { +typedef struct SchroDecoderParams { /** Schroedinger video format */ SchroVideoFormat *format; @@ -52,7 +52,7 @@ SchroDecoder* decoder; /** queue storing decoded frames */ - FfmpegDiracSchroQueue dec_frame_queue; + DiracSchroQueue dec_frame_queue; /** end of sequence signalled */ int eos_signalled; @@ -62,25 +62,25 @@ /** decoded picture */ AVPicture dec_pic; -} FfmpegSchroDecoderParams; +} SchroDecoderParams; -typedef struct FfmpegSchroParseUnitContext { +typedef struct SchroParseUnitContext { const uint8_t *buf; int buf_size; -} FfmpegSchroParseUnitContext; +} SchroParseUnitContext; static void libschroedinger_decode_buffer_free(SchroBuffer *schro_buf, void *priv); -static void FfmpegSchroParseContextInit(FfmpegSchroParseUnitContext *parse_ctx, - const uint8_t *buf, int buf_size) +static void SchroParseContextInit(SchroParseUnitContext *parse_ctx, + const uint8_t *buf, int buf_size) { parse_ctx->buf = buf; parse_ctx->buf_size = buf_size; } -static SchroBuffer* FfmpegFindNextSchroParseUnit(FfmpegSchroParseUnitContext *parse_ctx) +static SchroBuffer *FindNextSchroParseUnit(SchroParseUnitContext *parse_ctx) { SchroBuffer *enc_buf = NULL; int next_pu_offset = 0; @@ -120,22 +120,22 @@ /** * Returns FFmpeg chroma format. */ -static enum PixelFormat GetFfmpegChromaFormat(SchroChromaFormat schro_pix_fmt) +static enum PixelFormat get_chroma_format(SchroChromaFormat schro_pix_fmt) { - int num_formats = sizeof(ffmpeg_schro_pixel_format_map) / - sizeof(ffmpeg_schro_pixel_format_map[0]); + int num_formats = sizeof(schro_pixel_format_map) / + sizeof(schro_pixel_format_map[0]); int idx; for (idx = 0; idx < num_formats; ++idx) - if (ffmpeg_schro_pixel_format_map[idx].schro_pix_fmt == schro_pix_fmt) - return ffmpeg_schro_pixel_format_map[idx].ff_pix_fmt; + if (schro_pixel_format_map[idx].schro_pix_fmt == schro_pix_fmt) + return schro_pixel_format_map[idx].ff_pix_fmt; return PIX_FMT_NONE; } static av_cold int libschroedinger_decode_init(AVCodecContext *avccontext) { - FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data; + SchroDecoderParams *p_schro_params = avccontext->priv_data; /* First of all, initialize our supporting libraries. */ schro_init(); @@ -164,7 +164,7 @@ static void libschroedinger_handle_first_access_unit(AVCodecContext *avccontext) { - FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data; + SchroDecoderParams *p_schro_params = avccontext->priv_data; SchroDecoder *decoder = p_schro_params->decoder; p_schro_params->format = schro_decoder_get_video_format(decoder); @@ -179,7 +179,7 @@ } avccontext->height = p_schro_params->format->height; avccontext->width = p_schro_params->format->width; - avccontext->pix_fmt = GetFfmpegChromaFormat(p_schro_params->format->chroma_format); + avccontext->pix_fmt = get_chroma_format(p_schro_params->format->chroma_format); if (ff_get_schro_frame_format(p_schro_params->format->chroma_format, &p_schro_params->frame_format) == -1) { @@ -206,7 +206,7 @@ const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; - FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data; + SchroDecoderParams *p_schro_params = avccontext->priv_data; SchroDecoder *decoder = p_schro_params->decoder; AVPicture *picture = data; SchroBuffer *enc_buf; @@ -214,11 +214,11 @@ int state; int go = 1; int outer = 1; - FfmpegSchroParseUnitContext parse_ctx; + SchroParseUnitContext parse_ctx; *data_size = 0; - FfmpegSchroParseContextInit(&parse_ctx, buf, buf_size); + SchroParseContextInit(&parse_ctx, buf, buf_size); if (!buf_size) { if (!p_schro_params->eos_signalled) { state = schro_decoder_push_end_of_stream(decoder); @@ -228,7 +228,7 @@ /* Loop through all the individual parse units in the input buffer */ do { - if ((enc_buf = FfmpegFindNextSchroParseUnit(&parse_ctx))) { + if ((enc_buf = FindNextSchroParseUnit(&parse_ctx))) { /* Push buffer into decoder. */ if (SCHRO_PARSE_CODE_IS_PICTURE(enc_buf->data[4]) && SCHRO_PARSE_CODE_NUM_REFS(enc_buf->data[4]) > 0) @@ -314,7 +314,7 @@ static av_cold int libschroedinger_decode_close(AVCodecContext *avccontext) { - FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data; + SchroDecoderParams *p_schro_params = avccontext->priv_data; /* Free the decoder. */ schro_decoder_free(p_schro_params->decoder); av_freep(&p_schro_params->format); @@ -332,7 +332,7 @@ { /* Got a seek request. Free the decoded frames queue and then reset * the decoder */ - FfmpegSchroDecoderParams *p_schro_params = avccontext->priv_data; + SchroDecoderParams *p_schro_params = avccontext->priv_data; /* Free data in the output frame queue. */ ff_dirac_schro_queue_free(&p_schro_params->dec_frame_queue, @@ -348,7 +348,7 @@ .name = "libschroedinger", .type = AVMEDIA_TYPE_VIDEO, .id = CODEC_ID_DIRAC, - .priv_data_size = sizeof(FfmpegSchroDecoderParams), + .priv_data_size = sizeof(SchroDecoderParams), .init = libschroedinger_decode_init, .close = libschroedinger_decode_close, .decode = libschroedinger_decode_frame, diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libschroedingerenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libschroedingerenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libschroedingerenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libschroedingerenc.c 2011-11-04 12:38:26.000000000 +0000 @@ -41,7 +41,7 @@ /** libschroedinger encoder private data */ -typedef struct FfmpegSchroEncoderParams { +typedef struct SchroEncoderParams { /** Schroedinger video format */ SchroVideoFormat *format; @@ -64,31 +64,31 @@ int enc_buf_size; /** queue storing encoded frames */ - FfmpegDiracSchroQueue enc_frame_queue; + DiracSchroQueue enc_frame_queue; /** end of sequence signalled */ int eos_signalled; /** end of sequence pulled */ int eos_pulled; -} FfmpegSchroEncoderParams; +} SchroEncoderParams; /** * Works out Schro-compatible chroma format. */ static int SetSchroChromaFormat(AVCodecContext *avccontext) { - int num_formats = sizeof(ffmpeg_schro_pixel_format_map) / - sizeof(ffmpeg_schro_pixel_format_map[0]); + int num_formats = sizeof(schro_pixel_format_map) / + sizeof(schro_pixel_format_map[0]); int idx; - FfmpegSchroEncoderParams* p_schro_params = avccontext->priv_data; + SchroEncoderParams *p_schro_params = avccontext->priv_data; for (idx = 0; idx < num_formats; ++idx) { - if (ffmpeg_schro_pixel_format_map[idx].ff_pix_fmt == + if (schro_pixel_format_map[idx].ff_pix_fmt == avccontext->pix_fmt) { p_schro_params->format->chroma_format = - ffmpeg_schro_pixel_format_map[idx].schro_pix_fmt; + schro_pixel_format_map[idx].schro_pix_fmt; return 0; } } @@ -102,7 +102,7 @@ static int libschroedinger_encode_init(AVCodecContext *avccontext) { - FfmpegSchroEncoderParams* p_schro_params = avccontext->priv_data; + SchroEncoderParams *p_schro_params = avccontext->priv_data; SchroVideoFormatEnum preset; /* Initialize the libraries that libschroedinger depends on. */ @@ -238,7 +238,7 @@ static SchroFrame *libschroedinger_frame_from_data(AVCodecContext *avccontext, void *in_data) { - FfmpegSchroEncoderParams* p_schro_params = avccontext->priv_data; + SchroEncoderParams *p_schro_params = avccontext->priv_data; SchroFrame *in_frame; /* Input line size may differ from what the codec supports. Especially * when transcoding from one format to another. So use avpicture_layout @@ -256,7 +256,7 @@ static void SchroedingerFreeFrame(void *data) { - FfmpegDiracSchroEncodedFrame *enc_frame = data; + DiracSchroEncodedFrame *enc_frame = data; av_freep(&(enc_frame->p_encbuf)); av_free(enc_frame); @@ -267,9 +267,9 @@ int buf_size, void *data) { int enc_size = 0; - FfmpegSchroEncoderParams* p_schro_params = avccontext->priv_data; + SchroEncoderParams *p_schro_params = avccontext->priv_data; SchroEncoder *encoder = p_schro_params->encoder; - struct FfmpegDiracSchroEncodedFrame* p_frame_output = NULL; + struct DiracSchroEncodedFrame *p_frame_output = NULL; int go = 1; SchroBuffer *enc_buf; int presentation_frame; @@ -328,7 +328,7 @@ } /* Create output frame. */ - p_frame_output = av_mallocz(sizeof(FfmpegDiracSchroEncodedFrame)); + p_frame_output = av_mallocz(sizeof(DiracSchroEncodedFrame)); /* Set output data. */ p_frame_output->size = p_schro_params->enc_buf_size; p_frame_output->p_encbuf = p_schro_params->enc_buf; @@ -400,8 +400,7 @@ static int libschroedinger_encode_close(AVCodecContext *avccontext) { - - FfmpegSchroEncoderParams* p_schro_params = avccontext->priv_data; + SchroEncoderParams *p_schro_params = avccontext->priv_data; /* Close the encoder. */ schro_encoder_free(p_schro_params->encoder); @@ -426,7 +425,7 @@ .name = "libschroedinger", .type = AVMEDIA_TYPE_VIDEO, .id = CODEC_ID_DIRAC, - .priv_data_size = sizeof(FfmpegSchroEncoderParams), + .priv_data_size = sizeof(SchroEncoderParams), .init = libschroedinger_encode_init, .encode = libschroedinger_encode_frame, .close = libschroedinger_encode_close, diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libschroedinger.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libschroedinger.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libschroedinger.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libschroedinger.h 2011-11-04 12:38:26.000000000 +0000 @@ -34,7 +34,7 @@ enum PixelFormat ff_pix_fmt; SchroChromaFormat schro_pix_fmt; SchroFrameFormat schro_frame_fmt; -} ffmpeg_schro_pixel_format_map[] = { +} schro_pixel_format_map[] = { { PIX_FMT_YUV420P, SCHRO_CHROMA_420, SCHRO_FRAME_FORMAT_U8_420 }, { PIX_FMT_YUV422P, SCHRO_CHROMA_422, SCHRO_FRAME_FORMAT_U8_422 }, { PIX_FMT_YUV444P, SCHRO_CHROMA_444, SCHRO_FRAME_FORMAT_U8_444 }, diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libspeexdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libspeexdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libspeexdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libspeexdec.c 2011-11-04 12:38:26.000000000 +0000 @@ -18,11 +18,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "avcodec.h" #include #include #include #include +#include "avcodec.h" typedef struct { SpeexBits bits; @@ -60,14 +60,14 @@ mode = speex_lib_get_mode(s->header->mode); if (!mode) { av_log(avctx, AV_LOG_ERROR, "Unknown Speex mode %d", s->header->mode); - return -1; + return AVERROR_INVALIDDATA; } } else av_log(avctx, AV_LOG_INFO, "Missing Speex header, assuming defaults.\n"); if (avctx->channels > 2) { av_log(avctx, AV_LOG_ERROR, "Only stereo and mono are supported.\n"); - return -1; + return AVERROR(EINVAL); } speex_bits_init(&s->bits); @@ -99,32 +99,42 @@ uint8_t *buf = avpkt->data; int buf_size = avpkt->size; LibSpeexContext *s = avctx->priv_data; - int16_t *output = data, *end; - int i, num_samples; + int16_t *output = data; + int out_size, ret, consumed = 0; - num_samples = s->frame_size * avctx->channels; - end = output + *data_size / sizeof(*output); - - speex_bits_read_from(&s->bits, buf, buf_size); - - for (i = 0; speex_bits_remaining(&s->bits) && output + num_samples < end; i++) { - int ret = speex_decode_int(s->dec_state, &s->bits, output); - if (ret <= -2) { - av_log(avctx, AV_LOG_ERROR, "Error decoding Speex frame.\n"); - return -1; - } else if (ret == -1) - // end of stream - break; + /* check output buffer size */ + out_size = s->frame_size * avctx->channels * + av_get_bytes_per_sample(avctx->sample_fmt); + if (*data_size < out_size) { + av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); + return AVERROR(EINVAL); + } - if (avctx->channels == 2) - speex_decode_stereo_int(output, s->frame_size, &s->stereo); + /* if there is not enough data left for the smallest possible frame, + reset the libspeex buffer using the current packet, otherwise ignore + the current packet and keep decoding frames from the libspeex buffer. */ + if (speex_bits_remaining(&s->bits) < 43) { + /* check for flush packet */ + if (!buf || !buf_size) { + *data_size = 0; + return buf_size; + } + /* set new buffer */ + speex_bits_read_from(&s->bits, buf, buf_size); + consumed = buf_size; + } - output += num_samples; + /* decode a single frame */ + ret = speex_decode_int(s->dec_state, &s->bits, output); + if (ret <= -2) { + av_log(avctx, AV_LOG_ERROR, "Error decoding Speex frame.\n"); + return AVERROR_INVALIDDATA; } + if (avctx->channels == 2) + speex_decode_stereo_int(output, s->frame_size, &s->stereo); - avctx->frame_size = s->frame_size * i; - *data_size = avctx->channels * avctx->frame_size * sizeof(*output); - return buf_size; + *data_size = out_size; + return consumed; } static av_cold int libspeex_decode_close(AVCodecContext *avctx) @@ -138,6 +148,12 @@ return 0; } +static av_cold void libspeex_decode_flush(AVCodecContext *avctx) +{ + LibSpeexContext *s = avctx->priv_data; + speex_bits_reset(&s->bits); +} + AVCodec ff_libspeex_decoder = { .name = "libspeex", .type = AVMEDIA_TYPE_AUDIO, @@ -146,5 +162,7 @@ .init = libspeex_decode_init, .close = libspeex_decode_close, .decode = libspeex_decode_frame, + .flush = libspeex_decode_flush, + .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_DELAY, .long_name = NULL_IF_CONFIG_SMALL("libspeex Speex"), }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libspeexenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libspeexenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libspeexenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libspeexenc.c 2011-11-04 12:38:26.000000000 +0000 @@ -1,5 +1,7 @@ /* - * Copyright (c) 2009 by Xuggle Incorporated. All rights reserved. + * Copyright (C) 2009 Justin Ruggles + * Copyright (c) 2009 Xuggle Incorporated + * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or @@ -16,163 +18,307 @@ * License along with FFmpeg; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include + +/** + * @file + * libspeex Speex audio encoder + * + * Usage Guide + * This explains the values that need to be set prior to initialization in + * order to control various encoding parameters. + * + * Channels + * Speex only supports mono or stereo, so avctx->channels must be set to + * 1 or 2. + * + * Sample Rate / Encoding Mode + * Speex has 3 modes, each of which uses a specific sample rate. + * narrowband : 8 kHz + * wideband : 16 kHz + * ultra-wideband : 32 kHz + * avctx->sample_rate must be set to one of these 3 values. This will be + * used to set the encoding mode. + * + * Rate Control + * VBR mode is turned on by setting CODEC_FLAG_QSCALE in avctx->flags. + * avctx->global_quality is used to set the encoding quality. + * For CBR mode, avctx->bit_rate can be used to set the constant bitrate. + * Alternatively, the 'cbr_quality' option can be set from 0 to 10 to set + * a constant bitrate based on quality. + * For ABR mode, set avctx->bit_rate and set the 'abr' option to 1. + * Approx. Bitrate Range: + * narrowband : 2400 - 25600 bps + * wideband : 4000 - 43200 bps + * ultra-wideband : 4400 - 45200 bps + * + * Complexity + * Encoding complexity is controlled by setting avctx->compression_level. + * The valid range is 0 to 10. A higher setting gives generally better + * quality at the expense of encoding speed. This does not affect the + * bit rate. + * + * Frames-per-Packet + * The encoder defaults to using 1 frame-per-packet. However, it is + * sometimes desirable to use multiple frames-per-packet to reduce the + * amount of container overhead. This can be done by setting the + * 'frames_per_packet' option to a value 1 to 8. + */ + #include #include #include +#include "libavutil/mathematics.h" +#include "libavutil/opt.h" +#include "avcodec.h" +#include "internal.h" typedef struct { - SpeexBits bits; - void *enc_state; - SpeexHeader header; + AVClass *class; ///< AVClass for private options + SpeexBits bits; ///< libspeex bitwriter context + SpeexHeader header; ///< libspeex header struct + void *enc_state; ///< libspeex encoder state + int frames_per_packet; ///< number of frames to encode in each packet + float vbr_quality; ///< VBR quality 0.0 to 10.0 + int cbr_quality; ///< CBR quality 0 to 10 + int abr; ///< flag to enable ABR + int pkt_frame_count; ///< frame count for the current packet + int lookahead; ///< encoder delay + int sample_count; ///< total sample count (used for pts) } LibSpeexEncContext; +static av_cold void print_enc_params(AVCodecContext *avctx, + LibSpeexEncContext *s) +{ + const char *mode_str = "unknown"; -static av_cold int libspeex_encode_init(AVCodecContext *avctx) + av_log(avctx, AV_LOG_DEBUG, "channels: %d\n", avctx->channels); + switch (s->header.mode) { + case SPEEX_MODEID_NB: mode_str = "narrowband"; break; + case SPEEX_MODEID_WB: mode_str = "wideband"; break; + case SPEEX_MODEID_UWB: mode_str = "ultra-wideband"; break; + } + av_log(avctx, AV_LOG_DEBUG, "mode: %s\n", mode_str); + if (s->header.vbr) { + av_log(avctx, AV_LOG_DEBUG, "rate control: VBR\n"); + av_log(avctx, AV_LOG_DEBUG, " quality: %f\n", s->vbr_quality); + } else if (s->abr) { + av_log(avctx, AV_LOG_DEBUG, "rate control: ABR\n"); + av_log(avctx, AV_LOG_DEBUG, " bitrate: %d bps\n", avctx->bit_rate); + } else { + av_log(avctx, AV_LOG_DEBUG, "rate control: CBR\n"); + av_log(avctx, AV_LOG_DEBUG, " bitrate: %d bps\n", avctx->bit_rate); + } + av_log(avctx, AV_LOG_DEBUG, "complexity: %d\n", + avctx->compression_level); + av_log(avctx, AV_LOG_DEBUG, "frame size: %d samples\n", + avctx->frame_size); + av_log(avctx, AV_LOG_DEBUG, "frames per packet: %d\n", + s->frames_per_packet); + av_log(avctx, AV_LOG_DEBUG, "packet size: %d\n", + avctx->frame_size * s->frames_per_packet); +} + +static av_cold int encode_init(AVCodecContext *avctx) { - LibSpeexEncContext *s = (LibSpeexEncContext*)avctx->priv_data; + LibSpeexEncContext *s = avctx->priv_data; const SpeexMode *mode; - - if ((avctx->sample_fmt != SAMPLE_FMT_S16 && avctx->sample_fmt != SAMPLE_FMT_FLT) || - avctx->sample_rate <= 0 || - avctx->channels <= 0 || - avctx->channels > 2) - { - av_log(avctx, AV_LOG_ERROR, "Unsupported sample format, rate, or channels for speex"); - return -1; + uint8_t *header_data; + int header_size; + int32_t complexity; + + /* channels */ + if (avctx->channels < 1 || avctx->channels > 2) { + av_log(avctx, AV_LOG_ERROR, "Invalid channels (%d). Only stereo and " + "mono are supported\n", avctx->channels); + return AVERROR(EINVAL); } - if (avctx->sample_rate <= 8000) - mode = &speex_nb_mode; - else if (avctx->sample_rate <= 16000) - mode = &speex_wb_mode; - else - mode = &speex_uwb_mode; + /* sample rate and encoding mode */ + switch (avctx->sample_rate) { + case 8000: mode = &speex_nb_mode; break; + case 16000: mode = &speex_wb_mode; break; + case 32000: mode = &speex_uwb_mode; break; + default: + av_log(avctx, AV_LOG_ERROR, "Sample rate of %d Hz is not supported. " + "Resample to 8, 16, or 32 kHz.\n", avctx->sample_rate); + return AVERROR(EINVAL); + } - speex_bits_init(&s->bits); + /* initialize libspeex */ s->enc_state = speex_encoder_init(mode); - if (!s->enc_state) - { - av_log(avctx, AV_LOG_ERROR, "could not initialize speex encoder"); + if (!s->enc_state) { + av_log(avctx, AV_LOG_ERROR, "Error initializing libspeex\n"); return -1; } + speex_init_header(&s->header, avctx->sample_rate, avctx->channels, mode); - // initialize the header - speex_init_header(&s->header, avctx->sample_rate, - avctx->channels, mode); - - // TODO: It'd be nice to support VBR here, but - // I'm uncertain what AVCodecContext options to use - // to signal whether to turn it on. + /* rate control method and parameters */ if (avctx->flags & CODEC_FLAG_QSCALE) { - spx_int32_t quality = 0; - // Map global_quality's mpeg 1/2/4 scale into Speex's 0-10 scale - if (avctx->global_quality > FF_LAMBDA_MAX) - quality = 0; // lowest possible quality - else - quality = (spx_int32_t)((FF_LAMBDA_MAX-avctx->global_quality)*10.0/FF_LAMBDA_MAX); - speex_encoder_ctl(s->enc_state, SPEEX_SET_QUALITY, &quality); + /* VBR */ + s->header.vbr = 1; + speex_encoder_ctl(s->enc_state, SPEEX_SET_VBR, &s->header.vbr); + s->vbr_quality = av_clipf(avctx->global_quality / (float)FF_QP2LAMBDA, + 0.0f, 10.0f); + speex_encoder_ctl(s->enc_state, SPEEX_SET_VBR_QUALITY, &s->vbr_quality); } else { - // default to CBR - if (avctx->bit_rate > 0) - speex_encoder_ctl(s->enc_state, SPEEX_SET_BITRATE, &avctx->bit_rate); - // otherwise just take the default quality setting - } - // reset the bit-rate to the actual bit rate speex will use - speex_encoder_ctl(s->enc_state, SPEEX_GET_BITRATE, &s->header.bitrate); - avctx->bit_rate = s->header.bitrate; - - // get the actual sample rate - speex_encoder_ctl(s->enc_state, SPEEX_GET_SAMPLING_RATE, &s->header.rate); - avctx->sample_rate = s->header.rate; - - // get the frame-size. To align with FLV, we're going to put 2 frames - // per packet. If someone can tell me how to make this configurable - // from the avcodec contents, I'll mod this so it's not hard-coded. - // but without this, FLV files with speex data won't play correctly - // in flash player 10. - speex_encoder_ctl(s->enc_state, SPEEX_GET_FRAME_SIZE, &s->header.frame_size); - s->header.frames_per_packet = 2; // Need for FLV container support - avctx->frame_size = s->header.frame_size*s->header.frames_per_packet; - - // and we'll put a speex header packet into extradata so that muxers - // can use it. - avctx->extradata = speex_header_to_packet(&s->header, &avctx->extradata_size); + s->header.bitrate = avctx->bit_rate; + if (avctx->bit_rate > 0) { + /* CBR or ABR by bitrate */ + if (s->abr) { + speex_encoder_ctl(s->enc_state, SPEEX_SET_ABR, + &s->header.bitrate); + speex_encoder_ctl(s->enc_state, SPEEX_GET_ABR, + &s->header.bitrate); + } else { + speex_encoder_ctl(s->enc_state, SPEEX_SET_BITRATE, + &s->header.bitrate); + speex_encoder_ctl(s->enc_state, SPEEX_GET_BITRATE, + &s->header.bitrate); + } + } else { + /* CBR by quality */ + speex_encoder_ctl(s->enc_state, SPEEX_SET_QUALITY, + &s->cbr_quality); + speex_encoder_ctl(s->enc_state, SPEEX_GET_BITRATE, + &s->header.bitrate); + } + /* stereo side information adds about 800 bps to the base bitrate */ + /* TODO: this should be calculated exactly */ + avctx->bit_rate = s->header.bitrate + (avctx->channels == 2 ? 800 : 0); + } + + /* set encoding complexity */ + if (avctx->compression_level > FF_COMPRESSION_DEFAULT) { + complexity = av_clip(avctx->compression_level, 0, 10); + speex_encoder_ctl(s->enc_state, SPEEX_SET_COMPLEXITY, &complexity); + } + speex_encoder_ctl(s->enc_state, SPEEX_GET_COMPLEXITY, &complexity); + avctx->compression_level = complexity; + + /* set packet size */ + avctx->frame_size = s->header.frame_size; + s->header.frames_per_packet = s->frames_per_packet; + + /* set encoding delay */ + speex_encoder_ctl(s->enc_state, SPEEX_GET_LOOKAHEAD, &s->lookahead); + s->sample_count = -s->lookahead; + + /* create header packet bytes from header struct */ + /* note: libspeex allocates the memory for header_data, which is freed + below with speex_header_free() */ + header_data = speex_header_to_packet(&s->header, &header_size); + + /* allocate extradata and coded_frame */ + avctx->extradata = av_malloc(header_size + FF_INPUT_BUFFER_PADDING_SIZE); + avctx->coded_frame = avcodec_alloc_frame(); + if (!avctx->extradata || !avctx->coded_frame) { + speex_header_free(header_data); + speex_encoder_destroy(s->enc_state); + av_log(avctx, AV_LOG_ERROR, "memory allocation error\n"); + return AVERROR(ENOMEM); + } + + /* copy header packet to extradata */ + memcpy(avctx->extradata, header_data, header_size); + avctx->extradata_size = header_size; + speex_header_free(header_data); + + /* init libspeex bitwriter */ + speex_bits_init(&s->bits); + + print_enc_params(avctx, s); return 0; } -static av_cold int libspeex_encode_frame( - AVCodecContext *avctx, uint8_t *frame, - int buf_size, void *data) +static int encode_frame(AVCodecContext *avctx, uint8_t *frame, int buf_size, + void *data) { - LibSpeexEncContext *s = (LibSpeexEncContext*)avctx->priv_data; - int i = 0; - - if (!data) - // nothing to flush - return 0; - - speex_bits_reset(&s->bits); - for(i = 0; i < s->header.frames_per_packet; i++) - { - if (avctx->sample_fmt == SAMPLE_FMT_FLT) - { - if (avctx->channels == 2) { - speex_encode_stereo( - (float*)data+i*s->header.frame_size, - s->header.frame_size, - &s->bits); - } - speex_encode(s->enc_state, - (float*)data+i*s->header.frame_size, &s->bits); - } else { - if (avctx->channels == 2) { - speex_encode_stereo_int( - (spx_int16_t*)data+i*s->header.frame_size, - s->header.frame_size, - &s->bits); - } - speex_encode_int(s->enc_state, - (spx_int16_t*)data+i*s->header.frame_size, &s->bits); + LibSpeexEncContext *s = avctx->priv_data; + int16_t *samples = data; + int sample_count = s->sample_count; + + if (data) { + /* encode Speex frame */ + if (avctx->channels == 2) + speex_encode_stereo_int(samples, s->header.frame_size, &s->bits); + speex_encode_int(s->enc_state, samples, &s->bits); + s->pkt_frame_count++; + s->sample_count += avctx->frame_size; + } else { + /* handle end-of-stream */ + if (!s->pkt_frame_count) + return 0; + /* add extra terminator codes for unused frames in last packet */ + while (s->pkt_frame_count < s->frames_per_packet) { + speex_bits_pack(&s->bits, 15, 5); + s->pkt_frame_count++; } } - // put in a terminator so this will fit in a OGG or FLV packet - speex_bits_insert_terminator(&s->bits); - if (buf_size >= speex_bits_nbytes(&s->bits)) { - return speex_bits_write(&s->bits, frame, buf_size); - } else { - av_log(avctx, AV_LOG_ERROR, "output buffer too small"); - return -1; + /* write output if all frames for the packet have been encoded */ + if (s->pkt_frame_count == s->frames_per_packet) { + s->pkt_frame_count = 0; + avctx->coded_frame->pts = + av_rescale_q(sample_count, (AVRational){ 1, avctx->sample_rate }, + avctx->time_base); + if (buf_size > speex_bits_nbytes(&s->bits)) { + int ret = speex_bits_write(&s->bits, frame, buf_size); + speex_bits_reset(&s->bits); + return ret; + } else { + av_log(avctx, AV_LOG_ERROR, "output buffer too small"); + return AVERROR(EINVAL); + } } + return 0; } -static av_cold int libspeex_encode_close(AVCodecContext *avctx) +static av_cold int encode_close(AVCodecContext *avctx) { - LibSpeexEncContext *s = (LibSpeexEncContext*)avctx->priv_data; + LibSpeexEncContext *s = avctx->priv_data; speex_bits_destroy(&s->bits); speex_encoder_destroy(s->enc_state); - s->enc_state = 0; - if (avctx->extradata) - speex_header_free(avctx->extradata); - avctx->extradata = 0; - avctx->extradata_size = 0; + + av_freep(&avctx->coded_frame); + av_freep(&avctx->extradata); return 0; } +#define OFFSET(x) offsetof(LibSpeexEncContext, x) +#define AE AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM +static const AVOption options[] = { + { "abr", "Use average bit rate", OFFSET(abr), AV_OPT_TYPE_INT, { 0 }, 0, 1, AE }, + { "cbr_quality", "Set quality value (0 to 10) for CBR", OFFSET(cbr_quality), AV_OPT_TYPE_INT, { 8 }, 0, 10, AE }, + { "frames_per_packet", "Number of frames to encode in each packet", OFFSET(frames_per_packet), AV_OPT_TYPE_INT, { 1 }, 1, 8, AE }, + { NULL }, +}; + +static const AVClass class = { + .class_name = "libspeex", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + +static const AVCodecDefault defaults[] = { + { "b", "0" }, + { "compression_level", "3" }, + { NULL }, +}; + AVCodec ff_libspeex_encoder = { - "libspeex", - AVMEDIA_TYPE_AUDIO, - CODEC_ID_SPEEX, - sizeof(LibSpeexEncContext), - libspeex_encode_init, - libspeex_encode_frame, - libspeex_encode_close, - 0, - .capabilities = CODEC_CAP_DELAY, - .supported_samplerates = (const int[]){8000, 16000, 32000, 0}, - .sample_fmts = (enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_FLT,SAMPLE_FMT_NONE}, - .long_name = NULL_IF_CONFIG_SMALL("libspeex Speex Encoder"), + .name = "libspeex", + .type = AVMEDIA_TYPE_AUDIO, + .id = CODEC_ID_SPEEX, + .priv_data_size = sizeof(LibSpeexEncContext), + .init = encode_init, + .encode = encode_frame, + .close = encode_close, + .capabilities = CODEC_CAP_DELAY, + .sample_fmts = (const enum SampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, + .long_name = NULL_IF_CONFIG_SMALL("libspeex Speex"), + .priv_class = &class, + .defaults = defaults, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libstagefright.cpp ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libstagefright.cpp --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libstagefright.cpp 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libstagefright.cpp 2011-11-04 12:38:26.000000000 +0000 @@ -445,49 +445,49 @@ Frame *frame; if (s->thread_started) { - if (!s->thread_exited) { - s->stop_decode = 1; + if (!s->thread_exited) { + s->stop_decode = 1; - // Make sure decode_thread() doesn't get stuck - pthread_mutex_lock(&s->out_mutex); - while (!s->out_queue->empty()) { - frame = *s->out_queue->begin(); - s->out_queue->erase(s->out_queue->begin()); - if (frame->size) - frame->mbuffer->release(); - av_freep(&frame); - } - pthread_mutex_unlock(&s->out_mutex); + // Make sure decode_thread() doesn't get stuck + pthread_mutex_lock(&s->out_mutex); + while (!s->out_queue->empty()) { + frame = *s->out_queue->begin(); + s->out_queue->erase(s->out_queue->begin()); + if (frame->size) + frame->mbuffer->release(); + av_freep(&frame); + } + pthread_mutex_unlock(&s->out_mutex); + + // Feed a dummy frame prior to signalling EOF. + // This is required to terminate the decoder(OMX.SEC) + // when only one frame is read during stream info detection. + if (s->dummy_buf && (frame = (Frame*)av_mallocz(sizeof(Frame)))) { + frame->status = OK; + frame->size = s->dummy_bufsize; + frame->key = 1; + frame->buffer = s->dummy_buf; + pthread_mutex_lock(&s->in_mutex); + s->in_queue->push_back(frame); + pthread_cond_signal(&s->condition); + pthread_mutex_unlock(&s->in_mutex); + s->dummy_buf = NULL; + } - // Feed a dummy frame prior to signalling EOF. - // This is required to terminate the decoder(OMX.SEC) - // when only one frame is read during stream info detection. - if (s->dummy_buf && (frame = (Frame*)av_mallocz(sizeof(Frame)))) { - frame->status = OK; - frame->size = s->dummy_bufsize; - frame->key = 1; - frame->buffer = s->dummy_buf; pthread_mutex_lock(&s->in_mutex); - s->in_queue->push_back(frame); + s->end_frame->status = ERROR_END_OF_STREAM; + s->in_queue->push_back(s->end_frame); pthread_cond_signal(&s->condition); pthread_mutex_unlock(&s->in_mutex); - s->dummy_buf = NULL; + s->end_frame = NULL; } - pthread_mutex_lock(&s->in_mutex); - s->end_frame->status = ERROR_END_OF_STREAM; - s->in_queue->push_back(s->end_frame); - pthread_cond_signal(&s->condition); - pthread_mutex_unlock(&s->in_mutex); - s->end_frame = NULL; - } - - pthread_join(s->decode_thread_id, NULL); + pthread_join(s->decode_thread_id, NULL); - if (s->ret_frame.data[0]) - avctx->release_buffer(avctx, &s->ret_frame); + if (s->ret_frame.data[0]) + avctx->release_buffer(avctx, &s->ret_frame); - s->thread_started = false; + s->thread_started = false; } while (!s->in_queue->empty()) { diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libtheoraenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libtheoraenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libtheoraenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libtheoraenc.c 2011-11-04 12:38:26.000000000 +0000 @@ -241,7 +241,7 @@ header, comment, and tables. Each one is prefixed with a 16bit size, then they - are concatenated together into ffmpeg's extradata. + are concatenated together into libavcodec's extradata. */ offset = 0; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libutvideo.cpp ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libutvideo.cpp --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libutvideo.cpp 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libutvideo.cpp 2011-11-04 12:38:26.000000000 +0000 @@ -0,0 +1,230 @@ +/* + * Copyright (c) 2011 Derek Buitenhuis + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; + * version 2 of the License. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * Known FOURCCs: + * 'ULY0' (YCbCr 4:2:0), 'ULY2' (YCbCr 4:2:2), 'ULRG' (RGB), 'ULRA' (RGBA) + */ + +extern "C" { +#include "avcodec.h" +} + +#include +#include +#include + +#include "get_bits.h" + +typedef struct { + uint32_t version; + uint32_t original_format; + uint32_t stripes; + uint32_t flags; +} UtVideoExtra; + +typedef struct { + CCodec *codec; + unsigned int buf_size; + uint8_t *output; +} UtVideoContext; + +static av_cold int utvideo_decode_init(AVCodecContext *avctx) +{ + UtVideoContext *utv = (UtVideoContext *)avctx->priv_data; + UtVideoExtra info; + int defined_fourcc = 0; + + if(avctx->extradata_size != 4*4) + { + av_log(avctx, AV_LOG_ERROR, "Extradata size mismatch.\n"); + return -1; + } + + /* Read extradata */ + info.version = AV_RL32(avctx->extradata); + info.original_format = AV_RL32(avctx->extradata + 4); + info.stripes = AV_RL32(avctx->extradata + 8); + info.flags = AV_RL32(avctx->extradata + 12); + + /* Try to output the original format */ + switch(UNFCC(info.original_format)) + { + case UTVF_YV12: + avctx->pix_fmt = PIX_FMT_YUV420P; + break; + case UTVF_YUY2: + case UTVF_YUYV: + case UTVF_YUNV: + avctx->pix_fmt = PIX_FMT_YUYV422; + break; + case UTVF_UYVY: + case UTVF_UYNV: + avctx->pix_fmt = PIX_FMT_UYVY422; + break; + case UTVF_RGB24_WIN: + avctx->pix_fmt = PIX_FMT_BGR24; + break; + case UTVF_RGB32_WIN: + avctx->pix_fmt = PIX_FMT_RGB32; + break; + case UTVF_ARGB32_WIN: + avctx->pix_fmt = PIX_FMT_ARGB; + break; + case 0: + /* Fall back on FOURCC */ + switch(UNFCC(avctx->codec_tag)) + { + case UTVF_ULY0: + avctx->pix_fmt = PIX_FMT_YUV420P; + defined_fourcc = UTVF_YV12; + break; + case UTVF_ULY2: + avctx->pix_fmt = PIX_FMT_YUYV422; + defined_fourcc = UTVF_YUY2; + break; + case UTVF_ULRG: + avctx->pix_fmt = PIX_FMT_BGR24; + defined_fourcc = UTVF_RGB24_WIN; + break; + case UTVF_ULRA: + avctx->pix_fmt = PIX_FMT_RGB32; + defined_fourcc = UTVF_RGB32_WIN; + break; + } + break; + default: + av_log(avctx, AV_LOG_ERROR, + "Codec ExtraData is Corrupt or Invalid: %X\n", info.original_format); + return -1; + } + + /* Only allocate the buffer once */ + utv->buf_size = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height); + utv->output = (uint8_t *)av_malloc(utv->buf_size * sizeof(uint8_t)); + + if(utv->output == NULL) + { + av_log(avctx, AV_LOG_ERROR, "Unable to allocate output buffer.\n"); + return -1; + } + + /* Allocate the output frame */ + avctx->coded_frame = avcodec_alloc_frame(); + + /* Ut Video only supports 8-bit */ + avctx->bits_per_raw_sample = 8; + + /* Is it interlaced? */ + avctx->coded_frame->interlaced_frame = info.flags & 0x800 ? 1 : 0; + + /* Apparently Ut Video doesn't store this info... */ + avctx->coded_frame->top_field_first = 1; + + /* + * Create a Ut Video instance. Since the function wants + * an "interface name" string, pass it the name of the lib. + */ + utv->codec = CCodec::CreateInstance(UNFCC(avctx->codec_tag), "libavcodec"); + + /* Initialize Decoding */ + utv->codec->DecodeBegin(defined_fourcc ? defined_fourcc : UNFCC(info.original_format), + avctx->width, avctx->height, CBGROSSWIDTH_WINDOWS, &info, + sizeof(UtVideoExtra)); + + return 0; +} + +static int utvideo_decode_frame(AVCodecContext *avctx, void *data, + int *data_size, AVPacket *avpkt) +{ + UtVideoContext *utv = (UtVideoContext *)avctx->priv_data; + AVFrame *pic = avctx->coded_frame; + unsigned int w = avctx->width, h = avctx->height; + + /* Set flags */ + pic->reference = 0; + pic->pict_type = AV_PICTURE_TYPE_I; + pic->key_frame = 1; + + /* Decode the frame */ + utv->codec->DecodeFrame(utv->output, avpkt->data, true); + + /* Set the output data depending on the colorspace */ + switch(avctx->pix_fmt) + { + case PIX_FMT_YUV420P: + pic->linesize[0] = w; + pic->linesize[1] = pic->linesize[2] = w / 2; + pic->data[0] = utv->output; + pic->data[2] = utv->output + (w * h); + pic->data[1] = pic->data[2] + (w * h / 4); + break; + case PIX_FMT_YUYV422: + case PIX_FMT_UYVY422: + pic->linesize[0] = w * 2; + pic->data[0] = utv->output; + break; + case PIX_FMT_BGR24: + case PIX_FMT_RGB32: + /* Make the linesize negative, since Ut Video uses bottom-up BGR */ + pic->linesize[0] = -1 * w * (avctx->pix_fmt == PIX_FMT_BGR24 ? 3 : 4); + pic->data[0] = utv->output + utv->buf_size + pic->linesize[0]; + break; + } + + *data_size = sizeof(AVFrame); + *(AVFrame *)data = *pic; + + return avpkt->size; +} + +static av_cold int utvideo_decode_close(AVCodecContext *avctx) +{ + UtVideoContext *utv = (UtVideoContext *)avctx->priv_data; + + /* Free output */ + av_freep(&avctx->coded_frame); + av_freep(&utv->output); + + /* Finish decoding and clean up the instance */ + utv->codec->DecodeEnd(); + CCodec::DeleteInstance(utv->codec); + + return 0; +} + +AVCodec ff_libutvideo_decoder = { + "utvideo", + AVMEDIA_TYPE_VIDEO, + CODEC_ID_UTVIDEO, + sizeof(UtVideoContext), + utvideo_decode_init, + NULL, + utvideo_decode_close, + utvideo_decode_frame, + CODEC_CAP_LOSSLESS, + NULL, + NULL, + NULL, + NULL, + NULL_IF_CONFIG_SMALL("Ut Video"), +}; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libvo-aacenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libvo-aacenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libvo-aacenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libvo-aacenc.c 2011-11-04 12:38:26.000000000 +0000 @@ -63,7 +63,7 @@ } for (index = 0; index < 16; index++) - if (avctx->sample_rate == ff_mpeg4audio_sample_rates[index]) + if (avctx->sample_rate == avpriv_mpeg4audio_sample_rates[index]) break; if (index == 16) { av_log(avctx, AV_LOG_ERROR, "Unsupported sample rate %d\n", diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libvo-amrwbenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libvo-amrwbenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libvo-amrwbenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libvo-amrwbenc.c 2011-11-04 12:38:26.000000000 +0000 @@ -34,7 +34,7 @@ } AMRWBContext; static const AVOption options[] = { - { "dtx", "Allow DTX (generate comfort noise)", offsetof(AMRWBContext, allow_dtx), FF_OPT_TYPE_INT, { 0 }, 0, 1, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, + { "dtx", "Allow DTX (generate comfort noise)", offsetof(AMRWBContext, allow_dtx), AV_OPT_TYPE_INT, { 0 }, 0, 1, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM }, { NULL } }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libvorbis.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libvorbis.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libvorbis.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libvorbis.c 2011-11-04 12:38:26.000000000 +0000 @@ -56,7 +56,7 @@ } OggVorbisContext ; static const AVOption options[]={ -{"iblock", "Sets the impulse block bias", offsetof(OggVorbisContext, iblock), FF_OPT_TYPE_DOUBLE, {.dbl = 0}, -15, 0, AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_ENCODING_PARAM}, +{"iblock", "Sets the impulse block bias", offsetof(OggVorbisContext, iblock), AV_OPT_TYPE_DOUBLE, {.dbl = 0}, -15, 0, AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_ENCODING_PARAM}, {NULL} }; static const AVClass class = { "libvorbis", av_default_item_name, options, LIBAVUTIL_VERSION_INT }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libvpxenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libvpxenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libvpxenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libvpxenc.c 2011-11-04 12:38:26.000000000 +0000 @@ -547,45 +547,44 @@ #define OFFSET(x) offsetof(VP8Context, x) #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM - -static const AVOption options[]={ - { "cpu-used", "Quality/Speed ratio modifier", OFFSET(cpu_used), FF_OPT_TYPE_INT, {INT_MIN}, INT_MIN, INT_MAX, VE}, +static const AVOption options[] = { + { "cpu-used", "Quality/Speed ratio modifier", OFFSET(cpu_used), AV_OPT_TYPE_INT, {INT_MIN}, INT_MIN, INT_MAX, VE}, { "auto-alt-ref", "Enable use of alternate reference " - "frames (2-pass only)", OFFSET(auto_alt_ref), FF_OPT_TYPE_INT, {-1}, -1, 1, VE}, + "frames (2-pass only)", OFFSET(auto_alt_ref), AV_OPT_TYPE_INT, {-1}, -1, 1, VE}, { "lag-in-frames", "Number of frames to look ahead for " - "alternate reference frame selection", OFFSET(lag_in_frames), FF_OPT_TYPE_INT, {-1}, -1, INT_MAX, VE}, - { "arnr-maxframes", "altref noise reduction max frame count", OFFSET(arnr_max_frames), FF_OPT_TYPE_INT, {-1}, -1, INT_MAX, VE}, - { "arnr-strength", "altref noise reduction filter strength", OFFSET(arnr_strength), FF_OPT_TYPE_INT, {-1}, -1, INT_MAX, VE}, - { "arnr-type", "altref noise reduction filter type", OFFSET(arnr_type), FF_OPT_TYPE_INT, {-1}, -1, INT_MAX, VE, "arnr_type"}, - { "backward", NULL, 0, FF_OPT_TYPE_CONST, {1}, 0, 0, VE, "arnr_type" }, - { "forward", NULL, 0, FF_OPT_TYPE_CONST, {2}, 0, 0, VE, "arnr_type" }, - { "centered", NULL, 0, FF_OPT_TYPE_CONST, {3}, 0, 0, VE, "arnr_type" }, - { "deadline", "Time to spend encoding, in microseconds.", OFFSET(deadline), FF_OPT_TYPE_INT, {VPX_DL_GOOD_QUALITY}, INT_MIN, INT_MAX, VE, "quality"}, - { "best", NULL, 0, FF_OPT_TYPE_CONST, {VPX_DL_BEST_QUALITY}, 0, 0, VE, "quality"}, - { "good", NULL, 0, FF_OPT_TYPE_CONST, {VPX_DL_GOOD_QUALITY}, 0, 0, VE, "quality"}, - { "realtime", NULL, 0, FF_OPT_TYPE_CONST, {VPX_DL_REALTIME}, 0, 0, VE, "quality"}, - { "error-resilient", "Error resilience configuration", OFFSET(error_resilient), FF_OPT_TYPE_FLAGS, {0}, INT_MIN, INT_MAX, VE, "er"}, + "alternate reference frame selection", OFFSET(lag_in_frames), AV_OPT_TYPE_INT, {-1}, -1, INT_MAX, VE}, + { "arnr-maxframes", "altref noise reduction max frame count", OFFSET(arnr_max_frames), AV_OPT_TYPE_INT, {-1}, -1, INT_MAX, VE}, + { "arnr-strength", "altref noise reduction filter strength", OFFSET(arnr_strength), AV_OPT_TYPE_INT, {-1}, -1, INT_MAX, VE}, + { "arnr-type", "altref noise reduction filter type", OFFSET(arnr_type), AV_OPT_TYPE_INT, {-1}, -1, INT_MAX, VE, "arnr_type"}, + { "backward", NULL, 0, AV_OPT_TYPE_CONST, {1}, 0, 0, VE, "arnr_type" }, + { "forward", NULL, 0, AV_OPT_TYPE_CONST, {2}, 0, 0, VE, "arnr_type" }, + { "centered", NULL, 0, AV_OPT_TYPE_CONST, {3}, 0, 0, VE, "arnr_type" }, + { "deadline", "Time to spend encoding, in microseconds.", OFFSET(deadline), AV_OPT_TYPE_INT, {VPX_DL_GOOD_QUALITY}, INT_MIN, INT_MAX, VE, "quality"}, + { "best", NULL, 0, AV_OPT_TYPE_CONST, {VPX_DL_BEST_QUALITY}, 0, 0, VE, "quality"}, + { "good", NULL, 0, AV_OPT_TYPE_CONST, {VPX_DL_GOOD_QUALITY}, 0, 0, VE, "quality"}, + { "realtime", NULL, 0, AV_OPT_TYPE_CONST, {VPX_DL_REALTIME}, 0, 0, VE, "quality"}, + { "error-resilient", "Error resilience configuration", OFFSET(error_resilient), AV_OPT_TYPE_FLAGS, {0}, INT_MIN, INT_MAX, VE, "er"}, #ifdef VPX_ERROR_RESILIENT_DEFAULT - { "default", "Improve resiliency against losses of whole frames", 0, FF_OPT_TYPE_CONST, {VPX_ERROR_RESILIENT_DEFAULT}, 0, 0, VE, "er"}, + { "default", "Improve resiliency against losses of whole frames", 0, AV_OPT_TYPE_CONST, {VPX_ERROR_RESILIENT_DEFAULT}, 0, 0, VE, "er"}, { "partitions", "The frame partitions are independently decodable " "by the bool decoder, meaning that partitions can be decoded even " "though earlier partitions have been lost. Note that intra predicition" - " is still done over the partition boundary.", 0, FF_OPT_TYPE_CONST, {VPX_ERROR_RESILIENT_PARTITIONS}, 0, 0, VE, "er"}, + " is still done over the partition boundary.", 0, AV_OPT_TYPE_CONST, {VPX_ERROR_RESILIENT_PARTITIONS}, 0, 0, VE, "er"}, #endif -{"speed", "", offsetof(VP8Context, cpu_used), FF_OPT_TYPE_INT, {.dbl = 3}, -16, 16, VE}, -{"quality", "", offsetof(VP8Context, deadline), FF_OPT_TYPE_INT, {.dbl = VPX_DL_GOOD_QUALITY}, INT_MIN, INT_MAX, VE, "quality"}, -{"best", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = VPX_DL_BEST_QUALITY}, INT_MIN, INT_MAX, VE, "quality"}, -{"good", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = VPX_DL_GOOD_QUALITY}, INT_MIN, INT_MAX, VE, "quality"}, -{"realtime", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = VPX_DL_REALTIME}, INT_MIN, INT_MAX, VE, "quality"}, -{"arnr_max_frames", "altref noise reduction max frame count", offsetof(VP8Context, arnr_max_frames), FF_OPT_TYPE_INT, {.dbl = 0}, 0, 15, VE}, -{"arnr_strength", "altref noise reduction filter strength", offsetof(VP8Context, arnr_strength), FF_OPT_TYPE_INT, {.dbl = 3}, 0, 6, VE}, -{"arnr_type", "altref noise reduction filter type", offsetof(VP8Context, arnr_type), FF_OPT_TYPE_INT, {.dbl = 3}, 1, 3, VE}, +{"speed", "", offsetof(VP8Context, cpu_used), AV_OPT_TYPE_INT, {.dbl = 3}, -16, 16, VE}, +{"quality", "", offsetof(VP8Context, deadline), AV_OPT_TYPE_INT, {.dbl = VPX_DL_GOOD_QUALITY}, INT_MIN, INT_MAX, VE, "quality"}, +{"best", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = VPX_DL_BEST_QUALITY}, INT_MIN, INT_MAX, VE, "quality"}, +{"good", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = VPX_DL_GOOD_QUALITY}, INT_MIN, INT_MAX, VE, "quality"}, +{"realtime", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = VPX_DL_REALTIME}, INT_MIN, INT_MAX, VE, "quality"}, +{"arnr_max_frames", "altref noise reduction max frame count", offsetof(VP8Context, arnr_max_frames), AV_OPT_TYPE_INT, {.dbl = 0}, 0, 15, VE}, +{"arnr_strength", "altref noise reduction filter strength", offsetof(VP8Context, arnr_strength), AV_OPT_TYPE_INT, {.dbl = 3}, 0, 6, VE}, +{"arnr_type", "altref noise reduction filter type", offsetof(VP8Context, arnr_type), AV_OPT_TYPE_INT, {.dbl = 3}, 1, 3, VE}, #if FF_API_X264_GLOBAL_OPTS -{"rc_lookahead", "Number of frames to look ahead for alternate reference frame selection", offsetof(VP8Context, lag_in_frames), FF_OPT_TYPE_INT, {.dbl = -1}, -1, 25, VE}, -{"crf", "Select the quality for constant quality mode", offsetof(VP8Context, crf), FF_OPT_TYPE_INT, {.dbl = -1}, -1, 63, VE}, +{"rc_lookahead", "Number of frames to look ahead for alternate reference frame selection", offsetof(VP8Context, lag_in_frames), AV_OPT_TYPE_INT, {.dbl = -1}, -1, 25, VE}, +{"crf", "Select the quality for constant quality mode", offsetof(VP8Context, crf), AV_OPT_TYPE_INT, {.dbl = -1}, -1, 63, VE}, #else -{"rc_lookahead", "Number of frames to look ahead for alternate reference frame selection", offsetof(VP8Context, lag_in_frames), FF_OPT_TYPE_INT, {.dbl = 25}, 0, 25, VE}, -{"crf", "Select the quality for constant quality mode", offsetof(VP8Context, crf), FF_OPT_TYPE_INT, {.dbl = 0}, 0, 63, VE}, +{"rc_lookahead", "Number of frames to look ahead for alternate reference frame selection", offsetof(VP8Context, lag_in_frames), AV_OPT_TYPE_INT, {.dbl = 25}, 0, 25, VE}, +{"crf", "Select the quality for constant quality mode", offsetof(VP8Context, crf), AV_OPT_TYPE_INT, {.dbl = 0}, 0, 63, VE}, #endif {NULL} }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libx264.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libx264.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libx264.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libx264.c 2011-11-04 12:38:26.000000000 +0000 @@ -127,6 +127,25 @@ return p - buf; } +static int avfmt2_num_planes(int avfmt) +{ + switch (avfmt) { + case PIX_FMT_YUV420P: + case PIX_FMT_YUVJ420P: + case PIX_FMT_YUV420P9: + case PIX_FMT_YUV420P10: + case PIX_FMT_YUV444P: + return 3; + + case PIX_FMT_BGR24: + case PIX_FMT_RGB24: + return 1; + + default: + return 3; + } +} + static int X264_frame(AVCodecContext *ctx, uint8_t *buf, int orig_bufsize, void *data) { @@ -138,13 +157,13 @@ int bufsize; x264_picture_init( &x4->pic ); - x4->pic.img.i_csp = X264_CSP_I420; + x4->pic.img.i_csp = x4->params.i_csp; if (x264_bit_depth > 8) x4->pic.img.i_csp |= X264_CSP_HIGH_DEPTH; - x4->pic.img.i_plane = 3; + x4->pic.img.i_plane = avfmt2_num_planes(ctx->pix_fmt); if (frame) { - for (i = 0; i < 3; i++) { + for (i = 0; i < x4->pic.img.i_plane; i++) { x4->pic.img.plane[i] = frame->data[i]; x4->pic.img.i_stride[i] = frame->linesize[i]; } @@ -228,6 +247,29 @@ } \ } while (0); +static int convert_pix_fmt(enum PixelFormat pix_fmt) +{ + switch (pix_fmt) { + case PIX_FMT_YUV420P: + case PIX_FMT_YUVJ420P: + case PIX_FMT_YUV420P9: + case PIX_FMT_YUV420P10: return X264_CSP_I420; + case PIX_FMT_YUV422P: + case PIX_FMT_YUV422P10: return X264_CSP_I422; + case PIX_FMT_YUV444P: + case PIX_FMT_YUV444P9: + case PIX_FMT_YUV444P10: return X264_CSP_I444; +#ifdef X264_CSP_BGR + case PIX_FMT_BGR24: + return X264_CSP_BGR; + + case PIX_FMT_RGB24: + return X264_CSP_RGB; +#endif + }; + return 0; +} + #define PARSE_X264_OPT(name, var)\ if (x4->var && x264_param_parse(&x4->params, name, x4->var) < 0) {\ av_log(avctx, AV_LOG_ERROR, "Error parsing option '%s' with value '%s'.\n", name, x4->var);\ @@ -257,6 +299,7 @@ x4->params.pf_log = X264_log; x4->params.p_log_private = avctx; x4->params.i_log_level = X264_LOG_DEBUG; + x4->params.i_csp = convert_pix_fmt(avctx->pix_fmt); OPT_STR("weightp", x4->wpredp); @@ -516,14 +559,23 @@ static const enum PixelFormat pix_fmts_8bit[] = { PIX_FMT_YUV420P, PIX_FMT_YUVJ420P, + PIX_FMT_YUV422P, + PIX_FMT_YUV444P, +#ifdef X264_CSP_BGR + PIX_FMT_BGR24, + PIX_FMT_RGB24, +#endif PIX_FMT_NONE }; static const enum PixelFormat pix_fmts_9bit[] = { PIX_FMT_YUV420P9, + PIX_FMT_YUV444P9, PIX_FMT_NONE }; static const enum PixelFormat pix_fmts_10bit[] = { PIX_FMT_YUV420P10, + PIX_FMT_YUV422P10, + PIX_FMT_YUV444P10, PIX_FMT_NONE }; @@ -540,52 +592,52 @@ #define OFFSET(x) offsetof(X264Context, x) #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { - { "preset", "Set the encoding preset (cf. x264 --fullhelp)", OFFSET(preset), FF_OPT_TYPE_STRING, { .str = "medium" }, 0, 0, VE}, - { "tune", "Tune the encoding params (cf. x264 --fullhelp)", OFFSET(tune), FF_OPT_TYPE_STRING, { 0 }, 0, 0, VE}, - { "profile", "Set profile restrictions (cf. x264 --fullhelp) ", OFFSET(profile), FF_OPT_TYPE_STRING, { 0 }, 0, 0, VE}, - { "fastfirstpass", "Use fast settings when encoding first pass", OFFSET(fastfirstpass), FF_OPT_TYPE_INT, { 1 }, 0, 1, VE}, - {"level", "Specify level (as defined by Annex A)", OFFSET(level), FF_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE}, - {"passlogfile", "Filename for 2 pass stats", OFFSET(stats), FF_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE}, - {"wpredp", "Weighted prediction for P-frames", OFFSET(wpredp), FF_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE}, - {"x264opts", "x264 options", OFFSET(x264opts), FF_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE}, - { "crf", "Select the quality for constant quality mode", OFFSET(crf), FF_OPT_TYPE_FLOAT, {-1 }, -1, FLT_MAX, VE }, - { "crf_max", "In CRF mode, prevents VBV from lowering quality beyond this point.",OFFSET(crf_max), FF_OPT_TYPE_FLOAT, {-1 }, -1, FLT_MAX, VE }, - { "qp", "Constant quantization parameter rate control method",OFFSET(cqp), FF_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE }, - { "aq-mode", "AQ method", OFFSET(aq_mode), FF_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE, "aq_mode"}, - { "none", NULL, 0, FF_OPT_TYPE_CONST, {X264_AQ_NONE}, INT_MIN, INT_MAX, VE, "aq_mode" }, - { "variance", "Variance AQ (complexity mask)", 0, FF_OPT_TYPE_CONST, {X264_AQ_VARIANCE}, INT_MIN, INT_MAX, VE, "aq_mode" }, - { "autovariance", "Auto-variance AQ (experimental)", 0, FF_OPT_TYPE_CONST, {X264_AQ_AUTOVARIANCE}, INT_MIN, INT_MAX, VE, "aq_mode" }, - { "aq-strength", "AQ strength. Reduces blocking and blurring in flat and textured areas.", OFFSET(aq_strength), FF_OPT_TYPE_FLOAT, {-1}, -1, FLT_MAX, VE}, - { "psy", "Use psychovisual optimizations.", OFFSET(psy), FF_OPT_TYPE_INT, {-1 }, -1, 1, VE }, - { "psy-rd", "Strength of psychovisual optimization, in : format.", OFFSET(psy_rd), FF_OPT_TYPE_STRING, {0 }, 0, 0, VE}, - { "rc-lookahead", "Number of frames to look ahead for frametype and ratecontrol", OFFSET(rc_lookahead), FF_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE }, - { "weightb", "Weighted prediction for B-frames.", OFFSET(weightb), FF_OPT_TYPE_INT, {-1 }, -1, 1, VE }, - { "weightp", "Weighted prediction analysis method.", OFFSET(weightp), FF_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE, "weightp" }, - { "none", NULL, 0, FF_OPT_TYPE_CONST, {X264_WEIGHTP_NONE}, INT_MIN, INT_MAX, VE, "weightp" }, - { "simple", NULL, 0, FF_OPT_TYPE_CONST, {X264_WEIGHTP_SIMPLE}, INT_MIN, INT_MAX, VE, "weightp" }, - { "smart", NULL, 0, FF_OPT_TYPE_CONST, {X264_WEIGHTP_SMART}, INT_MIN, INT_MAX, VE, "weightp" }, - { "ssim", "Calculate and print SSIM stats.", OFFSET(ssim), FF_OPT_TYPE_INT, {-1 }, -1, 1, VE }, - { "intra-refresh", "Use Periodic Intra Refresh instead of IDR frames.",OFFSET(intra_refresh),FF_OPT_TYPE_INT, {-1 }, -1, 1, VE }, - { "b-bias", "Influences how often B-frames are used", OFFSET(b_bias), FF_OPT_TYPE_INT, {INT_MIN}, INT_MIN, INT_MAX, VE }, - { "b-pyramid", "Keep some B-frames as references.", OFFSET(b_pyramid), FF_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE, "b_pyramid" }, - { "none", NULL, 0, FF_OPT_TYPE_CONST, {X264_B_PYRAMID_NONE}, INT_MIN, INT_MAX, VE, "b_pyramid" }, - { "strict", "Strictly hierarchical pyramid", 0, FF_OPT_TYPE_CONST, {X264_B_PYRAMID_STRICT}, INT_MIN, INT_MAX, VE, "b_pyramid" }, - { "normal", "Non-strict (not Blu-ray compatible)", 0, FF_OPT_TYPE_CONST, {X264_B_PYRAMID_NORMAL}, INT_MIN, INT_MAX, VE, "b_pyramid" }, - { "mixed-refs", "One reference per partition, as opposed to one reference per macroblock", OFFSET(mixed_refs), FF_OPT_TYPE_INT, {-1}, -1, 1, VE }, - { "8x8dct", "High profile 8x8 transform.", OFFSET(dct8x8), FF_OPT_TYPE_INT, {-1 }, -1, 1, VE}, - { "fast-pskip", NULL, OFFSET(fast_pskip), FF_OPT_TYPE_INT, {-1 }, -1, 1, VE}, - { "aud", "Use access unit delimiters.", OFFSET(aud), FF_OPT_TYPE_INT, {-1 }, -1, 1, VE}, - { "mbtree", "Use macroblock tree ratecontrol.", OFFSET(mbtree), FF_OPT_TYPE_INT, {-1 }, -1, 1, VE}, - { "deblock", "Loop filter parameters, in form.", OFFSET(deblock), FF_OPT_TYPE_STRING, { 0 }, 0, 0, VE}, - { "cplxblur", "Reduce fluctuations in QP (before curve compression)", OFFSET(cplxblur), FF_OPT_TYPE_FLOAT, {-1 }, -1, FLT_MAX, VE}, + { "preset", "Set the encoding preset (cf. x264 --fullhelp)", OFFSET(preset), AV_OPT_TYPE_STRING, { .str = "medium" }, 0, 0, VE}, + { "tune", "Tune the encoding params (cf. x264 --fullhelp)", OFFSET(tune), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE}, + { "profile", "Set profile restrictions (cf. x264 --fullhelp) ", OFFSET(profile), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE}, + { "fastfirstpass", "Use fast settings when encoding first pass", OFFSET(fastfirstpass), AV_OPT_TYPE_INT, { 1 }, 0, 1, VE}, + {"level", "Specify level (as defined by Annex A)", OFFSET(level), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE}, + {"passlogfile", "Filename for 2 pass stats", OFFSET(stats), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE}, + {"wpredp", "Weighted prediction for P-frames", OFFSET(wpredp), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE}, + {"x264opts", "x264 options", OFFSET(x264opts), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE}, + { "crf", "Select the quality for constant quality mode", OFFSET(crf), AV_OPT_TYPE_FLOAT, {-1 }, -1, FLT_MAX, VE }, + { "crf_max", "In CRF mode, prevents VBV from lowering quality beyond this point.",OFFSET(crf_max), AV_OPT_TYPE_FLOAT, {-1 }, -1, FLT_MAX, VE }, + { "qp", "Constant quantization parameter rate control method",OFFSET(cqp), AV_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE }, + { "aq-mode", "AQ method", OFFSET(aq_mode), AV_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE, "aq_mode"}, + { "none", NULL, 0, AV_OPT_TYPE_CONST, {X264_AQ_NONE}, INT_MIN, INT_MAX, VE, "aq_mode" }, + { "variance", "Variance AQ (complexity mask)", 0, AV_OPT_TYPE_CONST, {X264_AQ_VARIANCE}, INT_MIN, INT_MAX, VE, "aq_mode" }, + { "autovariance", "Auto-variance AQ (experimental)", 0, AV_OPT_TYPE_CONST, {X264_AQ_AUTOVARIANCE}, INT_MIN, INT_MAX, VE, "aq_mode" }, + { "aq-strength", "AQ strength. Reduces blocking and blurring in flat and textured areas.", OFFSET(aq_strength), AV_OPT_TYPE_FLOAT, {-1}, -1, FLT_MAX, VE}, + { "psy", "Use psychovisual optimizations.", OFFSET(psy), AV_OPT_TYPE_INT, {-1 }, -1, 1, VE }, + { "psy-rd", "Strength of psychovisual optimization, in : format.", OFFSET(psy_rd), AV_OPT_TYPE_STRING, {0 }, 0, 0, VE}, + { "rc-lookahead", "Number of frames to look ahead for frametype and ratecontrol", OFFSET(rc_lookahead), AV_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE }, + { "weightb", "Weighted prediction for B-frames.", OFFSET(weightb), AV_OPT_TYPE_INT, {-1 }, -1, 1, VE }, + { "weightp", "Weighted prediction analysis method.", OFFSET(weightp), AV_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE, "weightp" }, + { "none", NULL, 0, AV_OPT_TYPE_CONST, {X264_WEIGHTP_NONE}, INT_MIN, INT_MAX, VE, "weightp" }, + { "simple", NULL, 0, AV_OPT_TYPE_CONST, {X264_WEIGHTP_SIMPLE}, INT_MIN, INT_MAX, VE, "weightp" }, + { "smart", NULL, 0, AV_OPT_TYPE_CONST, {X264_WEIGHTP_SMART}, INT_MIN, INT_MAX, VE, "weightp" }, + { "ssim", "Calculate and print SSIM stats.", OFFSET(ssim), AV_OPT_TYPE_INT, {-1 }, -1, 1, VE }, + { "intra-refresh", "Use Periodic Intra Refresh instead of IDR frames.",OFFSET(intra_refresh),AV_OPT_TYPE_INT, {-1 }, -1, 1, VE }, + { "b-bias", "Influences how often B-frames are used", OFFSET(b_bias), AV_OPT_TYPE_INT, {INT_MIN}, INT_MIN, INT_MAX, VE }, + { "b-pyramid", "Keep some B-frames as references.", OFFSET(b_pyramid), AV_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE, "b_pyramid" }, + { "none", NULL, 0, AV_OPT_TYPE_CONST, {X264_B_PYRAMID_NONE}, INT_MIN, INT_MAX, VE, "b_pyramid" }, + { "strict", "Strictly hierarchical pyramid", 0, AV_OPT_TYPE_CONST, {X264_B_PYRAMID_STRICT}, INT_MIN, INT_MAX, VE, "b_pyramid" }, + { "normal", "Non-strict (not Blu-ray compatible)", 0, AV_OPT_TYPE_CONST, {X264_B_PYRAMID_NORMAL}, INT_MIN, INT_MAX, VE, "b_pyramid" }, + { "mixed-refs", "One reference per partition, as opposed to one reference per macroblock", OFFSET(mixed_refs), AV_OPT_TYPE_INT, {-1}, -1, 1, VE }, + { "8x8dct", "High profile 8x8 transform.", OFFSET(dct8x8), AV_OPT_TYPE_INT, {-1 }, -1, 1, VE}, + { "fast-pskip", NULL, OFFSET(fast_pskip), AV_OPT_TYPE_INT, {-1 }, -1, 1, VE}, + { "aud", "Use access unit delimiters.", OFFSET(aud), AV_OPT_TYPE_INT, {-1 }, -1, 1, VE}, + { "mbtree", "Use macroblock tree ratecontrol.", OFFSET(mbtree), AV_OPT_TYPE_INT, {-1 }, -1, 1, VE}, + { "deblock", "Loop filter parameters, in form.", OFFSET(deblock), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE}, + { "cplxblur", "Reduce fluctuations in QP (before curve compression)", OFFSET(cplxblur), AV_OPT_TYPE_FLOAT, {-1 }, -1, FLT_MAX, VE}, { "partitions", "A comma-separated list of partitions to consider. " - "Possible values: p8x8, p4x4, b8x8, i8x8, i4x4, none, all", OFFSET(partitions), FF_OPT_TYPE_STRING, { 0 }, 0, 0, VE}, - { "direct-pred", "Direct MV prediction mode", OFFSET(direct_pred), FF_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE, "direct-pred" }, - { "none", NULL, 0, FF_OPT_TYPE_CONST, { X264_DIRECT_PRED_NONE }, 0, 0, VE, "direct-pred" }, - { "spatial", NULL, 0, FF_OPT_TYPE_CONST, { X264_DIRECT_PRED_SPATIAL }, 0, 0, VE, "direct-pred" }, - { "temporal", NULL, 0, FF_OPT_TYPE_CONST, { X264_DIRECT_PRED_TEMPORAL }, 0, 0, VE, "direct-pred" }, - { "auto", NULL, 0, FF_OPT_TYPE_CONST, { X264_DIRECT_PRED_AUTO }, 0, 0, VE, "direct-pred" }, - { "slice-max-size","Constant quantization parameter rate control method",OFFSET(slice_max_size), FF_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE }, + "Possible values: p8x8, p4x4, b8x8, i8x8, i4x4, none, all", OFFSET(partitions), AV_OPT_TYPE_STRING, { 0 }, 0, 0, VE}, + { "direct-pred", "Direct MV prediction mode", OFFSET(direct_pred), AV_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE, "direct-pred" }, + { "none", NULL, 0, AV_OPT_TYPE_CONST, { X264_DIRECT_PRED_NONE }, 0, 0, VE, "direct-pred" }, + { "spatial", NULL, 0, AV_OPT_TYPE_CONST, { X264_DIRECT_PRED_SPATIAL }, 0, 0, VE, "direct-pred" }, + { "temporal", NULL, 0, AV_OPT_TYPE_CONST, { X264_DIRECT_PRED_TEMPORAL }, 0, 0, VE, "direct-pred" }, + { "auto", NULL, 0, AV_OPT_TYPE_CONST, { X264_DIRECT_PRED_AUTO }, 0, 0, VE, "direct-pred" }, + { "slice-max-size","Constant quantization parameter rate control method",OFFSET(slice_max_size), AV_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE }, { NULL }, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libxavs.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libxavs.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libxavs.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libxavs.c 2011-11-04 12:38:26.000000000 +0000 @@ -378,19 +378,19 @@ #define OFFSET(x) offsetof(XavsContext, x) #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { - { "crf", "Select the quality for constant quality mode", OFFSET(crf), FF_OPT_TYPE_FLOAT, {-1 }, -1, FLT_MAX, VE }, - { "qp", "Constant quantization parameter rate control method",OFFSET(cqp), FF_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE }, - { "b-bias", "Influences how often B-frames are used", OFFSET(b_bias), FF_OPT_TYPE_INT, {INT_MIN}, INT_MIN, INT_MAX, VE }, - { "cplxblur", "Reduce fluctuations in QP (before curve compression)", OFFSET(cplxblur), FF_OPT_TYPE_FLOAT, {-1 }, -1, FLT_MAX, VE}, - { "direct-pred", "Direct MV prediction mode", OFFSET(direct_pred), FF_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE, "direct-pred" }, - { "none", NULL, 0, FF_OPT_TYPE_CONST, { XAVS_DIRECT_PRED_NONE }, 0, 0, VE, "direct-pred" }, - { "spatial", NULL, 0, FF_OPT_TYPE_CONST, { XAVS_DIRECT_PRED_SPATIAL }, 0, 0, VE, "direct-pred" }, - { "temporal", NULL, 0, FF_OPT_TYPE_CONST, { XAVS_DIRECT_PRED_TEMPORAL }, 0, 0, VE, "direct-pred" }, - { "auto", NULL, 0, FF_OPT_TYPE_CONST, { XAVS_DIRECT_PRED_AUTO }, 0, 0, VE, "direct-pred" }, - { "aud", "Use access unit delimiters.", OFFSET(aud), FF_OPT_TYPE_INT, {-1 }, -1, 1, VE}, - { "mbtree", "Use macroblock tree ratecontrol.", OFFSET(mbtree), FF_OPT_TYPE_INT, {-1 }, -1, 1, VE}, - { "mixed-refs", "One reference per partition, as opposed to one reference per macroblock", OFFSET(mixed_refs), FF_OPT_TYPE_INT, {-1}, -1, 1, VE }, - { "fast-pskip", NULL, OFFSET(fast_pskip), FF_OPT_TYPE_INT, {-1 }, -1, 1, VE}, + { "crf", "Select the quality for constant quality mode", OFFSET(crf), AV_OPT_TYPE_FLOAT, {-1 }, -1, FLT_MAX, VE }, + { "qp", "Constant quantization parameter rate control method",OFFSET(cqp), AV_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE }, + { "b-bias", "Influences how often B-frames are used", OFFSET(b_bias), AV_OPT_TYPE_INT, {INT_MIN}, INT_MIN, INT_MAX, VE }, + { "cplxblur", "Reduce fluctuations in QP (before curve compression)", OFFSET(cplxblur), AV_OPT_TYPE_FLOAT, {-1 }, -1, FLT_MAX, VE}, + { "direct-pred", "Direct MV prediction mode", OFFSET(direct_pred), AV_OPT_TYPE_INT, {-1 }, -1, INT_MAX, VE, "direct-pred" }, + { "none", NULL, 0, AV_OPT_TYPE_CONST, { XAVS_DIRECT_PRED_NONE }, 0, 0, VE, "direct-pred" }, + { "spatial", NULL, 0, AV_OPT_TYPE_CONST, { XAVS_DIRECT_PRED_SPATIAL }, 0, 0, VE, "direct-pred" }, + { "temporal", NULL, 0, AV_OPT_TYPE_CONST, { XAVS_DIRECT_PRED_TEMPORAL }, 0, 0, VE, "direct-pred" }, + { "auto", NULL, 0, AV_OPT_TYPE_CONST, { XAVS_DIRECT_PRED_AUTO }, 0, 0, VE, "direct-pred" }, + { "aud", "Use access unit delimiters.", OFFSET(aud), AV_OPT_TYPE_INT, {-1 }, -1, 1, VE}, + { "mbtree", "Use macroblock tree ratecontrol.", OFFSET(mbtree), AV_OPT_TYPE_INT, {-1 }, -1, 1, VE}, + { "mixed-refs", "One reference per partition, as opposed to one reference per macroblock", OFFSET(mixed_refs), AV_OPT_TYPE_INT, {-1}, -1, 1, VE }, + { "fast-pskip", NULL, OFFSET(fast_pskip), AV_OPT_TYPE_INT, {-1 }, -1, 1, VE}, { NULL }, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libxvidff.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libxvidff.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libxvidff.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libxvidff.c 2011-11-04 12:38:26.000000000 +0000 @@ -28,13 +28,11 @@ #include #include #include "avcodec.h" +#include "libavutil/file.h" #include "libavutil/cpu.h" #include "libavutil/intreadwrite.h" #include "libavutil/mathematics.h" #include "libxvid_internal.h" -#if !HAVE_MKSTEMP -#include -#endif /** * Buffer management macros. @@ -77,42 +75,6 @@ int xvid_ff_2pass(void *ref, int opt, void *p1, void *p2); void xvid_correct_framerate(AVCodecContext *avctx); -/* Wrapper to work around the lack of mkstemp() on mingw. - * Also, tries to create file in /tmp first, if possible. - * *prefix can be a character constant; *filename will be allocated internally. - * @return file descriptor of opened file (or -1 on error) - * and opened file name in **filename. */ -int ff_tempfile(const char *prefix, char **filename) { - int fd=-1; -#if !HAVE_MKSTEMP - *filename = tempnam(".", prefix); -#else - size_t len = strlen(prefix) + 12; /* room for "/tmp/" and "XXXXXX\0" */ - *filename = av_malloc(len); -#endif - /* -----common section-----*/ - if (*filename == NULL) { - av_log(NULL, AV_LOG_ERROR, "ff_tempfile: Cannot allocate file name\n"); - return -1; - } -#if !HAVE_MKSTEMP - fd = open(*filename, O_RDWR | O_BINARY | O_CREAT, 0444); -#else - snprintf(*filename, len, "/tmp/%sXXXXXX", prefix); - fd = mkstemp(*filename); - if (fd < 0) { - snprintf(*filename, len, "./%sXXXXXX", prefix); - fd = mkstemp(*filename); - } -#endif - /* -----common section-----*/ - if (fd < 0) { - av_log(NULL, AV_LOG_ERROR, "ff_tempfile: Cannot open temporary file %s\n", *filename); - return -1; - } - return fd; /* success */ -} - #if CONFIG_LIBXVID_ENCODER /** @@ -270,7 +232,7 @@ rc2pass2.version = XVID_VERSION; rc2pass2.bitrate = avctx->bit_rate; - fd = ff_tempfile("xvidff.", &(x->twopassfile)); + fd = av_tempfile("xvidff.", &(x->twopassfile), 0, avctx); if( fd == -1 ) { av_log(avctx, AV_LOG_ERROR, "Xvid: Cannot write 2-pass pipe\n"); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libxvid_rc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libxvid_rc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/libxvid_rc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/libxvid_rc.c 2011-11-04 12:38:26.000000000 +0000 @@ -22,6 +22,7 @@ #include #include +#include "libavutil/file.h" #include "avcodec.h" #include "libxvid_internal.h" //#include "dsputil.h" @@ -40,7 +41,7 @@ //xvid_debug=-1; - fd=ff_tempfile("xvidrc.", &tmp_name); + fd=av_tempfile("xvidrc.", &tmp_name, 0, s->avctx); if (fd == -1) { av_log(NULL, AV_LOG_ERROR, "Can't create temporary pass2 file.\n"); return -1; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mace.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mace.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mace.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mace.c 2011-11-04 12:38:26.000000000 +0000 @@ -27,7 +27,7 @@ #include "avcodec.h" /* - * Adapted to ffmpeg by Francois Revol + * Adapted to libavcodec by Francois Revol * (removed 68k REG stuff, changed types, added some statics and consts, * libavcodec api, context stuff, interlaced stereo out). */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/Makefile ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/Makefile --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/Makefile 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/Makefile 2011-11-04 12:38:26.000000000 +0000 @@ -3,7 +3,7 @@ NAME = avcodec FFLIBS = avutil -HEADERS = avcodec.h avfft.h dxva2.h opt.h vaapi.h vdpau.h version.h xvmc.h +HEADERS = avcodec.h avfft.h dxva2.h opt.h vaapi.h vda.h vdpau.h version.h xvmc.h OBJS = allcodecs.o \ audioconvert.o \ @@ -49,6 +49,7 @@ OBJS-$(CONFIG_RDFT) += rdft.o $(RDFT-OBJS-yes) OBJS-$(CONFIG_SINEWIN) += sinewin.o OBJS-$(CONFIG_VAAPI) += vaapi.o +OBJS-$(CONFIG_VDA) += vda.o OBJS-$(CONFIG_VDPAU) += vdpau.o # decoders/encoders/hardware accelerators @@ -111,6 +112,8 @@ OBJS-$(CONFIG_CYUV_DECODER) += cyuv.o OBJS-$(CONFIG_DCA_DECODER) += dca.o synth_filter.o dcadsp.o OBJS-$(CONFIG_DCA_ENCODER) += dcaenc.o +OBJS-$(CONFIG_DIRAC_DECODER) += diracdec.o dirac.o diracdsp.o \ + dirac_arith.o mpeg12data.o dwt.o OBJS-$(CONFIG_DFA_DECODER) += dfa.o OBJS-$(CONFIG_DNXHD_DECODER) += dnxhddec.o dnxhddata.o OBJS-$(CONFIG_DNXHD_ENCODER) += dnxhdenc.o dnxhddata.o \ @@ -161,6 +164,7 @@ OBJS-$(CONFIG_FRWU_DECODER) += frwu.o OBJS-$(CONFIG_G723_1_DECODER) += g723_1.o acelp_vectors.o \ celp_filters.o celp_math.o +OBJS-$(CONFIG_G723_1_ENCODER) += g723_1.o OBJS-$(CONFIG_G729_DECODER) += g729dec.o lsp.o celp_math.o acelp_filters.o acelp_pitch_delay.o acelp_vectors.o g729postfilter.o OBJS-$(CONFIG_GIF_DECODER) += gifdec.o lzw.o OBJS-$(CONFIG_GIF_ENCODER) += gif.o lzwenc.o @@ -189,6 +193,7 @@ mpegvideo.o error_resilience.o OBJS-$(CONFIG_H264_DXVA2_HWACCEL) += dxva2_h264.o OBJS-$(CONFIG_H264_VAAPI_HWACCEL) += vaapi_h264.o +OBJS-$(CONFIG_H264_VDA_HWACCEL) += vda_h264.o OBJS-$(CONFIG_HUFFYUV_DECODER) += huffyuv.o OBJS-$(CONFIG_HUFFYUV_ENCODER) += huffyuv.o OBJS-$(CONFIG_IDCIN_DECODER) += idcinvideo.o @@ -312,8 +317,9 @@ OBJS-$(CONFIG_PNG_ENCODER) += png.o pngenc.o OBJS-$(CONFIG_PPM_DECODER) += pnmdec.o pnm.o OBJS-$(CONFIG_PPM_ENCODER) += pnmenc.o pnm.o -OBJS-$(CONFIG_PRORES_GPL_DECODER) += proresdec_gpl.o -OBJS-$(CONFIG_PRORES_LGPL_DECODER) += proresdec_lgpl.o +OBJS-$(CONFIG_PRORES_DECODER) += proresdec2.o +OBJS-$(CONFIG_PRORES_LGPL_DECODER) += proresdec_lgpl.o proresdsp.o +OBJS-$(CONFIG_PRORES_ENCODER) += proresenc.o OBJS-$(CONFIG_PTX_DECODER) += ptx.o OBJS-$(CONFIG_QCELP_DECODER) += qcelpdec.o celp_math.o \ celp_filters.o acelp_vectors.o \ @@ -342,9 +348,9 @@ OBJS-$(CONFIG_RV10_ENCODER) += rv10enc.o OBJS-$(CONFIG_RV20_DECODER) += rv10.o OBJS-$(CONFIG_RV20_ENCODER) += rv20enc.o -OBJS-$(CONFIG_RV30_DECODER) += rv30.o rv34.o rv30dsp.o \ +OBJS-$(CONFIG_RV30_DECODER) += rv30.o rv34.o rv30dsp.o rv34dsp.o \ mpegvideo.o error_resilience.o -OBJS-$(CONFIG_RV40_DECODER) += rv40.o rv34.o rv40dsp.o \ +OBJS-$(CONFIG_RV40_DECODER) += rv40.o rv34.o rv34dsp.o rv40dsp.o \ mpegvideo.o error_resilience.o OBJS-$(CONFIG_S302M_DECODER) += s302m.o OBJS-$(CONFIG_SGI_DECODER) += sgidec.o @@ -400,6 +406,7 @@ OBJS-$(CONFIG_TWINVQ_DECODER) += twinvq.o celp_math.o OBJS-$(CONFIG_TXD_DECODER) += txd.o s3tc.o OBJS-$(CONFIG_ULTI_DECODER) += ulti.o +OBJS-$(CONFIG_UTVIDEO_DECODER) += utvideo.o OBJS-$(CONFIG_V210_DECODER) += v210dec.o OBJS-$(CONFIG_V210_ENCODER) += v210enc.o OBJS-$(CONFIG_V210X_DECODER) += v210x.o @@ -426,6 +433,7 @@ OBJS-$(CONFIG_VP8_DECODER) += vp8.o vp8dsp.o vp56rac.o OBJS-$(CONFIG_VQA_DECODER) += vqavideo.o OBJS-$(CONFIG_WAVPACK_DECODER) += wavpack.o +OBJS-$(CONFIG_WMALOSSLESS_DECODER) += wmalosslessdec.o wma.o OBJS-$(CONFIG_WMAPRO_DECODER) += wmaprodec.o wma.o OBJS-$(CONFIG_WMAV1_DECODER) += wmadec.o wma.o aactab.o OBJS-$(CONFIG_WMAV1_ENCODER) += wmaenc.o wma.o aactab.o @@ -505,7 +513,6 @@ OBJS-$(CONFIG_PCM_U32LE_DECODER) += pcm.o OBJS-$(CONFIG_PCM_U32LE_ENCODER) += pcm.o OBJS-$(CONFIG_PCM_ZORK_DECODER) += pcm.o -OBJS-$(CONFIG_PCM_ZORK_ENCODER) += pcm.o OBJS-$(CONFIG_ADPCM_4XM_DECODER) += adpcm.o adpcm_data.o OBJS-$(CONFIG_ADPCM_ADX_DECODER) += adxdec.o @@ -517,8 +524,8 @@ OBJS-$(CONFIG_ADPCM_EA_R2_DECODER) += adpcm.o OBJS-$(CONFIG_ADPCM_EA_R3_DECODER) += adpcm.o OBJS-$(CONFIG_ADPCM_EA_XAS_DECODER) += adpcm.o -OBJS-$(CONFIG_ADPCM_G722_DECODER) += g722.o -OBJS-$(CONFIG_ADPCM_G722_ENCODER) += g722.o +OBJS-$(CONFIG_ADPCM_G722_DECODER) += g722.o g722dec.o +OBJS-$(CONFIG_ADPCM_G722_ENCODER) += g722.o g722enc.o OBJS-$(CONFIG_ADPCM_G726_DECODER) += g726.o OBJS-$(CONFIG_ADPCM_G726_ENCODER) += g726.o OBJS-$(CONFIG_ADPCM_IMA_AMV_DECODER) += adpcm.o adpcm_data.o @@ -605,6 +612,7 @@ OBJS-$(CONFIG_LIBSPEEX_ENCODER) += libspeexenc.o OBJS-$(CONFIG_LIBSTAGEFRIGHT_H264_DECODER)+= libstagefright.o OBJS-$(CONFIG_LIBTHEORA_ENCODER) += libtheoraenc.o +OBJS-$(CONFIG_LIBUTVIDEO_DECODER) += libutvideo.o OBJS-$(CONFIG_LIBVO_AACENC_ENCODER) += libvo-aacenc.o mpeg4audio.o OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o OBJS-$(CONFIG_LIBVORBIS_ENCODER) += libvorbis.o vorbis_data.o @@ -675,7 +683,7 @@ # thread libraries OBJS-$(HAVE_PTHREADS) += pthread.o -OBJS-$(HAVE_W32THREADS) += w32thread.o +OBJS-$(HAVE_W32THREADS) += pthread.o OBJS-$(CONFIG_MLIB) += mlib/dsputil_mlib.o \ @@ -697,8 +705,10 @@ SKIPHEADERS-$(CONFIG_LIBDIRAC) += libdirac.h SKIPHEADERS-$(CONFIG_LIBSCHROEDINGER) += libschroedinger.h SKIPHEADERS-$(CONFIG_VAAPI) += vaapi_internal.h +SKIPHEADERS-$(CONFIG_VDA) += vda_internal.h SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h SKIPHEADERS-$(CONFIG_XVMC) += xvmc.h +SKIPHEADERS-$(HAVE_W32THREADS) += w32pthreads.h TESTPROGS = cabac dct fft fft-fixed h264 iirfilter rangecoder snow TESTPROGS-$(HAVE_MMX) += motion @@ -752,5 +762,6 @@ CODEC_NAMES_SH := $(SRC_PATH)/$(SUBDIR)codec_names.sh AVCODEC_H := $(SRC_PATH)/$(SUBDIR)avcodec.h $(SUBDIR)codec_names.h: $(CODEC_NAMES_SH) config.h $(AVCODEC_H) - $(M)$(CODEC_NAMES_SH) config.h $(AVCODEC_H) $@ + $(CC) $(CPPFLAGS) $(CFLAGS) -E $(AVCODEC_H) | \ + $(CODEC_NAMES_SH) config.h $@ $(SUBDIR)utils.o: $(SUBDIR)codec_names.h diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mathops.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mathops.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mathops.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mathops.h 2011-11-04 12:38:26.000000000 +0000 @@ -116,7 +116,9 @@ #ifndef sign_extend static inline av_const int sign_extend(int val, unsigned bits) { - return (val << ((8 * sizeof(int)) - bits)) >> ((8 * sizeof(int)) - bits); + unsigned shift = 8 * sizeof(int) - bits; + union { unsigned u; int s; } v = { (unsigned) val << shift }; + return v.s >> shift; } #endif diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mjpegbdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mjpegbdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mjpegbdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mjpegbdec.c 2011-11-04 12:38:26.000000000 +0000 @@ -82,7 +82,7 @@ init_get_bits(&s->gb, buf_ptr+dqt_offs, (buf_end - (buf_ptr+dqt_offs))*8); s->start_code = DQT; if (ff_mjpeg_decode_dqt(s) < 0 && - avctx->error_recognition >= FF_ER_EXPLODE) + (avctx->err_recognition & AV_EF_EXPLODE)) return AVERROR_INVALIDDATA; } @@ -116,7 +116,7 @@ s->mjpb_skiptosod = (sod_offs - sos_offs - show_bits(&s->gb, 16)); s->start_code = SOS; if (ff_mjpeg_decode_sos(s, NULL, NULL) < 0 && - avctx->error_recognition >= FF_ER_EXPLODE) + (avctx->err_recognition & AV_EF_EXPLODE)) return AVERROR_INVALIDDATA; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mjpegdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mjpegdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mjpegdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mjpegdec.c 2011-11-04 12:38:26.000000000 +0000 @@ -326,8 +326,12 @@ if(s->rgb){ s->avctx->pix_fmt = PIX_FMT_BGRA; }else{ + if(s->component_id[0] == 'Q' && s->component_id[1] == 'F' && s->component_id[2] == 'A'){ + s->avctx->pix_fmt = PIX_FMT_GBR24P; + }else{ s->avctx->pix_fmt = s->cs_itu601 ? PIX_FMT_YUV444P : PIX_FMT_YUVJ444P; s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG; + } } assert(s->nb_components==3); break; @@ -992,6 +996,9 @@ && nb_components == 3 && s->nb_components == 3 && i) index = 3 - i; + if(nb_components == 3 && s->nb_components == 3 && s->avctx->pix_fmt == PIX_FMT_GBR24P) + index = (i+2)%3; + s->comp_index[i] = index; s->nb_blocks[i] = s->h_count[index] * s->v_count[index]; @@ -1522,7 +1529,7 @@ break; } if (ff_mjpeg_decode_sos(s, NULL, NULL) < 0 && - avctx->error_recognition >= FF_ER_EXPLODE) + (avctx->err_recognition & AV_EF_EXPLODE)) return AVERROR_INVALIDDATA; break; case DRI: @@ -1591,7 +1598,7 @@ #define OFFSET(x) offsetof(MJpegDecodeContext, x) #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { - { "extern_huff", "Use external huffman table.", OFFSET(extern_huff), FF_OPT_TYPE_INT, { 0 }, 0, 1, VD }, + { "extern_huff", "Use external huffman table.", OFFSET(extern_huff), AV_OPT_TYPE_INT, { 0 }, 0, 1, VD }, { NULL }, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mjpeg_parser.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mjpeg_parser.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mjpeg_parser.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mjpeg_parser.c 2011-11-04 12:38:26.000000000 +0000 @@ -28,27 +28,44 @@ #include "parser.h" +typedef struct MJPEGParserContext{ + ParseContext pc; + int size; +}MJPEGParserContext; /** * finds the end of the current frame in the bitstream. * @return the position of the first byte of the next frame, or -1 */ -static int find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size){ +static int find_frame_end(MJPEGParserContext *m, const uint8_t *buf, int buf_size){ + ParseContext *pc= &m->pc; int vop_found, i; - uint16_t state; + uint32_t state; vop_found= pc->frame_start_found; state= pc->state; i=0; if(!vop_found){ - for(i=0; i=0xFFC00000 && state<=0xFFFEFFFF){ + if(state>=0xFFD80000 && state<=0xFFD8FFFF){ + i++; + vop_found=1; + break; + }else if(state<0xFFD00000 || state>0xFFD9FFFF){ + m->size= (state&0xFFFF)-1; + } } + if(m->size>0){ + int size= FFMIN(buf_size-i, m->size); + i+=size; + m->size-=size; + state=0; + continue; + }else + i++; } } @@ -56,13 +73,25 @@ /* EOF considered as end of frame */ if (buf_size == 0) return 0; - for(; iframe_start_found=0; - pc->state=0; - return i-1; + if(state>=0xFFC00000 && state<=0xFFFEFFFF){ + if(state>=0xFFD80000 && state<=0xFFD8FFFF){ + pc->frame_start_found=0; + pc->state=0; + return i-3; + } else if(state<0xFFD00000 || state>0xFFD9FFFF){ + m->size= (state&0xFFFF)-1; + } } + if(m->size>0){ + int size= FFMIN(buf_size-i, m->size); + i+=size; + m->size-=size; + state=0; + continue; + }else + i++; } } pc->frame_start_found= vop_found; @@ -75,13 +104,14 @@ const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size) { - ParseContext *pc = s->priv_data; + MJPEGParserContext *m = s->priv_data; + ParseContext *pc = &m->pc; int next; if(s->flags & PARSER_FLAG_COMPLETE_FRAMES){ next= buf_size; }else{ - next= find_frame_end(pc, buf, buf_size); + next= find_frame_end(m, buf, buf_size); if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) { *poutbuf = NULL; @@ -97,9 +127,8 @@ AVCodecParser ff_mjpeg_parser = { - { CODEC_ID_MJPEG }, - sizeof(ParseContext), - NULL, - jpeg_parse, - ff_parse_close, + .codec_ids = { CODEC_ID_MJPEG }, + .priv_data_size = sizeof(MJPEGParserContext), + .parser_parse = jpeg_parse, + .parser_close = ff_parse_close, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mlpdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mlpdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mlpdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mlpdec.c 2011-11-04 12:38:26.000000000 +0000 @@ -217,7 +217,7 @@ VLC_BITS, (9 + VLC_BITS - 1) / VLC_BITS); if (result < 0) - return -1; + return AVERROR_INVALIDDATA; if (lsb_bits > 0) result = (result << lsb_bits) + get_bits(gbp, lsb_bits); @@ -253,61 +253,61 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb) { MLPHeaderInfo mh; - int substr; + int substr, ret; - if (ff_mlp_read_major_sync(m->avctx, &mh, gb) != 0) - return -1; + if ((ret = ff_mlp_read_major_sync(m->avctx, &mh, gb)) != 0) + return ret; if (mh.group1_bits == 0) { av_log(m->avctx, AV_LOG_ERROR, "invalid/unknown bits per sample\n"); - return -1; + return AVERROR_INVALIDDATA; } if (mh.group2_bits > mh.group1_bits) { av_log(m->avctx, AV_LOG_ERROR, "Channel group 2 cannot have more bits per sample than group 1.\n"); - return -1; + return AVERROR_INVALIDDATA; } if (mh.group2_samplerate && mh.group2_samplerate != mh.group1_samplerate) { av_log(m->avctx, AV_LOG_ERROR, "Channel groups with differing sample rates are not currently supported.\n"); - return -1; + return AVERROR_INVALIDDATA; } if (mh.group1_samplerate == 0) { av_log(m->avctx, AV_LOG_ERROR, "invalid/unknown sampling rate\n"); - return -1; + return AVERROR_INVALIDDATA; } if (mh.group1_samplerate > MAX_SAMPLERATE) { av_log(m->avctx, AV_LOG_ERROR, "Sampling rate %d is greater than the supported maximum (%d).\n", mh.group1_samplerate, MAX_SAMPLERATE); - return -1; + return AVERROR_INVALIDDATA; } if (mh.access_unit_size > MAX_BLOCKSIZE) { av_log(m->avctx, AV_LOG_ERROR, "Block size %d is greater than the supported maximum (%d).\n", mh.access_unit_size, MAX_BLOCKSIZE); - return -1; + return AVERROR_INVALIDDATA; } if (mh.access_unit_size_pow2 > MAX_BLOCKSIZE_POW2) { av_log(m->avctx, AV_LOG_ERROR, "Block size pow2 %d is greater than the supported maximum (%d).\n", mh.access_unit_size_pow2, MAX_BLOCKSIZE_POW2); - return -1; + return AVERROR_INVALIDDATA; } if (mh.num_substreams == 0) - return -1; + return AVERROR_INVALIDDATA; if (m->avctx->codec_id == CODEC_ID_MLP && mh.num_substreams > 2) { av_log(m->avctx, AV_LOG_ERROR, "MLP only supports up to 2 substreams.\n"); - return -1; + return AVERROR_INVALIDDATA; } if (mh.num_substreams > MAX_SUBSTREAMS) { av_log(m->avctx, AV_LOG_ERROR, "Number of substreams %d is larger than the maximum supported " "by the decoder. %s\n", mh.num_substreams, sample_message); - return -1; + return AVERROR_INVALIDDATA; } m->access_unit_size = mh.access_unit_size; @@ -374,14 +374,14 @@ if (sync_word != 0x31ea >> 1) { av_log(m->avctx, AV_LOG_ERROR, "restart header sync incorrect (got 0x%04x)\n", sync_word); - return -1; + return AVERROR_INVALIDDATA; } s->noise_type = get_bits1(gbp); if (m->avctx->codec_id == CODEC_ID_MLP && s->noise_type) { av_log(m->avctx, AV_LOG_ERROR, "MLP must have 0x31ea sync word.\n"); - return -1; + return AVERROR_INVALIDDATA; } skip_bits(gbp, 16); /* Output timestamp */ @@ -394,13 +394,13 @@ av_log(m->avctx, AV_LOG_ERROR, "Max matrix channel cannot be greater than %d.\n", max_matrix_channel); - return -1; + return AVERROR_INVALIDDATA; } if (s->max_channel != s->max_matrix_channel) { av_log(m->avctx, AV_LOG_ERROR, "Max channel must be equal max matrix channel.\n"); - return -1; + return AVERROR_INVALIDDATA; } /* This should happen for TrueHD streams with >6 channels and MLP's noise @@ -409,13 +409,13 @@ av_log(m->avctx, AV_LOG_ERROR, "Number of channels %d is larger than the maximum supported " "by the decoder. %s\n", s->max_channel+2, sample_message); - return -1; + return AVERROR_INVALIDDATA; } if (s->min_channel > s->max_channel) { av_log(m->avctx, AV_LOG_ERROR, "Substream min channel cannot be greater than max channel.\n"); - return -1; + return AVERROR_INVALIDDATA; } if (m->avctx->request_channels > 0 @@ -454,7 +454,7 @@ av_log(m->avctx, AV_LOG_ERROR, "Assignment of matrix channel %d to invalid output channel %d. %s\n", ch, ch_assign, sample_message); - return -1; + return AVERROR_INVALIDDATA; } s->ch_assign[ch_assign] = ch; } @@ -528,7 +528,7 @@ if (m->filter_changed[channel][filter]++ > 1) { av_log(m->avctx, AV_LOG_ERROR, "Filters may change only once per access unit.\n"); - return -1; + return AVERROR_INVALIDDATA; } order = get_bits(gbp, 4); @@ -536,7 +536,7 @@ av_log(m->avctx, AV_LOG_ERROR, "%cIR filter order %d is greater than maximum %d.\n", fchar, order, max_order); - return -1; + return AVERROR_INVALIDDATA; } fp->order = order; @@ -552,13 +552,13 @@ av_log(m->avctx, AV_LOG_ERROR, "%cIR filter coeff_bits must be between 1 and 16.\n", fchar); - return -1; + return AVERROR_INVALIDDATA; } if (coeff_bits + coeff_shift > 16) { av_log(m->avctx, AV_LOG_ERROR, "Sum of coeff_bits and coeff_shift for %cIR filter must be 16 or less.\n", fchar); - return -1; + return AVERROR_INVALIDDATA; } for (i = 0; i < order; i++) @@ -570,7 +570,7 @@ if (filter == FIR) { av_log(m->avctx, AV_LOG_ERROR, "FIR filter has state data specified.\n"); - return -1; + return AVERROR_INVALIDDATA; } state_bits = get_bits(gbp, 4); @@ -598,7 +598,7 @@ if (m->matrix_changed++ > 1) { av_log(m->avctx, AV_LOG_ERROR, "Matrices may change only once per access unit.\n"); - return -1; + return AVERROR_INVALIDDATA; } s->num_primitive_matrices = get_bits(gbp, 4); @@ -607,7 +607,7 @@ av_log(m->avctx, AV_LOG_ERROR, "Number of primitive matrices cannot be greater than %d.\n", max_primitive_matrices); - return -1; + return AVERROR_INVALIDDATA; } for (mat = 0; mat < s->num_primitive_matrices; mat++) { @@ -620,12 +620,12 @@ av_log(m->avctx, AV_LOG_ERROR, "Invalid channel %d specified as output from matrix.\n", s->matrix_out_ch[mat]); - return -1; + return AVERROR_INVALIDDATA; } if (frac_bits > 14) { av_log(m->avctx, AV_LOG_ERROR, "Too many fractional bits specified.\n"); - return -1; + return AVERROR_INVALIDDATA; } max_chan = s->max_matrix_channel; @@ -658,27 +658,28 @@ ChannelParams *cp = &s->channel_params[ch]; FilterParams *fir = &cp->filter_params[FIR]; FilterParams *iir = &cp->filter_params[IIR]; + int ret; if (s->param_presence_flags & PARAM_FIR) if (get_bits1(gbp)) - if (read_filter_params(m, gbp, substr, ch, FIR) < 0) - return -1; + if ((ret = read_filter_params(m, gbp, substr, ch, FIR)) < 0) + return ret; if (s->param_presence_flags & PARAM_IIR) if (get_bits1(gbp)) - if (read_filter_params(m, gbp, substr, ch, IIR) < 0) - return -1; + if ((ret = read_filter_params(m, gbp, substr, ch, IIR)) < 0) + return ret; if (fir->order + iir->order > 8) { av_log(m->avctx, AV_LOG_ERROR, "Total filter orders too high.\n"); - return -1; + return AVERROR_INVALIDDATA; } if (fir->order && iir->order && fir->shift != iir->shift) { av_log(m->avctx, AV_LOG_ERROR, "FIR and IIR filters must use the same precision.\n"); - return -1; + return AVERROR_INVALIDDATA; } /* The FIR and IIR filters must have the same precision. * To simplify the filtering code, only the precision of the @@ -697,7 +698,7 @@ if (cp->huff_lsbs > 24) { av_log(m->avctx, AV_LOG_ERROR, "Invalid huff_lsbs.\n"); - return -1; + return AVERROR_INVALIDDATA; } cp->sign_huff_offset = calculate_sign_huff(m, substr, ch); @@ -713,6 +714,7 @@ { SubStream *s = &m->substream[substr]; unsigned int ch; + int ret; if (s->param_presence_flags & PARAM_PRESENCE) if (get_bits1(gbp)) @@ -724,14 +726,14 @@ if (s->blocksize < 8 || s->blocksize > m->access_unit_size) { av_log(m->avctx, AV_LOG_ERROR, "Invalid blocksize."); s->blocksize = 0; - return -1; + return AVERROR_INVALIDDATA; } } if (s->param_presence_flags & PARAM_MATRIX) if (get_bits1(gbp)) - if (read_matrix_params(m, substr, gbp) < 0) - return -1; + if ((ret = read_matrix_params(m, substr, gbp)) < 0) + return ret; if (s->param_presence_flags & PARAM_OUTSHIFT) if (get_bits1(gbp)) @@ -750,8 +752,8 @@ for (ch = s->min_channel; ch <= s->max_channel; ch++) if (get_bits1(gbp)) - if (read_channel_params(m, substr, gbp, ch) < 0) - return -1; + if ((ret = read_channel_params(m, substr, gbp, ch)) < 0) + return ret; return 0; } @@ -793,6 +795,7 @@ { SubStream *s = &m->substream[substr]; unsigned int i, ch, expected_stream_pos = 0; + int ret; if (s->data_check_present) { expected_stream_pos = get_bits_count(gbp); @@ -803,15 +806,15 @@ if (s->blockpos + s->blocksize > m->access_unit_size) { av_log(m->avctx, AV_LOG_ERROR, "too many audio samples in frame\n"); - return -1; + return AVERROR_INVALIDDATA; } memset(&m->bypassed_lsbs[s->blockpos][0], 0, s->blocksize * sizeof(m->bypassed_lsbs[0])); for (i = 0; i < s->blocksize; i++) - if (read_huff_channels(m, gbp, substr, i) < 0) - return -1; + if ((ret = read_huff_channels(m, gbp, substr, i)) < 0) + return ret; for (ch = s->min_channel; ch <= s->max_channel; ch++) filter_channel(m, substr, ch); @@ -942,16 +945,26 @@ /** Write the audio data into the output buffer. */ -static int output_data_internal(MLPDecodeContext *m, unsigned int substr, - uint8_t *data, unsigned int *data_size, int is32) +static int output_data(MLPDecodeContext *m, unsigned int substr, + uint8_t *data, unsigned int *data_size) { SubStream *s = &m->substream[substr]; unsigned int i, out_ch = 0; + int out_size; int32_t *data_32 = (int32_t*) data; int16_t *data_16 = (int16_t*) data; + int is32 = (m->avctx->sample_fmt == AV_SAMPLE_FMT_S32); - if (*data_size < (s->max_channel + 1) * s->blockpos * (is32 ? 4 : 2)) - return -1; + if (m->avctx->channels != s->max_matrix_channel + 1) { + av_log(m->avctx, AV_LOG_ERROR, "channel count mismatch\n"); + return AVERROR_INVALIDDATA; + } + + out_size = s->blockpos * m->avctx->channels * + av_get_bytes_per_sample(m->avctx->sample_fmt); + + if (*data_size < out_size) + return AVERROR(EINVAL); for (i = 0; i < s->blockpos; i++) { for (out_ch = 0; out_ch <= s->max_matrix_channel; out_ch++) { @@ -964,21 +977,11 @@ } } - *data_size = i * out_ch * (is32 ? 4 : 2); + *data_size = out_size; return 0; } -static int output_data(MLPDecodeContext *m, unsigned int substr, - uint8_t *data, unsigned int *data_size) -{ - if (m->avctx->sample_fmt == AV_SAMPLE_FMT_S32) - return output_data_internal(m, substr, data, data_size, 1); - else - return output_data_internal(m, substr, data, data_size, 0); -} - - /** Read an access unit from the stream. * @return negative on error, 0 if not enough data is present in the input stream, * otherwise the number of bytes consumed. */ @@ -997,6 +1000,7 @@ uint8_t substream_parity_present[MAX_SUBSTREAMS]; uint16_t substream_data_len[MAX_SUBSTREAMS]; uint8_t parity_bits; + int ret; if (buf_size < 4) return 0; @@ -1004,7 +1008,7 @@ length = (AV_RB16(buf) & 0xfff) * 2; if (length < 4 || length > buf_size) - return -1; + return AVERROR_INVALIDDATA; init_get_bits(&gb, (buf + 4), (length - 4) * 8); @@ -1110,8 +1114,8 @@ if (!s->restart_seen) goto next_substr; - if (read_block_data(m, &gb, substr) < 0) - return -1; + if ((ret = read_block_data(m, &gb, substr)) < 0) + return ret; if (get_bits_count(&gb) >= substream_data_len[substr] * 8) goto substream_length_mismatch; @@ -1124,13 +1128,13 @@ int shorten_by; if (get_bits(&gb, 16) != 0xD234) - return -1; + return AVERROR_INVALIDDATA; shorten_by = get_bits(&gb, 16); if (m->avctx->codec_id == CODEC_ID_TRUEHD && shorten_by & 0x2000) s->blockpos -= FFMIN(shorten_by & 0x1FFF, s->blockpos); else if (m->avctx->codec_id == CODEC_ID_MLP && shorten_by != 0xD234) - return -1; + return AVERROR_INVALIDDATA; if (substr == m->max_decoded_substream) av_log(m->avctx, AV_LOG_INFO, "End of stream indicated.\n"); @@ -1164,18 +1168,18 @@ rematrix_channels(m, m->max_decoded_substream); - if (output_data(m, m->max_decoded_substream, data, data_size) < 0) - return -1; + if ((ret = output_data(m, m->max_decoded_substream, data, data_size)) < 0) + return ret; return length; substream_length_mismatch: av_log(m->avctx, AV_LOG_ERROR, "substream %d length mismatch\n", substr); - return -1; + return AVERROR_INVALIDDATA; error: m->params_valid = 0; - return -1; + return AVERROR_INVALIDDATA; } AVCodec ff_mlp_decoder = { diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mlp_parser.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mlp_parser.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mlp_parser.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mlp_parser.c 2011-11-04 12:38:26.000000000 +0000 @@ -138,11 +138,11 @@ checksum = ff_mlp_checksum16(gb->buffer, 26); if (checksum != AV_RL16(gb->buffer+26)) { av_log(log, AV_LOG_ERROR, "major sync info header checksum error\n"); - return -1; + return AVERROR_INVALIDDATA; } if (get_bits_long(gb, 24) != 0xf8726f) /* Sync words */ - return -1; + return AVERROR_INVALIDDATA; mh->stream_type = get_bits(gb, 8); @@ -173,7 +173,7 @@ mh->channels_thd_stream2 = get_bits(gb, 13); } else - return -1; + return AVERROR_INVALIDDATA; mh->access_unit_size = 40 << (ratebits & 7); mh->access_unit_size_pow2 = 64 << (ratebits & 7); @@ -345,9 +345,9 @@ } AVCodecParser ff_mlp_parser = { - { CODEC_ID_MLP, CODEC_ID_TRUEHD }, - sizeof(MLPParseContext), - mlp_init, - mlp_parse, - ff_parse_close, + .codec_ids = { CODEC_ID_MLP, CODEC_ID_TRUEHD }, + .priv_data_size = sizeof(MLPParseContext), + .parser_init = mlp_init, + .parser_parse = mlp_parse, + .parser_close = ff_parse_close, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/motion_est.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/motion_est.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/motion_est.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/motion_est.c 2011-11-04 12:38:26.000000000 +0000 @@ -52,7 +52,7 @@ int src_index, int ref_index, int size, int h); -static inline int update_map_generation(MotionEstContext *c) +static inline unsigned update_map_generation(MotionEstContext *c) { c->map_generation+= 1<<(ME_MAP_MV_BITS*2); if(c->map_generation==0){ @@ -1016,7 +1016,7 @@ /* intra / predictive decision */ pix = c->src[0][0]; sum = s->dsp.pix_sum(pix, s->linesize); - varc = s->dsp.pix_norm1(pix, s->linesize) - (((unsigned)(sum*sum))>>8) + 500; + varc = s->dsp.pix_norm1(pix, s->linesize) - (((unsigned)sum*sum)>>8) + 500; pic->mb_mean[s->mb_stride * mb_y + mb_x] = (sum+128)>>8; pic->mb_var [s->mb_stride * mb_y + mb_x] = (varc+128)>>8; @@ -1178,7 +1178,7 @@ if((c->avctx->mb_cmp&0xFF)==FF_CMP_SSE){ intra_score= varc - 500; }else{ - int mean= (sum+128)>>8; + unsigned mean = (sum+128)>>8; mean*= 0x01010101; for(i=0; i<16; i++){ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/motion_est_template.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/motion_est_template.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/motion_est_template.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/motion_est_template.c 2011-11-04 12:38:26.000000000 +0000 @@ -90,8 +90,8 @@ + (mv_penalty[bx - pred_x] + mv_penalty[by+2 - pred_y])*c->penalty_factor; #if 1 - int key; - int map_generation= c->map_generation; + unsigned key; + unsigned map_generation= c->map_generation; #ifndef NDEBUG uint32_t *map= c->map; #endif @@ -210,7 +210,7 @@ const int mx = *mx_ptr; const int my = *my_ptr; const int penalty_factor= c->sub_penalty_factor; - const int map_generation= c->map_generation; + const unsigned map_generation = c->map_generation; const int subpel_quality= c->avctx->me_subpel_quality; uint32_t *map= c->map; me_cmp_func cmpf, chroma_cmpf; @@ -356,7 +356,7 @@ #define CHECK_MV(x,y)\ {\ - const int key= ((y)<= xmin);\ assert((x) <= xmax);\ @@ -384,7 +384,7 @@ #define CHECK_MV_DIR(x,y,new_dir)\ {\ - const int key= ((y)<map_generation; + unsigned map_generation = c->map_generation; cmpf= s->dsp.me_cmp[size]; chroma_cmpf= s->dsp.me_cmp[size+1]; { /* ensure that the best point is in the MAP as h/qpel refinement needs it */ - const int key= (best[1]<map_generation; + unsigned map_generation = c->map_generation; cmpf= s->dsp.me_cmp[size]; chroma_cmpf= s->dsp.me_cmp[size+1]; @@ -505,7 +505,7 @@ me_cmp_func cmpf, chroma_cmpf; LOAD_COMMON LOAD_COMMON2 - int map_generation= c->map_generation; + unsigned map_generation = c->map_generation; int x,y,d; const int dec= dia_size & (dia_size-1); @@ -539,7 +539,7 @@ me_cmp_func cmpf, chroma_cmpf; LOAD_COMMON LOAD_COMMON2 - int map_generation= c->map_generation; + unsigned map_generation = c->map_generation; int x,y,i,d; int dia_size= c->dia_size&0xFF; const int dec= dia_size & (dia_size-1); @@ -577,7 +577,7 @@ me_cmp_func cmpf, chroma_cmpf; LOAD_COMMON LOAD_COMMON2 - int map_generation= c->map_generation; + unsigned map_generation = c->map_generation; int x,y,x2,y2, i, j, d; const int dia_size= c->dia_size&0xFE; static const int hex[16][2]={{-4,-2}, {-4,-1}, {-4, 0}, {-4, 1}, {-4, 2}, @@ -624,7 +624,7 @@ me_cmp_func cmpf, chroma_cmpf; LOAD_COMMON LOAD_COMMON2 - int map_generation= c->map_generation; + unsigned map_generation = c->map_generation; int x,y, d; const int dia_size= c->dia_size&0xFF; @@ -653,7 +653,7 @@ #define SAB_CHECK_MV(ax,ay)\ {\ - const int key= ((ay)<map_generation; + unsigned map_generation = c->map_generation; cmpf= s->dsp.me_cmp[size]; chroma_cmpf= s->dsp.me_cmp[size+1]; @@ -777,7 +777,7 @@ int dia_size; LOAD_COMMON LOAD_COMMON2 - int map_generation= c->map_generation; + unsigned map_generation = c->map_generation; cmpf= s->dsp.me_cmp[size]; chroma_cmpf= s->dsp.me_cmp[size+1]; @@ -869,7 +869,7 @@ int d; ///< the score (cmp + penalty) of any given mv int dmin; /**< the best value of d, i.e. the score corresponding to the mv stored in best[]. */ - int map_generation; + unsigned map_generation; int penalty_factor; const int ref_mv_stride= s->mb_stride; //pass as arg FIXME const int ref_mv_xy= s->mb_x + s->mb_y*ref_mv_stride; //add to last_mv beforepassing FIXME @@ -997,7 +997,7 @@ MotionEstContext * const c= &s->me; int best[2]={0, 0}; int d, dmin; - int map_generation; + unsigned map_generation; const int penalty_factor= c->penalty_factor; const int size=1; const int h=8; @@ -1057,7 +1057,7 @@ MotionEstContext * const c= &s->me; int best[2]={0, 0}; int d, dmin; - int map_generation; + unsigned map_generation; const int penalty_factor= c->penalty_factor; const int size=0; //FIXME pass as arg const int h=8; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mp3_header_decompress_bsf.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mp3_header_decompress_bsf.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mp3_header_decompress_bsf.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mp3_header_decompress_bsf.c 2011-11-04 12:38:26.000000000 +0000 @@ -50,10 +50,10 @@ lsf = sample_rate < (24000+32000)/2; mpeg25 = sample_rate < (12000+16000)/2; sample_rate_index= (header>>10)&3; - sample_rate= ff_mpa_freq_tab[sample_rate_index] >> (lsf + mpeg25); //in case sample rate is a little off + sample_rate= avpriv_mpa_freq_tab[sample_rate_index] >> (lsf + mpeg25); //in case sample rate is a little off for(bitrate_index=2; bitrate_index<30; bitrate_index++){ - frame_size = ff_mpa_bitrate_tab[lsf][2][bitrate_index>>1]; + frame_size = avpriv_mpa_bitrate_tab[lsf][2][bitrate_index>>1]; frame_size = (frame_size * 144000) / (sample_rate << lsf) + (bitrate_index&1); if(frame_size == buf_size + 4) break; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpeg12.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpeg12.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpeg12.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpeg12.c 2011-11-04 12:38:26.000000000 +0000 @@ -55,7 +55,7 @@ /* as H.263, but only 17 codes */ static int mpeg_decode_motion(MpegEncContext *s, int fcode, int pred) { - int code, sign, val, l, shift; + int code, sign, val, shift; code = get_vlc2(&s->gb, mv_vlc.table, MV_VLC_BITS, 2); if (code == 0) { @@ -78,9 +78,7 @@ val += pred; /* modulo decoding */ - l = INT_BIT - 5 - shift; - val = (val << l) >> l; - return val; + return sign_extend(val, 5 + shift); } static inline int mpeg1_decode_block_intra(MpegEncContext *s, DCTELEM *block, int n) @@ -938,10 +936,6 @@ } break; case MT_FIELD: - if(s->progressive_sequence){ - av_log(s->avctx, AV_LOG_ERROR, "MT_FIELD in progressive_sequence\n"); - return -1; - } s->mv_type = MV_TYPE_FIELD; if (s->picture_structure == PICT_FRAME) { mb_type |= MB_TYPE_16x8 | MB_TYPE_INTERLACED; @@ -963,6 +957,7 @@ } } } else { + av_assert0(!s->progressive_sequence); mb_type |= MB_TYPE_16x16 | MB_TYPE_INTERLACED; for (i = 0; i < 2; i++) { if (USES_LIST(mb_type, i)) { @@ -1117,20 +1112,6 @@ return 0; } -typedef struct Mpeg1Context { - MpegEncContext mpeg_enc_ctx; - int mpeg_enc_ctx_allocated; /* true if decoding context allocated */ - int repeat_field; /* true if we must repeat the field */ - AVPanScan pan_scan; /**< some temporary storage for the panscan */ - int slice_count; - int swap_uv;//indicate VCR2 - int save_aspect_info; - int save_width, save_height, save_progressive_seq; - AVRational frame_rate_ext; ///< MPEG-2 specific framerate modificator - int sync; ///< Did we reach a sync point like a GOP/SEQ/KEYFrame? - int tmpgexs; -} Mpeg1Context; - static av_cold int mpeg_decode_init(AVCodecContext *avctx) { Mpeg1Context *s = avctx->priv_data; @@ -1295,8 +1276,8 @@ assert((avctx->sub_id == 1) == (avctx->codec_id == CODEC_ID_MPEG1VIDEO)); if (avctx->codec_id == CODEC_ID_MPEG1VIDEO) { //MPEG-1 fps - avctx->time_base.den = ff_frame_rate_tab[s->frame_rate_index].num; - avctx->time_base.num = ff_frame_rate_tab[s->frame_rate_index].den; + avctx->time_base.den = avpriv_frame_rate_tab[s->frame_rate_index].num; + avctx->time_base.num = avpriv_frame_rate_tab[s->frame_rate_index].den; //MPEG-1 aspect avctx->sample_aspect_ratio = av_d2q(1.0/ff_mpeg1_aspect[s->aspect_ratio_info], 255); avctx->ticks_per_frame=1; @@ -1304,8 +1285,8 @@ //MPEG-2 fps av_reduce(&s->avctx->time_base.den, &s->avctx->time_base.num, - ff_frame_rate_tab[s->frame_rate_index].num * s1->frame_rate_ext.num*2, - ff_frame_rate_tab[s->frame_rate_index].den * s1->frame_rate_ext.den, + avpriv_frame_rate_tab[s->frame_rate_index].num * s1->frame_rate_ext.num*2, + avpriv_frame_rate_tab[s->frame_rate_index].den * s1->frame_rate_ext.den, 1 << 30); avctx->ticks_per_frame = 2; //MPEG-2 aspect @@ -1383,7 +1364,7 @@ if (s->pict_type == AV_PICTURE_TYPE_P || s->pict_type == AV_PICTURE_TYPE_B) { s->full_pel[0] = get_bits1(&s->gb); f_code = get_bits(&s->gb, 3); - if (f_code == 0 && avctx->error_recognition >= FF_ER_COMPLIANT) + if (f_code == 0 && (avctx->err_recognition & AV_EF_BITSTREAM)) return -1; s->mpeg_f_code[0][0] = f_code; s->mpeg_f_code[0][1] = f_code; @@ -1391,7 +1372,7 @@ if (s->pict_type == AV_PICTURE_TYPE_B) { s->full_pel[1] = get_bits1(&s->gb); f_code = get_bits(&s->gb, 3); - if (f_code == 0 && avctx->error_recognition >= FF_ER_COMPLIANT) + if (f_code == 0 && (avctx->err_recognition & AV_EF_BITSTREAM)) return -1; s->mpeg_f_code[1][0] = f_code; s->mpeg_f_code[1][1] = f_code; @@ -1636,7 +1617,7 @@ *s->current_picture_ptr->f.pan_scan = s1->pan_scan; - if (HAVE_PTHREADS && (avctx->active_thread_type & FF_THREAD_FRAME)) + if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_FRAME)) ff_thread_finish_setup(avctx); } else { // second field int i; @@ -1676,10 +1657,9 @@ * @return DECODE_SLICE_ERROR if the slice is damaged
* DECODE_SLICE_OK if this slice is ok
*/ -static int mpeg_decode_slice(Mpeg1Context *s1, int mb_y, +static int mpeg_decode_slice(MpegEncContext *s, int mb_y, const uint8_t **buf, int buf_size) { - MpegEncContext *s = &s1->mpeg_enc_ctx; AVCodecContext *avctx = s->avctx; const int lowres = s->avctx->lowres; const int field_pic = s->picture_structure != PICT_FRAME; @@ -1737,7 +1717,7 @@ if (avctx->hwaccel) { const uint8_t *buf_end, *buf_start = *buf - 4; /* include start_code */ int start_code = -1; - buf_end = ff_find_start_code(buf_start + 2, *buf + buf_size, &start_code); + buf_end = avpriv_mpv_find_start_code(buf_start + 2, *buf + buf_size, &start_code); if (buf_end < *buf + buf_size) buf_end -= 4; s->mb_y = mb_y; @@ -1824,7 +1804,7 @@ && s->progressive_frame == 0 /* vbv_delay == 0xBBB || 0xE10*/; if (left < 0 || (left && show_bits(&s->gb, FFMIN(left, 23)) && !is_d10) - || (avctx->error_recognition >= FF_ER_AGGRESSIVE && left > 8)) { + || ((avctx->err_recognition & AV_EF_BUFFER) && left > 8)) { av_log(avctx, AV_LOG_ERROR, "end mismatch left=%d %0X\n", left, show_bits(&s->gb, FFMIN(left, 23))); return -1; } else @@ -1911,12 +1891,12 @@ uint32_t start_code; int ret; - ret = mpeg_decode_slice((Mpeg1Context*)s, mb_y, &buf, s->gb.buffer_end - buf); + ret = mpeg_decode_slice(s, mb_y, &buf, s->gb.buffer_end - buf); emms_c(); //av_log(c, AV_LOG_DEBUG, "ret:%d resync:%d/%d mb:%d/%d ts:%d/%d ec:%d\n", //ret, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, s->start_mb_y, s->end_mb_y, s->error_count); if (ret < 0) { - if (c->error_recognition >= FF_ER_EXPLODE) + if (c->err_recognition & AV_EF_EXPLODE) return ret; if (s->resync_mb_x >= 0 && s->resync_mb_y >= 0) ff_er_add_slice(s, s->resync_mb_x, s->resync_mb_y, s->mb_x, s->mb_y, AC_ERROR | DC_ERROR | MV_ERROR); @@ -1928,7 +1908,7 @@ return 0; start_code = -1; - buf = ff_find_start_code(buf, s->gb.buffer_end, &start_code); + buf = avpriv_mpv_find_start_code(buf, s->gb.buffer_end, &start_code); mb_y= (start_code - SLICE_MIN_START_CODE) << field_pic; if (s->picture_structure == PICT_BOTTOM_FIELD) mb_y++; @@ -2004,7 +1984,7 @@ s->aspect_ratio_info = get_bits(&s->gb, 4); if (s->aspect_ratio_info == 0) { av_log(avctx, AV_LOG_ERROR, "aspect ratio has forbidden 0 value\n"); - if (avctx->error_recognition >= FF_ER_COMPLIANT) + if (avctx->err_recognition & AV_EF_BITSTREAM) return -1; } s->frame_rate_index = get_bits(&s->gb, 4); @@ -2162,14 +2142,14 @@ Mpeg1Context *s1 = avctx->priv_data; MpegEncContext *s = &s1->mpeg_enc_ctx; + int drop_frame_flag; int time_code_hours, time_code_minutes; int time_code_seconds, time_code_pictures; int broken_link; init_get_bits(&s->gb, buf, buf_size*8); - skip_bits1(&s->gb); /* drop_frame_flag */ - + drop_frame_flag = get_bits(&s->gb, 1); time_code_hours = get_bits(&s->gb, 5); time_code_minutes = get_bits(&s->gb, 6); skip_bits1(&s->gb); // marker bit @@ -2183,8 +2163,9 @@ broken_link = get_bits1(&s->gb); if (s->avctx->debug & FF_DEBUG_PICT_INFO) - av_log(s->avctx, AV_LOG_DEBUG, "GOP (%2d:%02d:%02d.[%02d]) closed_gop=%d broken_link=%d\n", + av_log(s->avctx, AV_LOG_DEBUG, "GOP (%02d:%02d:%02d%c%02d) closed_gop=%d broken_link=%d\n", time_code_hours, time_code_minutes, time_code_seconds, + drop_frame_flag ? ';' : ':', time_code_pictures, s->closed_gop, broken_link); } /** @@ -2221,7 +2202,7 @@ } state++; } else { - i = ff_find_start_code(buf + i, buf + buf_size, &state) - buf - 1; + i = avpriv_mpv_find_start_code(buf + i, buf + buf_size, &state) - buf - 1; if (pc->frame_start_found == 0 && state >= SLICE_MIN_START_CODE && state <= SLICE_MAX_START_CODE) { i++; pc->frame_start_found = 4; @@ -2291,7 +2272,7 @@ if (avctx->extradata && !avctx->frame_number) { int ret = decode_chunks(avctx, picture, data_size, avctx->extradata, avctx->extradata_size); - if (ret < 0 && avctx->error_recognition >= FF_ER_EXPLODE) + if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE)) return ret; } @@ -2312,7 +2293,7 @@ for (;;) { /* find next start code */ uint32_t start_code = -1; - buf_ptr = ff_find_start_code(buf_ptr, buf_end, &start_code); + buf_ptr = avpriv_mpv_find_start_code(buf_ptr, buf_end, &start_code); if (start_code > 0x1ff) { if (s2->pict_type != AV_PICTURE_TYPE_B || avctx->skip_frame <= AVDISCARD_DEFAULT) { if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_SLICE)) { @@ -2327,6 +2308,7 @@ if (CONFIG_VDPAU && uses_vdpau(avctx)) ff_vdpau_mpeg_picture_complete(s2, buf, buf_size, s->slice_count); + if (slice_end(avctx, picture)) { if (s2->last_picture_ptr || s2->low_delay) //FIXME merge with the stuff in mpeg_decode_slice *data_size = sizeof(AVPicture); @@ -2347,10 +2329,11 @@ case SEQ_START_CODE: if (last_code == 0) { mpeg1_decode_sequence(avctx, buf_ptr, input_size); - s->sync=1; + if(buf != avctx->extradata) + s->sync=1; } else { av_log(avctx, AV_LOG_ERROR, "ignoring SEQ_START_CODE after %X\n", last_code); - if (avctx->error_recognition >= FF_ER_EXPLODE) + if (avctx->err_recognition & AV_EF_EXPLODE) return AVERROR_INVALIDDATA; } break; @@ -2384,7 +2367,7 @@ last_code = PICTURE_START_CODE; } else { av_log(avctx, AV_LOG_ERROR, "ignoring pic after %X\n", last_code); - if (avctx->error_recognition >= FF_ER_EXPLODE) + if (avctx->err_recognition & AV_EF_EXPLODE) return AVERROR_INVALIDDATA; } break; @@ -2397,7 +2380,7 @@ mpeg_decode_sequence_extension(s); } else { av_log(avctx, AV_LOG_ERROR, "ignoring seq ext after %X\n", last_code); - if (avctx->error_recognition >= FF_ER_EXPLODE) + if (avctx->err_recognition & AV_EF_EXPLODE) return AVERROR_INVALIDDATA; } break; @@ -2415,7 +2398,7 @@ mpeg_decode_picture_coding_extension(s); } else { av_log(avctx, AV_LOG_ERROR, "ignoring pic cod ext after %X\n", last_code); - if (avctx->error_recognition >= FF_ER_EXPLODE) + if (avctx->err_recognition & AV_EF_EXPLODE) return AVERROR_INVALIDDATA; } break; @@ -2431,7 +2414,7 @@ s->sync=1; } else { av_log(avctx, AV_LOG_ERROR, "ignoring GOP_START_CODE after %X\n", last_code); - if (avctx->error_recognition >= FF_ER_EXPLODE) + if (avctx->err_recognition & AV_EF_EXPLODE) return AVERROR_INVALIDDATA; } break; @@ -2478,7 +2461,7 @@ if (!s2->pict_type) { av_log(avctx, AV_LOG_ERROR, "Missing picture start code\n"); - if (avctx->error_recognition >= FF_ER_EXPLODE) + if (avctx->err_recognition & AV_EF_EXPLODE) return AVERROR_INVALIDDATA; break; } @@ -2515,11 +2498,11 @@ } buf_ptr += 2; // FIXME add minimum number of bytes per slice } else { - ret = mpeg_decode_slice(s, mb_y, &buf_ptr, input_size); + ret = mpeg_decode_slice(s2, mb_y, &buf_ptr, input_size); emms_c(); if (ret < 0) { - if (avctx->error_recognition >= FF_ER_EXPLODE) + if (avctx->err_recognition & AV_EF_EXPLODE) return ret; if (s2->resync_mb_x >= 0 && s2->resync_mb_y >= 0) ff_er_add_slice(s2, s2->resync_mb_x, s2->resync_mb_y, s2->mb_x, s2->mb_y, AC_ERROR | DC_ERROR | MV_ERROR); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpeg12data.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpeg12data.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpeg12data.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpeg12data.c 2011-11-04 12:38:26.000000000 +0000 @@ -305,7 +305,7 @@ { 0xc, 10 }, }; -const AVRational ff_frame_rate_tab[] = { +const AVRational avpriv_frame_rate_tab[] = { { 0, 0}, {24000, 1001}, { 24, 1}, diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpeg12data.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpeg12data.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpeg12data.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpeg12data.h 2011-11-04 12:38:26.000000000 +0000 @@ -48,7 +48,7 @@ extern const uint8_t ff_mpeg12_mbMotionVectorTable[17][2]; -extern const AVRational ff_frame_rate_tab[]; +extern const AVRational avpriv_frame_rate_tab[]; extern const float ff_mpeg1_aspect[16]; extern const AVRational ff_mpeg2_aspect[16]; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpeg12enc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpeg12enc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpeg12enc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpeg12enc.c 2011-11-04 12:38:26.000000000 +0000 @@ -27,6 +27,7 @@ #include "avcodec.h" #include "dsputil.h" +#include "mathops.h" #include "mpegvideo.h" #include "mpeg12.h" @@ -120,7 +121,7 @@ int64_t d; for(i=1;i<14;i++) { - int64_t n0= 1001LL/ff_frame_rate_tab[i].den*ff_frame_rate_tab[i].num*s->avctx->time_base.num; + int64_t n0= 1001LL/avpriv_frame_rate_tab[i].den*avpriv_frame_rate_tab[i].num*s->avctx->time_base.num; int64_t n1= 1001LL*s->avctx->time_base.den; if(s->avctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL && i>=9) break; @@ -189,7 +190,7 @@ } if (s->tc.str) { - s->tc.rate = ff_frame_rate_tab[s->frame_rate_index]; + s->tc.rate = avpriv_frame_rate_tab[s->frame_rate_index]; if (ff_init_smtpe_timecode(s, &s->tc) < 0) return -1; s->avctx->timecode_frame_start = s->tc.start; @@ -199,7 +200,7 @@ static void put_header(MpegEncContext *s, int header) { - align_put_bits(&s->pb); + avpriv_align_put_bits(&s->pb); put_bits(&s->pb, 16, header>>16); put_sbits(&s->pb, 16, header); } @@ -218,7 +219,7 @@ if(aspect_ratio==0.0) aspect_ratio= 1.0; //pixel aspect 1:1 (VGA) if (s->current_picture.f.key_frame) { - AVRational framerate= ff_frame_rate_tab[s->frame_rate_index]; + AVRational framerate= avpriv_frame_rate_tab[s->frame_rate_index]; /* mpeg1 header repeated every gop */ put_header(s, SEQ_START_CODE); @@ -694,8 +695,7 @@ int bit_size = f_or_b_code - 1; int range = 1 << bit_size; /* modulo encoding */ - int l= INT_BIT - 5 - bit_size; - val= (val<>l; + val = sign_extend(val, 5 + bit_size); if (val >= 0) { val--; @@ -943,9 +943,9 @@ #define COMMON_OPTS\ {TIMECODE_OPT(MpegEncContext,\ AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)},\ - { "intra_vlc", "Use MPEG-2 intra VLC table.", OFFSET(intra_vlc_format), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE },\ - { "drop_frame_timecode", "Timecode is in drop frame format.", OFFSET(drop_frame_timecode), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE}, \ - { "scan_offset", "Reserve space for SVCD scan offset user data.", OFFSET(scan_offset), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE }, + { "intra_vlc", "Use MPEG-2 intra VLC table.", OFFSET(intra_vlc_format), AV_OPT_TYPE_INT, { 0 }, 0, 1, VE },\ + { "drop_frame_timecode", "Timecode is in drop frame format.", OFFSET(drop_frame_timecode), AV_OPT_TYPE_INT, { 0 }, 0, 1, VE}, \ + { "scan_offset", "Reserve space for SVCD scan offset user data.", OFFSET(scan_offset), AV_OPT_TYPE_INT, { 0 }, 0, 1, VE }, static const AVOption mpeg1_options[] = { COMMON_OPTS @@ -954,8 +954,8 @@ static const AVOption mpeg2_options[] = { COMMON_OPTS - { "non_linear_quant", "Use nonlinear quantizer.", OFFSET(q_scale_type), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE }, - { "alternate_scan", "Enable alternate scantable.", OFFSET(alternate_scan), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE }, + { "non_linear_quant", "Use nonlinear quantizer.", OFFSET(q_scale_type), AV_OPT_TYPE_INT, { 0 }, 0, 1, VE }, + { "alternate_scan", "Enable alternate scantable.", OFFSET(alternate_scan), AV_OPT_TYPE_INT, { 0 }, 0, 1, VE }, { NULL }, }; @@ -978,7 +978,7 @@ .init = encode_init, .encode = MPV_encode_picture, .close = MPV_encode_end, - .supported_framerates= ff_frame_rate_tab+1, + .supported_framerates= avpriv_frame_rate_tab+1, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE}, .capabilities= CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, .long_name= NULL_IF_CONFIG_SMALL("MPEG-1 video"), @@ -993,7 +993,7 @@ .init = encode_init, .encode = MPV_encode_picture, .close = MPV_encode_end, - .supported_framerates= ff_frame_rate_tab+1, + .supported_framerates= avpriv_frame_rate_tab+1, .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV422P, PIX_FMT_NONE}, .capabilities= CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS, .long_name= NULL_IF_CONFIG_SMALL("MPEG-2 video"), diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpeg12.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpeg12.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpeg12.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpeg12.h 2011-11-04 12:38:26.000000000 +0000 @@ -30,6 +30,20 @@ extern VLC ff_dc_lum_vlc; extern VLC ff_dc_chroma_vlc; +typedef struct Mpeg1Context { + MpegEncContext mpeg_enc_ctx; + int mpeg_enc_ctx_allocated; /* true if decoding context allocated */ + int repeat_field; /* true if we must repeat the field */ + AVPanScan pan_scan; /**< some temporary storage for the panscan */ + int slice_count; + int swap_uv;//indicate VCR2 + int save_aspect_info; + int save_width, save_height, save_progressive_seq; + AVRational frame_rate_ext; ///< MPEG-2 specific framerate modificator + int sync; ///< Did we reach a sync point like a GOP/SEQ/KEYFrame? + int tmpgexs; +} Mpeg1Context; + extern uint8_t ff_mpeg12_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3]; void ff_mpeg12_common_init(MpegEncContext *s); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpeg4audio.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpeg4audio.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpeg4audio.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpeg4audio.c 2011-11-04 12:38:26.000000000 +0000 @@ -52,7 +52,7 @@ return 0; } -const int ff_mpeg4audio_sample_rates[16] = { +const int avpriv_mpeg4audio_sample_rates[16] = { 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350 }; @@ -73,10 +73,10 @@ { *index = get_bits(gb, 4); return *index == 0x0f ? get_bits(gb, 24) : - ff_mpeg4audio_sample_rates[*index]; + avpriv_mpeg4audio_sample_rates[*index]; } -int ff_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int buf_size) +int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int buf_size) { GetBitContext gb; int specific_config_bitindex; @@ -151,7 +151,7 @@ return el; } -int ff_copy_pce_data(PutBitContext *pb, GetBitContext *gb) +int avpriv_copy_pce_data(PutBitContext *pb, GetBitContext *gb) { int five_bit_ch, four_bit_ch, comment_size, bits; int offset = put_bits_count(pb); @@ -173,7 +173,7 @@ copy_bits(pb, gb, 16); if (bits) copy_bits(pb, gb, bits); - align_put_bits(pb); + avpriv_align_put_bits(pb); align_get_bits(gb); comment_size = copy_bits(pb, gb, 8); for (; comment_size > 0; comment_size--) diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpeg4audio.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpeg4audio.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpeg4audio.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpeg4audio.h 2011-11-04 12:38:26.000000000 +0000 @@ -40,7 +40,7 @@ int ps; ///< -1 implicit, 1 presence } MPEG4AudioConfig; -extern const int ff_mpeg4audio_sample_rates[16]; +extern const int avpriv_mpeg4audio_sample_rates[16]; extern const uint8_t ff_mpeg4audio_channels[8]; /** * Parse MPEG-4 systems extradata to retrieve audio configuration. @@ -49,7 +49,7 @@ * @param[in] buf_size Extradata size. * @return On error -1 is returned, on success AudioSpecificConfig bit index in extradata. */ -int ff_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int buf_size); +int avpriv_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int buf_size); enum AudioObjectType { AOT_NULL, @@ -101,6 +101,6 @@ #define MAX_PCE_SIZE 304 ///flags & CODEC_FLAG_CBP_RD) { + int score = 0; + const int lambda = s->lambda2 >> (FF_LAMBDA_SHIFT - 6); + + for (i = 0; i < 6; i++) + if (s->coded_score[i] < 0) { + score += s->coded_score[i]; + cbp |= 1 << (5 - i); + } + + if (cbp) { + int zero_score = -6; + if ((motion_x | motion_y | s->dquant | mb_type) == 0) + zero_score -= 4; //2*MV + mb_type + cbp bit + + zero_score *= lambda; + if (zero_score <= score) + cbp = 0; + } + + for (i = 0; i < 6; i++) { + if (s->block_last_index[i] >= 0 && ((cbp >> (5 - i)) & 1) == 0) { + s->block_last_index[i] = -1; + s->dsp.clear_block(s->block[i]); + } + } + } else { + for (i = 0; i < 6; i++) { + if (s->block_last_index[i] >= 0) + cbp |= 1 << (5 - i); + } + } + return cbp; +} + //FIXME this is duplicated to h263.c static const int dquant_code[5]= {1,0,9,2,3}; @@ -1213,7 +1253,6 @@ s->inter_ac_vlc_length = uni_mpeg4_inter_rl_len; s->inter_ac_vlc_last_length= uni_mpeg4_inter_rl_len + 128*64; s->luma_dc_vlc_length= uni_DCtab_lum_len; - s->chroma_dc_vlc_length= uni_DCtab_chrom_len; s->ac_esc_length= 7+2+1+6+1+12+1; s->y_dc_scale_table= ff_mpeg4_y_dc_scale_table; s->c_dc_scale_table= ff_mpeg4_c_dc_scale_table; @@ -1268,8 +1307,8 @@ flush_put_bits(&s->tex_pb); set_put_bits_buffer_size(&s->pb, s->pb2.buf_end - s->pb.buf); - ff_copy_bits(&s->pb, s->pb2.buf , pb2_len); - ff_copy_bits(&s->pb, s->tex_pb.buf, tex_pb_len); + avpriv_copy_bits(&s->pb, s->pb2.buf , pb2_len); + avpriv_copy_bits(&s->pb, s->tex_pb.buf, tex_pb_len); s->last_bits= put_bits_count(&s->pb); } @@ -1289,8 +1328,8 @@ #define OFFSET(x) offsetof(MpegEncContext, x) #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { - { "data_partitioning", "Use data partitioning.", OFFSET(data_partitioning), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE }, - { "alternate_scan", "Enable alternate scantable.", OFFSET(alternate_scan), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE }, + { "data_partitioning", "Use data partitioning.", OFFSET(data_partitioning), AV_OPT_TYPE_INT, { 0 }, 0, 1, VE }, + { "alternate_scan", "Enable alternate scantable.", OFFSET(alternate_scan), AV_OPT_TYPE_INT, { 0 }, 0, 1, VE }, { NULL }, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpeg4video_parser.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpeg4video_parser.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpeg4video_parser.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpeg4video_parser.c 2011-11-04 12:38:26.000000000 +0000 @@ -99,6 +99,7 @@ if (!pc->enc) return -1; pc->first_picture = 1; + pc->enc->quant_precision=5; return 0; } @@ -130,10 +131,10 @@ AVCodecParser ff_mpeg4video_parser = { - { CODEC_ID_MPEG4 }, - sizeof(ParseContext1), - mpeg4video_parse_init, - mpeg4video_parse, - ff_parse1_close, - ff_mpeg4video_split, + .codec_ids = { CODEC_ID_MPEG4 }, + .priv_data_size = sizeof(ParseContext1), + .parser_init = mpeg4video_parse_init, + .parser_parse = mpeg4video_parse, + .parser_close = ff_parse1_close, + .split = ff_mpeg4video_split, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpegaudiodata.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpegaudiodata.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpegaudiodata.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpegaudiodata.c 2011-11-04 12:38:26.000000000 +0000 @@ -27,7 +27,7 @@ #include "mpegaudiodata.h" -const uint16_t ff_mpa_bitrate_tab[2][3][15] = { +const uint16_t avpriv_mpa_bitrate_tab[2][3][15] = { { {0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448 }, {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384 }, {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 } }, @@ -37,7 +37,7 @@ } }; -const uint16_t ff_mpa_freq_tab[3] = { 44100, 48000, 32000 }; +const uint16_t avpriv_mpa_freq_tab[3] = { 44100, 48000, 32000 }; /*******************************************************/ /* half mpeg encoding window (full precision) */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpegaudiodata.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpegaudiodata.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpegaudiodata.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpegaudiodata.h 2011-11-04 12:38:26.000000000 +0000 @@ -32,8 +32,8 @@ #define MODE_EXT_MS_STEREO 2 #define MODE_EXT_I_STEREO 1 -extern const uint16_t ff_mpa_bitrate_tab[2][3][15]; -extern const uint16_t ff_mpa_freq_tab[3]; +extern const uint16_t avpriv_mpa_bitrate_tab[2][3][15]; +extern const uint16_t avpriv_mpa_freq_tab[3]; extern const int32_t ff_mpa_enwindow[257]; extern const int ff_mpa_sblimit_table[5]; extern const int ff_mpa_quant_steps[17]; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpegaudiodec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpegaudiodec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpegaudiodec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpegaudiodec.c 2011-11-04 12:38:26.000000000 +0000 @@ -21,7 +21,7 @@ /** * @file - * MPEG Audio decoder. + * MPEG Audio decoder */ #include "libavutil/audioconvert.h" @@ -63,7 +63,7 @@ typedef struct MPADecodeContext { MPA_DECODE_HEADER - uint8_t last_buf[2*BACKSTEP_SIZE + EXTRABYTES]; + uint8_t last_buf[2 * BACKSTEP_SIZE + EXTRABYTES]; int last_buf_size; /* next header (used in free format parsing) */ uint32_t free_format_next_header; @@ -74,12 +74,9 @@ DECLARE_ALIGNED(32, INTFLOAT, sb_samples)[MPA_MAX_CHANNELS][36][SBLIMIT]; INTFLOAT mdct_buf[MPA_MAX_CHANNELS][SBLIMIT * 18]; /* previous samples, for layer 3 MDCT */ GranuleDef granules[2][2]; /* Used in Layer 3 */ -#ifdef DEBUG - int frame_count; -#endif int adu_mode; ///< 0 for standard mp3, 1 for adu formatted mp3 int dither_state; - int error_recognition; + int err_recognition; AVCodecContext* avctx; MPADSPContext mpadsp; } MPADecodeContext; @@ -95,7 +92,7 @@ # define OUT_FMT AV_SAMPLE_FMT_FLT #else # define SHR(a,b) ((a)>>(b)) -/* WARNING: only correct for posititive numbers */ +/* WARNING: only correct for positive numbers */ # define FIXR_OLD(a) ((int)((a) * FRAC_ONE + 0.5)) # define FIXR(a) ((int)((a) * FRAC_ONE + 0.5)) # define FIXHR(a) ((int)((a) * (1LL<<32) + 0.5)) @@ -115,18 +112,16 @@ /* vlc structure for decoding layer 3 huffman tables */ static VLC huff_vlc[16]; static VLC_TYPE huff_vlc_tables[ - 0+128+128+128+130+128+154+166+ - 142+204+190+170+542+460+662+414 + 0 + 128 + 128 + 128 + 130 + 128 + 154 + 166 + + 142 + 204 + 190 + 170 + 542 + 460 + 662 + 414 ][2]; static const int huff_vlc_tables_sizes[16] = { - 0, 128, 128, 128, 130, 128, 154, 166, - 142, 204, 190, 170, 542, 460, 662, 414 + 0, 128, 128, 128, 130, 128, 154, 166, + 142, 204, 190, 170, 542, 460, 662, 414 }; static VLC huff_quad_vlc[2]; -static VLC_TYPE huff_quad_vlc_tables[128+16][2]; -static const int huff_quad_vlc_tables_sizes[2] = { - 128, 16 -}; +static VLC_TYPE huff_quad_vlc_tables[128+16][2]; +static const int huff_quad_vlc_tables_sizes[2] = { 128, 16 }; /* computed from band_size_long */ static uint16_t band_index_long[9][23]; #include "mpegaudio_tablegen.h" @@ -163,17 +158,19 @@ * Convert region offsets to region sizes and truncate * size to big_values. */ -static void ff_region_offset2size(GranuleDef *g){ - int i, k, j=0; - g->region_size[2] = (576 / 2); - for(i=0;i<3;i++) { +static void ff_region_offset2size(GranuleDef *g) +{ + int i, k, j = 0; + g->region_size[2] = 576 / 2; + for (i = 0; i < 3; i++) { k = FFMIN(g->region_size[i], g->big_values); g->region_size[i] = k - j; j = k; } } -static void ff_init_short_region(MPADecodeContext *s, GranuleDef *g){ +static void ff_init_short_region(MPADecodeContext *s, GranuleDef *g) +{ if (g->block_type == 2) g->region_size[0] = (36 / 2); else { @@ -187,17 +184,17 @@ g->region_size[1] = (576 / 2); } -static void ff_init_long_region(MPADecodeContext *s, GranuleDef *g, int ra1, int ra2){ +static void ff_init_long_region(MPADecodeContext *s, GranuleDef *g, int ra1, int ra2) +{ int l; - g->region_size[0] = - band_index_long[s->sample_rate_index][ra1 + 1] >> 1; + g->region_size[0] = band_index_long[s->sample_rate_index][ra1 + 1] >> 1; /* should not overflow */ l = FFMIN(ra1 + ra2 + 2, 22); - g->region_size[1] = - band_index_long[s->sample_rate_index][l] >> 1; + g->region_size[1] = band_index_long[s->sample_rate_index][ l] >> 1; } -static void ff_compute_band_indexes(MPADecodeContext *s, GranuleDef *g){ +static void ff_compute_band_indexes(MPADecodeContext *s, GranuleDef *g) +{ if (g->block_type == 2) { if (g->switch_point) { /* if switched mode, we handle the 36 first samples as @@ -212,12 +209,12 @@ g->short_start = 2 + (s->sample_rate_index != 8); } else { - g->long_end = 0; + g->long_end = 0; g->short_start = 0; } } else { g->short_start = 13; - g->long_end = 22; + g->long_end = 22; } } @@ -228,11 +225,11 @@ int shift, mod; int64_t val; - shift = scale_factor_modshift[scale_factor]; - mod = shift & 3; + shift = scale_factor_modshift[scale_factor]; + mod = shift & 3; shift >>= 2; - val = MUL64(mant + (-1 << n) + 1, scale_factor_mult[n-1][mod]); - shift += n; + val = MUL64(mant + (-1 << n) + 1, scale_factor_mult[n-1][mod]); + shift += n; /* NOTE: at this point, 1 <= shift >= 21 + 15 */ return (int)((val + (1LL << (shift - 1))) >> shift); } @@ -241,8 +238,8 @@ { int shift, mod, val; - shift = scale_factor_modshift[scale_factor]; - mod = shift & 3; + shift = scale_factor_modshift[scale_factor]; + mod = shift & 3; shift >>= 2; val = (mant - (steps >> 1)) * scale_factor_mult2[steps >> 2][mod]; @@ -258,13 +255,13 @@ unsigned int m; int e; - e = table_4_3_exp [4*value + (exponent&3)]; - m = table_4_3_value[4*value + (exponent&3)]; - e -= (exponent >> 2); - assert(e>=1); + e = table_4_3_exp [4 * value + (exponent & 3)]; + m = table_4_3_value[4 * value + (exponent & 3)]; + e -= exponent >> 2; + assert(e >= 1); if (e > 31) return 0; - m = (m + (1 << (e-1))) >> e; + m = (m + (1 << (e - 1))) >> e; return m; } @@ -272,7 +269,7 @@ static av_cold int decode_init(AVCodecContext * avctx) { MPADecodeContext *s = avctx->priv_data; - static int init=0; + static int init = 0; int i, j, k; s->avctx = avctx; @@ -280,30 +277,33 @@ ff_mpadsp_init(&s->mpadsp); avctx->sample_fmt= OUT_FMT; - s->error_recognition= avctx->error_recognition; + s->err_recognition = avctx->err_recognition; +#if FF_API_PARSE_FRAME if (!init && !avctx->parse_only) { +#else + if (!init) { +#endif int offset; /* scale factors table for layer 1/2 */ - for(i=0;i<64;i++) { + for (i = 0; i < 64; i++) { int shift, mod; /* 1.0 (i = 3) is normalized to 2 ^ FRAC_BITS */ - shift = (i / 3); - mod = i % 3; + shift = i / 3; + mod = i % 3; scale_factor_modshift[i] = mod | (shift << 2); } /* scale factor multiply for layer 1 */ - for(i=0;i<15;i++) { + for (i = 0; i < 15; i++) { int n, norm; n = i + 2; norm = ((INT64_C(1) << n) * FRAC_ONE) / ((1 << n) - 1); scale_factor_mult[i][0] = MULLx(norm, FIXR(1.0 * 2.0), FRAC_BITS); scale_factor_mult[i][1] = MULLx(norm, FIXR(0.7937005259 * 2.0), FRAC_BITS); scale_factor_mult[i][2] = MULLx(norm, FIXR(0.6299605249 * 2.0), FRAC_BITS); - av_dlog(avctx, "%d: norm=%x s=%x %x %x\n", - i, norm, + av_dlog(avctx, "%d: norm=%x s=%x %x %x\n", i, norm, scale_factor_mult[i][0], scale_factor_mult[i][1], scale_factor_mult[i][2]); @@ -313,7 +313,7 @@ /* huffman decode tables */ offset = 0; - for(i=1;i<16;i++) { + for (i = 1; i < 16; i++) { const HuffTable *h = &mpa_huff_tables[i]; int xsize, x, y; uint8_t tmp_bits [512]; @@ -325,8 +325,8 @@ xsize = h->xsize; j = 0; - for(x=0;xbits [j ]; tmp_codes[(x << 5) | y | ((x&&y)<<4)]= h->codes[j++]; } @@ -343,7 +343,7 @@ assert(offset == FF_ARRAY_ELEMS(huff_vlc_tables)); offset = 0; - for(i=0;i<2;i++) { + for (i = 0; i < 2; i++) { huff_quad_vlc[i].table = huff_quad_vlc_tables+offset; huff_quad_vlc[i].table_allocated = huff_quad_vlc_tables_sizes[i]; init_vlc(&huff_quad_vlc[i], i == 0 ? 7 : 4, 16, @@ -353,9 +353,9 @@ } assert(offset == FF_ARRAY_ELEMS(huff_quad_vlc_tables)); - for(i=0;i<9;i++) { + for (i = 0; i < 9; i++) { k = 0; - for(j=0;j<22;j++) { + for (j = 0; j < 22; j++) { band_index_long[i][j] = k; k += band_size_long[i][j]; } @@ -366,21 +366,23 @@ mpegaudio_tableinit(); - for (i = 0; i < 4; i++) - if (ff_mpa_quant_bits[i] < 0) - for (j = 0; j < (1<<(-ff_mpa_quant_bits[i]+1)); j++) { + for (i = 0; i < 4; i++) { + if (ff_mpa_quant_bits[i] < 0) { + for (j = 0; j < (1 << (-ff_mpa_quant_bits[i]+1)); j++) { int val1, val2, val3, steps; int val = j; - steps = ff_mpa_quant_steps[i]; - val1 = val % steps; - val /= steps; - val2 = val % steps; - val3 = val / steps; + steps = ff_mpa_quant_steps[i]; + val1 = val % steps; + val /= steps; + val2 = val % steps; + val3 = val / steps; division_tabs[i][j] = val1 + (val2 << 4) + (val3 << 8); } + } + } - for(i=0;i<7;i++) { + for (i = 0; i < 7; i++) { float f; INTFLOAT v; if (i != 6) { @@ -389,30 +391,30 @@ } else { v = FIXR(1.0); } - is_table[0][i] = v; + is_table[0][ i] = v; is_table[1][6 - i] = v; } /* invalid values */ - for(i=7;i<16;i++) + for (i = 7; i < 16; i++) is_table[0][i] = is_table[1][i] = 0.0; - for(i=0;i<16;i++) { + for (i = 0; i < 16; i++) { double f; int e, k; - for(j=0;j<2;j++) { + for (j = 0; j < 2; j++) { e = -(j + 1) * ((i + 1) >> 1); f = pow(2.0, e / 4.0); k = i & 1; is_table_lsf[j][k ^ 1][i] = FIXR(f); - is_table_lsf[j][k][i] = FIXR(1.0); + is_table_lsf[j][k ][i] = FIXR(1.0); av_dlog(avctx, "is_table_lsf %d %d: %f %f\n", i, j, (float) is_table_lsf[j][0][i], (float) is_table_lsf[j][1][i]); } } - for(i=0;i<8;i++) { + for (i = 0; i < 8; i++) { float ci, cs, ca; ci = ci_table[i]; cs = 1.0 / sqrt(1.0 + ci * ci); @@ -431,27 +433,27 @@ } /* compute mdct windows */ - for(i=0;i<36;i++) { - for(j=0; j<4; j++){ + for (i = 0; i < 36; i++) { + for (j = 0; j < 4; j++) { double d; - if(j==2 && i%3 != 1) + if (j == 2 && i % 3 != 1) continue; - d= sin(M_PI * (i + 0.5) / 36.0); - if(j==1){ - if (i>=30) d= 0; - else if(i>=24) d= sin(M_PI * (i - 18 + 0.5) / 12.0); - else if(i>=18) d= 1; - }else if(j==3){ - if (i< 6) d= 0; - else if(i< 12) d= sin(M_PI * (i - 6 + 0.5) / 12.0); - else if(i< 18) d= 1; + d = sin(M_PI * (i + 0.5) / 36.0); + if (j == 1) { + if (i >= 30) d = 0; + else if (i >= 24) d = sin(M_PI * (i - 18 + 0.5) / 12.0); + else if (i >= 18) d = 1; + } else if (j == 3) { + if (i < 6) d = 0; + else if (i < 12) d = sin(M_PI * (i - 6 + 0.5) / 12.0); + else if (i < 18) d = 1; } //merge last stage of imdct into the window coefficients - d*= 0.5 / cos(M_PI*(2*i + 19)/72); + d *= 0.5 / cos(M_PI * (2 * i + 19) / 72); - if(j==2) + if (j == 2) mdct_win[j][i/3] = FIXHR((d / (1<<5))); else mdct_win[j][i ] = FIXHR((d / (1<<5))); @@ -460,9 +462,9 @@ /* NOTE: we do frequency inversion adter the MDCT by changing the sign of the right window coefs */ - for(j=0;j<4;j++) { - for(i=0;i<36;i+=2) { - mdct_win[j + 4][i] = mdct_win[j][i]; + for (j = 0; j < 4; j++) { + for (i = 0; i < 36; i += 2) { + mdct_win[j + 4][i ] = mdct_win[j][i ]; mdct_win[j + 4][i + 1] = -mdct_win[j][i + 1]; } } @@ -509,41 +511,41 @@ { INTFLOAT in0, in1, in2, in3, in4, in5, t1, t2; - in0= in[0*3]; - in1= in[1*3] + in[0*3]; - in2= in[2*3] + in[1*3]; - in3= in[3*3] + in[2*3]; - in4= in[4*3] + in[3*3]; - in5= in[5*3] + in[4*3]; + in0 = in[0*3]; + in1 = in[1*3] + in[0*3]; + in2 = in[2*3] + in[1*3]; + in3 = in[3*3] + in[2*3]; + in4 = in[4*3] + in[3*3]; + in5 = in[5*3] + in[4*3]; in5 += in3; in3 += in1; - in2= MULH3(in2, C3, 2); - in3= MULH3(in3, C3, 4); + in2 = MULH3(in2, C3, 2); + in3 = MULH3(in3, C3, 4); - t1 = in0 - in4; - t2 = MULH3(in1 - in5, icos36h[4], 2); + t1 = in0 - in4; + t2 = MULH3(in1 - in5, icos36h[4], 2); - out[ 7]= - out[10]= t1 + t2; - out[ 1]= - out[ 4]= t1 - t2; - - in0 += SHR(in4, 1); - in4 = in0 + in2; - in5 += 2*in1; - in1 = MULH3(in5 + in3, icos36h[1], 1); - out[ 8]= - out[ 9]= in4 + in1; - out[ 2]= - out[ 3]= in4 - in1; - - in0 -= in2; - in5 = MULH3(in5 - in3, icos36h[7], 2); - out[ 0]= - out[ 5]= in0 - in5; - out[ 6]= - out[11]= in0 + in5; + out[ 7] = + out[10] = t1 + t2; + out[ 1] = + out[ 4] = t1 - t2; + + in0 += SHR(in4, 1); + in4 = in0 + in2; + in5 += 2*in1; + in1 = MULH3(in5 + in3, icos36h[1], 1); + out[ 8] = + out[ 9] = in4 + in1; + out[ 2] = + out[ 3] = in4 - in1; + + in0 -= in2; + in5 = MULH3(in5 - in3, icos36h[7], 2); + out[ 0] = + out[ 5] = in0 - in5; + out[ 6] = + out[11] = in0 + in5; } /* cos(pi*i/18) */ @@ -564,12 +566,12 @@ INTFLOAT t0, t1, t2, t3, s0, s1, s2, s3; INTFLOAT tmp[18], *tmp1, *in1; - for(i=17;i>=1;i--) + for (i = 17; i >= 1; i--) in[i] += in[i-1]; - for(i=17;i>=3;i-=2) + for (i = 17; i >= 3; i -= 2) in[i] += in[i-2]; - for(j=0;j<2;j++) { + for (j = 0; j < 2; j++) { tmp1 = tmp + j; in1 = in + j; @@ -601,7 +603,7 @@ } i = 0; - for(j=0;j<4;j++) { + for (j = 0; j < 4; j++) { t0 = tmp[i]; t1 = tmp[i + 2]; s0 = t1 + t0; @@ -609,22 +611,22 @@ t2 = tmp[i + 1]; t3 = tmp[i + 3]; - s1 = MULH3(t3 + t2, icos36h[j], 2); - s3 = MULLx(t3 - t2, icos36[8 - j], FRAC_BITS); + s1 = MULH3(t3 + t2, icos36h[ j], 2); + s3 = MULLx(t3 - t2, icos36 [8 - j], FRAC_BITS); t0 = s0 + s1; t1 = s0 - s1; - out[(9 + j)*SBLIMIT] = MULH3(t1, win[9 + j], 1) + buf[9 + j]; - out[(8 - j)*SBLIMIT] = MULH3(t1, win[8 - j], 1) + buf[8 - j]; - buf[9 + j] = MULH3(t0, win[18 + 9 + j], 1); - buf[8 - j] = MULH3(t0, win[18 + 8 - j], 1); + out[(9 + j) * SBLIMIT] = MULH3(t1, win[ 9 + j], 1) + buf[9 + j]; + out[(8 - j) * SBLIMIT] = MULH3(t1, win[ 8 - j], 1) + buf[8 - j]; + buf[ 9 + j ] = MULH3(t0, win[18 + 9 + j], 1); + buf[ 8 - j ] = MULH3(t0, win[18 + 8 - j], 1); t0 = s2 + s3; t1 = s2 - s3; - out[(9 + 8 - j)*SBLIMIT] = MULH3(t1, win[9 + 8 - j], 1) + buf[9 + 8 - j]; - out[( j)*SBLIMIT] = MULH3(t1, win[ j], 1) + buf[ j]; - buf[9 + 8 - j] = MULH3(t0, win[18 + 9 + 8 - j], 1); - buf[ + j] = MULH3(t0, win[18 + j], 1); + out[(9 + 8 - j) * SBLIMIT] = MULH3(t1, win[ 9 + 8 - j], 1) + buf[9 + 8 - j]; + out[ j * SBLIMIT] = MULH3(t1, win[ j], 1) + buf[ j]; + buf[ 9 + 8 - j ] = MULH3(t0, win[18 + 9 + 8 - j], 1); + buf[ j ] = MULH3(t0, win[18 + j], 1); i += 4; } @@ -632,10 +634,10 @@ s1 = MULH3(tmp[17], icos36h[4], 2); t0 = s0 + s1; t1 = s0 - s1; - out[(9 + 4)*SBLIMIT] = MULH3(t1, win[9 + 4], 1) + buf[9 + 4]; - out[(8 - 4)*SBLIMIT] = MULH3(t1, win[8 - 4], 1) + buf[8 - 4]; - buf[9 + 4] = MULH3(t0, win[18 + 9 + 4], 1); - buf[8 - 4] = MULH3(t0, win[18 + 8 - 4], 1); + out[(9 + 4) * SBLIMIT] = MULH3(t1, win[ 9 + 4], 1) + buf[9 + 4]; + out[(8 - 4) * SBLIMIT] = MULH3(t1, win[ 8 - 4], 1) + buf[8 - 4]; + buf[ 9 + 4 ] = MULH3(t0, win[18 + 9 + 4], 1); + buf[ 8 - 4 ] = MULH3(t0, win[18 + 8 - 4], 1); } /* return the number of decoded frames */ @@ -651,23 +653,22 @@ bound = SBLIMIT; /* allocation bits */ - for(i=0;inb_channels;ch++) { + for (i = 0; i < bound; i++) { + for (ch = 0; ch < s->nb_channels; ch++) { allocation[ch][i] = get_bits(&s->gb, 4); } } - for(i=bound;igb, 4); - } /* scale factors */ - for(i=0;inb_channels;ch++) { + for (i = 0; i < bound; i++) { + for (ch = 0; ch < s->nb_channels; ch++) { if (allocation[ch][i]) scale_factors[ch][i] = get_bits(&s->gb, 6); } } - for(i=bound;igb, 6); scale_factors[1][i] = get_bits(&s->gb, 6); @@ -675,9 +676,9 @@ } /* compute samples */ - for(j=0;j<12;j++) { - for(i=0;inb_channels;ch++) { + for (j = 0; j < 12; j++) { + for (i = 0; i < bound; i++) { + for (ch = 0; ch < s->nb_channels; ch++) { n = allocation[ch][i]; if (n) { mant = get_bits(&s->gb, n + 1); @@ -688,7 +689,7 @@ s->sb_samples[ch][j][i] = v; } } - for(i=bound;igb, n + 1); @@ -717,8 +718,8 @@ /* select decoding table */ table = ff_mpa_l2_select_table(s->bit_rate / 1000, s->nb_channels, - s->sample_rate, s->lsf); - sblimit = ff_mpa_sblimit_table[table]; + s->sample_rate, s->lsf); + sblimit = ff_mpa_sblimit_table[table]; alloc_table = ff_mpa_alloc_tables[table]; if (s->mode == MPA_JSTEREO) @@ -729,18 +730,18 @@ av_dlog(s->avctx, "bound=%d sblimit=%d\n", bound, sblimit); /* sanity check */ - if( bound > sblimit ) bound = sblimit; + if (bound > sblimit) + bound = sblimit; /* parse bit allocation */ j = 0; - for(i=0;inb_channels;ch++) { + for (ch = 0; ch < s->nb_channels; ch++) bit_alloc[ch][i] = get_bits(&s->gb, bit_alloc_bits); - } j += 1 << bit_alloc_bits; } - for(i=bound;igb, bit_alloc_bits); bit_alloc[0][i] = v; @@ -749,19 +750,19 @@ } /* scale codes */ - for(i=0;inb_channels;ch++) { + for (i = 0; i < sblimit; i++) { + for (ch = 0; ch < s->nb_channels; ch++) { if (bit_alloc[ch][i]) scale_code[ch][i] = get_bits(&s->gb, 2); } } /* scale factors */ - for(i=0;inb_channels;ch++) { + for (i = 0; i < sblimit; i++) { + for (ch = 0; ch < s->nb_channels; ch++) { if (bit_alloc[ch][i]) { sf = scale_factors[ch][i]; - switch(scale_code[ch][i]) { + switch (scale_code[ch][i]) { default: case 0: sf[0] = get_bits(&s->gb, 6); @@ -789,12 +790,12 @@ } /* samples */ - for(k=0;k<3;k++) { - for(l=0;l<12;l+=3) { + for (k = 0; k < 3; k++) { + for (l = 0; l < 12; l += 3) { j = 0; - for(i=0;inb_channels;ch++) { + for (ch = 0; ch < s->nb_channels; ch++) { b = bit_alloc[ch][i]; if (b) { scale = scale_factors[ch][i][k]; @@ -808,13 +809,13 @@ steps = ff_mpa_quant_steps[qindex]; s->sb_samples[ch][k * 12 + l + 0][i] = - l2_unscale_group(steps, v2 & 15, scale); + l2_unscale_group(steps, v2 & 15, scale); s->sb_samples[ch][k * 12 + l + 1][i] = l2_unscale_group(steps, (v2 >> 4) & 15, scale); s->sb_samples[ch][k * 12 + l + 2][i] = l2_unscale_group(steps, v2 >> 8 , scale); } else { - for(m=0;m<3;m++) { + for (m = 0; m < 3; m++) { v = get_bits(&s->gb, bits); v = l1_unscale(bits - 1, v, scale); s->sb_samples[ch][k * 12 + l + m][i] = v; @@ -830,7 +831,7 @@ j += 1 << bit_alloc_bits; } /* XXX: find a way to avoid this duplication of code */ - for(i=bound;isb_samples[1][k * 12 + l + 2][i] = l2_unscale_group(steps, v, scale1); } else { - for(m=0;m<3;m++) { + for (m = 0; m < 3; m++) { mant = get_bits(&s->gb, bits); s->sb_samples[0][k * 12 + l + m][i] = l1_unscale(bits - 1, mant, scale0); @@ -880,8 +881,8 @@ j += 1 << bit_alloc_bits; } /* fill remaining samples to zero */ - for(i=sblimit;inb_channels;ch++) { + for (i = sblimit; i < SBLIMIT; i++) { + for (ch = 0; ch < s->nb_channels; ch++) { s->sb_samples[ch][k * 12 + l + 0][i] = 0; s->sb_samples[ch][k * 12 + l + 1][i] = 0; s->sb_samples[ch][k * 12 + l + 2][i] = 0; @@ -892,28 +893,28 @@ return 3 * 12; } -#define SPLIT(dst,sf,n)\ - if(n==3){\ - int m= (sf*171)>>9;\ - dst= sf - 3*m;\ - sf=m;\ - }else if(n==4){\ - dst= sf&3;\ - sf>>=2;\ - }else if(n==5){\ - int m= (sf*205)>>10;\ - dst= sf - 5*m;\ - sf=m;\ - }else if(n==6){\ - int m= (sf*171)>>10;\ - dst= sf - 6*m;\ - sf=m;\ - }else{\ - dst=0;\ +#define SPLIT(dst,sf,n) \ + if (n == 3) { \ + int m = (sf * 171) >> 9; \ + dst = sf - 3 * m; \ + sf = m; \ + } else if (n == 4) { \ + dst = sf & 3; \ + sf >>= 2; \ + } else if (n == 5) { \ + int m = (sf * 205) >> 10; \ + dst = sf - 5 * m; \ + sf = m; \ + } else if (n == 6) { \ + int m = (sf * 171) >> 10; \ + dst = sf - 6 * m; \ + sf = m; \ + } else { \ + dst = 0; \ } -static av_always_inline void lsf_sf_expand(int *slen, - int sf, int n1, int n2, int n3) +static av_always_inline void lsf_sf_expand(int *slen, int sf, int n1, int n2, + int n3) { SPLIT(slen[3], sf, n3) SPLIT(slen[2], sf, n2) @@ -921,8 +922,7 @@ slen[0] = sf; } -static void exponents_from_scale_factors(MPADecodeContext *s, - GranuleDef *g, +static void exponents_from_scale_factors(MPADecodeContext *s, GranuleDef *g, int16_t *exponents) { const uint8_t *bstab, *pretab; @@ -930,30 +930,30 @@ int16_t *exp_ptr; exp_ptr = exponents; - gain = g->global_gain - 210; - shift = g->scalefac_scale + 1; + gain = g->global_gain - 210; + shift = g->scalefac_scale + 1; - bstab = band_size_long[s->sample_rate_index]; + bstab = band_size_long[s->sample_rate_index]; pretab = mpa_pretab[g->preflag]; - for(i=0;ilong_end;i++) { + for (i = 0; i < g->long_end; i++) { v0 = gain - ((g->scale_factors[i] + pretab[i]) << shift) + 400; len = bstab[i]; - for(j=len;j>0;j--) + for (j = len; j > 0; j--) *exp_ptr++ = v0; } if (g->short_start < 13) { - bstab = band_size_short[s->sample_rate_index]; + bstab = band_size_short[s->sample_rate_index]; gains[0] = gain - (g->subblock_gain[0] << 3); gains[1] = gain - (g->subblock_gain[1] << 3); gains[2] = gain - (g->subblock_gain[2] << 3); - k = g->long_end; - for(i=g->short_start;i<13;i++) { + k = g->long_end; + for (i = g->short_start; i < 13; i++) { len = bstab[i]; - for(l=0;l<3;l++) { + for (l = 0; l < 3; l++) { v0 = gains[l] - (g->scale_factors[k++] << shift) + 400; - for(j=len;j>0;j--) - *exp_ptr++ = v0; + for (j = len; j > 0; j--) + *exp_ptr++ = v0; } } } @@ -962,22 +962,21 @@ /* handle n = 0 too */ static inline int get_bitsz(GetBitContext *s, int n) { - if (n == 0) - return 0; - else - return get_bits(s, n); + return n ? get_bits(s, n) : 0; } -static void switch_buffer(MPADecodeContext *s, int *pos, int *end_pos, int *end_pos2){ - if(s->in_gb.buffer && *pos >= s->gb.size_in_bits){ - s->gb= s->in_gb; - s->in_gb.buffer=NULL; +static void switch_buffer(MPADecodeContext *s, int *pos, int *end_pos, + int *end_pos2) +{ + if (s->in_gb.buffer && *pos >= s->gb.size_in_bits) { + s->gb = s->in_gb; + s->in_gb.buffer = NULL; assert((get_bits_count(&s->gb) & 7) == 0); skip_bits_long(&s->gb, *pos - *end_pos); - *end_pos2= - *end_pos= *end_pos2 + get_bits_count(&s->gb) - *pos; - *pos= get_bits_count(&s->gb); + *end_pos2 = + *end_pos = *end_pos2 + get_bits_count(&s->gb) - *pos; + *pos = get_bits_count(&s->gb); } } @@ -988,13 +987,13 @@ *dst = v; */ #if CONFIG_FLOAT -#define READ_FLIP_SIGN(dst,src)\ - v = AV_RN32A(src) ^ (get_bits1(&s->gb)<<31);\ - AV_WN32A(dst, v); +#define READ_FLIP_SIGN(dst,src) \ + v = AV_RN32A(src) ^ (get_bits1(&s->gb) << 31); \ + AV_WN32A(dst, v); #else -#define READ_FLIP_SIGN(dst,src)\ - v= -get_bits1(&s->gb);\ - *(dst) = (*(src) ^ v) - v; +#define READ_FLIP_SIGN(dst,src) \ + v = -get_bits1(&s->gb); \ + *(dst) = (*(src) ^ v) - v; #endif static int huffman_decode(MPADecodeContext *s, GranuleDef *g, @@ -1004,43 +1003,43 @@ int i; int last_pos, bits_left; VLC *vlc; - int end_pos= FFMIN(end_pos2, s->gb.size_in_bits); + int end_pos = FFMIN(end_pos2, s->gb.size_in_bits); /* low frequencies (called big values) */ s_index = 0; - for(i=0;i<3;i++) { + for (i = 0; i < 3; i++) { int j, k, l, linbits; j = g->region_size[i]; if (j == 0) continue; /* select vlc table */ - k = g->table_select[i]; - l = mpa_huff_data[k][0]; + k = g->table_select[i]; + l = mpa_huff_data[k][0]; linbits = mpa_huff_data[k][1]; - vlc = &huff_vlc[l]; + vlc = &huff_vlc[l]; - if(!l){ - memset(&g->sb_hybrid[s_index], 0, sizeof(*g->sb_hybrid)*2*j); - s_index += 2*j; + if (!l) { + memset(&g->sb_hybrid[s_index], 0, sizeof(*g->sb_hybrid) * 2 * j); + s_index += 2 * j; continue; } /* read huffcode and compute each couple */ - for(;j>0;j--) { + for (; j > 0; j--) { int exponent, x, y; int v; - int pos= get_bits_count(&s->gb); + int pos = get_bits_count(&s->gb); if (pos >= end_pos){ // av_log(NULL, AV_LOG_ERROR, "pos: %d %d %d %d\n", pos, end_pos, end_pos2, s_index); switch_buffer(s, &pos, &end_pos, &end_pos2); // av_log(NULL, AV_LOG_ERROR, "new pos: %d %d\n", pos, end_pos); - if(pos >= end_pos) + if (pos >= end_pos) break; } y = get_vlc2(&s->gb, vlc->table, 7, 3); - if(!y){ + if (!y) { g->sb_hybrid[s_index ] = g->sb_hybrid[s_index+1] = 0; s_index += 2; @@ -1051,100 +1050,100 @@ av_dlog(s->avctx, "region=%d n=%d x=%d y=%d exp=%d\n", i, g->region_size[i] - j, x, y, exponent); - if(y&16){ + if (y & 16) { x = y >> 5; y = y & 0x0f; - if (x < 15){ - READ_FLIP_SIGN(g->sb_hybrid+s_index, RENAME(expval_table)[ exponent ]+x) - }else{ + if (x < 15) { + READ_FLIP_SIGN(g->sb_hybrid + s_index, RENAME(expval_table)[exponent] + x) + } else { x += get_bitsz(&s->gb, linbits); - v = l3_unscale(x, exponent); + v = l3_unscale(x, exponent); if (get_bits1(&s->gb)) v = -v; g->sb_hybrid[s_index] = v; } - if (y < 15){ - READ_FLIP_SIGN(g->sb_hybrid+s_index+1, RENAME(expval_table)[ exponent ]+y) - }else{ + if (y < 15) { + READ_FLIP_SIGN(g->sb_hybrid + s_index + 1, RENAME(expval_table)[exponent] + y) + } else { y += get_bitsz(&s->gb, linbits); - v = l3_unscale(y, exponent); + v = l3_unscale(y, exponent); if (get_bits1(&s->gb)) v = -v; g->sb_hybrid[s_index+1] = v; } - }else{ + } else { x = y >> 5; y = y & 0x0f; x += y; - if (x < 15){ - READ_FLIP_SIGN(g->sb_hybrid+s_index+!!y, RENAME(expval_table)[ exponent ]+x) - }else{ + if (x < 15) { + READ_FLIP_SIGN(g->sb_hybrid + s_index + !!y, RENAME(expval_table)[exponent] + x) + } else { x += get_bitsz(&s->gb, linbits); - v = l3_unscale(x, exponent); + v = l3_unscale(x, exponent); if (get_bits1(&s->gb)) v = -v; g->sb_hybrid[s_index+!!y] = v; } - g->sb_hybrid[s_index+ !y] = 0; + g->sb_hybrid[s_index + !y] = 0; } - s_index+=2; + s_index += 2; } } /* high frequencies */ vlc = &huff_quad_vlc[g->count1table_select]; - last_pos=0; + last_pos = 0; while (s_index <= 572) { int pos, code; pos = get_bits_count(&s->gb); if (pos >= end_pos) { - if (pos > end_pos2 && last_pos){ + if (pos > end_pos2 && last_pos) { /* some encoders generate an incorrect size for this part. We must go back into the data */ s_index -= 4; skip_bits_long(&s->gb, last_pos - pos); av_log(s->avctx, AV_LOG_INFO, "overread, skip %d enddists: %d %d\n", last_pos - pos, end_pos-pos, end_pos2-pos); - if(s->error_recognition >= FF_ER_COMPLIANT) + if(s->err_recognition & AV_EF_BITSTREAM) s_index=0; break; } // av_log(NULL, AV_LOG_ERROR, "pos2: %d %d %d %d\n", pos, end_pos, end_pos2, s_index); switch_buffer(s, &pos, &end_pos, &end_pos2); // av_log(NULL, AV_LOG_ERROR, "new pos2: %d %d %d\n", pos, end_pos, s_index); - if(pos >= end_pos) + if (pos >= end_pos) break; } - last_pos= pos; + last_pos = pos; code = get_vlc2(&s->gb, vlc->table, vlc->bits, 1); av_dlog(s->avctx, "t=%d code=%d\n", g->count1table_select, code); - g->sb_hybrid[s_index+0]= - g->sb_hybrid[s_index+1]= - g->sb_hybrid[s_index+2]= - g->sb_hybrid[s_index+3]= 0; - while(code){ - static const int idxtab[16]={3,3,2,2,1,1,1,1,0,0,0,0,0,0,0,0}; + g->sb_hybrid[s_index+0] = + g->sb_hybrid[s_index+1] = + g->sb_hybrid[s_index+2] = + g->sb_hybrid[s_index+3] = 0; + while (code) { + static const int idxtab[16] = { 3,3,2,2,1,1,1,1,0,0,0,0,0,0,0,0 }; int v; - int pos= s_index+idxtab[code]; - code ^= 8>>idxtab[code]; - READ_FLIP_SIGN(g->sb_hybrid+pos, RENAME(exp_table)+exponents[pos]) + int pos = s_index + idxtab[code]; + code ^= 8 >> idxtab[code]; + READ_FLIP_SIGN(g->sb_hybrid + pos, RENAME(exp_table)+exponents[pos]) } - s_index+=4; + s_index += 4; } /* skip extension bits */ bits_left = end_pos2 - get_bits_count(&s->gb); //av_log(NULL, AV_LOG_ERROR, "left:%d buf:%p\n", bits_left, s->in_gb.buffer); - if (bits_left < 0 && s->error_recognition >= FF_ER_COMPLIANT) { + if (bits_left < 0 && (s->err_recognition & AV_EF_BITSTREAM)) { av_log(s->avctx, AV_LOG_ERROR, "bits_left=%d\n", bits_left); s_index=0; - }else if(bits_left > 0 && s->error_recognition >= FF_ER_AGGRESSIVE){ + } else if (bits_left > 0 && (s->err_recognition & AV_EF_BUFFER)) { av_log(s->avctx, AV_LOG_ERROR, "bits_left=%d\n", bits_left); - s_index=0; + s_index = 0; } - memset(&g->sb_hybrid[s_index], 0, sizeof(*g->sb_hybrid)*(576 - s_index)); + memset(&g->sb_hybrid[s_index], 0, sizeof(*g->sb_hybrid) * (576 - s_index)); skip_bits_long(&s->gb, bits_left); - i= get_bits_count(&s->gb); + i = get_bits_count(&s->gb); switch_buffer(s, &i, &end_pos, &end_pos2); return 0; @@ -1163,34 +1162,32 @@ return; if (g->switch_point) { - if (s->sample_rate_index != 8) { + if (s->sample_rate_index != 8) ptr = g->sb_hybrid + 36; - } else { + else ptr = g->sb_hybrid + 48; - } } else { ptr = g->sb_hybrid; } - for(i=g->short_start;i<13;i++) { - len = band_size_short[s->sample_rate_index][i]; + for (i = g->short_start; i < 13; i++) { + len = band_size_short[s->sample_rate_index][i]; ptr1 = ptr; - dst = tmp; - for(j=len;j>0;j--) { + dst = tmp; + for (j = len; j > 0; j--) { *dst++ = ptr[0*len]; *dst++ = ptr[1*len]; *dst++ = ptr[2*len]; ptr++; } - ptr+=2*len; + ptr += 2 * len; memcpy(ptr1, tmp, len * 3 * sizeof(*ptr1)); } } #define ISQRT2 FIXR(0.70710678118654752440) -static void compute_stereo(MPADecodeContext *s, - GranuleDef *g0, GranuleDef *g1) +static void compute_stereo(MPADecodeContext *s, GranuleDef *g0, GranuleDef *g1) { int i, j, k, l; int sf_max, sf, len, non_zero_found; @@ -1214,17 +1211,17 @@ non_zero_found_short[1] = 0; non_zero_found_short[2] = 0; k = (13 - g1->short_start) * 3 + g1->long_end - 3; - for(i = 12;i >= g1->short_start;i--) { + for (i = 12; i >= g1->short_start; i--) { /* for last band, use previous scale factor */ if (i != 11) k -= 3; len = band_size_short[s->sample_rate_index][i]; - for(l=2;l>=0;l--) { + for (l = 2; l >= 0; l--) { tab0 -= len; tab1 -= len; if (!non_zero_found_short[l]) { /* test if non zero band. if so, stop doing i-stereo */ - for(j=0;jmode_ext & MODE_EXT_MS_STEREO) { /* lower part of the spectrum : do ms stereo if enabled */ - for(j=0;jlong_end - 1;i >= 0;i--) { - len = band_size_long[s->sample_rate_index][i]; + for (i = g1->long_end - 1;i >= 0;i--) { + len = band_size_long[s->sample_rate_index][i]; tab0 -= len; tab1 -= len; /* test if non zero band. if so, stop doing i-stereo */ if (!non_zero_found) { - for(j=0;jscale_factors[k]; if (sf >= sf_max) goto found2; v1 = is_tab[0][sf]; v2 = is_tab[1][sf]; - for(j=0;jmode_ext & MODE_EXT_MS_STEREO) { /* lower part of the spectrum : do ms stereo if enabled */ - for(j=0;jsb_hybrid; tab1 = g1->sb_hybrid; - for(i=0;i<576;i++) { - tmp0 = tab0[i]; - tmp1 = tab1[i]; + for (i = 0; i < 576; i++) { + tmp0 = tab0[i]; + tmp1 = tab1[i]; tab0[i] = tmp0 + tmp1; tab1[i] = tmp0 - tmp1; } @@ -1326,8 +1323,8 @@ int tmp0 = ptr[-1-j]; \ int tmp1 = ptr[ j]; \ int tmp2 = MULH(tmp0 + tmp1, csa_table[j][0]); \ - ptr[-1-j] = 4*(tmp2 - MULH(tmp1, csa_table[j][2])); \ - ptr[ j] = 4*(tmp2 + MULH(tmp0, csa_table[j][3])); \ + ptr[-1-j] = 4 * (tmp2 - MULH(tmp1, csa_table[j][2])); \ + ptr[ j] = 4 * (tmp2 + MULH(tmp0, csa_table[j][3])); \ } while (0) #endif @@ -1347,7 +1344,7 @@ } ptr = g->sb_hybrid + 18; - for(i = n;i > 0;i--) { + for (i = n; i > 0; i--) { AA(0); AA(1); AA(2); @@ -1361,23 +1358,21 @@ } } -static void compute_imdct(MPADecodeContext *s, - GranuleDef *g, - INTFLOAT *sb_samples, - INTFLOAT *mdct_buf) +static void compute_imdct(MPADecodeContext *s, GranuleDef *g, + INTFLOAT *sb_samples, INTFLOAT *mdct_buf) { INTFLOAT *win, *win1, *out_ptr, *ptr, *buf, *ptr1; INTFLOAT out2[12]; int i, j, mdct_long_end, sblimit; /* find last non zero block */ - ptr = g->sb_hybrid + 576; + ptr = g->sb_hybrid + 576; ptr1 = g->sb_hybrid + 2 * 18; while (ptr >= ptr1) { int32_t *p; ptr -= 6; - p= (int32_t*)ptr; - if(p[0] | p[1] | p[2] | p[3] | p[4] | p[5]) + p = (int32_t*)ptr; + if (p[0] | p[1] | p[2] | p[3] | p[4] | p[5]) break; } sblimit = ((ptr - g->sb_hybrid) / 18) + 1; @@ -1394,7 +1389,7 @@ buf = mdct_buf; ptr = g->sb_hybrid; - for(j=0;jgb, 5); nb_granules = 2; - for(ch=0;chnb_channels;ch++) { + for (ch = 0; ch < s->nb_channels; ch++) { s->granules[ch][0].scfsi = 0;/* all scale factors are transmitted */ s->granules[ch][1].scfsi = get_bits(&s->gb, 4); } } - for(gr=0;grnb_channels;ch++) { + for (gr = 0; gr < nb_granules; gr++) { + for (ch = 0; ch < s->nb_channels; ch++) { av_dlog(s->avctx, "gr=%d ch=%d: side_info\n", gr, ch); g = &s->granules[ch][gr]; g->part2_3_length = get_bits(&s->gb, 12); - g->big_values = get_bits(&s->gb, 9); - if(g->big_values > 288){ + g->big_values = get_bits(&s->gb, 9); + if (g->big_values > 288) { av_log(s->avctx, AV_LOG_ERROR, "big_values too big\n"); - return -1; + return AVERROR_INVALIDDATA; } g->global_gain = get_bits(&s->gb, 8); @@ -1502,21 +1497,21 @@ blocksplit_flag = get_bits1(&s->gb); if (blocksplit_flag) { g->block_type = get_bits(&s->gb, 2); - if (g->block_type == 0){ + if (g->block_type == 0) { av_log(s->avctx, AV_LOG_ERROR, "invalid block type\n"); - return -1; + return AVERROR_INVALIDDATA; } g->switch_point = get_bits1(&s->gb); - for(i=0;i<2;i++) + for (i = 0; i < 2; i++) g->table_select[i] = get_bits(&s->gb, 5); - for(i=0;i<3;i++) + for (i = 0; i < 3; i++) g->subblock_gain[i] = get_bits(&s->gb, 3); ff_init_short_region(s, g); } else { int region_address1, region_address2; g->block_type = 0; g->switch_point = 0; - for(i=0;i<3;i++) + for (i = 0; i < 3; i++) g->table_select[i] = get_bits(&s->gb, 5); /* compute huffman coded region sizes */ region_address1 = get_bits(&s->gb, 4); @@ -1531,38 +1526,38 @@ g->preflag = 0; if (!s->lsf) g->preflag = get_bits1(&s->gb); - g->scalefac_scale = get_bits1(&s->gb); + g->scalefac_scale = get_bits1(&s->gb); g->count1table_select = get_bits1(&s->gb); av_dlog(s->avctx, "block_type=%d switch_point=%d\n", g->block_type, g->switch_point); } } - if (!s->adu_mode) { - const uint8_t *ptr = s->gb.buffer + (get_bits_count(&s->gb)>>3); - assert((get_bits_count(&s->gb) & 7) == 0); - /* now we get bits from the main_data_begin offset */ - av_dlog(s->avctx, "seekback: %d\n", main_data_begin); -//av_log(NULL, AV_LOG_ERROR, "backstep:%d, lastbuf:%d\n", main_data_begin, s->last_buf_size); + if (!s->adu_mode) { + const uint8_t *ptr = s->gb.buffer + (get_bits_count(&s->gb)>>3); + assert((get_bits_count(&s->gb) & 7) == 0); + /* now we get bits from the main_data_begin offset */ + av_dlog(s->avctx, "seekback: %d\n", main_data_begin); + //av_log(NULL, AV_LOG_ERROR, "backstep:%d, lastbuf:%d\n", main_data_begin, s->last_buf_size); - memcpy(s->last_buf + s->last_buf_size, ptr, EXTRABYTES); - s->in_gb= s->gb; + memcpy(s->last_buf + s->last_buf_size, ptr, EXTRABYTES); + s->in_gb = s->gb; init_get_bits(&s->gb, s->last_buf, s->last_buf_size*8); skip_bits_long(&s->gb, 8*(s->last_buf_size - main_data_begin)); - } + } - for(gr=0;grnb_channels;ch++) { + for (gr = 0; gr < nb_granules; gr++) { + for (ch = 0; ch < s->nb_channels; ch++) { g = &s->granules[ch][gr]; - if(get_bits_count(&s->gb)<0){ + if (get_bits_count(&s->gb) < 0) { av_log(s->avctx, AV_LOG_DEBUG, "mdb:%d, lastbuf:%d skipping granule %d\n", - main_data_begin, s->last_buf_size, gr); + main_data_begin, s->last_buf_size, gr); skip_bits_long(&s->gb, g->part2_3_length); memset(g->sb_hybrid, 0, sizeof(g->sb_hybrid)); - if(get_bits_count(&s->gb) >= s->gb.size_in_bits && s->in_gb.buffer){ + if (get_bits_count(&s->gb) >= s->gb.size_in_bits && s->in_gb.buffer) { skip_bits_long(&s->in_gb, get_bits_count(&s->gb) - s->gb.size_in_bits); - s->gb= s->in_gb; - s->in_gb.buffer=NULL; + s->gb = s->in_gb; + s->in_gb.buffer = NULL; } continue; } @@ -1580,39 +1575,39 @@ if (g->block_type == 2) { n = g->switch_point ? 17 : 18; j = 0; - if(slen1){ - for(i=0;iscale_factors[j++] = get_bits(&s->gb, slen1); - }else{ - for(i=0;iscale_factors[j++] = 0; } - if(slen2){ - for(i=0;i<18;i++) + if (slen2) { + for (i = 0; i < 18; i++) g->scale_factors[j++] = get_bits(&s->gb, slen2); - for(i=0;i<3;i++) + for (i = 0; i < 3; i++) g->scale_factors[j++] = 0; - }else{ - for(i=0;i<21;i++) + } else { + for (i = 0; i < 21; i++) g->scale_factors[j++] = 0; } } else { sc = s->granules[ch][0].scale_factors; j = 0; - for(k=0;k<4;k++) { - n = (k == 0 ? 6 : 5); + for (k = 0; k < 4; k++) { + n = k == 0 ? 6 : 5; if ((g->scfsi & (0x8 >> k)) == 0) { slen = (k < 2) ? slen1 : slen2; - if(slen){ - for(i=0;iscale_factors[j++] = get_bits(&s->gb, slen); - }else{ - for(i=0;iscale_factors[j++] = 0; } } else { /* simply copy from last granule */ - for(i=0;iscale_factors[j] = sc[j]; j++; } @@ -1624,11 +1619,11 @@ int tindex, tindex2, slen[4], sl, sf; /* LSF scale factors */ - if (g->block_type == 2) { + if (g->block_type == 2) tindex = g->switch_point ? 2 : 1; - } else { + else tindex = 0; - } + sf = g->scalefac_compress; if ((s->mode_ext & MODE_EXT_I_STEREO) && ch == 1) { /* intensity stereo case */ @@ -1659,19 +1654,19 @@ } j = 0; - for(k=0;k<4;k++) { - n = lsf_nsf_table[tindex2][tindex][k]; + for (k = 0; k < 4; k++) { + n = lsf_nsf_table[tindex2][tindex][k]; sl = slen[k]; - if(sl){ - for(i=0;iscale_factors[j++] = get_bits(&s->gb, sl); - }else{ - for(i=0;iscale_factors[j++] = 0; } } /* XXX: should compute exact size */ - for(;j<40;j++) + for (; j < 40; j++) g->scale_factors[j] = 0; } @@ -1684,7 +1679,7 @@ if (s->nb_channels == 2) compute_stereo(s, &s->granules[0][gr], &s->granules[1][gr]); - for(ch=0;chnb_channels;ch++) { + for (ch = 0; ch < s->nb_channels; ch++) { g = &s->granules[ch][gr]; reorder_block(s, g); @@ -1692,18 +1687,18 @@ compute_imdct(s, g, &s->sb_samples[ch][18 * gr][0], s->mdct_buf[ch]); } } /* gr */ - if(get_bits_count(&s->gb)<0) + if (get_bits_count(&s->gb) < 0) skip_bits_long(&s->gb, -get_bits_count(&s->gb)); return nb_granules * 18; } -static int mp_decode_frame(MPADecodeContext *s, - OUT_INT *samples, const uint8_t *buf, int buf_size) +static int mp_decode_frame(MPADecodeContext *s, OUT_INT *samples, + const uint8_t *buf, int buf_size) { int i, nb_frames, ch; OUT_INT *samples_ptr; - init_get_bits(&s->gb, buf + HEADER_SIZE, (buf_size - HEADER_SIZE)*8); + init_get_bits(&s->gb, buf + HEADER_SIZE, (buf_size - HEADER_SIZE) * 8); /* skip error protection field */ if (s->error_protection) @@ -1724,28 +1719,28 @@ nb_frames = mp_decode_layer3(s); s->last_buf_size=0; - if(s->in_gb.buffer){ + if (s->in_gb.buffer) { align_get_bits(&s->gb); - i= get_bits_left(&s->gb)>>3; - if(i >= 0 && i <= BACKSTEP_SIZE){ + i = get_bits_left(&s->gb)>>3; + if (i >= 0 && i <= BACKSTEP_SIZE) { memmove(s->last_buf, s->gb.buffer + (get_bits_count(&s->gb)>>3), i); s->last_buf_size=i; - }else + } else av_log(s->avctx, AV_LOG_ERROR, "invalid old backstep %d\n", i); - s->gb= s->in_gb; - s->in_gb.buffer= NULL; + s->gb = s->in_gb; + s->in_gb.buffer = NULL; } align_get_bits(&s->gb); assert((get_bits_count(&s->gb) & 7) == 0); - i= get_bits_left(&s->gb)>>3; + i = get_bits_left(&s->gb) >> 3; - if(i<0 || i > BACKSTEP_SIZE || nb_frames<0){ - if(i<0) + if (i < 0 || i > BACKSTEP_SIZE || nb_frames < 0) { + if (i < 0) av_log(s->avctx, AV_LOG_ERROR, "invalid new backstep %d\n", i); - i= FFMIN(BACKSTEP_SIZE, buf_size - HEADER_SIZE); + i = FFMIN(BACKSTEP_SIZE, buf_size - HEADER_SIZE); } - assert(i <= buf_size - HEADER_SIZE && i>= 0); + assert(i <= buf_size - HEADER_SIZE && i >= 0); memcpy(s->last_buf + s->last_buf_size, s->gb.buffer + buf_size - HEADER_SIZE - i, i); s->last_buf_size += i; @@ -1753,9 +1748,9 @@ } /* apply the synthesis filter */ - for(ch=0;chnb_channels;ch++) { + for (ch = 0; ch < s->nb_channels; ch++) { samples_ptr = samples + ch; - for(i=0;impadsp, s->synth_buf[ch], &(s->synth_buf_offset[ch]), @@ -1769,74 +1764,80 @@ return nb_frames * 32 * sizeof(OUT_INT) * s->nb_channels; } -static int decode_frame(AVCodecContext * avctx, - void *data, int *data_size, +static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, AVPacket *avpkt) { - const uint8_t *buf = avpkt->data; - int buf_size = avpkt->size; + const uint8_t *buf = avpkt->data; + int buf_size = avpkt->size; MPADecodeContext *s = avctx->priv_data; uint32_t header; int out_size; OUT_INT *out_samples = data; - if(buf_size < HEADER_SIZE) - return -1; + if (buf_size < HEADER_SIZE) + return AVERROR_INVALIDDATA; header = AV_RB32(buf); - if(ff_mpa_check_header(header) < 0){ + if (ff_mpa_check_header(header) < 0) { av_log(avctx, AV_LOG_ERROR, "Header missing\n"); - return -1; + return AVERROR_INVALIDDATA; } - if (ff_mpegaudio_decode_header((MPADecodeHeader *)s, header) == 1) { + if (avpriv_mpegaudio_decode_header((MPADecodeHeader *)s, header) == 1) { /* free format: prepare to compute frame size */ s->frame_size = -1; - return -1; + return AVERROR_INVALIDDATA; } /* update codec info */ - avctx->channels = s->nb_channels; + avctx->channels = s->nb_channels; avctx->channel_layout = s->nb_channels == 1 ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO; if (!avctx->bit_rate) avctx->bit_rate = s->bit_rate; avctx->sub_id = s->layer; - if(*data_size < 1152*avctx->channels*sizeof(OUT_INT)) - return -1; + if (*data_size < avctx->frame_size * avctx->channels * sizeof(OUT_INT)) + return AVERROR(EINVAL); *data_size = 0; - if(s->frame_size<=0 || s->frame_size > buf_size){ + if (s->frame_size <= 0 || s->frame_size > buf_size) { av_log(avctx, AV_LOG_ERROR, "incomplete frame\n"); - return -1; + return AVERROR_INVALIDDATA; }else if(s->frame_size < buf_size){ av_log(avctx, AV_LOG_DEBUG, "incorrect frame size - multiple frames in buffer?\n"); buf_size= s->frame_size; } out_size = mp_decode_frame(s, out_samples, buf, buf_size); - if(out_size>=0){ - *data_size = out_size; + if (out_size >= 0) { + *data_size = out_size; avctx->sample_rate = s->sample_rate; //FIXME maybe move the other codec info stuff from above here too - }else - av_log(avctx, AV_LOG_DEBUG, "Error while decoding MPEG audio frame.\n"); //FIXME return -1 / but also return the number of bytes consumed + } else { + av_log(avctx, AV_LOG_ERROR, "Error while decoding MPEG audio frame.\n"); + /* Only return an error if the bad frame makes up the whole packet. + If there is more data in the packet, just consume the bad frame + instead of returning an error, which would discard the whole + packet. */ + if (buf_size == avpkt->size) + return out_size; + } s->frame_size = 0; return buf_size; } -static void flush(AVCodecContext *avctx){ +static void flush(AVCodecContext *avctx) +{ MPADecodeContext *s = avctx->priv_data; memset(s->synth_buf, 0, sizeof(s->synth_buf)); - s->last_buf_size= 0; + s->last_buf_size = 0; } #if CONFIG_MP3ADU_DECODER || CONFIG_MP3ADUFLOAT_DECODER -static int decode_frame_adu(AVCodecContext * avctx, - void *data, int *data_size, - AVPacket *avpkt) +static int decode_frame_adu(AVCodecContext *avctx, void *data, int *data_size, + AVPacket *avpkt) { - const uint8_t *buf = avpkt->data; - int buf_size = avpkt->size; + const uint8_t *buf = avpkt->data; + int buf_size = avpkt->size; MPADecodeContext *s = avctx->priv_data; uint32_t header; int len, out_size; @@ -1846,8 +1847,8 @@ // Discard too short frames if (buf_size < HEADER_SIZE) { - *data_size = 0; - return buf_size; + av_log(avctx, AV_LOG_ERROR, "Packet is too small\n"); + return AVERROR_INVALIDDATA; } @@ -1858,25 +1859,29 @@ header = AV_RB32(buf) | 0xffe00000; if (ff_mpa_check_header(header) < 0) { // Bad header, discard frame - *data_size = 0; - return buf_size; + av_log(avctx, AV_LOG_ERROR, "Invalid frame header\n"); + return AVERROR_INVALIDDATA; } - ff_mpegaudio_decode_header((MPADecodeHeader *)s, header); + avpriv_mpegaudio_decode_header((MPADecodeHeader *)s, header); /* update codec info */ avctx->sample_rate = s->sample_rate; - avctx->channels = s->nb_channels; + avctx->channels = s->nb_channels; if (!avctx->bit_rate) avctx->bit_rate = s->bit_rate; avctx->sub_id = s->layer; + if (*data_size < avctx->frame_size * avctx->channels * sizeof(OUT_INT)) + return AVERROR(EINVAL); + s->frame_size = len; - if (avctx->parse_only) { +#if FF_API_PARSE_FRAME + if (avctx->parse_only) out_size = buf_size; - } else { - out_size = mp_decode_frame(s, out_samples, buf, buf_size); - } + else +#endif + out_size = mp_decode_frame(s, out_samples, buf, buf_size); *data_size = out_size; return buf_size; @@ -1889,28 +1894,57 @@ * Context for MP3On4 decoder */ typedef struct MP3On4DecodeContext { - int frames; ///< number of mp3 frames per block (number of mp3 decoder instances) - int syncword; ///< syncword patch - const uint8_t *coff; ///< channels offsets in output buffer + int frames; ///< number of mp3 frames per block (number of mp3 decoder instances) + int syncword; ///< syncword patch + const uint8_t *coff; ///< channel offsets in output buffer MPADecodeContext *mp3decctx[5]; ///< MPADecodeContext for every decoder instance + OUT_INT *decoded_buf; ///< output buffer for decoded samples } MP3On4DecodeContext; #include "mpeg4audio.h" /* Next 3 arrays are indexed by channel config number (passed via codecdata) */ -static const uint8_t mp3Frames[8] = {0,1,1,2,3,3,4,5}; /* number of mp3 decoder instances */ -/* offsets into output buffer, assume output order is FL FR BL BR C LFE */ + +/* number of mp3 decoder instances */ +static const uint8_t mp3Frames[8] = { 0, 1, 1, 2, 3, 3, 4, 5 }; + +/* offsets into output buffer, assume output order is FL FR C LFE BL BR SL SR */ static const uint8_t chan_offset[8][5] = { - {0}, - {0}, // C - {0}, // FLR - {2,0}, // C FLR - {2,0,3}, // C FLR BS - {4,0,2}, // C FLR BLRS - {4,0,2,5}, // C FLR BLRS LFE - {4,0,2,6,5}, // C FLR BLRS BLR LFE + { 0 }, + { 0 }, // C + { 0 }, // FLR + { 2, 0 }, // C FLR + { 2, 0, 3 }, // C FLR BS + { 2, 0, 3 }, // C FLR BLRS + { 2, 0, 4, 3 }, // C FLR BLRS LFE + { 2, 0, 6, 4, 3 }, // C FLR BLRS BLR LFE }; +/* mp3on4 channel layouts */ +static const int16_t chan_layout[8] = { + 0, + AV_CH_LAYOUT_MONO, + AV_CH_LAYOUT_STEREO, + AV_CH_LAYOUT_SURROUND, + AV_CH_LAYOUT_4POINT0, + AV_CH_LAYOUT_5POINT0, + AV_CH_LAYOUT_5POINT1, + AV_CH_LAYOUT_7POINT1 +}; + +static av_cold int decode_close_mp3on4(AVCodecContext * avctx) +{ + MP3On4DecodeContext *s = avctx->priv_data; + int i; + + for (i = 0; i < s->frames; i++) + av_free(s->mp3decctx[i]); + + av_freep(&s->decoded_buf); + + return 0; +} + static int decode_init_mp3on4(AVCodecContext * avctx) { @@ -1920,17 +1954,18 @@ if ((avctx->extradata_size < 2) || (avctx->extradata == NULL)) { av_log(avctx, AV_LOG_ERROR, "Codec extradata missing or too short.\n"); - return -1; + return AVERROR_INVALIDDATA; } - ff_mpeg4audio_get_config(&cfg, avctx->extradata, avctx->extradata_size); + avpriv_mpeg4audio_get_config(&cfg, avctx->extradata, avctx->extradata_size); if (!cfg.chan_config || cfg.chan_config > 7) { av_log(avctx, AV_LOG_ERROR, "Invalid channel config number.\n"); - return -1; + return AVERROR_INVALIDDATA; } - s->frames = mp3Frames[cfg.chan_config]; - s->coff = chan_offset[cfg.chan_config]; - avctx->channels = ff_mpeg4audio_channels[cfg.chan_config]; + s->frames = mp3Frames[cfg.chan_config]; + s->coff = chan_offset[cfg.chan_config]; + avctx->channels = ff_mpeg4audio_channels[cfg.chan_config]; + avctx->channel_layout = chan_layout[cfg.chan_config]; if (cfg.sample_rate < 16000) s->syncword = 0xffe00000; @@ -1944,6 +1979,8 @@ */ // Allocate zeroed memory for the first decoder context s->mp3decctx[0] = av_mallocz(sizeof(MPADecodeContext)); + if (!s->mp3decctx[0]) + goto alloc_fail; // Put decoder context in place to make init_decode() happy avctx->priv_data = s->mp3decctx[0]; decode_init(avctx); @@ -1956,23 +1993,38 @@ */ for (i = 1; i < s->frames; i++) { s->mp3decctx[i] = av_mallocz(sizeof(MPADecodeContext)); + if (!s->mp3decctx[i]) + goto alloc_fail; s->mp3decctx[i]->adu_mode = 1; s->mp3decctx[i]->avctx = avctx; + s->mp3decctx[i]->mpadsp = s->mp3decctx[0]->mpadsp; + } + + /* Allocate buffer for multi-channel output if needed */ + if (s->frames > 1) { + s->decoded_buf = av_malloc(MPA_FRAME_SIZE * MPA_MAX_CHANNELS * + sizeof(*s->decoded_buf)); + if (!s->decoded_buf) + goto alloc_fail; } return 0; +alloc_fail: + decode_close_mp3on4(avctx); + return AVERROR(ENOMEM); } -static av_cold int decode_close_mp3on4(AVCodecContext * avctx) +static void flush_mp3on4(AVCodecContext *avctx) { - MP3On4DecodeContext *s = avctx->priv_data; int i; + MP3On4DecodeContext *s = avctx->priv_data; - for (i = 0; i < s->frames; i++) - av_free(s->mp3decctx[i]); - - return 0; + for (i = 0; i < s->frames; i++) { + MPADecodeContext *m = s->mp3decctx[i]; + memset(m->synth_buf, 0, sizeof(m->synth_buf)); + m->last_buf_size = 0; + } } @@ -1980,60 +2032,69 @@ void *data, int *data_size, AVPacket *avpkt) { - const uint8_t *buf = avpkt->data; - int buf_size = avpkt->size; + const uint8_t *buf = avpkt->data; + int buf_size = avpkt->size; MP3On4DecodeContext *s = avctx->priv_data; MPADecodeContext *m; int fsize, len = buf_size, out_size = 0; uint32_t header; OUT_INT *out_samples = data; - OUT_INT decoded_buf[MPA_FRAME_SIZE * MPA_MAX_CHANNELS]; OUT_INT *outptr, *bp; - int fr, j, n; + int fr, j, n, ch; - if(*data_size < MPA_FRAME_SIZE * MPA_MAX_CHANNELS * s->frames * sizeof(OUT_INT)) - return -1; + if (*data_size < MPA_FRAME_SIZE * avctx->channels * sizeof(OUT_INT)) { + av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n"); + return AVERROR(EINVAL); + } - *data_size = 0; // Discard too short frames if (buf_size < HEADER_SIZE) - return -1; + return AVERROR_INVALIDDATA; // If only one decoder interleave is not needed - outptr = s->frames == 1 ? out_samples : decoded_buf; + outptr = s->frames == 1 ? out_samples : s->decoded_buf; avctx->bit_rate = 0; + ch = 0; for (fr = 0; fr < s->frames; fr++) { fsize = AV_RB16(buf) >> 4; fsize = FFMIN3(fsize, len, MPA_MAX_CODED_FRAME_SIZE); - m = s->mp3decctx[fr]; - assert (m != NULL); + m = s->mp3decctx[fr]; + assert(m != NULL); header = (AV_RB32(buf) & 0x000fffff) | s->syncword; // patch header if (ff_mpa_check_header(header) < 0) // Bad header, discard block break; - ff_mpegaudio_decode_header((MPADecodeHeader *)m, header); + avpriv_mpegaudio_decode_header((MPADecodeHeader *)m, header); + + if (ch + m->nb_channels > avctx->channels) { + av_log(avctx, AV_LOG_ERROR, "frame channel count exceeds codec " + "channel count\n"); + return AVERROR_INVALIDDATA; + } + ch += m->nb_channels; + out_size += mp_decode_frame(m, outptr, buf, fsize); - buf += fsize; - len -= fsize; + buf += fsize; + len -= fsize; - if(s->frames > 1) { + if (s->frames > 1) { n = m->avctx->frame_size*m->nb_channels; /* interleave output data */ bp = out_samples + s->coff[fr]; - if(m->nb_channels == 1) { - for(j = 0; j < n; j++) { - *bp = decoded_buf[j]; + if (m->nb_channels == 1) { + for (j = 0; j < n; j++) { + *bp = s->decoded_buf[j]; bp += avctx->channels; } } else { - for(j = 0; j < n; j++) { - bp[0] = decoded_buf[j++]; - bp[1] = decoded_buf[j]; - bp += avctx->channels; + for (j = 0; j < n; j++) { + bp[0] = s->decoded_buf[j++]; + bp[1] = s->decoded_buf[j]; + bp += avctx->channels; } } } @@ -2057,7 +2118,9 @@ .priv_data_size = sizeof(MPADecodeContext), .init = decode_init, .decode = decode_frame, +#if FF_API_PARSE_FRAME .capabilities = CODEC_CAP_PARSE_ONLY, +#endif .flush = flush, .long_name = NULL_IF_CONFIG_SMALL("MP1 (MPEG audio layer 1)"), }; @@ -2070,7 +2133,9 @@ .priv_data_size = sizeof(MPADecodeContext), .init = decode_init, .decode = decode_frame, +#if FF_API_PARSE_FRAME .capabilities = CODEC_CAP_PARSE_ONLY, +#endif .flush = flush, .long_name = NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"), }; @@ -2083,7 +2148,9 @@ .priv_data_size = sizeof(MPADecodeContext), .init = decode_init, .decode = decode_frame, +#if FF_API_PARSE_FRAME .capabilities = CODEC_CAP_PARSE_ONLY, +#endif .flush = flush, .long_name = NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"), }; @@ -2096,7 +2163,9 @@ .priv_data_size = sizeof(MPADecodeContext), .init = decode_init, .decode = decode_frame_adu, +#if FF_API_PARSE_FRAME .capabilities = CODEC_CAP_PARSE_ONLY, +#endif .flush = flush, .long_name = NULL_IF_CONFIG_SMALL("ADU (Application Data Unit) MP3 (MPEG audio layer 3)"), }; @@ -2110,7 +2179,7 @@ .init = decode_init_mp3on4, .close = decode_close_mp3on4, .decode = decode_frame_mp3on4, - .flush = flush, + .flush = flush_mp3on4, .long_name = NULL_IF_CONFIG_SMALL("MP3onMP4"), }; #endif diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpegaudiodec_float.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpegaudiodec_float.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpegaudiodec_float.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpegaudiodec_float.c 2011-11-04 12:38:26.000000000 +0000 @@ -30,7 +30,9 @@ .priv_data_size = sizeof(MPADecodeContext), .init = decode_init, .decode = decode_frame, +#if FF_API_PARSE_FRAME .capabilities = CODEC_CAP_PARSE_ONLY, +#endif .flush = flush, .long_name = NULL_IF_CONFIG_SMALL("MP1 (MPEG audio layer 1)"), }; @@ -43,7 +45,9 @@ .priv_data_size = sizeof(MPADecodeContext), .init = decode_init, .decode = decode_frame, +#if FF_API_PARSE_FRAME .capabilities = CODEC_CAP_PARSE_ONLY, +#endif .flush = flush, .long_name = NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"), }; @@ -56,7 +60,9 @@ .priv_data_size = sizeof(MPADecodeContext), .init = decode_init, .decode = decode_frame, +#if FF_API_PARSE_FRAME .capabilities = CODEC_CAP_PARSE_ONLY, +#endif .flush = flush, .long_name = NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"), }; @@ -69,7 +75,9 @@ .priv_data_size = sizeof(MPADecodeContext), .init = decode_init, .decode = decode_frame_adu, +#if FF_API_PARSE_FRAME .capabilities = CODEC_CAP_PARSE_ONLY, +#endif .flush = flush, .long_name = NULL_IF_CONFIG_SMALL("ADU (Application Data Unit) MP3 (MPEG audio layer 3)"), }; @@ -83,7 +91,7 @@ .init = decode_init_mp3on4, .close = decode_close_mp3on4, .decode = decode_frame_mp3on4, - .flush = flush, + .flush = flush_mp3on4, .long_name = NULL_IF_CONFIG_SMALL("MP3onMP4"), }; #endif diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpegaudiodecheader.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpegaudiodecheader.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpegaudiodecheader.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpegaudiodecheader.c 2011-11-04 12:38:26.000000000 +0000 @@ -31,7 +31,7 @@ #include "mpegaudiodecheader.h" -int ff_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header) +int avpriv_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header) { int sample_rate, frame_size, mpeg25, padding; int sample_rate_index, bitrate_index; @@ -46,7 +46,7 @@ s->layer = 4 - ((header >> 17) & 3); /* extract frequency */ sample_rate_index = (header >> 10) & 3; - sample_rate = ff_mpa_freq_tab[sample_rate_index] >> (s->lsf + mpeg25); + sample_rate = avpriv_mpa_freq_tab[sample_rate_index] >> (s->lsf + mpeg25); sample_rate_index += 3 * (s->lsf + mpeg25); s->sample_rate_index = sample_rate_index; s->error_protection = ((header >> 16) & 1) ^ 1; @@ -67,7 +67,7 @@ s->nb_channels = 2; if (bitrate_index != 0) { - frame_size = ff_mpa_bitrate_tab[s->lsf][s->layer - 1][bitrate_index]; + frame_size = avpriv_mpa_bitrate_tab[s->lsf][s->layer - 1][bitrate_index]; s->bit_rate = frame_size * 1000; switch(s->layer) { case 1: @@ -109,14 +109,14 @@ return 0; } -int ff_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bit_rate) +int avpriv_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bit_rate) { MPADecodeHeader s1, *s = &s1; if (ff_mpa_check_header(head) != 0) return -1; - if (ff_mpegaudio_decode_header(s, head) != 0) { + if (avpriv_mpegaudio_decode_header(s, head) != 0) { return -1; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpegaudiodecheader.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpegaudiodecheader.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpegaudiodecheader.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpegaudiodecheader.h 2011-11-04 12:38:26.000000000 +0000 @@ -50,11 +50,11 @@ /* header decoding. MUST check the header before because no consistency check is done there. Return 1 if free format found and that the frame size must be computed externally */ -int ff_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header); +int avpriv_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header); /* useful helper to get mpeg audio stream infos. Return -1 if error in header, otherwise the coded frame size in bytes */ -int ff_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bitrate); +int avpriv_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bitrate); /* fast header check for resync */ static inline int ff_mpa_check_header(uint32_t header){ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpegaudioenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpegaudioenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpegaudioenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpegaudioenc.c 2011-11-04 12:38:26.000000000 +0000 @@ -84,9 +84,9 @@ /* encoding freq */ s->lsf = 0; for(i=0;i<3;i++) { - if (ff_mpa_freq_tab[i] == freq) + if (avpriv_mpa_freq_tab[i] == freq) break; - if ((ff_mpa_freq_tab[i] / 2) == freq) { + if ((avpriv_mpa_freq_tab[i] / 2) == freq) { s->lsf = 1; break; } @@ -99,7 +99,7 @@ /* encoding bitrate & frequency */ for(i=0;i<15;i++) { - if (ff_mpa_bitrate_tab[s->lsf][1][i] == bitrate) + if (avpriv_mpa_bitrate_tab[s->lsf][1][i] == bitrate) break; } if (i == 15){ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpegaudio_parser.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpegaudio_parser.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpegaudio_parser.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpegaudio_parser.c 2011-11-04 12:38:26.000000000 +0000 @@ -64,7 +64,7 @@ state= (state<<8) + buf[i++]; - ret = ff_mpa_decode_header(avctx, state, &sr, &channels, &frame_size, &bit_rate); + ret = avpriv_mpa_decode_header(avctx, state, &sr, &channels, &frame_size, &bit_rate); if (ret < 4) { if(i > 4) s->header_count= -2; @@ -101,9 +101,8 @@ AVCodecParser ff_mpegaudio_parser = { - { CODEC_ID_MP1, CODEC_ID_MP2, CODEC_ID_MP3 }, - sizeof(MpegAudioParseContext), - NULL, - mpegaudio_parse, - ff_parse_close, + .codec_ids = { CODEC_ID_MP1, CODEC_ID_MP2, CODEC_ID_MP3 }, + .priv_data_size = sizeof(MpegAudioParseContext), + .parser_parse = mpegaudio_parse, + .parser_close = ff_parse_close, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpegvideo.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpegvideo.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpegvideo.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpegvideo.c 2011-11-04 12:38:26.000000000 +0000 @@ -118,11 +118,12 @@ const enum PixelFormat ff_hwaccel_pixfmt_list_420[] = { PIX_FMT_DXVA2_VLD, PIX_FMT_VAAPI_VLD, + PIX_FMT_VDA_VLD, PIX_FMT_YUV420P, PIX_FMT_NONE }; -const uint8_t *ff_find_start_code(const uint8_t * restrict p, const uint8_t *end, uint32_t * restrict state){ +const uint8_t *avpriv_mpv_find_start_code(const uint8_t * restrict p, const uint8_t *end, uint32_t * restrict state){ int i; assert(p<=end); @@ -645,9 +646,8 @@ yc_size = y_size + 2 * c_size; /* convert fourcc to upper case */ - s->codec_tag = ff_toupper4(s->avctx->codec_tag); - - s->stream_codec_tag = ff_toupper4(s->avctx->stream_codec_tag); + s->codec_tag = avpriv_toupper4(s->avctx->codec_tag); + s->stream_codec_tag = avpriv_toupper4(s->avctx->stream_codec_tag); s->avctx->coded_frame= (AVFrame*)&s->current_picture; @@ -1132,6 +1132,12 @@ s->last_picture_ptr->f.key_frame = 0; if(ff_alloc_picture(s, s->last_picture_ptr, 0) < 0) return -1; + + if(s->codec_id == CODEC_ID_FLV1){ + for(i=0; iheight; i++) + memset(s->last_picture_ptr->f.data[0] + s->last_picture_ptr->f.linesize[0]*i, 16, s->width); + } + ff_thread_report_progress((AVFrame*)s->last_picture_ptr, INT_MAX, 0); ff_thread_report_progress((AVFrame*)s->last_picture_ptr, INT_MAX, 1); } @@ -2135,7 +2141,7 @@ /* decoding or more than one mb_type (MC was already done otherwise) */ if(!s->encoding){ - if(HAVE_PTHREADS && s->avctx->active_thread_type&FF_THREAD_FRAME) { + if(HAVE_THREADS && s->avctx->active_thread_type&FF_THREAD_FRAME) { if (s->mv_dir & MV_DIR_FORWARD) { ff_thread_await_progress((AVFrame*)s->last_picture_ptr, MPV_lowest_referenced_row(s, 0), 0); } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpegvideo_enc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpegvideo_enc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpegvideo_enc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpegvideo_enc.c 2011-11-04 12:38:26.000000000 +0000 @@ -2030,7 +2030,7 @@ int varc; int sum = s->dsp.pix_sum(pix, s->linesize); - varc = (s->dsp.pix_norm1(pix, s->linesize) - (((unsigned)(sum*sum))>>8) + 500 + 128)>>8; + varc = (s->dsp.pix_norm1(pix, s->linesize) - (((unsigned)sum*sum)>>8) + 500 + 128)>>8; s->current_picture.mb_var [s->mb_stride * mb_y + mb_x] = varc; s->current_picture.mb_mean[s->mb_stride * mb_y + mb_x] = (sum+128)>>8; @@ -2051,7 +2051,7 @@ ff_mjpeg_encode_stuffing(&s->pb); } - align_put_bits(&s->pb); + avpriv_align_put_bits(&s->pb); flush_put_bits(&s->pb); if((s->flags&CODEC_FLAG_PASS1) && !s->partitioned_frame) @@ -2492,18 +2492,18 @@ pb_bits_count= put_bits_count(&s->pb); flush_put_bits(&s->pb); - ff_copy_bits(&backup_s.pb, bit_buf[next_block^1], pb_bits_count); + avpriv_copy_bits(&backup_s.pb, bit_buf[next_block^1], pb_bits_count); s->pb= backup_s.pb; if(s->data_partitioning){ pb2_bits_count= put_bits_count(&s->pb2); flush_put_bits(&s->pb2); - ff_copy_bits(&backup_s.pb2, bit_buf2[next_block^1], pb2_bits_count); + avpriv_copy_bits(&backup_s.pb2, bit_buf2[next_block^1], pb2_bits_count); s->pb2= backup_s.pb2; tex_pb_bits_count= put_bits_count(&s->tex_pb); flush_put_bits(&s->tex_pb); - ff_copy_bits(&backup_s.tex_pb, bit_buf_tex[next_block^1], tex_pb_bits_count); + avpriv_copy_bits(&backup_s.tex_pb, bit_buf_tex[next_block^1], tex_pb_bits_count); s->tex_pb= backup_s.tex_pb; } s->last_bits= put_bits_count(&s->pb); @@ -2726,7 +2726,7 @@ assert(put_bits_count(&src->pb) % 8 ==0); assert(put_bits_count(&dst->pb) % 8 ==0); - ff_copy_bits(&dst->pb, src->pb.buf, put_bits_count(&src->pb)); + avpriv_copy_bits(&dst->pb, src->pb.buf, put_bits_count(&src->pb)); flush_put_bits(&dst->pb); } @@ -3825,8 +3825,8 @@ #define OFFSET(x) offsetof(MpegEncContext, x) #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM static const AVOption h263_options[] = { - { "obmc", "use overlapped block motion compensation.", OFFSET(obmc), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE }, - { "structured_slices","Write slice start position at every GOB header instead of just GOB number.", OFFSET(h263_slice_structured), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE}, + { "obmc", "use overlapped block motion compensation.", OFFSET(obmc), AV_OPT_TYPE_INT, { 0 }, 0, 1, VE }, + { "structured_slices","Write slice start position at every GOB header instead of just GOB number.", OFFSET(h263_slice_structured), AV_OPT_TYPE_INT, { 0 }, 0, 1, VE}, { NULL }, }; @@ -3851,10 +3851,10 @@ }; static const AVOption h263p_options[] = { - { "umv", "Use unlimited motion vectors.", OFFSET(umvplus), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE }, - { "aiv", "Use alternative inter VLC.", OFFSET(alt_inter_vlc), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE }, - { "obmc", "use overlapped block motion compensation.", OFFSET(obmc), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE }, - { "structured_slices", "Write slice start position at every GOB header instead of just GOB number.", OFFSET(h263_slice_structured), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE}, + { "umv", "Use unlimited motion vectors.", OFFSET(umvplus), AV_OPT_TYPE_INT, { 0 }, 0, 1, VE }, + { "aiv", "Use alternative inter VLC.", OFFSET(alt_inter_vlc), AV_OPT_TYPE_INT, { 0 }, 0, 1, VE }, + { "obmc", "use overlapped block motion compensation.", OFFSET(obmc), AV_OPT_TYPE_INT, { 0 }, 0, 1, VE }, + { "structured_slices", "Write slice start position at every GOB header instead of just GOB number.", OFFSET(h263_slice_structured), AV_OPT_TYPE_INT, { 0 }, 0, 1, VE}, { NULL }, }; static const AVClass h263p_class = { diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpegvideo.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpegvideo.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpegvideo.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpegvideo.h 2011-11-04 12:38:26.000000000 +0000 @@ -156,7 +156,7 @@ int best_bits; uint32_t *map; ///< map to avoid duplicate evaluations uint32_t *score_map; ///< map to store the scores - int map_generation; + unsigned map_generation; int pre_penalty_factor; int penalty_factor; /**< an estimate of the bits required to code a given mv value, e.g. (1,0) takes @@ -236,7 +236,6 @@ int coded_picture_number; ///< used to set pic->coded_picture_number, should not be used for/by anything else int picture_number; //FIXME remove, unclear definition int picture_in_gop_number; ///< 0-> first pic in gop, ... - int b_frames_since_non_b; ///< used for encoding, relative to not yet reordered input int mb_width, mb_height; ///< number of MBs horizontally & vertically int mb_stride; ///< mb_width+1 used for some arrays to allow simple addressing of left & top MBs without sig11 int b8_stride; ///< 2*mb_width+1 used for some 8x8 block arrays to allow simple addressing @@ -305,7 +304,6 @@ int last_dc[3]; ///< last DC values for MPEG1 int16_t *dc_val_base; int16_t *dc_val[3]; ///< used for mpeg4 DC prediction, all 3 arrays must be continuous - int16_t dc_cache[4*5]; const uint8_t *y_dc_scale_table; ///< qscale -> y_dc_scale table const uint8_t *c_dc_scale_table; ///< qscale -> c_dc_scale table const uint8_t *chroma_qscale_table; ///< qscale -> chroma_qscale (h263) @@ -345,7 +343,6 @@ /* motion compensation */ int unrestricted_mv; ///< mv can point outside of the coded picture int h263_long_vectors; ///< use horrible h263v1 long vector mode - int decode; ///< if 0 then decoding will be skipped (for encoding b frames for example) DSPContext dsp; ///< pointers for accelerated dsp functions int f_code; ///< forward MV resolution @@ -440,7 +437,6 @@ uint8_t *inter_ac_vlc_length; uint8_t *inter_ac_vlc_last_length; uint8_t *luma_dc_vlc_length; - uint8_t *chroma_dc_vlc_length; #define UNI_AC_ENC_INDEX(run,level) ((run)*128 + (level)) int coded_score[8]; @@ -462,7 +458,6 @@ void *opaque; ///< private data for the user /* bit rate control */ - int64_t wanted_bits; int64_t total_bits; int frame_bits; ///< bits used for the current frame int next_lambda; ///< next lambda used for retrying to encode a frame @@ -725,7 +720,7 @@ int MPV_lowest_referenced_row(MpegEncContext *s, int dir); void MPV_report_decode_progress(MpegEncContext *s); int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src); -const uint8_t *ff_find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state); +const uint8_t *avpriv_mpv_find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state); void ff_set_qscale(MpegEncContext * s, int qscale); void ff_er_frame_start(MpegEncContext *s); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpegvideo_parser.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpegvideo_parser.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mpegvideo_parser.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mpegvideo_parser.c 2011-11-04 12:38:26.000000000 +0000 @@ -40,7 +40,7 @@ while (buf < buf_end) { start_code= -1; - buf= ff_find_start_code(buf, buf_end, &start_code); + buf= avpriv_mpv_find_start_code(buf, buf_end, &start_code); bytes_left = buf_end - buf; switch(start_code) { case PICTURE_START_CODE: @@ -57,8 +57,8 @@ did_set_size=1; } frame_rate_index = buf[3] & 0xf; - pc->frame_rate.den = avctx->time_base.den = ff_frame_rate_tab[frame_rate_index].num; - pc->frame_rate.num = avctx->time_base.num = ff_frame_rate_tab[frame_rate_index].den; + pc->frame_rate.den = avctx->time_base.den = avpriv_frame_rate_tab[frame_rate_index].num; + pc->frame_rate.num = avctx->time_base.num = avpriv_frame_rate_tab[frame_rate_index].den; avctx->bit_rate = ((buf[4]<<10) | (buf[5]<<2) | (buf[6]>>6))*400; avctx->codec_id = CODEC_ID_MPEG1VIDEO; avctx->sub_id = 1; @@ -164,20 +164,22 @@ { int i; uint32_t state= -1; + int found=0; for(i=0; i= 0x100) + if(state == 0x1B3){ + found=1; + }else if(found && state != 0x1B5 && state < 0x200 && state >= 0x100) return i-3; } return 0; } AVCodecParser ff_mpegvideo_parser = { - { CODEC_ID_MPEG1VIDEO, CODEC_ID_MPEG2VIDEO }, - sizeof(ParseContext1), - NULL, - mpegvideo_parse, - ff_parse1_close, - mpegvideo_split, + .codec_ids = { CODEC_ID_MPEG1VIDEO, CODEC_ID_MPEG2VIDEO }, + .priv_data_size = sizeof(ParseContext1), + .parser_parse = mpegvideo_parse, + .parser_close = ff_parse1_close, + .split = mpegvideo_split, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/msmpeg4.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/msmpeg4.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/msmpeg4.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/msmpeg4.c 2011-11-04 12:38:26.000000000 +0000 @@ -1,5 +1,5 @@ /* - * MSMPEG4 backend for ffmpeg encoder and decoder + * MSMPEG4 backend for encoder and decoder * Copyright (c) 2001 Fabrice Bellard * Copyright (c) 2002-2004 Michael Niedermayer * @@ -24,7 +24,7 @@ /** * @file - * MSMPEG4 backend for ffmpeg encoder and decoder. + * MSMPEG4 backend for encoder and decoder */ #include "avcodec.h" @@ -351,7 +351,7 @@ { find_best_tables(s); - align_put_bits(&s->pb); + avpriv_align_put_bits(&s->pb); put_bits(&s->pb, 2, s->pict_type - 1); put_bits(&s->pb, 5, s->qscale); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/msmpeg4data.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/msmpeg4data.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/msmpeg4data.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/msmpeg4data.c 2011-11-04 12:38:26.000000000 +0000 @@ -1,5 +1,5 @@ /* - * MSMPEG4 backend for ffmpeg encoder and decoder + * MSMPEG4 backend for encoder and decoder * copyright (c) 2001 Fabrice Bellard * copyright (c) 2002-2004 Michael Niedermayer * diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/msmpeg4data.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/msmpeg4data.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/msmpeg4data.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/msmpeg4data.h 2011-11-04 12:38:26.000000000 +0000 @@ -1,5 +1,5 @@ /* - * MSMPEG4 backend for ffmpeg encoder and decoder + * MSMPEG4 backend for encoder and decoder * copyright (c) 2001 Fabrice Bellard * copyright (c) 2002-2004 Michael Niedermayer * diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/msmpeg4.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/msmpeg4.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/msmpeg4.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/msmpeg4.h 2011-11-04 12:38:26.000000000 +0000 @@ -1,5 +1,5 @@ /* - * MSMPEG4 backend for ffmpeg encoder and decoder + * MSMPEG4 backend for encoder and decoder * copyright (c) 2007 Aurelien Jacobs * * This file is part of FFmpeg. diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mxpegdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mxpegdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/mxpegdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/mxpegdec.c 2011-11-04 12:38:26.000000000 +0000 @@ -275,11 +275,11 @@ } ret = ff_mjpeg_decode_sos(jpg, s->mxm_bitmask, reference_ptr); - if (ret < 0 && avctx->error_recognition >= FF_ER_EXPLODE) + if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE)) return ret; } else { ret = ff_mjpeg_decode_sos(jpg, NULL, NULL); - if (ret < 0 && avctx->error_recognition >= FF_ER_EXPLODE) + if (ret < 0 && (avctx->err_recognition & AV_EF_EXPLODE)) return ret; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/nellymoserdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/nellymoserdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/nellymoserdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/nellymoserdec.c 2011-11-04 12:38:26.000000000 +0000 @@ -48,7 +48,7 @@ typedef struct NellyMoserDecodeContext { AVCodecContext* avctx; float *float_buf; - float state[NELLY_BUF_LEN]; + DECLARE_ALIGNED(16, float, state)[NELLY_BUF_LEN]; AVLFG random_state; GetBitContext gb; float scale_bias; @@ -58,23 +58,6 @@ DECLARE_ALIGNED(32, float, imdct_out)[NELLY_BUF_LEN * 2]; } NellyMoserDecodeContext; -static void overlap_and_window(NellyMoserDecodeContext *s, float *state, float *audio, float *a_in) -{ - int bot, top; - - bot = 0; - top = NELLY_BUF_LEN-1; - - while (bot < NELLY_BUF_LEN) { - audio[bot] = a_in [bot]*ff_sine_128[bot] - +state[bot]*ff_sine_128[top]; - - bot++; - top--; - } - memcpy(state, a_in + NELLY_BUF_LEN, sizeof(float)*NELLY_BUF_LEN); -} - static void nelly_decode_block(NellyMoserDecodeContext *s, const unsigned char block[NELLY_BLOCK_LEN], float audio[NELLY_SAMPLES]) @@ -125,7 +108,9 @@ s->imdct_ctx.imdct_calc(&s->imdct_ctx, s->imdct_out, aptr); /* XXX: overlapping and windowing should be part of a more generic imdct function */ - overlap_and_window(s, s->state, aptr, s->imdct_out); + s->dsp.vector_fmul_reverse(s->state, s->state, ff_sine_128, NELLY_BUF_LEN); + s->dsp.vector_fmul_add(aptr, s->imdct_out, ff_sine_128, s->state, NELLY_BUF_LEN); + memcpy(s->state, s->imdct_out + NELLY_BUF_LEN, sizeof(float)*NELLY_BUF_LEN); } } @@ -172,20 +157,21 @@ float *samples_flt = data; *data_size = 0; - if (buf_size < avctx->block_align) { - return buf_size; - } - - if (buf_size % NELLY_BLOCK_LEN) { - av_log(avctx, AV_LOG_ERROR, "Tag size %d.\n", buf_size); - return buf_size; - } block_size = NELLY_SAMPLES * av_get_bytes_per_sample(avctx->sample_fmt); - blocks = FFMIN(buf_size / NELLY_BLOCK_LEN, data_max / block_size); + blocks = buf_size / NELLY_BLOCK_LEN; + if (blocks <= 0) { + av_log(avctx, AV_LOG_ERROR, "Packet is too small\n"); + return AVERROR_INVALIDDATA; + } + if (data_max < blocks * block_size) { av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); return AVERROR(EINVAL); } + if (buf_size % NELLY_BLOCK_LEN) { + av_log(avctx, AV_LOG_WARNING, "Leftover bytes: %d.\n", + buf_size % NELLY_BLOCK_LEN); + } /* Normal numbers of blocks for sample rates: * 8000 Hz - 1 * 11025 Hz - 2 diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/nellymoserenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/nellymoserenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/nellymoserenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/nellymoserenc.c 2011-11-04 12:38:26.000000000 +0000 @@ -146,7 +146,7 @@ avctx->frame_size = NELLY_SAMPLES; s->avctx = avctx; - ff_mdct_init(&s->mdct_ctx, 8, 0, 1.0); + ff_mdct_init(&s->mdct_ctx, 8, 0, 32768.0); dsputil_init(&s->dsp, avctx); /* Generate overlap window */ @@ -352,17 +352,15 @@ static int encode_frame(AVCodecContext *avctx, uint8_t *frame, int buf_size, void *data) { NellyMoserEncodeContext *s = avctx->priv_data; - const int16_t *samples = data; + const float *samples = data; int i; if (s->last_frame) return 0; if (data) { - for (i = 0; i < avctx->frame_size; i++) { - s->buf[s->bufsel][i] = samples[i]; - } - for (; i < NELLY_SAMPLES; i++) { + memcpy(s->buf[s->bufsel], samples, avctx->frame_size * sizeof(*samples)); + for (i = avctx->frame_size; i < NELLY_SAMPLES; i++) { s->buf[s->bufsel][i] = 0; } s->bufsel = 1 - s->bufsel; @@ -393,5 +391,5 @@ .close = encode_end, .capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY, .long_name = NULL_IF_CONFIG_SMALL("Nellymoser Asao"), - .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, + .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_FLT,AV_SAMPLE_FMT_NONE}, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/options.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/options.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/options.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/options.c 2011-11-04 12:38:26.000000000 +0000 @@ -39,22 +39,27 @@ return "NULL"; } -static const AVOption *opt_find(void *obj, const char *name, const char *unit, int opt_flags, int search_flags) +static void *codec_child_next(void *obj, void *prev) { AVCodecContext *s = obj; - AVCodec *c = NULL; + if (!prev && s->codec && s->codec->priv_class && s->priv_data) + return s->priv_data; + return NULL; +} - if (!(search_flags & AV_OPT_SEARCH_FAKE_OBJ) && s->priv_data) { - if (s->codec && s->codec->priv_class) - return av_opt_find(s->priv_data, name, unit, opt_flags, search_flags); - return NULL; - } +static const AVClass *codec_child_class_next(const AVClass *prev) +{ + AVCodec *c = NULL; - while ((c = av_codec_next(c))) { - const AVOption *o; - if (c->priv_class && (o = av_opt_find(&c->priv_class, name, unit, opt_flags, search_flags))) - return o; - } + /* find the codec that corresponds to prev */ + while (prev && (c = av_codec_next(c))) + if (c->priv_class == prev) + break; + + /* find next codec with priv options */ + while (c = av_codec_next(c)) + if (c->priv_class) + return c->priv_class; return NULL; } @@ -70,443 +75,448 @@ #define AV_CODEC_DEFAULT_BITRATE 200*1000 static const AVOption options[]={ -{"b", "set bitrate (in bits/s)", OFFSET(bit_rate), FF_OPT_TYPE_INT, {.dbl = AV_CODEC_DEFAULT_BITRATE }, INT_MIN, INT_MAX, A|V|E}, -{"ab", "set bitrate (in bits/s)", OFFSET(bit_rate), FF_OPT_TYPE_INT, {.dbl = 128*1000 }, INT_MIN, INT_MAX, A|E}, -{"bt", "set video bitrate tolerance (in bits/s)", OFFSET(bit_rate_tolerance), FF_OPT_TYPE_INT, {.dbl = AV_CODEC_DEFAULT_BITRATE*20 }, 1, INT_MAX, V|E}, -{"flags", NULL, OFFSET(flags), FF_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, 0, UINT_MAX, V|A|E|D, "flags"}, -{"mv4", "use four motion vector by macroblock (mpeg4)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_4MV }, INT_MIN, INT_MAX, V|E, "flags"}, +{"b", "set bitrate (in bits/s)", OFFSET(bit_rate), AV_OPT_TYPE_INT, {.dbl = AV_CODEC_DEFAULT_BITRATE }, INT_MIN, INT_MAX, A|V|E}, +{"ab", "set bitrate (in bits/s)", OFFSET(bit_rate), AV_OPT_TYPE_INT, {.dbl = 128*1000 }, INT_MIN, INT_MAX, A|E}, +{"bt", "set video bitrate tolerance (in bits/s)", OFFSET(bit_rate_tolerance), AV_OPT_TYPE_INT, {.dbl = AV_CODEC_DEFAULT_BITRATE*20 }, 1, INT_MAX, V|E}, +{"flags", NULL, OFFSET(flags), AV_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, 0, UINT_MAX, V|A|E|D, "flags"}, +{"mv4", "use four motion vector by macroblock (mpeg4)", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_4MV }, INT_MIN, INT_MAX, V|E, "flags"}, #if FF_API_MPEGVIDEO_GLOBAL_OPTS -{"obmc", "use overlapped block motion compensation (h263+)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_OBMC }, INT_MIN, INT_MAX, V|E, "flags"}, +{"obmc", "use overlapped block motion compensation (h263+)", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_OBMC }, INT_MIN, INT_MAX, V|E, "flags"}, #endif -{"qpel", "use 1/4 pel motion compensation", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_QPEL }, INT_MIN, INT_MAX, V|E, "flags"}, -{"loop", "use loop filter", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_LOOP_FILTER }, INT_MIN, INT_MAX, V|E, "flags"}, -{"qscale", "use fixed qscale", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_QSCALE }, INT_MIN, INT_MAX, 0, "flags"}, -{"gmc", "use gmc", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_GMC }, INT_MIN, INT_MAX, V|E, "flags"}, -{"mv0", "always try a mb with mv=<0,0>", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_MV0 }, INT_MIN, INT_MAX, V|E, "flags"}, +{"qpel", "use 1/4 pel motion compensation", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_QPEL }, INT_MIN, INT_MAX, V|E, "flags"}, +{"loop", "use loop filter", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_LOOP_FILTER }, INT_MIN, INT_MAX, V|E, "flags"}, +{"qscale", "use fixed qscale", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_QSCALE }, INT_MIN, INT_MAX, 0, "flags"}, +{"gmc", "use gmc", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_GMC }, INT_MIN, INT_MAX, V|E, "flags"}, +{"mv0", "always try a mb with mv=<0,0>", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_MV0 }, INT_MIN, INT_MAX, V|E, "flags"}, #if FF_API_MPEGVIDEO_GLOBAL_OPTS -{"part", "use data partitioning", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_PART }, INT_MIN, INT_MAX, V|E, "flags"}, +{"part", "use data partitioning", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_PART }, INT_MIN, INT_MAX, V|E, "flags"}, #endif -{"input_preserved", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_INPUT_PRESERVED }, INT_MIN, INT_MAX, 0, "flags"}, -{"pass1", "use internal 2pass ratecontrol in first pass mode", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_PASS1 }, INT_MIN, INT_MAX, 0, "flags"}, -{"pass2", "use internal 2pass ratecontrol in second pass mode", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_PASS2 }, INT_MIN, INT_MAX, 0, "flags"}, +{"input_preserved", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_INPUT_PRESERVED }, INT_MIN, INT_MAX, 0, "flags"}, +{"pass1", "use internal 2pass ratecontrol in first pass mode", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_PASS1 }, INT_MIN, INT_MAX, 0, "flags"}, +{"pass2", "use internal 2pass ratecontrol in second pass mode", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_PASS2 }, INT_MIN, INT_MAX, 0, "flags"}, #if FF_API_MJPEG_GLOBAL_OPTS -{"extern_huff", "use external huffman table (for mjpeg)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_EXTERN_HUFF }, INT_MIN, INT_MAX, 0, "flags"}, +{"extern_huff", "use external huffman table (for mjpeg)", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_EXTERN_HUFF }, INT_MIN, INT_MAX, 0, "flags"}, #endif -{"gray", "only decode/encode grayscale", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_GRAY }, INT_MIN, INT_MAX, V|E|D, "flags"}, -{"emu_edge", "don't draw edges", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_EMU_EDGE }, INT_MIN, INT_MAX, 0, "flags"}, -{"psnr", "error[?] variables will be set during encoding", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_PSNR }, INT_MIN, INT_MAX, V|E, "flags"}, -{"truncated", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_TRUNCATED }, INT_MIN, INT_MAX, 0, "flags"}, -{"naq", "normalize adaptive quantization", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_NORMALIZE_AQP }, INT_MIN, INT_MAX, V|E, "flags"}, -{"ildct", "use interlaced dct", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_INTERLACED_DCT }, INT_MIN, INT_MAX, V|E, "flags"}, -{"low_delay", "force low delay", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_LOW_DELAY }, INT_MIN, INT_MAX, V|D|E, "flags"}, +{"gray", "only decode/encode grayscale", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_GRAY }, INT_MIN, INT_MAX, V|E|D, "flags"}, +{"emu_edge", "don't draw edges", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_EMU_EDGE }, INT_MIN, INT_MAX, 0, "flags"}, +{"psnr", "error[?] variables will be set during encoding", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_PSNR }, INT_MIN, INT_MAX, V|E, "flags"}, +{"truncated", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_TRUNCATED }, INT_MIN, INT_MAX, 0, "flags"}, +{"naq", "normalize adaptive quantization", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_NORMALIZE_AQP }, INT_MIN, INT_MAX, V|E, "flags"}, +{"ildct", "use interlaced dct", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_INTERLACED_DCT }, INT_MIN, INT_MAX, V|E, "flags"}, +{"low_delay", "force low delay", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_LOW_DELAY }, INT_MIN, INT_MAX, V|D|E, "flags"}, #if FF_API_MPEGVIDEO_GLOBAL_OPTS -{"alt", "enable alternate scantable (mpeg2/mpeg4)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_ALT_SCAN }, INT_MIN, INT_MAX, V|E, "flags"}, +{"alt", "enable alternate scantable (mpeg2/mpeg4)", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_ALT_SCAN }, INT_MIN, INT_MAX, V|E, "flags"}, #endif -{"global_header", "place global headers in extradata instead of every keyframe", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_GLOBAL_HEADER }, INT_MIN, INT_MAX, V|A|E, "flags"}, -{"bitexact", "use only bitexact stuff (except (i)dct)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_BITEXACT }, INT_MIN, INT_MAX, A|V|S|D|E, "flags"}, -{"aic", "h263 advanced intra coding / mpeg4 ac prediction", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_AC_PRED }, INT_MIN, INT_MAX, V|E, "flags"}, +{"global_header", "place global headers in extradata instead of every keyframe", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_GLOBAL_HEADER }, INT_MIN, INT_MAX, V|A|E, "flags"}, +{"bitexact", "use only bitexact stuff (except (i)dct)", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_BITEXACT }, INT_MIN, INT_MAX, A|V|S|D|E, "flags"}, +{"aic", "h263 advanced intra coding / mpeg4 ac prediction", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_AC_PRED }, INT_MIN, INT_MAX, V|E, "flags"}, #if FF_API_MPEGVIDEO_GLOBAL_OPTS -{"umv", "use unlimited motion vectors", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_H263P_UMV }, INT_MIN, INT_MAX, V|E, "flags"}, +{"umv", "use unlimited motion vectors", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_H263P_UMV }, INT_MIN, INT_MAX, V|E, "flags"}, #endif -{"cbp", "use rate distortion optimization for cbp", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_CBP_RD }, INT_MIN, INT_MAX, V|E, "flags"}, -{"qprd", "use rate distortion optimization for qp selection", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_QP_RD }, INT_MIN, INT_MAX, V|E, "flags"}, +{"cbp", "use rate distortion optimization for cbp", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_CBP_RD }, INT_MIN, INT_MAX, V|E, "flags"}, +{"qprd", "use rate distortion optimization for qp selection", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_QP_RD }, INT_MIN, INT_MAX, V|E, "flags"}, #if FF_API_MPEGVIDEO_GLOBAL_OPTS -{"aiv", "h263 alternative inter vlc", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_H263P_AIV }, INT_MIN, INT_MAX, V|E, "flags"}, -{"slice", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_H263P_SLICE_STRUCT }, INT_MIN, INT_MAX, V|E, "flags"}, +{"aiv", "h263 alternative inter vlc", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_H263P_AIV }, INT_MIN, INT_MAX, V|E, "flags"}, +{"slice", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_H263P_SLICE_STRUCT }, INT_MIN, INT_MAX, V|E, "flags"}, #endif -{"ilme", "interlaced motion estimation", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_INTERLACED_ME }, INT_MIN, INT_MAX, V|E, "flags"}, +{"ilme", "interlaced motion estimation", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_INTERLACED_ME }, INT_MIN, INT_MAX, V|E, "flags"}, #if FF_API_MPEGVIDEO_GLOBAL_OPTS -{"scan_offset", "will reserve space for svcd scan offset user data", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_SVCD_SCAN_OFFSET }, INT_MIN, INT_MAX, V|E, "flags"}, +{"scan_offset", "will reserve space for svcd scan offset user data", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_SVCD_SCAN_OFFSET }, INT_MIN, INT_MAX, V|E, "flags"}, #endif -{"cgop", "closed gop", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_CLOSED_GOP }, INT_MIN, INT_MAX, V|E, "flags"}, -{"fast", "allow non spec compliant speedup tricks", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_FAST }, INT_MIN, INT_MAX, V|E, "flags2"}, -{"sgop", "strictly enforce gop size", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_STRICT_GOP }, INT_MIN, INT_MAX, V|E, "flags2"}, -{"noout", "skip bitstream encoding", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_NO_OUTPUT }, INT_MIN, INT_MAX, V|E, "flags2"}, -{"local_header", "place global headers at every keyframe instead of in extradata", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_LOCAL_HEADER }, INT_MIN, INT_MAX, V|E, "flags2"}, -{"showall", "Show all frames before the first keyframe", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_SHOW_ALL }, INT_MIN, INT_MAX, V|D, "flags2"}, -{"sub_id", NULL, OFFSET(sub_id), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, -{"me_method", "set motion estimation method", OFFSET(me_method), FF_OPT_TYPE_INT, {.dbl = ME_EPZS }, INT_MIN, INT_MAX, V|E, "me_method"}, -{"zero", "zero motion estimation (fastest)", 0, FF_OPT_TYPE_CONST, {.dbl = ME_ZERO }, INT_MIN, INT_MAX, V|E, "me_method" }, -{"full", "full motion estimation (slowest)", 0, FF_OPT_TYPE_CONST, {.dbl = ME_FULL }, INT_MIN, INT_MAX, V|E, "me_method" }, -{"epzs", "EPZS motion estimation (default)", 0, FF_OPT_TYPE_CONST, {.dbl = ME_EPZS }, INT_MIN, INT_MAX, V|E, "me_method" }, -{"esa", "esa motion estimation (alias for full)", 0, FF_OPT_TYPE_CONST, {.dbl = ME_FULL }, INT_MIN, INT_MAX, V|E, "me_method" }, -{"tesa", "tesa motion estimation", 0, FF_OPT_TYPE_CONST, {.dbl = ME_TESA }, INT_MIN, INT_MAX, V|E, "me_method" }, -{"dia", "dia motion estimation (alias for epzs)", 0, FF_OPT_TYPE_CONST, {.dbl = ME_EPZS }, INT_MIN, INT_MAX, V|E, "me_method" }, -{"log", "log motion estimation", 0, FF_OPT_TYPE_CONST, {.dbl = ME_LOG }, INT_MIN, INT_MAX, V|E, "me_method" }, -{"phods", "phods motion estimation", 0, FF_OPT_TYPE_CONST, {.dbl = ME_PHODS }, INT_MIN, INT_MAX, V|E, "me_method" }, -{"x1", "X1 motion estimation", 0, FF_OPT_TYPE_CONST, {.dbl = ME_X1 }, INT_MIN, INT_MAX, V|E, "me_method" }, -{"hex", "hex motion estimation", 0, FF_OPT_TYPE_CONST, {.dbl = ME_HEX }, INT_MIN, INT_MAX, V|E, "me_method" }, -{"umh", "umh motion estimation", 0, FF_OPT_TYPE_CONST, {.dbl = ME_UMH }, INT_MIN, INT_MAX, V|E, "me_method" }, -{"iter", "iter motion estimation", 0, FF_OPT_TYPE_CONST, {.dbl = ME_ITER }, INT_MIN, INT_MAX, V|E, "me_method" }, -{"extradata_size", NULL, OFFSET(extradata_size), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, -{"time_base", NULL, OFFSET(time_base), FF_OPT_TYPE_RATIONAL, {.dbl = 0}, INT_MIN, INT_MAX}, -{"g", "set the group of picture size", OFFSET(gop_size), FF_OPT_TYPE_INT, {.dbl = 12 }, INT_MIN, INT_MAX, V|E}, -{"ar", "set audio sampling rate (in Hz)", OFFSET(sample_rate), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, A|D|E}, -{"ac", "set number of audio channels", OFFSET(channels), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, A|D|E}, -{"cutoff", "set cutoff bandwidth", OFFSET(cutoff), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, A|E}, -{"frame_size", NULL, OFFSET(frame_size), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, A|E}, -{"frame_number", NULL, OFFSET(frame_number), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, -{"delay", NULL, OFFSET(delay), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, -{"qcomp", "video quantizer scale compression (VBR)", OFFSET(qcompress), FF_OPT_TYPE_FLOAT, {.dbl = 0.5 }, -FLT_MAX, FLT_MAX, V|E}, -{"qblur", "video quantizer scale blur (VBR)", OFFSET(qblur), FF_OPT_TYPE_FLOAT, {.dbl = 0.5 }, -1, FLT_MAX, V|E}, -{"qmin", "min video quantizer scale (VBR)", OFFSET(qmin), FF_OPT_TYPE_INT, {.dbl = 2 }, -1, 69, V|E}, -{"qmax", "max video quantizer scale (VBR)", OFFSET(qmax), FF_OPT_TYPE_INT, {.dbl = 31 }, -1, 69, V|E}, -{"qdiff", "max difference between the quantizer scale (VBR)", OFFSET(max_qdiff), FF_OPT_TYPE_INT, {.dbl = 3 }, INT_MIN, INT_MAX, V|E}, -{"bf", "use 'frames' B frames", OFFSET(max_b_frames), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, -1, FF_MAX_B_FRAMES, V|E}, -{"b_qfactor", "qp factor between p and b frames", OFFSET(b_quant_factor), FF_OPT_TYPE_FLOAT, {.dbl = 1.25 }, -FLT_MAX, FLT_MAX, V|E}, -{"rc_strategy", "ratecontrol method", OFFSET(rc_strategy), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, -{"b_strategy", "strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), FF_OPT_TYPE_INT, {.dbl = 0 }, INT_MIN, INT_MAX, V|E}, +{"cgop", "closed gop", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG_CLOSED_GOP }, INT_MIN, INT_MAX, V|E, "flags"}, +{"fast", "allow non spec compliant speedup tricks", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_FAST }, INT_MIN, INT_MAX, V|E, "flags2"}, +{"sgop", "strictly enforce gop size", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_STRICT_GOP }, INT_MIN, INT_MAX, V|E, "flags2"}, +{"noout", "skip bitstream encoding", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_NO_OUTPUT }, INT_MIN, INT_MAX, V|E, "flags2"}, +{"local_header", "place global headers at every keyframe instead of in extradata", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_LOCAL_HEADER }, INT_MIN, INT_MAX, V|E, "flags2"}, +{"showall", "Show all frames before the first keyframe", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_SHOW_ALL }, INT_MIN, INT_MAX, V|D, "flags2"}, +{"sub_id", NULL, OFFSET(sub_id), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, +{"me_method", "set motion estimation method", OFFSET(me_method), AV_OPT_TYPE_INT, {.dbl = ME_EPZS }, INT_MIN, INT_MAX, V|E, "me_method"}, +{"zero", "zero motion estimation (fastest)", 0, AV_OPT_TYPE_CONST, {.dbl = ME_ZERO }, INT_MIN, INT_MAX, V|E, "me_method" }, +{"full", "full motion estimation (slowest)", 0, AV_OPT_TYPE_CONST, {.dbl = ME_FULL }, INT_MIN, INT_MAX, V|E, "me_method" }, +{"epzs", "EPZS motion estimation (default)", 0, AV_OPT_TYPE_CONST, {.dbl = ME_EPZS }, INT_MIN, INT_MAX, V|E, "me_method" }, +{"esa", "esa motion estimation (alias for full)", 0, AV_OPT_TYPE_CONST, {.dbl = ME_FULL }, INT_MIN, INT_MAX, V|E, "me_method" }, +{"tesa", "tesa motion estimation", 0, AV_OPT_TYPE_CONST, {.dbl = ME_TESA }, INT_MIN, INT_MAX, V|E, "me_method" }, +{"dia", "dia motion estimation (alias for epzs)", 0, AV_OPT_TYPE_CONST, {.dbl = ME_EPZS }, INT_MIN, INT_MAX, V|E, "me_method" }, +{"log", "log motion estimation", 0, AV_OPT_TYPE_CONST, {.dbl = ME_LOG }, INT_MIN, INT_MAX, V|E, "me_method" }, +{"phods", "phods motion estimation", 0, AV_OPT_TYPE_CONST, {.dbl = ME_PHODS }, INT_MIN, INT_MAX, V|E, "me_method" }, +{"x1", "X1 motion estimation", 0, AV_OPT_TYPE_CONST, {.dbl = ME_X1 }, INT_MIN, INT_MAX, V|E, "me_method" }, +{"hex", "hex motion estimation", 0, AV_OPT_TYPE_CONST, {.dbl = ME_HEX }, INT_MIN, INT_MAX, V|E, "me_method" }, +{"umh", "umh motion estimation", 0, AV_OPT_TYPE_CONST, {.dbl = ME_UMH }, INT_MIN, INT_MAX, V|E, "me_method" }, +{"iter", "iter motion estimation", 0, AV_OPT_TYPE_CONST, {.dbl = ME_ITER }, INT_MIN, INT_MAX, V|E, "me_method" }, +{"extradata_size", NULL, OFFSET(extradata_size), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, +{"time_base", NULL, OFFSET(time_base), AV_OPT_TYPE_RATIONAL, {.dbl = 0}, INT_MIN, INT_MAX}, +{"g", "set the group of picture size", OFFSET(gop_size), AV_OPT_TYPE_INT, {.dbl = 12 }, INT_MIN, INT_MAX, V|E}, +{"ar", "set audio sampling rate (in Hz)", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, A|D|E}, +{"ac", "set number of audio channels", OFFSET(channels), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, A|D|E}, +{"cutoff", "set cutoff bandwidth", OFFSET(cutoff), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, A|E}, +{"frame_size", NULL, OFFSET(frame_size), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, A|E}, +{"frame_number", NULL, OFFSET(frame_number), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, +{"delay", NULL, OFFSET(delay), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, +{"qcomp", "video quantizer scale compression (VBR)", OFFSET(qcompress), AV_OPT_TYPE_FLOAT, {.dbl = 0.5 }, -FLT_MAX, FLT_MAX, V|E}, +{"qblur", "video quantizer scale blur (VBR)", OFFSET(qblur), AV_OPT_TYPE_FLOAT, {.dbl = 0.5 }, -1, FLT_MAX, V|E}, +{"qmin", "min video quantizer scale (VBR)", OFFSET(qmin), AV_OPT_TYPE_INT, {.dbl = 2 }, -1, 69, V|E}, +{"qmax", "max video quantizer scale (VBR)", OFFSET(qmax), AV_OPT_TYPE_INT, {.dbl = 31 }, -1, 69, V|E}, +{"qdiff", "max difference between the quantizer scale (VBR)", OFFSET(max_qdiff), AV_OPT_TYPE_INT, {.dbl = 3 }, INT_MIN, INT_MAX, V|E}, +{"bf", "use 'frames' B frames", OFFSET(max_b_frames), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, -1, FF_MAX_B_FRAMES, V|E}, +{"b_qfactor", "qp factor between p and b frames", OFFSET(b_quant_factor), AV_OPT_TYPE_FLOAT, {.dbl = 1.25 }, -FLT_MAX, FLT_MAX, V|E}, +{"rc_strategy", "ratecontrol method", OFFSET(rc_strategy), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, +{"b_strategy", "strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), AV_OPT_TYPE_INT, {.dbl = 0 }, INT_MIN, INT_MAX, V|E}, #if FF_API_X264_GLOBAL_OPTS -{"wpredp", "weighted prediction analysis method", OFFSET(weighted_p_pred), FF_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, V|E}, +{"wpredp", "weighted prediction analysis method", OFFSET(weighted_p_pred), AV_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, V|E}, #endif -{"ps", "rtp payload size in bytes", OFFSET(rtp_payload_size), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, -{"mv_bits", NULL, OFFSET(mv_bits), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, -{"header_bits", NULL, OFFSET(header_bits), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, -{"i_tex_bits", NULL, OFFSET(i_tex_bits), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, -{"p_tex_bits", NULL, OFFSET(p_tex_bits), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, -{"i_count", NULL, OFFSET(i_count), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, -{"p_count", NULL, OFFSET(p_count), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, -{"skip_count", NULL, OFFSET(skip_count), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, -{"misc_bits", NULL, OFFSET(misc_bits), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, -{"frame_bits", NULL, OFFSET(frame_bits), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, -{"codec_tag", NULL, OFFSET(codec_tag), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, -{"bug", "workaround not auto detected encoder bugs", OFFSET(workaround_bugs), FF_OPT_TYPE_FLAGS, {.dbl = FF_BUG_AUTODETECT }, INT_MIN, INT_MAX, V|D, "bug"}, -{"autodetect", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_BUG_AUTODETECT }, INT_MIN, INT_MAX, V|D, "bug"}, -{"old_msmpeg4", "some old lavc generated msmpeg4v3 files (no autodetection)", 0, FF_OPT_TYPE_CONST, {.dbl = FF_BUG_OLD_MSMPEG4 }, INT_MIN, INT_MAX, V|D, "bug"}, -{"xvid_ilace", "Xvid interlacing bug (autodetected if fourcc==XVIX)", 0, FF_OPT_TYPE_CONST, {.dbl = FF_BUG_XVID_ILACE }, INT_MIN, INT_MAX, V|D, "bug"}, -{"ump4", "(autodetected if fourcc==UMP4)", 0, FF_OPT_TYPE_CONST, {.dbl = FF_BUG_UMP4 }, INT_MIN, INT_MAX, V|D, "bug"}, -{"no_padding", "padding bug (autodetected)", 0, FF_OPT_TYPE_CONST, {.dbl = FF_BUG_NO_PADDING }, INT_MIN, INT_MAX, V|D, "bug"}, -{"amv", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_BUG_AMV }, INT_MIN, INT_MAX, V|D, "bug"}, -{"ac_vlc", "illegal vlc bug (autodetected per fourcc)", 0, FF_OPT_TYPE_CONST, {.dbl = FF_BUG_AC_VLC }, INT_MIN, INT_MAX, V|D, "bug"}, -{"qpel_chroma", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_BUG_QPEL_CHROMA }, INT_MIN, INT_MAX, V|D, "bug"}, -{"std_qpel", "old standard qpel (autodetected per fourcc/version)", 0, FF_OPT_TYPE_CONST, {.dbl = FF_BUG_STD_QPEL }, INT_MIN, INT_MAX, V|D, "bug"}, -{"qpel_chroma2", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_BUG_QPEL_CHROMA2 }, INT_MIN, INT_MAX, V|D, "bug"}, -{"direct_blocksize", "direct-qpel-blocksize bug (autodetected per fourcc/version)", 0, FF_OPT_TYPE_CONST, {.dbl = FF_BUG_DIRECT_BLOCKSIZE }, INT_MIN, INT_MAX, V|D, "bug"}, -{"edge", "edge padding bug (autodetected per fourcc/version)", 0, FF_OPT_TYPE_CONST, {.dbl = FF_BUG_EDGE }, INT_MIN, INT_MAX, V|D, "bug"}, -{"hpel_chroma", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_BUG_HPEL_CHROMA }, INT_MIN, INT_MAX, V|D, "bug"}, -{"dc_clip", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_BUG_DC_CLIP }, INT_MIN, INT_MAX, V|D, "bug"}, -{"ms", "workaround various bugs in microsofts broken decoders", 0, FF_OPT_TYPE_CONST, {.dbl = FF_BUG_MS }, INT_MIN, INT_MAX, V|D, "bug"}, -{"trunc", "trancated frames", 0, FF_OPT_TYPE_CONST, {.dbl = FF_BUG_TRUNCATED}, INT_MIN, INT_MAX, V|D, "bug"}, -{"lelim", "single coefficient elimination threshold for luminance (negative values also consider dc coefficient)", OFFSET(luma_elim_threshold), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, -{"celim", "single coefficient elimination threshold for chrominance (negative values also consider dc coefficient)", OFFSET(chroma_elim_threshold), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, -{"strict", "how strictly to follow the standards", OFFSET(strict_std_compliance), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, A|V|D|E, "strict"}, -{"very", "strictly conform to a older more strict version of the spec or reference software", 0, FF_OPT_TYPE_CONST, {.dbl = FF_COMPLIANCE_VERY_STRICT }, INT_MIN, INT_MAX, V|D|E, "strict"}, -{"strict", "strictly conform to all the things in the spec no matter what consequences", 0, FF_OPT_TYPE_CONST, {.dbl = FF_COMPLIANCE_STRICT }, INT_MIN, INT_MAX, V|D|E, "strict"}, -{"normal", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_COMPLIANCE_NORMAL }, INT_MIN, INT_MAX, V|D|E, "strict"}, -{"unofficial", "allow unofficial extensions", 0, FF_OPT_TYPE_CONST, {.dbl = FF_COMPLIANCE_UNOFFICIAL }, INT_MIN, INT_MAX, V|D|E, "strict"}, -{"experimental", "allow non standardized experimental things", 0, FF_OPT_TYPE_CONST, {.dbl = FF_COMPLIANCE_EXPERIMENTAL }, INT_MIN, INT_MAX, V|D|E, "strict"}, -{"b_qoffset", "qp offset between P and B frames", OFFSET(b_quant_offset), FF_OPT_TYPE_FLOAT, {.dbl = 1.25 }, -FLT_MAX, FLT_MAX, V|E}, -{"er", "set error detection aggressivity", OFFSET(error_recognition), FF_OPT_TYPE_INT, {.dbl = FF_ER_CAREFUL }, INT_MIN, INT_MAX, A|V|D, "er"}, -{"careful", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_ER_CAREFUL }, INT_MIN, INT_MAX, V|D, "er"}, -{"compliant", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_ER_COMPLIANT }, INT_MIN, INT_MAX, V|D, "er"}, -{"aggressive", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_ER_AGGRESSIVE }, INT_MIN, INT_MAX, V|D, "er"}, -#if FF_API_VERY_AGGRESSIVE -{"very_aggressive", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_ER_VERY_AGGRESSIVE }, INT_MIN, INT_MAX, V|D, "er"}, -#endif /* FF_API_VERY_AGGRESSIVE */ -{"explode", "abort decoding on error recognition", 0, FF_OPT_TYPE_CONST, {.dbl = FF_ER_EXPLODE }, INT_MIN, INT_MAX, V|D, "er"}, -{"has_b_frames", NULL, OFFSET(has_b_frames), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, -{"block_align", NULL, OFFSET(block_align), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, -{"parse_only", NULL, OFFSET(parse_only), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, -{"mpeg_quant", "use MPEG quantizers instead of H.263", OFFSET(mpeg_quant), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, -{"stats_out", NULL, OFFSET(stats_out), FF_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX}, -{"stats_in", NULL, OFFSET(stats_in), FF_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX}, -{"qsquish", "how to keep quantizer between qmin and qmax (0 = clip, 1 = use differentiable function)", OFFSET(rc_qsquish), FF_OPT_TYPE_FLOAT, {.dbl = DEFAULT }, 0, 99, V|E}, -{"rc_qmod_amp", "experimental quantizer modulation", OFFSET(rc_qmod_amp), FF_OPT_TYPE_FLOAT, {.dbl = DEFAULT }, -FLT_MAX, FLT_MAX, V|E}, -{"rc_qmod_freq", "experimental quantizer modulation", OFFSET(rc_qmod_freq), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, -{"rc_override_count", NULL, OFFSET(rc_override_count), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, -{"rc_eq", "set rate control equation", OFFSET(rc_eq), FF_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, V|E}, -{"maxrate", "set max video bitrate tolerance (in bits/s)", OFFSET(rc_max_rate), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, -{"minrate", "set min video bitrate tolerance (in bits/s)", OFFSET(rc_min_rate), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, -{"bufsize", "set ratecontrol buffer size (in bits)", OFFSET(rc_buffer_size), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, A|V|E}, -{"rc_buf_aggressivity", "currently useless", OFFSET(rc_buffer_aggressivity), FF_OPT_TYPE_FLOAT, {.dbl = 1.0 }, -FLT_MAX, FLT_MAX, V|E}, -{"i_qfactor", "qp factor between P and I frames", OFFSET(i_quant_factor), FF_OPT_TYPE_FLOAT, {.dbl = -0.8 }, -FLT_MAX, FLT_MAX, V|E}, -{"i_qoffset", "qp offset between P and I frames", OFFSET(i_quant_offset), FF_OPT_TYPE_FLOAT, {.dbl = 0.0 }, -FLT_MAX, FLT_MAX, V|E}, -{"rc_init_cplx", "initial complexity for 1-pass encoding", OFFSET(rc_initial_cplx), FF_OPT_TYPE_FLOAT, {.dbl = DEFAULT }, -FLT_MAX, FLT_MAX, V|E}, -{"dct", "DCT algorithm", OFFSET(dct_algo), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, V|E, "dct"}, -{"auto", "autoselect a good one (default)", 0, FF_OPT_TYPE_CONST, {.dbl = FF_DCT_AUTO }, INT_MIN, INT_MAX, V|E, "dct"}, -{"fastint", "fast integer", 0, FF_OPT_TYPE_CONST, {.dbl = FF_DCT_FASTINT }, INT_MIN, INT_MAX, V|E, "dct"}, -{"int", "accurate integer", 0, FF_OPT_TYPE_CONST, {.dbl = FF_DCT_INT }, INT_MIN, INT_MAX, V|E, "dct"}, -{"mmx", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_DCT_MMX }, INT_MIN, INT_MAX, V|E, "dct"}, -{"mlib", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_DCT_MLIB }, INT_MIN, INT_MAX, V|E, "dct"}, -{"altivec", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_DCT_ALTIVEC }, INT_MIN, INT_MAX, V|E, "dct"}, -{"faan", "floating point AAN DCT", 0, FF_OPT_TYPE_CONST, {.dbl = FF_DCT_FAAN }, INT_MIN, INT_MAX, V|E, "dct"}, -{"lumi_mask", "compresses bright areas stronger than medium ones", OFFSET(lumi_masking), FF_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, V|E}, -{"tcplx_mask", "temporal complexity masking", OFFSET(temporal_cplx_masking), FF_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, V|E}, -{"scplx_mask", "spatial complexity masking", OFFSET(spatial_cplx_masking), FF_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, V|E}, -{"p_mask", "inter masking", OFFSET(p_masking), FF_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, V|E}, -{"dark_mask", "compresses dark areas stronger than medium ones", OFFSET(dark_masking), FF_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, V|E}, -{"idct", "select IDCT implementation", OFFSET(idct_algo), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, V|E|D, "idct"}, -{"auto", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_IDCT_AUTO }, INT_MIN, INT_MAX, V|E|D, "idct"}, -{"int", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_IDCT_INT }, INT_MIN, INT_MAX, V|E|D, "idct"}, -{"simple", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_IDCT_SIMPLE }, INT_MIN, INT_MAX, V|E|D, "idct"}, -{"simplemmx", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_IDCT_SIMPLEMMX }, INT_MIN, INT_MAX, V|E|D, "idct"}, -{"libmpeg2mmx", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_IDCT_LIBMPEG2MMX }, INT_MIN, INT_MAX, V|E|D, "idct"}, -{"ps2", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_IDCT_PS2 }, INT_MIN, INT_MAX, V|E|D, "idct"}, -{"mlib", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_IDCT_MLIB }, INT_MIN, INT_MAX, V|E|D, "idct"}, -{"arm", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_IDCT_ARM }, INT_MIN, INT_MAX, V|E|D, "idct"}, -{"altivec", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_IDCT_ALTIVEC }, INT_MIN, INT_MAX, V|E|D, "idct"}, -{"sh4", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_IDCT_SH4 }, INT_MIN, INT_MAX, V|E|D, "idct"}, -{"simplearm", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_IDCT_SIMPLEARM }, INT_MIN, INT_MAX, V|E|D, "idct"}, -{"simplearmv5te", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_IDCT_SIMPLEARMV5TE }, INT_MIN, INT_MAX, V|E|D, "idct"}, -{"simplearmv6", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_IDCT_SIMPLEARMV6 }, INT_MIN, INT_MAX, V|E|D, "idct"}, -{"simpleneon", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_IDCT_SIMPLENEON }, INT_MIN, INT_MAX, V|E|D, "idct"}, -{"simplealpha", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_IDCT_SIMPLEALPHA }, INT_MIN, INT_MAX, V|E|D, "idct"}, -{"h264", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_IDCT_H264 }, INT_MIN, INT_MAX, V|E|D, "idct"}, -{"vp3", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_IDCT_VP3 }, INT_MIN, INT_MAX, V|E|D, "idct"}, -{"ipp", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_IDCT_IPP }, INT_MIN, INT_MAX, V|E|D, "idct"}, -{"xvidmmx", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_IDCT_XVIDMMX }, INT_MIN, INT_MAX, V|E|D, "idct"}, -{"faani", "floating point AAN IDCT", 0, FF_OPT_TYPE_CONST, {.dbl = FF_IDCT_FAAN }, INT_MIN, INT_MAX, V|D|E, "idct"}, -{"slice_count", NULL, OFFSET(slice_count), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, -{"ec", "set error concealment strategy", OFFSET(error_concealment), FF_OPT_TYPE_FLAGS, {.dbl = 3 }, INT_MIN, INT_MAX, V|D, "ec"}, -{"guess_mvs", "iterative motion vector (MV) search (slow)", 0, FF_OPT_TYPE_CONST, {.dbl = FF_EC_GUESS_MVS }, INT_MIN, INT_MAX, V|D, "ec"}, -{"deblock", "use strong deblock filter for damaged MBs", 0, FF_OPT_TYPE_CONST, {.dbl = FF_EC_DEBLOCK }, INT_MIN, INT_MAX, V|D, "ec"}, -{"bits_per_coded_sample", NULL, OFFSET(bits_per_coded_sample), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, -{"pred", "prediction method", OFFSET(prediction_method), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E, "pred"}, -{"left", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_PRED_LEFT }, INT_MIN, INT_MAX, V|E, "pred"}, -{"plane", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_PRED_PLANE }, INT_MIN, INT_MAX, V|E, "pred"}, -{"median", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_PRED_MEDIAN }, INT_MIN, INT_MAX, V|E, "pred"}, -{"aspect", "sample aspect ratio", OFFSET(sample_aspect_ratio), FF_OPT_TYPE_RATIONAL, {.dbl = 0}, 0, 10, V|E}, -{"debug", "print specific debug info", OFFSET(debug), FF_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, 0, INT_MAX, V|A|S|E|D, "debug"}, -{"pict", "picture info", 0, FF_OPT_TYPE_CONST, {.dbl = FF_DEBUG_PICT_INFO }, INT_MIN, INT_MAX, V|D, "debug"}, -{"rc", "rate control", 0, FF_OPT_TYPE_CONST, {.dbl = FF_DEBUG_RC }, INT_MIN, INT_MAX, V|E, "debug"}, -{"bitstream", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_DEBUG_BITSTREAM }, INT_MIN, INT_MAX, V|D, "debug"}, -{"mb_type", "macroblock (MB) type", 0, FF_OPT_TYPE_CONST, {.dbl = FF_DEBUG_MB_TYPE }, INT_MIN, INT_MAX, V|D, "debug"}, -{"qp", "per-block quantization parameter (QP)", 0, FF_OPT_TYPE_CONST, {.dbl = FF_DEBUG_QP }, INT_MIN, INT_MAX, V|D, "debug"}, -{"mv", "motion vector", 0, FF_OPT_TYPE_CONST, {.dbl = FF_DEBUG_MV }, INT_MIN, INT_MAX, V|D, "debug"}, -{"dct_coeff", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_DEBUG_DCT_COEFF }, INT_MIN, INT_MAX, V|D, "debug"}, -{"skip", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_DEBUG_SKIP }, INT_MIN, INT_MAX, V|D, "debug"}, -{"startcode", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_DEBUG_STARTCODE }, INT_MIN, INT_MAX, V|D, "debug"}, -{"pts", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_DEBUG_PTS }, INT_MIN, INT_MAX, V|D, "debug"}, -{"er", "error recognition", 0, FF_OPT_TYPE_CONST, {.dbl = FF_DEBUG_ER }, INT_MIN, INT_MAX, V|D, "debug"}, -{"mmco", "memory management control operations (H.264)", 0, FF_OPT_TYPE_CONST, {.dbl = FF_DEBUG_MMCO }, INT_MIN, INT_MAX, V|D, "debug"}, -{"bugs", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_DEBUG_BUGS }, INT_MIN, INT_MAX, V|D, "debug"}, -{"vis_qp", "visualize quantization parameter (QP), lower QP are tinted greener", 0, FF_OPT_TYPE_CONST, {.dbl = FF_DEBUG_VIS_QP }, INT_MIN, INT_MAX, V|D, "debug"}, -{"vis_mb_type", "visualize block types", 0, FF_OPT_TYPE_CONST, {.dbl = FF_DEBUG_VIS_MB_TYPE }, INT_MIN, INT_MAX, V|D, "debug"}, -{"buffers", "picture buffer allocations", 0, FF_OPT_TYPE_CONST, {.dbl = FF_DEBUG_BUFFERS }, INT_MIN, INT_MAX, V|D, "debug"}, -{"thread_ops", "threading operations", 0, FF_OPT_TYPE_CONST, {.dbl = FF_DEBUG_THREADS }, INT_MIN, INT_MAX, V|D, "debug"}, -{"vismv", "visualize motion vectors (MVs)", OFFSET(debug_mv), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, V|D, "debug_mv"}, -{"pf", "forward predicted MVs of P-frames", 0, FF_OPT_TYPE_CONST, {.dbl = FF_DEBUG_VIS_MV_P_FOR }, INT_MIN, INT_MAX, V|D, "debug_mv"}, -{"bf", "forward predicted MVs of B-frames", 0, FF_OPT_TYPE_CONST, {.dbl = FF_DEBUG_VIS_MV_B_FOR }, INT_MIN, INT_MAX, V|D, "debug_mv"}, -{"bb", "backward predicted MVs of B-frames", 0, FF_OPT_TYPE_CONST, {.dbl = FF_DEBUG_VIS_MV_B_BACK }, INT_MIN, INT_MAX, V|D, "debug_mv"}, -{"cmp", "full pel me compare function", OFFSET(me_cmp), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"subcmp", "sub pel me compare function", OFFSET(me_sub_cmp), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"mbcmp", "macroblock compare function", OFFSET(mb_cmp), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"ildctcmp", "interlaced dct compare function", OFFSET(ildct_cmp), FF_OPT_TYPE_INT, {.dbl = FF_CMP_VSAD }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"dia_size", "diamond type & size for motion estimation", OFFSET(dia_size), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, -{"last_pred", "amount of motion predictors from the previous frame", OFFSET(last_predictor_count), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, -{"preme", "pre motion estimation", OFFSET(pre_me), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, -{"precmp", "pre motion estimation compare function", OFFSET(me_pre_cmp), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"sad", "sum of absolute differences, fast (default)", 0, FF_OPT_TYPE_CONST, {.dbl = FF_CMP_SAD }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"sse", "sum of squared errors", 0, FF_OPT_TYPE_CONST, {.dbl = FF_CMP_SSE }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"satd", "sum of absolute Hadamard transformed differences", 0, FF_OPT_TYPE_CONST, {.dbl = FF_CMP_SATD }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"dct", "sum of absolute DCT transformed differences", 0, FF_OPT_TYPE_CONST, {.dbl = FF_CMP_DCT }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"psnr", "sum of squared quantization errors (avoid, low quality)", 0, FF_OPT_TYPE_CONST, {.dbl = FF_CMP_PSNR }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"bit", "number of bits needed for the block", 0, FF_OPT_TYPE_CONST, {.dbl = FF_CMP_BIT }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"rd", "rate distortion optimal, slow", 0, FF_OPT_TYPE_CONST, {.dbl = FF_CMP_RD }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"zero", "0", 0, FF_OPT_TYPE_CONST, {.dbl = FF_CMP_ZERO }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"vsad", "sum of absolute vertical differences", 0, FF_OPT_TYPE_CONST, {.dbl = FF_CMP_VSAD }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"vsse", "sum of squared vertical differences", 0, FF_OPT_TYPE_CONST, {.dbl = FF_CMP_VSSE }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"nsse", "noise preserving sum of squared differences", 0, FF_OPT_TYPE_CONST, {.dbl = FF_CMP_NSSE }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"ps", "rtp payload size in bytes", OFFSET(rtp_payload_size), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, +{"mv_bits", NULL, OFFSET(mv_bits), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, +{"header_bits", NULL, OFFSET(header_bits), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, +{"i_tex_bits", NULL, OFFSET(i_tex_bits), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, +{"p_tex_bits", NULL, OFFSET(p_tex_bits), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, +{"i_count", NULL, OFFSET(i_count), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, +{"p_count", NULL, OFFSET(p_count), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, +{"skip_count", NULL, OFFSET(skip_count), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, +{"misc_bits", NULL, OFFSET(misc_bits), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, +{"frame_bits", NULL, OFFSET(frame_bits), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, +{"codec_tag", NULL, OFFSET(codec_tag), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, +{"bug", "workaround not auto detected encoder bugs", OFFSET(workaround_bugs), AV_OPT_TYPE_FLAGS, {.dbl = FF_BUG_AUTODETECT }, INT_MIN, INT_MAX, V|D, "bug"}, +{"autodetect", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_BUG_AUTODETECT }, INT_MIN, INT_MAX, V|D, "bug"}, +{"old_msmpeg4", "some old lavc generated msmpeg4v3 files (no autodetection)", 0, AV_OPT_TYPE_CONST, {.dbl = FF_BUG_OLD_MSMPEG4 }, INT_MIN, INT_MAX, V|D, "bug"}, +{"xvid_ilace", "Xvid interlacing bug (autodetected if fourcc==XVIX)", 0, AV_OPT_TYPE_CONST, {.dbl = FF_BUG_XVID_ILACE }, INT_MIN, INT_MAX, V|D, "bug"}, +{"ump4", "(autodetected if fourcc==UMP4)", 0, AV_OPT_TYPE_CONST, {.dbl = FF_BUG_UMP4 }, INT_MIN, INT_MAX, V|D, "bug"}, +{"no_padding", "padding bug (autodetected)", 0, AV_OPT_TYPE_CONST, {.dbl = FF_BUG_NO_PADDING }, INT_MIN, INT_MAX, V|D, "bug"}, +{"amv", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_BUG_AMV }, INT_MIN, INT_MAX, V|D, "bug"}, +{"ac_vlc", "illegal vlc bug (autodetected per fourcc)", 0, AV_OPT_TYPE_CONST, {.dbl = FF_BUG_AC_VLC }, INT_MIN, INT_MAX, V|D, "bug"}, +{"qpel_chroma", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_BUG_QPEL_CHROMA }, INT_MIN, INT_MAX, V|D, "bug"}, +{"std_qpel", "old standard qpel (autodetected per fourcc/version)", 0, AV_OPT_TYPE_CONST, {.dbl = FF_BUG_STD_QPEL }, INT_MIN, INT_MAX, V|D, "bug"}, +{"qpel_chroma2", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_BUG_QPEL_CHROMA2 }, INT_MIN, INT_MAX, V|D, "bug"}, +{"direct_blocksize", "direct-qpel-blocksize bug (autodetected per fourcc/version)", 0, AV_OPT_TYPE_CONST, {.dbl = FF_BUG_DIRECT_BLOCKSIZE }, INT_MIN, INT_MAX, V|D, "bug"}, +{"edge", "edge padding bug (autodetected per fourcc/version)", 0, AV_OPT_TYPE_CONST, {.dbl = FF_BUG_EDGE }, INT_MIN, INT_MAX, V|D, "bug"}, +{"hpel_chroma", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_BUG_HPEL_CHROMA }, INT_MIN, INT_MAX, V|D, "bug"}, +{"dc_clip", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_BUG_DC_CLIP }, INT_MIN, INT_MAX, V|D, "bug"}, +{"ms", "workaround various bugs in microsofts broken decoders", 0, AV_OPT_TYPE_CONST, {.dbl = FF_BUG_MS }, INT_MIN, INT_MAX, V|D, "bug"}, +{"trunc", "trancated frames", 0, AV_OPT_TYPE_CONST, {.dbl = FF_BUG_TRUNCATED}, INT_MIN, INT_MAX, V|D, "bug"}, +{"lelim", "single coefficient elimination threshold for luminance (negative values also consider dc coefficient)", OFFSET(luma_elim_threshold), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, +{"celim", "single coefficient elimination threshold for chrominance (negative values also consider dc coefficient)", OFFSET(chroma_elim_threshold), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, +{"strict", "how strictly to follow the standards", OFFSET(strict_std_compliance), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, A|V|D|E, "strict"}, +{"very", "strictly conform to a older more strict version of the spec or reference software", 0, AV_OPT_TYPE_CONST, {.dbl = FF_COMPLIANCE_VERY_STRICT }, INT_MIN, INT_MAX, V|D|E, "strict"}, +{"strict", "strictly conform to all the things in the spec no matter what consequences", 0, AV_OPT_TYPE_CONST, {.dbl = FF_COMPLIANCE_STRICT }, INT_MIN, INT_MAX, V|D|E, "strict"}, +{"normal", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_COMPLIANCE_NORMAL }, INT_MIN, INT_MAX, V|D|E, "strict"}, +{"unofficial", "allow unofficial extensions", 0, AV_OPT_TYPE_CONST, {.dbl = FF_COMPLIANCE_UNOFFICIAL }, INT_MIN, INT_MAX, V|D|E, "strict"}, +{"experimental", "allow non standardized experimental things", 0, AV_OPT_TYPE_CONST, {.dbl = FF_COMPLIANCE_EXPERIMENTAL }, INT_MIN, INT_MAX, V|D|E, "strict"}, +{"b_qoffset", "qp offset between P and B frames", OFFSET(b_quant_offset), AV_OPT_TYPE_FLOAT, {.dbl = 1.25 }, -FLT_MAX, FLT_MAX, V|E}, +#if FF_API_ER +{"er", "set error detection aggressivity", OFFSET(error_recognition), AV_OPT_TYPE_INT, {.dbl = FF_ER_CAREFUL }, INT_MIN, INT_MAX, A|V|D, "er"}, +{"careful", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_ER_CAREFUL }, INT_MIN, INT_MAX, V|D, "er"}, +{"compliant", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_ER_COMPLIANT }, INT_MIN, INT_MAX, V|D, "er"}, +{"aggressive", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_ER_AGGRESSIVE }, INT_MIN, INT_MAX, V|D, "er"}, +{"very_aggressive", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_ER_VERY_AGGRESSIVE }, INT_MIN, INT_MAX, V|D, "er"}, +{"explode", "abort decoding on error recognition", 0, AV_OPT_TYPE_CONST, {.dbl = FF_ER_EXPLODE }, INT_MIN, INT_MAX, V|D, "er"}, +#endif /* FF_API_ER */ +{"err_filter", "set error detection filter flags", OFFSET(err_recognition), AV_OPT_TYPE_FLAGS, {.dbl = AV_EF_CRCCHECK }, INT_MIN, INT_MAX, A|V|D, "err_filter"}, +{"crccheck", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_CRCCHECK }, INT_MIN, INT_MAX, V|D, "err_filter"}, +{"bitstream", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_BITSTREAM }, INT_MIN, INT_MAX, V|D, "err_filter"}, +{"buffer", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_BUFFER }, INT_MIN, INT_MAX, V|D, "err_filter"}, +{"explode", "abort decoding on minor error recognition", 0, AV_OPT_TYPE_CONST, {.dbl = AV_EF_EXPLODE }, INT_MIN, INT_MAX, V|D, "err_filter"}, +{"has_b_frames", NULL, OFFSET(has_b_frames), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, +{"block_align", NULL, OFFSET(block_align), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, +{"parse_only", NULL, OFFSET(parse_only), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, +{"mpeg_quant", "use MPEG quantizers instead of H.263", OFFSET(mpeg_quant), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, +{"stats_out", NULL, OFFSET(stats_out), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX}, +{"stats_in", NULL, OFFSET(stats_in), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX}, +{"qsquish", "how to keep quantizer between qmin and qmax (0 = clip, 1 = use differentiable function)", OFFSET(rc_qsquish), AV_OPT_TYPE_FLOAT, {.dbl = DEFAULT }, 0, 99, V|E}, +{"rc_qmod_amp", "experimental quantizer modulation", OFFSET(rc_qmod_amp), AV_OPT_TYPE_FLOAT, {.dbl = DEFAULT }, -FLT_MAX, FLT_MAX, V|E}, +{"rc_qmod_freq", "experimental quantizer modulation", OFFSET(rc_qmod_freq), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, +{"rc_override_count", NULL, OFFSET(rc_override_count), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, +{"rc_eq", "set rate control equation", OFFSET(rc_eq), AV_OPT_TYPE_STRING, {.str = NULL}, CHAR_MIN, CHAR_MAX, V|E}, +{"maxrate", "set max video bitrate tolerance (in bits/s)", OFFSET(rc_max_rate), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, +{"minrate", "set min video bitrate tolerance (in bits/s)", OFFSET(rc_min_rate), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, +{"bufsize", "set ratecontrol buffer size (in bits)", OFFSET(rc_buffer_size), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, A|V|E}, +{"rc_buf_aggressivity", "currently useless", OFFSET(rc_buffer_aggressivity), AV_OPT_TYPE_FLOAT, {.dbl = 1.0 }, -FLT_MAX, FLT_MAX, V|E}, +{"i_qfactor", "qp factor between P and I frames", OFFSET(i_quant_factor), AV_OPT_TYPE_FLOAT, {.dbl = -0.8 }, -FLT_MAX, FLT_MAX, V|E}, +{"i_qoffset", "qp offset between P and I frames", OFFSET(i_quant_offset), AV_OPT_TYPE_FLOAT, {.dbl = 0.0 }, -FLT_MAX, FLT_MAX, V|E}, +{"rc_init_cplx", "initial complexity for 1-pass encoding", OFFSET(rc_initial_cplx), AV_OPT_TYPE_FLOAT, {.dbl = DEFAULT }, -FLT_MAX, FLT_MAX, V|E}, +{"dct", "DCT algorithm", OFFSET(dct_algo), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, V|E, "dct"}, +{"auto", "autoselect a good one (default)", 0, AV_OPT_TYPE_CONST, {.dbl = FF_DCT_AUTO }, INT_MIN, INT_MAX, V|E, "dct"}, +{"fastint", "fast integer", 0, AV_OPT_TYPE_CONST, {.dbl = FF_DCT_FASTINT }, INT_MIN, INT_MAX, V|E, "dct"}, +{"int", "accurate integer", 0, AV_OPT_TYPE_CONST, {.dbl = FF_DCT_INT }, INT_MIN, INT_MAX, V|E, "dct"}, +{"mmx", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_DCT_MMX }, INT_MIN, INT_MAX, V|E, "dct"}, +{"mlib", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_DCT_MLIB }, INT_MIN, INT_MAX, V|E, "dct"}, +{"altivec", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_DCT_ALTIVEC }, INT_MIN, INT_MAX, V|E, "dct"}, +{"faan", "floating point AAN DCT", 0, AV_OPT_TYPE_CONST, {.dbl = FF_DCT_FAAN }, INT_MIN, INT_MAX, V|E, "dct"}, +{"lumi_mask", "compresses bright areas stronger than medium ones", OFFSET(lumi_masking), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, V|E}, +{"tcplx_mask", "temporal complexity masking", OFFSET(temporal_cplx_masking), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, V|E}, +{"scplx_mask", "spatial complexity masking", OFFSET(spatial_cplx_masking), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, V|E}, +{"p_mask", "inter masking", OFFSET(p_masking), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, V|E}, +{"dark_mask", "compresses dark areas stronger than medium ones", OFFSET(dark_masking), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, V|E}, +{"idct", "select IDCT implementation", OFFSET(idct_algo), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, V|E|D, "idct"}, +{"auto", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_IDCT_AUTO }, INT_MIN, INT_MAX, V|E|D, "idct"}, +{"int", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_IDCT_INT }, INT_MIN, INT_MAX, V|E|D, "idct"}, +{"simple", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_IDCT_SIMPLE }, INT_MIN, INT_MAX, V|E|D, "idct"}, +{"simplemmx", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_IDCT_SIMPLEMMX }, INT_MIN, INT_MAX, V|E|D, "idct"}, +{"libmpeg2mmx", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_IDCT_LIBMPEG2MMX }, INT_MIN, INT_MAX, V|E|D, "idct"}, +{"ps2", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_IDCT_PS2 }, INT_MIN, INT_MAX, V|E|D, "idct"}, +{"mlib", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_IDCT_MLIB }, INT_MIN, INT_MAX, V|E|D, "idct"}, +{"arm", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_IDCT_ARM }, INT_MIN, INT_MAX, V|E|D, "idct"}, +{"altivec", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_IDCT_ALTIVEC }, INT_MIN, INT_MAX, V|E|D, "idct"}, +{"sh4", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_IDCT_SH4 }, INT_MIN, INT_MAX, V|E|D, "idct"}, +{"simplearm", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_IDCT_SIMPLEARM }, INT_MIN, INT_MAX, V|E|D, "idct"}, +{"simplearmv5te", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_IDCT_SIMPLEARMV5TE }, INT_MIN, INT_MAX, V|E|D, "idct"}, +{"simplearmv6", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_IDCT_SIMPLEARMV6 }, INT_MIN, INT_MAX, V|E|D, "idct"}, +{"simpleneon", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_IDCT_SIMPLENEON }, INT_MIN, INT_MAX, V|E|D, "idct"}, +{"simplealpha", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_IDCT_SIMPLEALPHA }, INT_MIN, INT_MAX, V|E|D, "idct"}, +{"h264", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_IDCT_H264 }, INT_MIN, INT_MAX, V|E|D, "idct"}, +{"vp3", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_IDCT_VP3 }, INT_MIN, INT_MAX, V|E|D, "idct"}, +{"ipp", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_IDCT_IPP }, INT_MIN, INT_MAX, V|E|D, "idct"}, +{"xvidmmx", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_IDCT_XVIDMMX }, INT_MIN, INT_MAX, V|E|D, "idct"}, +{"faani", "floating point AAN IDCT", 0, AV_OPT_TYPE_CONST, {.dbl = FF_IDCT_FAAN }, INT_MIN, INT_MAX, V|D|E, "idct"}, +{"slice_count", NULL, OFFSET(slice_count), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, +{"ec", "set error concealment strategy", OFFSET(error_concealment), AV_OPT_TYPE_FLAGS, {.dbl = 3 }, INT_MIN, INT_MAX, V|D, "ec"}, +{"guess_mvs", "iterative motion vector (MV) search (slow)", 0, AV_OPT_TYPE_CONST, {.dbl = FF_EC_GUESS_MVS }, INT_MIN, INT_MAX, V|D, "ec"}, +{"deblock", "use strong deblock filter for damaged MBs", 0, AV_OPT_TYPE_CONST, {.dbl = FF_EC_DEBLOCK }, INT_MIN, INT_MAX, V|D, "ec"}, +{"bits_per_coded_sample", NULL, OFFSET(bits_per_coded_sample), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, +{"pred", "prediction method", OFFSET(prediction_method), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E, "pred"}, +{"left", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_PRED_LEFT }, INT_MIN, INT_MAX, V|E, "pred"}, +{"plane", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_PRED_PLANE }, INT_MIN, INT_MAX, V|E, "pred"}, +{"median", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_PRED_MEDIAN }, INT_MIN, INT_MAX, V|E, "pred"}, +{"aspect", "sample aspect ratio", OFFSET(sample_aspect_ratio), AV_OPT_TYPE_RATIONAL, {.dbl = 0}, 0, 10, V|E}, +{"debug", "print specific debug info", OFFSET(debug), AV_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, 0, INT_MAX, V|A|S|E|D, "debug"}, +{"pict", "picture info", 0, AV_OPT_TYPE_CONST, {.dbl = FF_DEBUG_PICT_INFO }, INT_MIN, INT_MAX, V|D, "debug"}, +{"rc", "rate control", 0, AV_OPT_TYPE_CONST, {.dbl = FF_DEBUG_RC }, INT_MIN, INT_MAX, V|E, "debug"}, +{"bitstream", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_DEBUG_BITSTREAM }, INT_MIN, INT_MAX, V|D, "debug"}, +{"mb_type", "macroblock (MB) type", 0, AV_OPT_TYPE_CONST, {.dbl = FF_DEBUG_MB_TYPE }, INT_MIN, INT_MAX, V|D, "debug"}, +{"qp", "per-block quantization parameter (QP)", 0, AV_OPT_TYPE_CONST, {.dbl = FF_DEBUG_QP }, INT_MIN, INT_MAX, V|D, "debug"}, +{"mv", "motion vector", 0, AV_OPT_TYPE_CONST, {.dbl = FF_DEBUG_MV }, INT_MIN, INT_MAX, V|D, "debug"}, +{"dct_coeff", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_DEBUG_DCT_COEFF }, INT_MIN, INT_MAX, V|D, "debug"}, +{"skip", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_DEBUG_SKIP }, INT_MIN, INT_MAX, V|D, "debug"}, +{"startcode", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_DEBUG_STARTCODE }, INT_MIN, INT_MAX, V|D, "debug"}, +{"pts", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_DEBUG_PTS }, INT_MIN, INT_MAX, V|D, "debug"}, +{"er", "error recognition", 0, AV_OPT_TYPE_CONST, {.dbl = FF_DEBUG_ER }, INT_MIN, INT_MAX, V|D, "debug"}, +{"mmco", "memory management control operations (H.264)", 0, AV_OPT_TYPE_CONST, {.dbl = FF_DEBUG_MMCO }, INT_MIN, INT_MAX, V|D, "debug"}, +{"bugs", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_DEBUG_BUGS }, INT_MIN, INT_MAX, V|D, "debug"}, +{"vis_qp", "visualize quantization parameter (QP), lower QP are tinted greener", 0, AV_OPT_TYPE_CONST, {.dbl = FF_DEBUG_VIS_QP }, INT_MIN, INT_MAX, V|D, "debug"}, +{"vis_mb_type", "visualize block types", 0, AV_OPT_TYPE_CONST, {.dbl = FF_DEBUG_VIS_MB_TYPE }, INT_MIN, INT_MAX, V|D, "debug"}, +{"buffers", "picture buffer allocations", 0, AV_OPT_TYPE_CONST, {.dbl = FF_DEBUG_BUFFERS }, INT_MIN, INT_MAX, V|D, "debug"}, +{"thread_ops", "threading operations", 0, AV_OPT_TYPE_CONST, {.dbl = FF_DEBUG_THREADS }, INT_MIN, INT_MAX, V|D, "debug"}, +{"vismv", "visualize motion vectors (MVs)", OFFSET(debug_mv), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, V|D, "debug_mv"}, +{"pf", "forward predicted MVs of P-frames", 0, AV_OPT_TYPE_CONST, {.dbl = FF_DEBUG_VIS_MV_P_FOR }, INT_MIN, INT_MAX, V|D, "debug_mv"}, +{"bf", "forward predicted MVs of B-frames", 0, AV_OPT_TYPE_CONST, {.dbl = FF_DEBUG_VIS_MV_B_FOR }, INT_MIN, INT_MAX, V|D, "debug_mv"}, +{"bb", "backward predicted MVs of B-frames", 0, AV_OPT_TYPE_CONST, {.dbl = FF_DEBUG_VIS_MV_B_BACK }, INT_MIN, INT_MAX, V|D, "debug_mv"}, +{"cmp", "full pel me compare function", OFFSET(me_cmp), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"subcmp", "sub pel me compare function", OFFSET(me_sub_cmp), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"mbcmp", "macroblock compare function", OFFSET(mb_cmp), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"ildctcmp", "interlaced dct compare function", OFFSET(ildct_cmp), AV_OPT_TYPE_INT, {.dbl = FF_CMP_VSAD }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"dia_size", "diamond type & size for motion estimation", OFFSET(dia_size), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, +{"last_pred", "amount of motion predictors from the previous frame", OFFSET(last_predictor_count), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, +{"preme", "pre motion estimation", OFFSET(pre_me), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, +{"precmp", "pre motion estimation compare function", OFFSET(me_pre_cmp), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"sad", "sum of absolute differences, fast (default)", 0, AV_OPT_TYPE_CONST, {.dbl = FF_CMP_SAD }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"sse", "sum of squared errors", 0, AV_OPT_TYPE_CONST, {.dbl = FF_CMP_SSE }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"satd", "sum of absolute Hadamard transformed differences", 0, AV_OPT_TYPE_CONST, {.dbl = FF_CMP_SATD }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"dct", "sum of absolute DCT transformed differences", 0, AV_OPT_TYPE_CONST, {.dbl = FF_CMP_DCT }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"psnr", "sum of squared quantization errors (avoid, low quality)", 0, AV_OPT_TYPE_CONST, {.dbl = FF_CMP_PSNR }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"bit", "number of bits needed for the block", 0, AV_OPT_TYPE_CONST, {.dbl = FF_CMP_BIT }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"rd", "rate distortion optimal, slow", 0, AV_OPT_TYPE_CONST, {.dbl = FF_CMP_RD }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"zero", "0", 0, AV_OPT_TYPE_CONST, {.dbl = FF_CMP_ZERO }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"vsad", "sum of absolute vertical differences", 0, AV_OPT_TYPE_CONST, {.dbl = FF_CMP_VSAD }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"vsse", "sum of squared vertical differences", 0, AV_OPT_TYPE_CONST, {.dbl = FF_CMP_VSSE }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"nsse", "noise preserving sum of squared differences", 0, AV_OPT_TYPE_CONST, {.dbl = FF_CMP_NSSE }, INT_MIN, INT_MAX, V|E, "cmp_func"}, #if CONFIG_SNOW_ENCODER -{"w53", "5/3 wavelet, only used in snow", 0, FF_OPT_TYPE_CONST, {.dbl = FF_CMP_W53 }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"w97", "9/7 wavelet, only used in snow", 0, FF_OPT_TYPE_CONST, {.dbl = FF_CMP_W97 }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"w53", "5/3 wavelet, only used in snow", 0, AV_OPT_TYPE_CONST, {.dbl = FF_CMP_W53 }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"w97", "9/7 wavelet, only used in snow", 0, AV_OPT_TYPE_CONST, {.dbl = FF_CMP_W97 }, INT_MIN, INT_MAX, V|E, "cmp_func"}, #endif -{"dctmax", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_CMP_DCTMAX }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"chroma", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_CMP_CHROMA }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"pre_dia_size", "diamond type & size for motion estimation pre-pass", OFFSET(pre_dia_size), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, -{"subq", "sub pel motion estimation quality", OFFSET(me_subpel_quality), FF_OPT_TYPE_INT, {.dbl = 8 }, INT_MIN, INT_MAX, V|E}, -{"dtg_active_format", NULL, OFFSET(dtg_active_format), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, -{"me_range", "limit motion vectors range (1023 for DivX player)", OFFSET(me_range), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, -{"ibias", "intra quant bias", OFFSET(intra_quant_bias), FF_OPT_TYPE_INT, {.dbl = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, V|E}, -{"pbias", "inter quant bias", OFFSET(inter_quant_bias), FF_OPT_TYPE_INT, {.dbl = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, V|E}, -{"color_table_id", NULL, OFFSET(color_table_id), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, -{"internal_buffer_count", NULL, OFFSET(internal_buffer_count), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, -{"global_quality", NULL, OFFSET(global_quality), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|A|E}, -{"coder", NULL, OFFSET(coder_type), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E, "coder"}, -{"vlc", "variable length coder / huffman coder", 0, FF_OPT_TYPE_CONST, {.dbl = FF_CODER_TYPE_VLC }, INT_MIN, INT_MAX, V|E, "coder"}, -{"ac", "arithmetic coder", 0, FF_OPT_TYPE_CONST, {.dbl = FF_CODER_TYPE_AC }, INT_MIN, INT_MAX, V|E, "coder"}, -{"raw", "raw (no encoding)", 0, FF_OPT_TYPE_CONST, {.dbl = FF_CODER_TYPE_RAW }, INT_MIN, INT_MAX, V|E, "coder"}, -{"rle", "run-length coder", 0, FF_OPT_TYPE_CONST, {.dbl = FF_CODER_TYPE_RLE }, INT_MIN, INT_MAX, V|E, "coder"}, -{"deflate", "deflate-based coder", 0, FF_OPT_TYPE_CONST, {.dbl = FF_CODER_TYPE_DEFLATE }, INT_MIN, INT_MAX, V|E, "coder"}, -{"context", "context model", OFFSET(context_model), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, -{"slice_flags", NULL, OFFSET(slice_flags), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, -{"xvmc_acceleration", NULL, OFFSET(xvmc_acceleration), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, -{"mbd", "macroblock decision algorithm (high quality mode)", OFFSET(mb_decision), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E, "mbd"}, -{"simple", "use mbcmp (default)", 0, FF_OPT_TYPE_CONST, {.dbl = FF_MB_DECISION_SIMPLE }, INT_MIN, INT_MAX, V|E, "mbd"}, -{"bits", "use fewest bits", 0, FF_OPT_TYPE_CONST, {.dbl = FF_MB_DECISION_BITS }, INT_MIN, INT_MAX, V|E, "mbd"}, -{"rd", "use best rate distortion", 0, FF_OPT_TYPE_CONST, {.dbl = FF_MB_DECISION_RD }, INT_MIN, INT_MAX, V|E, "mbd"}, -{"stream_codec_tag", NULL, OFFSET(stream_codec_tag), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, -{"sc_threshold", "scene change threshold", OFFSET(scenechange_threshold), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, -{"lmin", "min lagrange factor (VBR)", OFFSET(lmin), FF_OPT_TYPE_INT, {.dbl = 2*FF_QP2LAMBDA }, 0, INT_MAX, V|E}, -{"lmax", "max lagrange factor (VBR)", OFFSET(lmax), FF_OPT_TYPE_INT, {.dbl = 31*FF_QP2LAMBDA }, 0, INT_MAX, V|E}, -{"nr", "noise reduction", OFFSET(noise_reduction), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, -{"rc_init_occupancy", "number of bits which should be loaded into the rc buffer before decoding starts", OFFSET(rc_initial_buffer_occupancy), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, -{"inter_threshold", NULL, OFFSET(inter_threshold), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, -{"flags2", NULL, OFFSET(flags2), FF_OPT_TYPE_FLAGS, {.dbl = CODEC_FLAG2_FASTPSKIP|CODEC_FLAG2_BIT_RESERVOIR|CODEC_FLAG2_PSY|CODEC_FLAG2_MBTREE }, 0, UINT_MAX, V|A|E|D, "flags2"}, -{"error", NULL, OFFSET(error_rate), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, +{"dctmax", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_CMP_DCTMAX }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"chroma", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_CMP_CHROMA }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"pre_dia_size", "diamond type & size for motion estimation pre-pass", OFFSET(pre_dia_size), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, +{"subq", "sub pel motion estimation quality", OFFSET(me_subpel_quality), AV_OPT_TYPE_INT, {.dbl = 8 }, INT_MIN, INT_MAX, V|E}, +{"dtg_active_format", NULL, OFFSET(dtg_active_format), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, +{"me_range", "limit motion vectors range (1023 for DivX player)", OFFSET(me_range), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, +{"ibias", "intra quant bias", OFFSET(intra_quant_bias), AV_OPT_TYPE_INT, {.dbl = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, V|E}, +{"pbias", "inter quant bias", OFFSET(inter_quant_bias), AV_OPT_TYPE_INT, {.dbl = FF_DEFAULT_QUANT_BIAS }, INT_MIN, INT_MAX, V|E}, +{"color_table_id", NULL, OFFSET(color_table_id), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, +{"internal_buffer_count", NULL, OFFSET(internal_buffer_count), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, +{"global_quality", NULL, OFFSET(global_quality), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|A|E}, +{"coder", NULL, OFFSET(coder_type), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E, "coder"}, +{"vlc", "variable length coder / huffman coder", 0, AV_OPT_TYPE_CONST, {.dbl = FF_CODER_TYPE_VLC }, INT_MIN, INT_MAX, V|E, "coder"}, +{"ac", "arithmetic coder", 0, AV_OPT_TYPE_CONST, {.dbl = FF_CODER_TYPE_AC }, INT_MIN, INT_MAX, V|E, "coder"}, +{"raw", "raw (no encoding)", 0, AV_OPT_TYPE_CONST, {.dbl = FF_CODER_TYPE_RAW }, INT_MIN, INT_MAX, V|E, "coder"}, +{"rle", "run-length coder", 0, AV_OPT_TYPE_CONST, {.dbl = FF_CODER_TYPE_RLE }, INT_MIN, INT_MAX, V|E, "coder"}, +{"deflate", "deflate-based coder", 0, AV_OPT_TYPE_CONST, {.dbl = FF_CODER_TYPE_DEFLATE }, INT_MIN, INT_MAX, V|E, "coder"}, +{"context", "context model", OFFSET(context_model), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, +{"slice_flags", NULL, OFFSET(slice_flags), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, +{"xvmc_acceleration", NULL, OFFSET(xvmc_acceleration), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, +{"mbd", "macroblock decision algorithm (high quality mode)", OFFSET(mb_decision), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E, "mbd"}, +{"simple", "use mbcmp (default)", 0, AV_OPT_TYPE_CONST, {.dbl = FF_MB_DECISION_SIMPLE }, INT_MIN, INT_MAX, V|E, "mbd"}, +{"bits", "use fewest bits", 0, AV_OPT_TYPE_CONST, {.dbl = FF_MB_DECISION_BITS }, INT_MIN, INT_MAX, V|E, "mbd"}, +{"rd", "use best rate distortion", 0, AV_OPT_TYPE_CONST, {.dbl = FF_MB_DECISION_RD }, INT_MIN, INT_MAX, V|E, "mbd"}, +{"stream_codec_tag", NULL, OFFSET(stream_codec_tag), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, +{"sc_threshold", "scene change threshold", OFFSET(scenechange_threshold), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, +{"lmin", "min lagrange factor (VBR)", OFFSET(lmin), AV_OPT_TYPE_INT, {.dbl = 2*FF_QP2LAMBDA }, 0, INT_MAX, V|E}, +{"lmax", "max lagrange factor (VBR)", OFFSET(lmax), AV_OPT_TYPE_INT, {.dbl = 31*FF_QP2LAMBDA }, 0, INT_MAX, V|E}, +{"nr", "noise reduction", OFFSET(noise_reduction), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, +{"rc_init_occupancy", "number of bits which should be loaded into the rc buffer before decoding starts", OFFSET(rc_initial_buffer_occupancy), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, +{"inter_threshold", NULL, OFFSET(inter_threshold), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, +{"flags2", NULL, OFFSET(flags2), AV_OPT_TYPE_FLAGS, {.dbl = CODEC_FLAG2_FASTPSKIP|CODEC_FLAG2_BIT_RESERVOIR|CODEC_FLAG2_PSY|CODEC_FLAG2_MBTREE }, 0, UINT_MAX, V|A|E|D, "flags2"}, +{"error", NULL, OFFSET(error_rate), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, #if FF_API_ANTIALIAS_ALGO -{"antialias", "MP3 antialias algorithm", OFFSET(antialias_algo), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|D, "aa"}, -{"auto", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_AA_AUTO }, INT_MIN, INT_MAX, V|D, "aa"}, -{"fastint", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_AA_FASTINT }, INT_MIN, INT_MAX, V|D, "aa"}, -{"int", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_AA_INT }, INT_MIN, INT_MAX, V|D, "aa"}, -{"float", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_AA_FLOAT }, INT_MIN, INT_MAX, V|D, "aa"}, -#endif -{"qns", "quantizer noise shaping", OFFSET(quantizer_noise_shaping), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, -{"threads", NULL, OFFSET(thread_count), FF_OPT_TYPE_INT, {.dbl = 1 }, INT_MIN, INT_MAX, V|E|D}, -{"me_threshold", "motion estimaton threshold", OFFSET(me_threshold), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, -{"mb_threshold", "macroblock threshold", OFFSET(mb_threshold), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, -{"dc", "intra_dc_precision", OFFSET(intra_dc_precision), FF_OPT_TYPE_INT, {.dbl = 0 }, INT_MIN, INT_MAX, V|E}, -{"nssew", "nsse weight", OFFSET(nsse_weight), FF_OPT_TYPE_INT, {.dbl = 8 }, INT_MIN, INT_MAX, V|E}, -{"skip_top", "number of macroblock rows at the top which are skipped", OFFSET(skip_top), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|D}, -{"skip_bottom", "number of macroblock rows at the bottom which are skipped", OFFSET(skip_bottom), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|D}, -{"profile", NULL, OFFSET(profile), FF_OPT_TYPE_INT, {.dbl = FF_PROFILE_UNKNOWN }, INT_MIN, INT_MAX, V|A|E, "profile"}, -{"unknown", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_PROFILE_UNKNOWN }, INT_MIN, INT_MAX, V|A|E, "profile"}, -{"aac_main", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_PROFILE_AAC_MAIN }, INT_MIN, INT_MAX, A|E, "profile"}, -{"aac_low", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_PROFILE_AAC_LOW }, INT_MIN, INT_MAX, A|E, "profile"}, -{"aac_ssr", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_PROFILE_AAC_SSR }, INT_MIN, INT_MAX, A|E, "profile"}, -{"aac_ltp", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_PROFILE_AAC_LTP }, INT_MIN, INT_MAX, A|E, "profile"}, -{"dts", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_PROFILE_DTS }, INT_MIN, INT_MAX, A|E, "profile"}, -{"dts_es", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_PROFILE_DTS_ES }, INT_MIN, INT_MAX, A|E, "profile"}, -{"dts_96_24", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_PROFILE_DTS_96_24 }, INT_MIN, INT_MAX, A|E, "profile"}, -{"dts_hd_hra", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_PROFILE_DTS_HD_HRA }, INT_MIN, INT_MAX, A|E, "profile"}, -{"dts_hd_ma", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_PROFILE_DTS_HD_MA }, INT_MIN, INT_MAX, A|E, "profile"}, -{"level", NULL, OFFSET(level), FF_OPT_TYPE_INT, {.dbl = FF_LEVEL_UNKNOWN }, INT_MIN, INT_MAX, V|A|E, "level"}, -{"unknown", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_LEVEL_UNKNOWN }, INT_MIN, INT_MAX, V|A|E, "level"}, -{"lowres", "decode at 1= 1/2, 2=1/4, 3=1/8 resolutions", OFFSET(lowres), FF_OPT_TYPE_INT, {.dbl = 0 }, 0, INT_MAX, V|A|D}, -{"skip_threshold", "frame skip threshold", OFFSET(frame_skip_threshold), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, -{"skip_factor", "frame skip factor", OFFSET(frame_skip_factor), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, -{"skip_exp", "frame skip exponent", OFFSET(frame_skip_exp), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, -{"skipcmp", "frame skip compare function", OFFSET(frame_skip_cmp), FF_OPT_TYPE_INT, {.dbl = FF_CMP_DCTMAX }, INT_MIN, INT_MAX, V|E, "cmp_func"}, -{"border_mask", "increases the quantizer for macroblocks close to borders", OFFSET(border_masking), FF_OPT_TYPE_FLOAT, {.dbl = DEFAULT }, -FLT_MAX, FLT_MAX, V|E}, -{"mblmin", "min macroblock lagrange factor (VBR)", OFFSET(mb_lmin), FF_OPT_TYPE_INT, {.dbl = FF_QP2LAMBDA * 2 }, 1, FF_LAMBDA_MAX, V|E}, -{"mblmax", "max macroblock lagrange factor (VBR)", OFFSET(mb_lmax), FF_OPT_TYPE_INT, {.dbl = FF_QP2LAMBDA * 31 }, 1, FF_LAMBDA_MAX, V|E}, -{"mepc", "motion estimation bitrate penalty compensation (1.0 = 256)", OFFSET(me_penalty_compensation), FF_OPT_TYPE_INT, {.dbl = 256 }, INT_MIN, INT_MAX, V|E}, -{"skip_loop_filter", NULL, OFFSET(skip_loop_filter), FF_OPT_TYPE_INT, {.dbl = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX, V|D, "avdiscard"}, -{"skip_idct" , NULL, OFFSET(skip_idct) , FF_OPT_TYPE_INT, {.dbl = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX, V|D, "avdiscard"}, -{"skip_frame" , NULL, OFFSET(skip_frame) , FF_OPT_TYPE_INT, {.dbl = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX, V|D, "avdiscard"}, -{"none" , NULL, 0, FF_OPT_TYPE_CONST, {.dbl = AVDISCARD_NONE }, INT_MIN, INT_MAX, V|D, "avdiscard"}, -{"default" , NULL, 0, FF_OPT_TYPE_CONST, {.dbl = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX, V|D, "avdiscard"}, -{"noref" , NULL, 0, FF_OPT_TYPE_CONST, {.dbl = AVDISCARD_NONREF }, INT_MIN, INT_MAX, V|D, "avdiscard"}, -{"bidir" , NULL, 0, FF_OPT_TYPE_CONST, {.dbl = AVDISCARD_BIDIR }, INT_MIN, INT_MAX, V|D, "avdiscard"}, -{"nokey" , NULL, 0, FF_OPT_TYPE_CONST, {.dbl = AVDISCARD_NONKEY }, INT_MIN, INT_MAX, V|D, "avdiscard"}, -{"all" , NULL, 0, FF_OPT_TYPE_CONST, {.dbl = AVDISCARD_ALL }, INT_MIN, INT_MAX, V|D, "avdiscard"}, -{"bidir_refine", "refine the two motion vectors used in bidirectional macroblocks", OFFSET(bidir_refine), FF_OPT_TYPE_INT, {.dbl = 1 }, 0, 4, V|E}, -{"brd_scale", "downscales frames for dynamic B-frame decision", OFFSET(brd_scale), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, 10, V|E}, +{"antialias", "MP3 antialias algorithm", OFFSET(antialias_algo), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|D, "aa"}, +{"auto", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_AA_AUTO }, INT_MIN, INT_MAX, V|D, "aa"}, +{"fastint", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_AA_FASTINT }, INT_MIN, INT_MAX, V|D, "aa"}, +{"int", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_AA_INT }, INT_MIN, INT_MAX, V|D, "aa"}, +{"float", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_AA_FLOAT }, INT_MIN, INT_MAX, V|D, "aa"}, +#endif +{"qns", "quantizer noise shaping", OFFSET(quantizer_noise_shaping), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, +{"threads", NULL, OFFSET(thread_count), AV_OPT_TYPE_INT, {.dbl = 1 }, INT_MIN, INT_MAX, V|E|D}, +{"me_threshold", "motion estimaton threshold", OFFSET(me_threshold), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, +{"mb_threshold", "macroblock threshold", OFFSET(mb_threshold), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, +{"dc", "intra_dc_precision", OFFSET(intra_dc_precision), AV_OPT_TYPE_INT, {.dbl = 0 }, INT_MIN, INT_MAX, V|E}, +{"nssew", "nsse weight", OFFSET(nsse_weight), AV_OPT_TYPE_INT, {.dbl = 8 }, INT_MIN, INT_MAX, V|E}, +{"skip_top", "number of macroblock rows at the top which are skipped", OFFSET(skip_top), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|D}, +{"skip_bottom", "number of macroblock rows at the bottom which are skipped", OFFSET(skip_bottom), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|D}, +{"profile", NULL, OFFSET(profile), AV_OPT_TYPE_INT, {.dbl = FF_PROFILE_UNKNOWN }, INT_MIN, INT_MAX, V|A|E, "profile"}, +{"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_PROFILE_UNKNOWN }, INT_MIN, INT_MAX, V|A|E, "profile"}, +{"aac_main", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_PROFILE_AAC_MAIN }, INT_MIN, INT_MAX, A|E, "profile"}, +{"aac_low", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_PROFILE_AAC_LOW }, INT_MIN, INT_MAX, A|E, "profile"}, +{"aac_ssr", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_PROFILE_AAC_SSR }, INT_MIN, INT_MAX, A|E, "profile"}, +{"aac_ltp", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_PROFILE_AAC_LTP }, INT_MIN, INT_MAX, A|E, "profile"}, +{"dts", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_PROFILE_DTS }, INT_MIN, INT_MAX, A|E, "profile"}, +{"dts_es", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_PROFILE_DTS_ES }, INT_MIN, INT_MAX, A|E, "profile"}, +{"dts_96_24", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_PROFILE_DTS_96_24 }, INT_MIN, INT_MAX, A|E, "profile"}, +{"dts_hd_hra", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_PROFILE_DTS_HD_HRA }, INT_MIN, INT_MAX, A|E, "profile"}, +{"dts_hd_ma", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_PROFILE_DTS_HD_MA }, INT_MIN, INT_MAX, A|E, "profile"}, +{"level", NULL, OFFSET(level), AV_OPT_TYPE_INT, {.dbl = FF_LEVEL_UNKNOWN }, INT_MIN, INT_MAX, V|A|E, "level"}, +{"unknown", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_LEVEL_UNKNOWN }, INT_MIN, INT_MAX, V|A|E, "level"}, +{"lowres", "decode at 1= 1/2, 2=1/4, 3=1/8 resolutions", OFFSET(lowres), AV_OPT_TYPE_INT, {.dbl = 0 }, 0, INT_MAX, V|A|D}, +{"skip_threshold", "frame skip threshold", OFFSET(frame_skip_threshold), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, +{"skip_factor", "frame skip factor", OFFSET(frame_skip_factor), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, +{"skip_exp", "frame skip exponent", OFFSET(frame_skip_exp), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, +{"skipcmp", "frame skip compare function", OFFSET(frame_skip_cmp), AV_OPT_TYPE_INT, {.dbl = FF_CMP_DCTMAX }, INT_MIN, INT_MAX, V|E, "cmp_func"}, +{"border_mask", "increases the quantizer for macroblocks close to borders", OFFSET(border_masking), AV_OPT_TYPE_FLOAT, {.dbl = DEFAULT }, -FLT_MAX, FLT_MAX, V|E}, +{"mblmin", "min macroblock lagrange factor (VBR)", OFFSET(mb_lmin), AV_OPT_TYPE_INT, {.dbl = FF_QP2LAMBDA * 2 }, 1, FF_LAMBDA_MAX, V|E}, +{"mblmax", "max macroblock lagrange factor (VBR)", OFFSET(mb_lmax), AV_OPT_TYPE_INT, {.dbl = FF_QP2LAMBDA * 31 }, 1, FF_LAMBDA_MAX, V|E}, +{"mepc", "motion estimation bitrate penalty compensation (1.0 = 256)", OFFSET(me_penalty_compensation), AV_OPT_TYPE_INT, {.dbl = 256 }, INT_MIN, INT_MAX, V|E}, +{"skip_loop_filter", NULL, OFFSET(skip_loop_filter), AV_OPT_TYPE_INT, {.dbl = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX, V|D, "avdiscard"}, +{"skip_idct" , NULL, OFFSET(skip_idct) , AV_OPT_TYPE_INT, {.dbl = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX, V|D, "avdiscard"}, +{"skip_frame" , NULL, OFFSET(skip_frame) , AV_OPT_TYPE_INT, {.dbl = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX, V|D, "avdiscard"}, +{"none" , NULL, 0, AV_OPT_TYPE_CONST, {.dbl = AVDISCARD_NONE }, INT_MIN, INT_MAX, V|D, "avdiscard"}, +{"default" , NULL, 0, AV_OPT_TYPE_CONST, {.dbl = AVDISCARD_DEFAULT }, INT_MIN, INT_MAX, V|D, "avdiscard"}, +{"noref" , NULL, 0, AV_OPT_TYPE_CONST, {.dbl = AVDISCARD_NONREF }, INT_MIN, INT_MAX, V|D, "avdiscard"}, +{"bidir" , NULL, 0, AV_OPT_TYPE_CONST, {.dbl = AVDISCARD_BIDIR }, INT_MIN, INT_MAX, V|D, "avdiscard"}, +{"nokey" , NULL, 0, AV_OPT_TYPE_CONST, {.dbl = AVDISCARD_NONKEY }, INT_MIN, INT_MAX, V|D, "avdiscard"}, +{"all" , NULL, 0, AV_OPT_TYPE_CONST, {.dbl = AVDISCARD_ALL }, INT_MIN, INT_MAX, V|D, "avdiscard"}, +{"bidir_refine", "refine the two motion vectors used in bidirectional macroblocks", OFFSET(bidir_refine), AV_OPT_TYPE_INT, {.dbl = 1 }, 0, 4, V|E}, +{"brd_scale", "downscales frames for dynamic B-frame decision", OFFSET(brd_scale), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, 10, V|E}, #if FF_API_X264_GLOBAL_OPTS -{"crf", "enables constant quality mode, and selects the quality (x264/VP8)", OFFSET(crf), FF_OPT_TYPE_FLOAT, {.dbl = DEFAULT }, 0, 63, V|E}, -{"cqp", "constant quantization parameter rate control method", OFFSET(cqp), FF_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, V|E}, +{"crf", "enables constant quality mode, and selects the quality (x264/VP8)", OFFSET(crf), AV_OPT_TYPE_FLOAT, {.dbl = DEFAULT }, 0, 63, V|E}, +{"cqp", "constant quantization parameter rate control method", OFFSET(cqp), AV_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, V|E}, #endif -{"keyint_min", "minimum interval between IDR-frames", OFFSET(keyint_min), FF_OPT_TYPE_INT, {.dbl = 25 }, INT_MIN, INT_MAX, V|E}, -{"refs", "reference frames to consider for motion compensation", OFFSET(refs), FF_OPT_TYPE_INT, {.dbl = 1 }, INT_MIN, INT_MAX, V|E}, -{"chromaoffset", "chroma qp offset from luma", OFFSET(chromaoffset), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, +{"keyint_min", "minimum interval between IDR-frames", OFFSET(keyint_min), AV_OPT_TYPE_INT, {.dbl = 25 }, INT_MIN, INT_MAX, V|E}, +{"refs", "reference frames to consider for motion compensation", OFFSET(refs), AV_OPT_TYPE_INT, {.dbl = 1 }, INT_MIN, INT_MAX, V|E}, +{"chromaoffset", "chroma qp offset from luma", OFFSET(chromaoffset), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, #if FF_API_X264_GLOBAL_OPTS -{"bframebias", "influences how often B-frames are used", OFFSET(bframebias), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, +{"bframebias", "influences how often B-frames are used", OFFSET(bframebias), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E}, #endif -{"trellis", "rate-distortion optimal quantization", OFFSET(trellis), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|A|E}, +{"trellis", "rate-distortion optimal quantization", OFFSET(trellis), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|A|E}, #if FF_API_X264_GLOBAL_OPTS -{"directpred", "direct mv prediction mode - 0 (none), 1 (spatial), 2 (temporal), 3 (auto)", OFFSET(directpred), FF_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, V|E}, -{"bpyramid", "allows B-frames to be used as references for predicting", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_BPYRAMID }, INT_MIN, INT_MAX, V|E, "flags2"}, -{"wpred", "weighted biprediction for b-frames (H.264)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_WPRED }, INT_MIN, INT_MAX, V|E, "flags2"}, -{"mixed_refs", "one reference per partition, as opposed to one reference per macroblock", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_MIXED_REFS }, INT_MIN, INT_MAX, V|E, "flags2"}, -{"dct8x8", "high profile 8x8 transform (H.264)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_8X8DCT }, INT_MIN, INT_MAX, V|E, "flags2"}, -{"fastpskip", "fast pskip (H.264)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_FASTPSKIP }, INT_MIN, INT_MAX, V|E, "flags2"}, -{"aud", "access unit delimiters (H.264)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_AUD }, INT_MIN, INT_MAX, V|E, "flags2"}, +{"directpred", "direct mv prediction mode - 0 (none), 1 (spatial), 2 (temporal), 3 (auto)", OFFSET(directpred), AV_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, V|E}, +{"bpyramid", "allows B-frames to be used as references for predicting", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_BPYRAMID }, INT_MIN, INT_MAX, V|E, "flags2"}, +{"wpred", "weighted biprediction for b-frames (H.264)", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_WPRED }, INT_MIN, INT_MAX, V|E, "flags2"}, +{"mixed_refs", "one reference per partition, as opposed to one reference per macroblock", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_MIXED_REFS }, INT_MIN, INT_MAX, V|E, "flags2"}, +{"dct8x8", "high profile 8x8 transform (H.264)", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_8X8DCT }, INT_MIN, INT_MAX, V|E, "flags2"}, +{"fastpskip", "fast pskip (H.264)", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_FASTPSKIP }, INT_MIN, INT_MAX, V|E, "flags2"}, +{"aud", "access unit delimiters (H.264)", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_AUD }, INT_MIN, INT_MAX, V|E, "flags2"}, #endif -{"skiprd", "RD optimal MB level residual skipping", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_SKIP_RD }, INT_MIN, INT_MAX, V|E, "flags2"}, +{"skiprd", "RD optimal MB level residual skipping", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_SKIP_RD }, INT_MIN, INT_MAX, V|E, "flags2"}, #if FF_API_X264_GLOBAL_OPTS -{"complexityblur", "reduce fluctuations in qp (before curve compression)", OFFSET(complexityblur), FF_OPT_TYPE_FLOAT, {.dbl = -1 }, -1, FLT_MAX, V|E}, -{"deblockalpha", "in-loop deblocking filter alphac0 parameter", OFFSET(deblockalpha), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, -6, 6, V|E}, -{"deblockbeta", "in-loop deblocking filter beta parameter", OFFSET(deblockbeta), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, -6, 6, V|E}, -{"partitions", "macroblock subpartition sizes to consider", OFFSET(partitions), FF_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E, "partitions"}, -{"parti4x4", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = X264_PART_I4X4 }, INT_MIN, INT_MAX, V|E, "partitions"}, -{"parti8x8", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = X264_PART_I8X8 }, INT_MIN, INT_MAX, V|E, "partitions"}, -{"partp4x4", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = X264_PART_P4X4 }, INT_MIN, INT_MAX, V|E, "partitions"}, -{"partp8x8", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = X264_PART_P8X8 }, INT_MIN, INT_MAX, V|E, "partitions"}, -{"partb8x8", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = X264_PART_B8X8 }, INT_MIN, INT_MAX, V|E, "partitions"}, +{"complexityblur", "reduce fluctuations in qp (before curve compression)", OFFSET(complexityblur), AV_OPT_TYPE_FLOAT, {.dbl = -1 }, -1, FLT_MAX, V|E}, +{"deblockalpha", "in-loop deblocking filter alphac0 parameter", OFFSET(deblockalpha), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, -6, 6, V|E}, +{"deblockbeta", "in-loop deblocking filter beta parameter", OFFSET(deblockbeta), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, -6, 6, V|E}, +{"partitions", "macroblock subpartition sizes to consider", OFFSET(partitions), AV_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, INT_MIN, INT_MAX, V|E, "partitions"}, +{"parti4x4", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = X264_PART_I4X4 }, INT_MIN, INT_MAX, V|E, "partitions"}, +{"parti8x8", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = X264_PART_I8X8 }, INT_MIN, INT_MAX, V|E, "partitions"}, +{"partp4x4", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = X264_PART_P4X4 }, INT_MIN, INT_MAX, V|E, "partitions"}, +{"partp8x8", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = X264_PART_P8X8 }, INT_MIN, INT_MAX, V|E, "partitions"}, +{"partb8x8", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = X264_PART_B8X8 }, INT_MIN, INT_MAX, V|E, "partitions"}, #endif -{"sc_factor", "multiplied by qscale for each frame and added to scene_change_score", OFFSET(scenechange_factor), FF_OPT_TYPE_INT, {.dbl = 6 }, 0, INT_MAX, V|E}, -{"mv0_threshold", NULL, OFFSET(mv0_threshold), FF_OPT_TYPE_INT, {.dbl = 256 }, 0, INT_MAX, V|E}, +{"sc_factor", "multiplied by qscale for each frame and added to scene_change_score", OFFSET(scenechange_factor), AV_OPT_TYPE_INT, {.dbl = 6 }, 0, INT_MAX, V|E}, +{"mv0_threshold", NULL, OFFSET(mv0_threshold), AV_OPT_TYPE_INT, {.dbl = 256 }, 0, INT_MAX, V|E}, #if FF_API_MPEGVIDEO_GLOBAL_OPTS -{"ivlc", "intra vlc table", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_INTRA_VLC }, INT_MIN, INT_MAX, V|E, "flags2"}, +{"ivlc", "intra vlc table", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_INTRA_VLC }, INT_MIN, INT_MAX, V|E, "flags2"}, #endif -{"b_sensitivity", "adjusts sensitivity of b_frame_strategy 1", OFFSET(b_sensitivity), FF_OPT_TYPE_INT, {.dbl = 40 }, 1, INT_MAX, V|E}, -{"compression_level", NULL, OFFSET(compression_level), FF_OPT_TYPE_INT, {.dbl = FF_COMPRESSION_DEFAULT }, INT_MIN, INT_MAX, V|A|E}, -{"min_prediction_order", NULL, OFFSET(min_prediction_order), FF_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, A|E}, -{"max_prediction_order", NULL, OFFSET(max_prediction_order), FF_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, A|E}, +{"b_sensitivity", "adjusts sensitivity of b_frame_strategy 1", OFFSET(b_sensitivity), AV_OPT_TYPE_INT, {.dbl = 40 }, 1, INT_MAX, V|E}, +{"compression_level", NULL, OFFSET(compression_level), AV_OPT_TYPE_INT, {.dbl = FF_COMPRESSION_DEFAULT }, INT_MIN, INT_MAX, V|A|E}, +{"min_prediction_order", NULL, OFFSET(min_prediction_order), AV_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, A|E}, +{"max_prediction_order", NULL, OFFSET(max_prediction_order), AV_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, A|E}, #if FF_API_FLAC_GLOBAL_OPTS -{"lpc_coeff_precision", "deprecated, use flac-specific options", OFFSET(lpc_coeff_precision), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, A|E}, -{"prediction_order_method", "deprecated, use flac-specific options", OFFSET(prediction_order_method), FF_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, A|E}, -{"min_partition_order", "deprecated, use flac-specific options", OFFSET(min_partition_order), FF_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, A|E}, -{"max_partition_order", "deprecated, use flac-specific options", OFFSET(max_partition_order), FF_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, A|E}, +{"lpc_coeff_precision", "deprecated, use flac-specific options", OFFSET(lpc_coeff_precision), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, A|E}, +{"prediction_order_method", "deprecated, use flac-specific options", OFFSET(prediction_order_method), AV_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, A|E}, +{"min_partition_order", "deprecated, use flac-specific options", OFFSET(min_partition_order), AV_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, A|E}, +{"max_partition_order", "deprecated, use flac-specific options", OFFSET(max_partition_order), AV_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, A|E}, #endif -{"timecode_frame_start", "GOP timecode frame start number, in non drop frame format", OFFSET(timecode_frame_start), FF_OPT_TYPE_INT64, {.dbl = 0 }, 0, INT64_MAX, V|E}, +{"timecode_frame_start", "GOP timecode frame start number, in non drop frame format", OFFSET(timecode_frame_start), AV_OPT_TYPE_INT64, {.dbl = 0 }, 0, INT64_MAX, V|E}, #if FF_API_MPEGVIDEO_GLOBAL_OPTS -{"drop_frame_timecode", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_DROP_FRAME_TIMECODE }, INT_MIN, INT_MAX, V|E, "flags2"}, -{"non_linear_q", "use non linear quantizer", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_NON_LINEAR_QUANT }, INT_MIN, INT_MAX, V|E, "flags2"}, +{"drop_frame_timecode", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_DROP_FRAME_TIMECODE }, INT_MIN, INT_MAX, V|E, "flags2"}, +{"non_linear_q", "use non linear quantizer", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_NON_LINEAR_QUANT }, INT_MIN, INT_MAX, V|E, "flags2"}, #endif #if FF_API_REQUEST_CHANNELS -{"request_channels", "set desired number of audio channels", OFFSET(request_channels), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, A|D}, +{"request_channels", "set desired number of audio channels", OFFSET(request_channels), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, A|D}, #endif #if FF_API_DRC_SCALE -{"drc_scale", "percentage of dynamic range compression to apply", OFFSET(drc_scale), FF_OPT_TYPE_FLOAT, {.dbl = 0.0 }, 0.0, 1.0, A|D}, +{"drc_scale", "percentage of dynamic range compression to apply", OFFSET(drc_scale), AV_OPT_TYPE_FLOAT, {.dbl = 0.0 }, 0.0, 1.0, A|D}, #endif #if FF_API_LAME_GLOBAL_OPTS -{"reservoir", "use bit reservoir", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_BIT_RESERVOIR }, INT_MIN, INT_MAX, A|E, "flags2"}, +{"reservoir", "use bit reservoir", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_BIT_RESERVOIR }, INT_MIN, INT_MAX, A|E, "flags2"}, #endif #if FF_API_X264_GLOBAL_OPTS -{"mbtree", "use macroblock tree ratecontrol (x264 only)", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_MBTREE }, INT_MIN, INT_MAX, V|E, "flags2"}, +{"mbtree", "use macroblock tree ratecontrol (x264 only)", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_MBTREE }, INT_MIN, INT_MAX, V|E, "flags2"}, #endif -{"bits_per_raw_sample", NULL, OFFSET(bits_per_raw_sample), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, -{"channel_layout", NULL, OFFSET(channel_layout), FF_OPT_TYPE_INT64, {.dbl = DEFAULT }, 0, INT64_MAX, A|E|D, "channel_layout"}, -{"request_channel_layout", NULL, OFFSET(request_channel_layout), FF_OPT_TYPE_INT64, {.dbl = DEFAULT }, 0, INT64_MAX, A|D, "request_channel_layout"}, -{"rc_max_vbv_use", NULL, OFFSET(rc_max_available_vbv_use), FF_OPT_TYPE_FLOAT, {.dbl = 1.0/3 }, 0.0, FLT_MAX, V|E}, -{"rc_min_vbv_use", NULL, OFFSET(rc_min_vbv_overflow_use), FF_OPT_TYPE_FLOAT, {.dbl = 3 }, 0.0, FLT_MAX, V|E}, -{"ticks_per_frame", NULL, OFFSET(ticks_per_frame), FF_OPT_TYPE_INT, {.dbl = 1 }, 1, INT_MAX, A|V|E|D}, -{"color_primaries", NULL, OFFSET(color_primaries), FF_OPT_TYPE_INT, {.dbl = AVCOL_PRI_UNSPECIFIED }, 1, AVCOL_PRI_NB-1, V|E|D}, -{"color_trc", NULL, OFFSET(color_trc), FF_OPT_TYPE_INT, {.dbl = AVCOL_TRC_UNSPECIFIED }, 1, AVCOL_TRC_NB-1, V|E|D}, -{"colorspace", NULL, OFFSET(colorspace), FF_OPT_TYPE_INT, {.dbl = AVCOL_SPC_UNSPECIFIED }, 1, AVCOL_SPC_NB-1, V|E|D}, -{"color_range", NULL, OFFSET(color_range), FF_OPT_TYPE_INT, {.dbl = AVCOL_RANGE_UNSPECIFIED }, 0, AVCOL_RANGE_NB-1, V|E|D}, -{"chroma_sample_location", NULL, OFFSET(chroma_sample_location), FF_OPT_TYPE_INT, {.dbl = AVCHROMA_LOC_UNSPECIFIED }, 0, AVCHROMA_LOC_NB-1, V|E|D}, +{"bits_per_raw_sample", NULL, OFFSET(bits_per_raw_sample), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, INT_MIN, INT_MAX}, +{"channel_layout", NULL, OFFSET(channel_layout), AV_OPT_TYPE_INT64, {.dbl = DEFAULT }, 0, INT64_MAX, A|E|D, "channel_layout"}, +{"request_channel_layout", NULL, OFFSET(request_channel_layout), AV_OPT_TYPE_INT64, {.dbl = DEFAULT }, 0, INT64_MAX, A|D, "request_channel_layout"}, +{"rc_max_vbv_use", NULL, OFFSET(rc_max_available_vbv_use), AV_OPT_TYPE_FLOAT, {.dbl = 1.0/3 }, 0.0, FLT_MAX, V|E}, +{"rc_min_vbv_use", NULL, OFFSET(rc_min_vbv_overflow_use), AV_OPT_TYPE_FLOAT, {.dbl = 3 }, 0.0, FLT_MAX, V|E}, +{"ticks_per_frame", NULL, OFFSET(ticks_per_frame), AV_OPT_TYPE_INT, {.dbl = 1 }, 1, INT_MAX, A|V|E|D}, +{"color_primaries", NULL, OFFSET(color_primaries), AV_OPT_TYPE_INT, {.dbl = AVCOL_PRI_UNSPECIFIED }, 1, AVCOL_PRI_NB-1, V|E|D}, +{"color_trc", NULL, OFFSET(color_trc), AV_OPT_TYPE_INT, {.dbl = AVCOL_TRC_UNSPECIFIED }, 1, AVCOL_TRC_NB-1, V|E|D}, +{"colorspace", NULL, OFFSET(colorspace), AV_OPT_TYPE_INT, {.dbl = AVCOL_SPC_UNSPECIFIED }, 1, AVCOL_SPC_NB-1, V|E|D}, +{"color_range", NULL, OFFSET(color_range), AV_OPT_TYPE_INT, {.dbl = AVCOL_RANGE_UNSPECIFIED }, 0, AVCOL_RANGE_NB-1, V|E|D}, +{"chroma_sample_location", NULL, OFFSET(chroma_sample_location), AV_OPT_TYPE_INT, {.dbl = AVCHROMA_LOC_UNSPECIFIED }, 0, AVCHROMA_LOC_NB-1, V|E|D}, #if FF_API_X264_GLOBAL_OPTS -{"psy", "use psycho visual optimization", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_PSY }, INT_MIN, INT_MAX, V|E, "flags2"}, -{"psy_rd", "specify psycho visual strength", OFFSET(psy_rd), FF_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1, FLT_MAX, V|E}, -{"psy_trellis", "specify psycho visual trellis", OFFSET(psy_trellis), FF_OPT_TYPE_FLOAT, {.dbl = -1 }, -1, FLT_MAX, V|E}, -{"aq_mode", "specify aq method", OFFSET(aq_mode), FF_OPT_TYPE_INT, {.dbl = -1 }, -1, INT_MAX, V|E}, -{"aq_strength", "specify aq strength", OFFSET(aq_strength), FF_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1, FLT_MAX, V|E}, -{"rc_lookahead", "specify number of frames to look ahead for frametype", OFFSET(rc_lookahead), FF_OPT_TYPE_INT, {.dbl = 40 }, -1, INT_MAX, V|E}, -{"ssim", "ssim will be calculated during encoding", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_SSIM }, INT_MIN, INT_MAX, V|E, "flags2"}, -{"intra_refresh", "use periodic insertion of intra blocks instead of keyframes", 0, FF_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_INTRA_REFRESH }, INT_MIN, INT_MAX, V|E, "flags2"}, -{"crf_max", "in crf mode, prevents vbv from lowering quality beyond this point", OFFSET(crf_max), FF_OPT_TYPE_FLOAT, {.dbl = DEFAULT }, 0, 51, V|E}, +{"psy", "use psycho visual optimization", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_PSY }, INT_MIN, INT_MAX, V|E, "flags2"}, +{"psy_rd", "specify psycho visual strength", OFFSET(psy_rd), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1, FLT_MAX, V|E}, +{"psy_trellis", "specify psycho visual trellis", OFFSET(psy_trellis), AV_OPT_TYPE_FLOAT, {.dbl = -1 }, -1, FLT_MAX, V|E}, +{"aq_mode", "specify aq method", OFFSET(aq_mode), AV_OPT_TYPE_INT, {.dbl = -1 }, -1, INT_MAX, V|E}, +{"aq_strength", "specify aq strength", OFFSET(aq_strength), AV_OPT_TYPE_FLOAT, {.dbl = -1.0 }, -1, FLT_MAX, V|E}, +{"rc_lookahead", "specify number of frames to look ahead for frametype", OFFSET(rc_lookahead), AV_OPT_TYPE_INT, {.dbl = 40 }, -1, INT_MAX, V|E}, +{"ssim", "ssim will be calculated during encoding", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_SSIM }, INT_MIN, INT_MAX, V|E, "flags2"}, +{"intra_refresh", "use periodic insertion of intra blocks instead of keyframes", 0, AV_OPT_TYPE_CONST, {.dbl = CODEC_FLAG2_INTRA_REFRESH }, INT_MIN, INT_MAX, V|E, "flags2"}, +{"crf_max", "in crf mode, prevents vbv from lowering quality beyond this point", OFFSET(crf_max), AV_OPT_TYPE_FLOAT, {.dbl = DEFAULT }, 0, 51, V|E}, #endif -{"log_level_offset", "set the log level offset", OFFSET(log_level_offset), FF_OPT_TYPE_INT, {.dbl = 0 }, INT_MIN, INT_MAX }, +{"log_level_offset", "set the log level offset", OFFSET(log_level_offset), AV_OPT_TYPE_INT, {.dbl = 0 }, INT_MIN, INT_MAX }, #if FF_API_FLAC_GLOBAL_OPTS -{"lpc_type", "deprecated, use flac-specific options", OFFSET(lpc_type), FF_OPT_TYPE_INT, {.dbl = AV_LPC_TYPE_DEFAULT }, AV_LPC_TYPE_DEFAULT, AV_LPC_TYPE_NB-1, A|E}, -{"none", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = AV_LPC_TYPE_NONE }, INT_MIN, INT_MAX, A|E, "lpc_type"}, -{"fixed", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = AV_LPC_TYPE_FIXED }, INT_MIN, INT_MAX, A|E, "lpc_type"}, -{"levinson", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = AV_LPC_TYPE_LEVINSON }, INT_MIN, INT_MAX, A|E, "lpc_type"}, -{"cholesky", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = AV_LPC_TYPE_CHOLESKY }, INT_MIN, INT_MAX, A|E, "lpc_type"}, -{"lpc_passes", "deprecated, use flac-specific options", OFFSET(lpc_passes), FF_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, A|E}, -#endif -{"slices", "number of slices, used in parallelized decoding", OFFSET(slices), FF_OPT_TYPE_INT, {.dbl = 0 }, 0, INT_MAX, V|E}, -{"thread_type", "select multithreading type", OFFSET(thread_type), FF_OPT_TYPE_FLAGS, {.dbl = FF_THREAD_SLICE|FF_THREAD_FRAME }, 0, INT_MAX, V|E|D, "thread_type"}, -{"slice", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_THREAD_SLICE }, INT_MIN, INT_MAX, V|E|D, "thread_type"}, -{"frame", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_THREAD_FRAME }, INT_MIN, INT_MAX, V|E|D, "thread_type"}, -{"audio_service_type", "audio service type", OFFSET(audio_service_type), FF_OPT_TYPE_INT, {.dbl = AV_AUDIO_SERVICE_TYPE_MAIN }, 0, AV_AUDIO_SERVICE_TYPE_NB-1, A|E, "audio_service_type"}, -{"ma", "Main Audio Service", 0, FF_OPT_TYPE_CONST, {.dbl = AV_AUDIO_SERVICE_TYPE_MAIN }, INT_MIN, INT_MAX, A|E, "audio_service_type"}, -{"ef", "Effects", 0, FF_OPT_TYPE_CONST, {.dbl = AV_AUDIO_SERVICE_TYPE_EFFECTS }, INT_MIN, INT_MAX, A|E, "audio_service_type"}, -{"vi", "Visually Impaired", 0, FF_OPT_TYPE_CONST, {.dbl = AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED }, INT_MIN, INT_MAX, A|E, "audio_service_type"}, -{"hi", "Hearing Impaired", 0, FF_OPT_TYPE_CONST, {.dbl = AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED }, INT_MIN, INT_MAX, A|E, "audio_service_type"}, -{"di", "Dialogue", 0, FF_OPT_TYPE_CONST, {.dbl = AV_AUDIO_SERVICE_TYPE_DIALOGUE }, INT_MIN, INT_MAX, A|E, "audio_service_type"}, -{"co", "Commentary", 0, FF_OPT_TYPE_CONST, {.dbl = AV_AUDIO_SERVICE_TYPE_COMMENTARY }, INT_MIN, INT_MAX, A|E, "audio_service_type"}, -{"em", "Emergency", 0, FF_OPT_TYPE_CONST, {.dbl = AV_AUDIO_SERVICE_TYPE_EMERGENCY }, INT_MIN, INT_MAX, A|E, "audio_service_type"}, -{"vo", "Voice Over", 0, FF_OPT_TYPE_CONST, {.dbl = AV_AUDIO_SERVICE_TYPE_VOICE_OVER }, INT_MIN, INT_MAX, A|E, "audio_service_type"}, -{"ka", "Karaoke", 0, FF_OPT_TYPE_CONST, {.dbl = AV_AUDIO_SERVICE_TYPE_KARAOKE }, INT_MIN, INT_MAX, A|E, "audio_service_type"}, -{"request_sample_fmt", "sample format audio decoders should prefer", OFFSET(request_sample_fmt), FF_OPT_TYPE_INT, {.dbl = AV_SAMPLE_FMT_NONE }, AV_SAMPLE_FMT_NONE, AV_SAMPLE_FMT_NB-1, A|D, "request_sample_fmt"}, -{"u8" , "8-bit unsigned integer", 0, FF_OPT_TYPE_CONST, {.dbl = AV_SAMPLE_FMT_U8 }, INT_MIN, INT_MAX, A|D, "request_sample_fmt"}, -{"s16", "16-bit signed integer", 0, FF_OPT_TYPE_CONST, {.dbl = AV_SAMPLE_FMT_S16 }, INT_MIN, INT_MAX, A|D, "request_sample_fmt"}, -{"s32", "32-bit signed integer", 0, FF_OPT_TYPE_CONST, {.dbl = AV_SAMPLE_FMT_S32 }, INT_MIN, INT_MAX, A|D, "request_sample_fmt"}, -{"flt", "32-bit float", 0, FF_OPT_TYPE_CONST, {.dbl = AV_SAMPLE_FMT_FLT }, INT_MIN, INT_MAX, A|D, "request_sample_fmt"}, -{"dbl", "64-bit double", 0, FF_OPT_TYPE_CONST, {.dbl = AV_SAMPLE_FMT_DBL }, INT_MIN, INT_MAX, A|D, "request_sample_fmt"}, +{"lpc_type", "deprecated, use flac-specific options", OFFSET(lpc_type), AV_OPT_TYPE_INT, {.dbl = AV_LPC_TYPE_DEFAULT }, AV_LPC_TYPE_DEFAULT, AV_LPC_TYPE_NB-1, A|E}, +{"none", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = AV_LPC_TYPE_NONE }, INT_MIN, INT_MAX, A|E, "lpc_type"}, +{"fixed", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = AV_LPC_TYPE_FIXED }, INT_MIN, INT_MAX, A|E, "lpc_type"}, +{"levinson", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = AV_LPC_TYPE_LEVINSON }, INT_MIN, INT_MAX, A|E, "lpc_type"}, +{"cholesky", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = AV_LPC_TYPE_CHOLESKY }, INT_MIN, INT_MAX, A|E, "lpc_type"}, +{"lpc_passes", "deprecated, use flac-specific options", OFFSET(lpc_passes), AV_OPT_TYPE_INT, {.dbl = -1 }, INT_MIN, INT_MAX, A|E}, +#endif +{"slices", "number of slices, used in parallelized decoding", OFFSET(slices), AV_OPT_TYPE_INT, {.dbl = 0 }, 0, INT_MAX, V|E}, +{"thread_type", "select multithreading type", OFFSET(thread_type), AV_OPT_TYPE_FLAGS, {.dbl = FF_THREAD_SLICE|FF_THREAD_FRAME }, 0, INT_MAX, V|E|D, "thread_type"}, +{"slice", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_THREAD_SLICE }, INT_MIN, INT_MAX, V|E|D, "thread_type"}, +{"frame", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_THREAD_FRAME }, INT_MIN, INT_MAX, V|E|D, "thread_type"}, +{"audio_service_type", "audio service type", OFFSET(audio_service_type), AV_OPT_TYPE_INT, {.dbl = AV_AUDIO_SERVICE_TYPE_MAIN }, 0, AV_AUDIO_SERVICE_TYPE_NB-1, A|E, "audio_service_type"}, +{"ma", "Main Audio Service", 0, AV_OPT_TYPE_CONST, {.dbl = AV_AUDIO_SERVICE_TYPE_MAIN }, INT_MIN, INT_MAX, A|E, "audio_service_type"}, +{"ef", "Effects", 0, AV_OPT_TYPE_CONST, {.dbl = AV_AUDIO_SERVICE_TYPE_EFFECTS }, INT_MIN, INT_MAX, A|E, "audio_service_type"}, +{"vi", "Visually Impaired", 0, AV_OPT_TYPE_CONST, {.dbl = AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED }, INT_MIN, INT_MAX, A|E, "audio_service_type"}, +{"hi", "Hearing Impaired", 0, AV_OPT_TYPE_CONST, {.dbl = AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED }, INT_MIN, INT_MAX, A|E, "audio_service_type"}, +{"di", "Dialogue", 0, AV_OPT_TYPE_CONST, {.dbl = AV_AUDIO_SERVICE_TYPE_DIALOGUE }, INT_MIN, INT_MAX, A|E, "audio_service_type"}, +{"co", "Commentary", 0, AV_OPT_TYPE_CONST, {.dbl = AV_AUDIO_SERVICE_TYPE_COMMENTARY }, INT_MIN, INT_MAX, A|E, "audio_service_type"}, +{"em", "Emergency", 0, AV_OPT_TYPE_CONST, {.dbl = AV_AUDIO_SERVICE_TYPE_EMERGENCY }, INT_MIN, INT_MAX, A|E, "audio_service_type"}, +{"vo", "Voice Over", 0, AV_OPT_TYPE_CONST, {.dbl = AV_AUDIO_SERVICE_TYPE_VOICE_OVER }, INT_MIN, INT_MAX, A|E, "audio_service_type"}, +{"ka", "Karaoke", 0, AV_OPT_TYPE_CONST, {.dbl = AV_AUDIO_SERVICE_TYPE_KARAOKE }, INT_MIN, INT_MAX, A|E, "audio_service_type"}, +{"request_sample_fmt", "sample format audio decoders should prefer", OFFSET(request_sample_fmt), AV_OPT_TYPE_INT, {.dbl = AV_SAMPLE_FMT_NONE }, AV_SAMPLE_FMT_NONE, AV_SAMPLE_FMT_NB-1, A|D, "request_sample_fmt"}, +{"u8" , "8-bit unsigned integer", 0, AV_OPT_TYPE_CONST, {.dbl = AV_SAMPLE_FMT_U8 }, INT_MIN, INT_MAX, A|D, "request_sample_fmt"}, +{"s16", "16-bit signed integer", 0, AV_OPT_TYPE_CONST, {.dbl = AV_SAMPLE_FMT_S16 }, INT_MIN, INT_MAX, A|D, "request_sample_fmt"}, +{"s32", "32-bit signed integer", 0, AV_OPT_TYPE_CONST, {.dbl = AV_SAMPLE_FMT_S32 }, INT_MIN, INT_MAX, A|D, "request_sample_fmt"}, +{"flt", "32-bit float", 0, AV_OPT_TYPE_CONST, {.dbl = AV_SAMPLE_FMT_FLT }, INT_MIN, INT_MAX, A|D, "request_sample_fmt"}, +{"dbl", "64-bit double", 0, AV_OPT_TYPE_CONST, {.dbl = AV_SAMPLE_FMT_DBL }, INT_MIN, INT_MAX, A|D, "request_sample_fmt"}, {NULL}, }; @@ -523,40 +533,45 @@ .option = options, .version = LIBAVUTIL_VERSION_INT, .log_level_offset_offset = OFFSET(log_level_offset), - .opt_find = opt_find, + .child_next = codec_child_next, + .child_class_next = codec_child_class_next, }; +#if FF_API_ALLOC_CONTEXT void avcodec_get_context_defaults2(AVCodecContext *s, enum AVMediaType codec_type){ + AVCodec c= {0}; + c.type= codec_type; + avcodec_get_context_defaults3(s, &c); +} +#endif + +int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec){ int flags=0; memset(s, 0, sizeof(AVCodecContext)); - s->av_class= &av_codec_context_class; + s->av_class = &av_codec_context_class; - s->codec_type = codec_type; - if(codec_type == AVMEDIA_TYPE_AUDIO) + s->codec_type = codec ? codec->type : AVMEDIA_TYPE_UNKNOWN; + if(s->codec_type == AVMEDIA_TYPE_AUDIO) flags= AV_OPT_FLAG_AUDIO_PARAM; - else if(codec_type == AVMEDIA_TYPE_VIDEO) + else if(s->codec_type == AVMEDIA_TYPE_VIDEO) flags= AV_OPT_FLAG_VIDEO_PARAM; - else if(codec_type == AVMEDIA_TYPE_SUBTITLE) + else if(s->codec_type == AVMEDIA_TYPE_SUBTITLE) flags= AV_OPT_FLAG_SUBTITLE_PARAM; av_opt_set_defaults2(s, flags, flags); - s->time_base= (AVRational){0,1}; - s->get_buffer= avcodec_default_get_buffer; - s->release_buffer= avcodec_default_release_buffer; - s->get_format= avcodec_default_get_format; - s->execute= avcodec_default_execute; - s->execute2= avcodec_default_execute2; - s->sample_aspect_ratio= (AVRational){0,1}; - s->pix_fmt= PIX_FMT_NONE; - s->sample_fmt= AV_SAMPLE_FMT_NONE; - - s->reget_buffer= avcodec_default_reget_buffer; - s->reordered_opaque= AV_NOPTS_VALUE; -} + s->time_base = (AVRational){0,1}; + s->get_buffer = avcodec_default_get_buffer; + s->release_buffer = avcodec_default_release_buffer; + s->get_format = avcodec_default_get_format; + s->execute = avcodec_default_execute; + s->execute2 = avcodec_default_execute2; + s->sample_aspect_ratio = (AVRational){0,1}; + s->pix_fmt = PIX_FMT_NONE; + s->sample_fmt = AV_SAMPLE_FMT_NONE; -int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec){ - avcodec_get_context_defaults2(s, codec ? codec->type : AVMEDIA_TYPE_UNKNOWN); + s->reget_buffer = avcodec_default_reget_buffer; + s->reordered_opaque = AV_NOPTS_VALUE; if(codec && codec->priv_data_size){ if(!s->priv_data){ s->priv_data= av_mallocz(codec->priv_data_size); @@ -604,13 +619,11 @@ return avctx; } -#endif void avcodec_get_context_defaults(AVCodecContext *s){ avcodec_get_context_defaults2(s, AVMEDIA_TYPE_UNKNOWN); } -#if FF_API_ALLOC_CONTEXT AVCodecContext *avcodec_alloc_context(void){ return avcodec_alloc_context2(AVMEDIA_TYPE_UNKNOWN); } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/pcm.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/pcm.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/pcm.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/pcm.c 2011-11-04 12:38:26.000000000 +0000 @@ -95,11 +95,6 @@ samples = data; dst = frame; - if (avctx->sample_fmt!=avctx->codec->sample_fmts[0]) { - av_log(avctx, AV_LOG_ERROR, "invalid sample_fmt\n"); - return -1; - } - switch(avctx->codec->id) { case CODEC_ID_PCM_U32LE: ENCODE(uint32_t, le32, samples, dst, n, 0, 0x80000000) @@ -176,14 +171,6 @@ memcpy(dst, samples, n*sample_size); dst += n*sample_size; break; - case CODEC_ID_PCM_ZORK: - for(;n>0;n--) { - v= *samples++ >> 8; - if(v<0) v = -v; - else v+= 128; - *dst++ = v; - } - break; case CODEC_ID_PCM_ALAW: for(;n>0;n--) { v = *samples++; @@ -213,6 +200,11 @@ PCMDecode *s = avctx->priv_data; int i; + if (avctx->channels <= 0 || avctx->channels > MAX_CHANNELS) { + av_log(avctx, AV_LOG_ERROR, "PCM channels out of bounds\n"); + return AVERROR(EINVAL); + } + switch(avctx->codec->id) { case CODEC_ID_PCM_ALAW: for(i=0;i<256;i++) @@ -236,7 +228,7 @@ /** * Read PCM samples macro - * @param type Datatype of native machine format + * @param size Data size of native machine format * @param endian bytestream_get_xxx() endian suffix * @param src Source pointer (variable name) * @param dst Destination pointer (variable name) @@ -244,51 +236,40 @@ * @param shift Bitshift (bits) * @param offset Sample value offset */ -#define DECODE(type, endian, src, dst, n, shift, offset) \ - dst_##type = (type*)dst; \ +#define DECODE(size, endian, src, dst, n, shift, offset) \ for(;n>0;n--) { \ - register type v = bytestream_get_##endian(&src); \ - *dst_##type++ = (v - offset) << shift; \ - } \ - dst = (short*)dst_##type; + uint##size##_t v = bytestream_get_##endian(&src); \ + AV_WN##size##A(dst, (v - offset) << shift); \ + dst += size / 8; \ + } static int pcm_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { - const uint8_t *buf = avpkt->data; + const uint8_t *src = avpkt->data; int buf_size = avpkt->size; PCMDecode *s = avctx->priv_data; - int sample_size, c, n, i; - short *samples; - const uint8_t *src, *src8, *src2[MAX_CHANNELS]; - uint8_t *dstu8; - int16_t *dst_int16_t; + int sample_size, c, n, out_size; + uint8_t *samples; int32_t *dst_int32_t; - int64_t *dst_int64_t; - uint16_t *dst_uint16_t; - uint32_t *dst_uint32_t; samples = data; - src = buf; - - if (avctx->sample_fmt!=avctx->codec->sample_fmts[0]) { - av_log(avctx, AV_LOG_ERROR, "invalid sample_fmt\n"); - return -1; - } - - if(avctx->channels <= 0 || avctx->channels > MAX_CHANNELS){ - av_log(avctx, AV_LOG_ERROR, "PCM channels out of bounds\n"); - return -1; - } sample_size = av_get_bits_per_sample(avctx->codec_id)/8; /* av_get_bits_per_sample returns 0 for CODEC_ID_PCM_DVD */ - if (CODEC_ID_PCM_DVD == avctx->codec_id) + if (CODEC_ID_PCM_DVD == avctx->codec_id) { + if (avctx->bits_per_coded_sample != 20 && + avctx->bits_per_coded_sample != 24) { + av_log(avctx, AV_LOG_ERROR, + "PCM DVD unsupported sample depth %i\n", + avctx->bits_per_coded_sample); + return AVERROR(EINVAL); + } /* 2 samples are interleaved per block in PCM_DVD */ sample_size = avctx->bits_per_coded_sample * 2 / 8; - else if (avctx->codec_id == CODEC_ID_PCM_LXF) + } else if (avctx->codec_id == CODEC_ID_PCM_LXF) /* we process 40-bit blocks per channel for LXF */ sample_size = 5; @@ -307,70 +288,79 @@ buf_size -= buf_size % n; } - buf_size= FFMIN(buf_size, *data_size/2); - *data_size=0; - n = buf_size/sample_size; + out_size = n * av_get_bytes_per_sample(avctx->sample_fmt); + if (avctx->codec_id == CODEC_ID_PCM_DVD || + avctx->codec_id == CODEC_ID_PCM_LXF) + out_size *= 2; + if (*data_size < out_size) { + av_log(avctx, AV_LOG_ERROR, "output buffer too small\n"); + return AVERROR(EINVAL); + } + switch(avctx->codec->id) { case CODEC_ID_PCM_U32LE: - DECODE(uint32_t, le32, src, samples, n, 0, 0x80000000) + DECODE(32, le32, src, samples, n, 0, 0x80000000) break; case CODEC_ID_PCM_U32BE: - DECODE(uint32_t, be32, src, samples, n, 0, 0x80000000) + DECODE(32, be32, src, samples, n, 0, 0x80000000) break; case CODEC_ID_PCM_S24LE: - DECODE(int32_t, le24, src, samples, n, 8, 0) + DECODE(32, le24, src, samples, n, 8, 0) break; case CODEC_ID_PCM_S24BE: - DECODE(int32_t, be24, src, samples, n, 8, 0) + DECODE(32, be24, src, samples, n, 8, 0) break; case CODEC_ID_PCM_U24LE: - DECODE(uint32_t, le24, src, samples, n, 8, 0x800000) + DECODE(32, le24, src, samples, n, 8, 0x800000) break; case CODEC_ID_PCM_U24BE: - DECODE(uint32_t, be24, src, samples, n, 8, 0x800000) + DECODE(32, be24, src, samples, n, 8, 0x800000) break; case CODEC_ID_PCM_S24DAUD: for(;n>0;n--) { uint32_t v = bytestream_get_be24(&src); v >>= 4; // sync flags are here - *samples++ = av_reverse[(v >> 8) & 0xff] + - (av_reverse[v & 0xff] << 8); + AV_WN16A(samples, av_reverse[(v >> 8) & 0xff] + + (av_reverse[v & 0xff] << 8)); + samples += 2; } break; case CODEC_ID_PCM_S16LE_PLANAR: + { + const uint8_t *src2[MAX_CHANNELS]; n /= avctx->channels; for(c=0;cchannels;c++) src2[c] = &src[c*n*2]; for(;n>0;n--) - for(c=0;cchannels;c++) - *samples++ = bytestream_get_le16(&src2[c]); - src = src2[avctx->channels-1]; + for(c=0;cchannels;c++) { + AV_WN16A(samples, bytestream_get_le16(&src2[c])); + samples += 2; + } break; + } case CODEC_ID_PCM_U16LE: - DECODE(uint16_t, le16, src, samples, n, 0, 0x8000) + DECODE(16, le16, src, samples, n, 0, 0x8000) break; case CODEC_ID_PCM_U16BE: - DECODE(uint16_t, be16, src, samples, n, 0, 0x8000) + DECODE(16, be16, src, samples, n, 0, 0x8000) break; case CODEC_ID_PCM_S8: - dstu8= (uint8_t*)samples; for(;n>0;n--) { - *dstu8++ = *src++ + 128; + *samples++ = *src++ + 128; } - samples= (short*)dstu8; break; #if HAVE_BIGENDIAN case CODEC_ID_PCM_F64LE: - DECODE(int64_t, le64, src, samples, n, 0, 0) + DECODE(64, le64, src, samples, n, 0, 0) break; case CODEC_ID_PCM_S32LE: case CODEC_ID_PCM_F32LE: - DECODE(int32_t, le32, src, samples, n, 0, 0) + DECODE(32, le32, src, samples, n, 0, 0) break; case CODEC_ID_PCM_S16LE: - DECODE(int16_t, le16, src, samples, n, 0, 0) + DECODE(16, le16, src, samples, n, 0, 0) break; case CODEC_ID_PCM_F64BE: case CODEC_ID_PCM_F32BE: @@ -378,14 +368,14 @@ case CODEC_ID_PCM_S16BE: #else case CODEC_ID_PCM_F64BE: - DECODE(int64_t, be64, src, samples, n, 0, 0) + DECODE(64, be64, src, samples, n, 0, 0) break; case CODEC_ID_PCM_F32BE: case CODEC_ID_PCM_S32BE: - DECODE(int32_t, be32, src, samples, n, 0, 0) + DECODE(32, be32, src, samples, n, 0, 0) break; case CODEC_ID_PCM_S16BE: - DECODE(int16_t, be16, src, samples, n, 0, 0) + DECODE(16, be16, src, samples, n, 0, 0) break; case CODEC_ID_PCM_F64LE: case CODEC_ID_PCM_F32LE: @@ -394,24 +384,26 @@ #endif /* HAVE_BIGENDIAN */ case CODEC_ID_PCM_U8: memcpy(samples, src, n*sample_size); - src += n*sample_size; - samples = (short*)((uint8_t*)data + n*sample_size); + samples += n * sample_size; break; case CODEC_ID_PCM_ZORK: - for(;n>0;n--) { - int x= *src++; - if(x&128) x-= 128; - else x = -x; - *samples++ = x << 8; + for (; n > 0; n--) { + int v = *src++; + if (v < 128) + v = 128 - v; + *samples++ = v; } break; case CODEC_ID_PCM_ALAW: case CODEC_ID_PCM_MULAW: for(;n>0;n--) { - *samples++ = s->table[*src++]; + AV_WN16A(samples, s->table[*src++]); + samples += 2; } break; case CODEC_ID_PCM_DVD: + { + const uint8_t *src8; dst_int32_t = data; n /= avctx->channels; switch (avctx->bits_per_coded_sample) { @@ -437,13 +429,14 @@ src = src8; } break; - default: - av_log(avctx, AV_LOG_ERROR, "PCM DVD unsupported sample depth\n"); - return -1; } - samples = (short *) dst_int32_t; + samples = (uint8_t *) dst_int32_t; break; + } case CODEC_ID_PCM_LXF: + { + int i; + const uint8_t *src8; dst_int32_t = data; n /= avctx->channels; //unpack and de-planerize @@ -460,14 +453,14 @@ ((src8[2] & 0xF0) << 8) | (src8[4] << 4) | (src8[3] >> 4); } } - src += n * avctx->channels * 5; - samples = (short *) dst_int32_t; + samples = (uint8_t *) dst_int32_t; break; + } default: return -1; } - *data_size = (uint8_t *)samples - (uint8_t *)data; - return src - buf; + *data_size = out_size; + return buf_size; } #if CONFIG_ENCODERS @@ -530,4 +523,4 @@ PCM_CODEC (CODEC_ID_PCM_U24LE, AV_SAMPLE_FMT_S32, pcm_u24le, "PCM unsigned 24-bit little-endian"); PCM_CODEC (CODEC_ID_PCM_U32BE, AV_SAMPLE_FMT_S32, pcm_u32be, "PCM unsigned 32-bit big-endian"); PCM_CODEC (CODEC_ID_PCM_U32LE, AV_SAMPLE_FMT_S32, pcm_u32le, "PCM unsigned 32-bit little-endian"); -PCM_CODEC (CODEC_ID_PCM_ZORK, AV_SAMPLE_FMT_S16, pcm_zork, "PCM Zork"); +PCM_DECODER(CODEC_ID_PCM_ZORK, AV_SAMPLE_FMT_U8, pcm_zork, "PCM Zork"); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/pcm-mpeg.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/pcm-mpeg.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/pcm-mpeg.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/pcm-mpeg.c 2011-11-04 12:38:26.000000000 +0000 @@ -75,6 +75,8 @@ } avctx->sample_fmt = avctx->bits_per_coded_sample == 16 ? AV_SAMPLE_FMT_S16 : AV_SAMPLE_FMT_S32; + if (avctx->sample_fmt == AV_SAMPLE_FMT_S32) + avctx->bits_per_raw_sample = avctx->bits_per_coded_sample; /* get the sample rate. Not all values are known or exist. */ switch (header[2] & 0x0f) { diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/pnm_parser.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/pnm_parser.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/pnm_parser.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/pnm_parser.c 2011-11-04 12:38:26.000000000 +0000 @@ -84,9 +84,9 @@ } AVCodecParser ff_pnm_parser = { - { CODEC_ID_PGM, CODEC_ID_PGMYUV, CODEC_ID_PPM, CODEC_ID_PBM, CODEC_ID_PAM}, - sizeof(ParseContext), - NULL, - pnm_parse, - ff_parse_close, + .codec_ids = { CODEC_ID_PGM, CODEC_ID_PGMYUV, CODEC_ID_PPM, + CODEC_ID_PBM, CODEC_ID_PAM }, + .priv_data_size = sizeof(ParseContext), + .parser_parse = pnm_parse, + .parser_close = ff_parse_close, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ppc/h264_altivec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ppc/h264_altivec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ppc/h264_altivec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ppc/h264_altivec.c 2011-11-04 12:38:27.000000000 +0000 @@ -843,7 +843,8 @@ } static av_always_inline -void weight_h264_WxH_altivec(uint8_t *block, int stride, int log2_denom, int weight, int offset, int w, int h) +void weight_h264_W_altivec(uint8_t *block, int stride, int height, + int log2_denom, int weight, int offset, int w) { int y, aligned; vec_u8 vblock; @@ -864,7 +865,7 @@ voffset = vec_splat(vtemp, 5); aligned = !((unsigned long)block & 0xf); - for (y=0; ybits_per_raw_sample > 8; @@ -1015,16 +1015,10 @@ c->h264_v_loop_filter_luma= h264_v_loop_filter_luma_altivec; c->h264_h_loop_filter_luma= h264_h_loop_filter_luma_altivec; - c->weight_h264_pixels_tab[0] = ff_weight_h264_pixels16x16_altivec; - c->weight_h264_pixels_tab[1] = ff_weight_h264_pixels16x8_altivec; - c->weight_h264_pixels_tab[2] = ff_weight_h264_pixels8x16_altivec; - c->weight_h264_pixels_tab[3] = ff_weight_h264_pixels8x8_altivec; - c->weight_h264_pixels_tab[4] = ff_weight_h264_pixels8x4_altivec; - c->biweight_h264_pixels_tab[0] = ff_biweight_h264_pixels16x16_altivec; - c->biweight_h264_pixels_tab[1] = ff_biweight_h264_pixels16x8_altivec; - c->biweight_h264_pixels_tab[2] = ff_biweight_h264_pixels8x16_altivec; - c->biweight_h264_pixels_tab[3] = ff_biweight_h264_pixels8x8_altivec; - c->biweight_h264_pixels_tab[4] = ff_biweight_h264_pixels8x4_altivec; + c->weight_h264_pixels_tab[0] = ff_weight_h264_pixels16_altivec; + c->weight_h264_pixels_tab[1] = ff_weight_h264_pixels8_altivec; + c->biweight_h264_pixels_tab[0] = ff_biweight_h264_pixels16_altivec; + c->biweight_h264_pixels_tab[1] = ff_biweight_h264_pixels8_altivec; } } } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/proresdec2.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/proresdec2.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/proresdec2.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/proresdec2.c 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,593 @@ +/* + * Copyright (c) 2010-2011 Maxim Poliakovski + * Copyright (c) 2010-2011 Elvis Presley + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * Known FOURCCs: 'apch' (HQ), 'apcn' (SD), 'apcs' (LT), 'acpo' (Proxy), 'ap4h' (4444) + */ + +//#define DEBUG + +#define A32_BITSTREAM_READER + +#include "avcodec.h" +#include "get_bits.h" +#include "simple_idct.h" +#include "proresdec.h" + +static void permute(uint8_t *dst, const uint8_t *src, const uint8_t permutation[64]) +{ + int i; + for (i = 0; i < 64; i++) + dst[i] = permutation[src[i]]; +} + +static const uint8_t progressive_scan[64] = { + 0, 1, 8, 9, 2, 3, 10, 11, + 16, 17, 24, 25, 18, 19, 26, 27, + 4, 5, 12, 20, 13, 6, 7, 14, + 21, 28, 29, 22, 15, 23, 30, 31, + 32, 33, 40, 48, 41, 34, 35, 42, + 49, 56, 57, 50, 43, 36, 37, 44, + 51, 58, 59, 52, 45, 38, 39, 46, + 53, 60, 61, 54, 47, 55, 62, 63 +}; + +static const uint8_t interlaced_scan[64] = { + 0, 8, 1, 9, 16, 24, 17, 25, + 2, 10, 3, 11, 18, 26, 19, 27, + 32, 40, 33, 34, 41, 48, 56, 49, + 42, 35, 43, 50, 57, 58, 51, 59, + 4, 12, 5, 6, 13, 20, 28, 21, + 14, 7, 15, 22, 29, 36, 44, 37, + 30, 23, 31, 38, 45, 52, 60, 53, + 46, 39, 47, 54, 61, 62, 55, 63, +}; + +static av_cold int decode_init(AVCodecContext *avctx) +{ + ProresContext *ctx = avctx->priv_data; + uint8_t idct_permutation[64]; + + avctx->bits_per_raw_sample = 10; + + dsputil_init(&ctx->dsp, avctx); + ff_proresdsp_init(&ctx->prodsp, avctx); + + avctx->coded_frame = &ctx->frame; + ctx->frame.type = FF_I_TYPE; + ctx->frame.key_frame = 1; + + ff_init_scantable_permutation(idct_permutation, + ctx->prodsp.idct_permutation_type); + + permute(ctx->progressive_scan, progressive_scan, idct_permutation); + permute(ctx->interlaced_scan, interlaced_scan, idct_permutation); + + return 0; +} + +static int decode_frame_header(ProresContext *ctx, const uint8_t *buf, + const int data_size, AVCodecContext *avctx) +{ + int hdr_size, width, height, flags; + int version; + const uint8_t *ptr; + + hdr_size = AV_RB16(buf); + av_dlog(avctx, "header size %d\n", hdr_size); + if (hdr_size > data_size) { + av_log(avctx, AV_LOG_ERROR, "error, wrong header size\n"); + return -1; + } + + version = AV_RB16(buf + 2); + av_dlog(avctx, "%.4s version %d\n", buf+4, version); + if (version > 1) { + av_log(avctx, AV_LOG_ERROR, "unsupported version: %d\n", version); + return -1; + } + + width = AV_RB16(buf + 8); + height = AV_RB16(buf + 10); + if (width != avctx->width || height != avctx->height) { + av_log(avctx, AV_LOG_ERROR, "picture resolution change: %dx%d -> %dx%d\n", + avctx->width, avctx->height, width, height); + return -1; + } + + ctx->frame_type = (buf[12] >> 2) & 3; + + av_dlog(avctx, "frame type %d\n", ctx->frame_type); + + if (ctx->frame_type == 0) { + ctx->scan = ctx->progressive_scan; // permuted + } else { + ctx->scan = ctx->interlaced_scan; // permuted + ctx->frame.interlaced_frame = 1; + ctx->frame.top_field_first = ctx->frame_type == 1; + } + + avctx->pix_fmt = (buf[12] & 0xC0) == 0xC0 ? PIX_FMT_YUV444P10 : PIX_FMT_YUV422P10; + + ptr = buf + 20; + flags = buf[19]; + av_dlog(avctx, "flags %x\n", flags); + + if (flags & 2) { + permute(ctx->qmat_luma, ctx->prodsp.idct_permutation, ptr); + ptr += 64; + } else { + memset(ctx->qmat_luma, 4, 64); + } + + if (flags & 1) { + permute(ctx->qmat_chroma, ctx->prodsp.idct_permutation, ptr); + } else { + memset(ctx->qmat_chroma, 4, 64); + } + + return hdr_size; +} + +static int decode_picture_header(AVCodecContext *avctx, const uint8_t *buf, const int buf_size) +{ + ProresContext *ctx = avctx->priv_data; + int i, hdr_size, slice_count; + unsigned pic_data_size; + int log2_slice_mb_width, log2_slice_mb_height; + int slice_mb_count, mb_x, mb_y; + const uint8_t *data_ptr, *index_ptr; + + hdr_size = buf[0] >> 3; + if (hdr_size < 8 || hdr_size > buf_size) { + av_log(avctx, AV_LOG_ERROR, "error, wrong picture header size\n"); + return -1; + } + + pic_data_size = AV_RB32(buf + 1); + if (pic_data_size > buf_size) { + av_log(avctx, AV_LOG_ERROR, "error, wrong picture data size\n"); + return -1; + } + + log2_slice_mb_width = buf[7] >> 4; + log2_slice_mb_height = buf[7] & 0xF; + if (log2_slice_mb_width > 3 || log2_slice_mb_height) { + av_log(avctx, AV_LOG_ERROR, "unsupported slice resolution: %dx%d\n", + 1 << log2_slice_mb_width, 1 << log2_slice_mb_height); + return -1; + } + + ctx->mb_width = (avctx->width + 15) >> 4; + if (ctx->frame_type) + ctx->mb_height = (avctx->height + 31) >> 5; + else + ctx->mb_height = (avctx->height + 15) >> 4; + + slice_count = AV_RB16(buf + 5); + + if (ctx->slice_count != slice_count || !ctx->slices) { + av_freep(&ctx->slices); + ctx->slices = av_mallocz(slice_count * sizeof(*ctx->slices)); + if (!ctx->slices) + return AVERROR(ENOMEM); + ctx->slice_count = slice_count; + } + + if (!slice_count) + return AVERROR(EINVAL); + + if (hdr_size + slice_count*2 > buf_size) { + av_log(avctx, AV_LOG_ERROR, "error, wrong slice count\n"); + return -1; + } + + // parse slice information + index_ptr = buf + hdr_size; + data_ptr = index_ptr + slice_count*2; + + slice_mb_count = 1 << log2_slice_mb_width; + mb_x = 0; + mb_y = 0; + + for (i = 0; i < slice_count; i++) { + SliceContext *slice = &ctx->slices[i]; + + slice->data = data_ptr; + data_ptr += AV_RB16(index_ptr + i*2); + + while (ctx->mb_width - mb_x < slice_mb_count) + slice_mb_count >>= 1; + + slice->mb_x = mb_x; + slice->mb_y = mb_y; + slice->mb_count = slice_mb_count; + slice->data_size = data_ptr - slice->data; + + if (slice->data_size < 6) { + av_log(avctx, AV_LOG_ERROR, "error, wrong slice data size\n"); + return -1; + } + + mb_x += slice_mb_count; + if (mb_x == ctx->mb_width) { + slice_mb_count = 1 << log2_slice_mb_width; + mb_x = 0; + mb_y++; + } + if (data_ptr > buf + buf_size) { + av_log(avctx, AV_LOG_ERROR, "error, slice out of bounds\n"); + return -1; + } + } + + if (mb_x || mb_y != ctx->mb_height) { + av_log(avctx, AV_LOG_ERROR, "error wrong mb count y %d h %d\n", + mb_y, ctx->mb_height); + return -1; + } + + return pic_data_size; +} + +#define DECODE_CODEWORD(val, codebook) \ + do { \ + unsigned int rice_order, exp_order, switch_bits; \ + unsigned int q, buf, bits; \ + \ + UPDATE_CACHE(re, gb); \ + buf = GET_CACHE(re, gb); \ + \ + /* number of bits to switch between rice and exp golomb */ \ + switch_bits = codebook & 3; \ + rice_order = codebook >> 5; \ + exp_order = (codebook >> 2) & 7; \ + \ + q = 31 - av_log2(buf); \ + \ + if (q > switch_bits) { /* exp golomb */ \ + bits = exp_order - switch_bits + (q<<1); \ + val = SHOW_UBITS(re, gb, bits) - (1 << exp_order) + \ + ((switch_bits + 1) << rice_order); \ + SKIP_BITS(re, gb, bits); \ + } else if (rice_order) { \ + SKIP_BITS(re, gb, q+1); \ + val = (q << rice_order) + SHOW_UBITS(re, gb, rice_order); \ + SKIP_BITS(re, gb, rice_order); \ + } else { \ + val = q; \ + SKIP_BITS(re, gb, q+1); \ + } \ + } while (0); \ + +#define TOSIGNED(x) (((x) >> 1) ^ (-((x) & 1))) + +#define FIRST_DC_CB 0xB8 + +static const uint8_t dc_codebook[7] = { 0x04, 0x28, 0x28, 0x4D, 0x4D, 0x70, 0x70}; + +static av_always_inline void decode_dc_coeffs(GetBitContext *gb, DCTELEM *out, + int blocks_per_slice) +{ + DCTELEM prev_dc; + int code, i, sign; + + OPEN_READER(re, gb); + + DECODE_CODEWORD(code, FIRST_DC_CB); + prev_dc = TOSIGNED(code); + out[0] = prev_dc; + + out += 64; // dc coeff for the next block + + code = 5; + sign = 0; + for (i = 1; i < blocks_per_slice; i++, out += 64) { + DECODE_CODEWORD(code, dc_codebook[FFMIN(code, 6)]); + if(code) sign ^= -(code & 1); + else sign = 0; + prev_dc += (((code + 1) >> 1) ^ sign) - sign; + out[0] = prev_dc; + } + CLOSE_READER(re, gb); +} + +// adaptive codebook switching lut according to previous run/level values +static const uint8_t run_to_cb[16] = { 0x06, 0x06, 0x05, 0x05, 0x04, 0x29, 0x29, 0x29, 0x29, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x4C }; +static const uint8_t lev_to_cb[10] = { 0x04, 0x0A, 0x05, 0x06, 0x04, 0x28, 0x28, 0x28, 0x28, 0x4C }; + +static av_always_inline void decode_ac_coeffs(AVCodecContext *avctx, GetBitContext *gb, + DCTELEM *out, int blocks_per_slice) +{ + ProresContext *ctx = avctx->priv_data; + int block_mask, sign; + unsigned pos, run, level; + int max_coeffs, i, bits_left; + int log2_block_count = av_log2(blocks_per_slice); + + OPEN_READER(re, gb); + + run = 4; + level = 2; + + max_coeffs = 64 << log2_block_count; + block_mask = blocks_per_slice - 1; + + for (pos = block_mask;;) { + bits_left = gb->size_in_bits - (((uint8_t*)re_buffer_ptr - gb->buffer)*8 - 32 + re_bit_count); + if (!bits_left || (bits_left < 32 && !SHOW_UBITS(re, gb, bits_left))) + break; + + DECODE_CODEWORD(run, run_to_cb[FFMIN(run, 15)]); + pos += run + 1; + if (pos >= max_coeffs) { + av_log(avctx, AV_LOG_ERROR, "ac tex damaged %d, %d\n", pos, max_coeffs); + return; + } + + DECODE_CODEWORD(level, lev_to_cb[FFMIN(level, 9)]); + level += 1; + + i = pos >> log2_block_count; + + sign = SHOW_SBITS(re, gb, 1); + SKIP_BITS(re, gb, 1); + out[((pos & block_mask) << 6) + ctx->scan[i]] = ((level ^ sign) - sign); + } + + CLOSE_READER(re, gb); +} + +static void decode_slice_luma(AVCodecContext *avctx, SliceContext *slice, + uint8_t *dst, int dst_stride, + const uint8_t *buf, unsigned buf_size, + const int16_t *qmat) +{ + ProresContext *ctx = avctx->priv_data; + LOCAL_ALIGNED_16(DCTELEM, blocks, [8*4*64]); + DCTELEM *block; + GetBitContext gb; + int i, blocks_per_slice = slice->mb_count<<2; + + for (i = 0; i < blocks_per_slice; i++) + ctx->dsp.clear_block(blocks+(i<<6)); + + init_get_bits(&gb, buf, buf_size << 3); + + decode_dc_coeffs(&gb, blocks, blocks_per_slice); + decode_ac_coeffs(avctx, &gb, blocks, blocks_per_slice); + + block = blocks; + for (i = 0; i < slice->mb_count; i++) { + ctx->prodsp.idct_put(dst, dst_stride, block+(0<<6), qmat); + ctx->prodsp.idct_put(dst+16, dst_stride, block+(1<<6), qmat); + ctx->prodsp.idct_put(dst+8*dst_stride, dst_stride, block+(2<<6), qmat); + ctx->prodsp.idct_put(dst+8*dst_stride+16, dst_stride, block+(3<<6), qmat); + block += 4*64; + dst += 32; + } +} + +static void decode_slice_chroma(AVCodecContext *avctx, SliceContext *slice, + uint8_t *dst, int dst_stride, + const uint8_t *buf, unsigned buf_size, + const int16_t *qmat, int log2_blocks_per_mb) +{ + ProresContext *ctx = avctx->priv_data; + LOCAL_ALIGNED_16(DCTELEM, blocks, [8*4*64]); + DCTELEM *block; + GetBitContext gb; + int i, j, blocks_per_slice = slice->mb_count << log2_blocks_per_mb; + + for (i = 0; i < blocks_per_slice; i++) + ctx->dsp.clear_block(blocks+(i<<6)); + + init_get_bits(&gb, buf, buf_size << 3); + + decode_dc_coeffs(&gb, blocks, blocks_per_slice); + decode_ac_coeffs(avctx, &gb, blocks, blocks_per_slice); + + block = blocks; + for (i = 0; i < slice->mb_count; i++) { + for (j = 0; j < log2_blocks_per_mb; j++) { + ctx->prodsp.idct_put(dst, dst_stride, block+(0<<6), qmat); + ctx->prodsp.idct_put(dst+8*dst_stride, dst_stride, block+(1<<6), qmat); + block += 2*64; + dst += 16; + } + } +} + +static int decode_slice_thread(AVCodecContext *avctx, void *arg, int jobnr, int threadnr) +{ + ProresContext *ctx = avctx->priv_data; + SliceContext *slice = &ctx->slices[jobnr]; + const uint8_t *buf = slice->data; + AVFrame *pic = avctx->coded_frame; + int i, hdr_size, qscale, log2_chroma_blocks_per_mb; + int luma_stride, chroma_stride; + int y_data_size, u_data_size, v_data_size; + uint8_t *dest_y, *dest_u, *dest_v; + int16_t qmat_luma_scaled[64]; + int16_t qmat_chroma_scaled[64]; + int mb_x_shift; + + //av_log(avctx, AV_LOG_INFO, "slice %d mb width %d mb x %d y %d\n", + // jobnr, slice->mb_count, slice->mb_x, slice->mb_y); + + // slice header + hdr_size = buf[0] >> 3; + qscale = av_clip(buf[1], 1, 224); + qscale = qscale > 128 ? qscale - 96 << 2: qscale; + y_data_size = AV_RB16(buf + 2); + u_data_size = AV_RB16(buf + 4); + v_data_size = slice->data_size - y_data_size - u_data_size - hdr_size; + if (hdr_size > 7) v_data_size = AV_RB16(buf + 6); + + if (y_data_size < 0 || u_data_size < 0 || v_data_size < 0) { + av_log(avctx, AV_LOG_ERROR, "invalid plane data size\n"); + return -1; + } + + buf += hdr_size; + + for (i = 0; i < 64; i++) { + qmat_luma_scaled [i] = ctx->qmat_luma [i] * qscale; + qmat_chroma_scaled[i] = ctx->qmat_chroma[i] * qscale; + } + + if (ctx->frame_type == 0) { + luma_stride = pic->linesize[0]; + chroma_stride = pic->linesize[1]; + } else { + luma_stride = pic->linesize[0] << 1; + chroma_stride = pic->linesize[1] << 1; + } + + if (avctx->pix_fmt == PIX_FMT_YUV444P10) { + mb_x_shift = 5; + log2_chroma_blocks_per_mb = 2; + } else { + mb_x_shift = 4; + log2_chroma_blocks_per_mb = 1; + } + + dest_y = pic->data[0] + (slice->mb_y << 4) * luma_stride + (slice->mb_x << 5); + dest_u = pic->data[1] + (slice->mb_y << 4) * chroma_stride + (slice->mb_x << mb_x_shift); + dest_v = pic->data[2] + (slice->mb_y << 4) * chroma_stride + (slice->mb_x << mb_x_shift); + + if (ctx->frame_type && ctx->first_field ^ ctx->frame.top_field_first) { + dest_y += pic->linesize[0]; + dest_u += pic->linesize[1]; + dest_v += pic->linesize[2]; + } + + decode_slice_luma(avctx, slice, dest_y, luma_stride, + buf, y_data_size, qmat_luma_scaled); + + if (!(avctx->flags & CODEC_FLAG_GRAY)) { + decode_slice_chroma(avctx, slice, dest_u, chroma_stride, + buf + y_data_size, u_data_size, + qmat_chroma_scaled, log2_chroma_blocks_per_mb); + decode_slice_chroma(avctx, slice, dest_v, chroma_stride, + buf + y_data_size + u_data_size, v_data_size, + qmat_chroma_scaled, log2_chroma_blocks_per_mb); + } + + return 0; +} + +static int decode_picture(AVCodecContext *avctx) +{ + ProresContext *ctx = avctx->priv_data; + int i, threads_ret[ctx->slice_count]; + + avctx->execute2(avctx, decode_slice_thread, NULL, threads_ret, ctx->slice_count); + + for (i = 0; i < ctx->slice_count; i++) + if (threads_ret[i] < 0) + return threads_ret[i]; + + return 0; +} + +static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, + AVPacket *avpkt) +{ + ProresContext *ctx = avctx->priv_data; + AVFrame *frame = avctx->coded_frame; + const uint8_t *buf = avpkt->data; + int buf_size = avpkt->size; + int frame_hdr_size, pic_size; + + if (buf_size < 28 || AV_RL32(buf + 4) != AV_RL32("icpf")) { + av_log(avctx, AV_LOG_ERROR, "invalid frame header\n"); + return -1; + } + + ctx->first_field = 1; + + buf += 8; + buf_size -= 8; + + frame_hdr_size = decode_frame_header(ctx, buf, buf_size, avctx); + if (frame_hdr_size < 0) + return -1; + + buf += frame_hdr_size; + buf_size -= frame_hdr_size; + + if (frame->data[0]) + avctx->release_buffer(avctx, frame); + + if (avctx->get_buffer(avctx, frame) < 0) + return -1; + + decode_picture: + pic_size = decode_picture_header(avctx, buf, buf_size); + if (pic_size < 0) { + av_log(avctx, AV_LOG_ERROR, "error decoding picture header\n"); + return -1; + } + + if (decode_picture(avctx)) { + av_log(avctx, AV_LOG_ERROR, "error decoding picture\n"); + return -1; + } + + buf += pic_size; + buf_size -= pic_size; + + if (ctx->frame_type && buf_size > 0 && ctx->first_field) { + ctx->first_field = 0; + goto decode_picture; + } + + *data_size = sizeof(AVFrame); + *(AVFrame*)data = *frame; + + return avpkt->size; +} + +static av_cold int decode_close(AVCodecContext *avctx) +{ + ProresContext *ctx = avctx->priv_data; + + AVFrame *frame = avctx->coded_frame; + if (frame->data[0]) + avctx->release_buffer(avctx, frame); + av_freep(&ctx->slices); + + return 0; +} + +AVCodec ff_prores_decoder = { + .name = "prores", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_PRORES, + .priv_data_size = sizeof(ProresContext), + .init = decode_init, + .close = decode_close, + .decode = decode_frame, + .long_name = NULL_IF_CONFIG_SMALL("ProRes"), + .capabilities = CODEC_CAP_DR1 | CODEC_CAP_SLICE_THREADS, +}; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/proresdec_gpl.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/proresdec_gpl.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/proresdec_gpl.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/proresdec_gpl.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,632 +0,0 @@ -/* - * Copyright (c) 2010-2011 Maxim Poliakovski - * Copyright (c) 2010-2011 Elvis Presley - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; - * version 2 of the License. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * Known FOURCCs: 'apch' (HQ), 'apcn' (SD), 'apcs' (LT), 'acpo' (Proxy), 'ap4c' (4444) - */ - -//#define DEBUG - -#define A32_BITSTREAM_READER - -#include "avcodec.h" -#include "get_bits.h" -#include "dsputil.h" -#include "simple_idct.h" - -typedef struct { - const uint8_t *data; - unsigned mb_x; - unsigned mb_y; - unsigned mb_count; - unsigned data_size; -} SliceContext; - -typedef struct { - AVFrame frame; - DSPContext dsp; - int frame_type; ///< 0 = progressive, 1 = tff, 2 = bff - uint8_t qmat_luma[64]; - uint8_t qmat_chroma[64]; - SliceContext *slices; - int slice_count; ///< number of slices in the current picture - unsigned mb_width; ///< width of the current picture in mb - unsigned mb_height; ///< height of the current picture in mb - uint8_t progressive_scan[64]; - uint8_t interlaced_scan[64]; - const uint8_t *scan; - int first_field; - void (*idct_put)(DCTELEM *, uint8_t *restrict, int); -} ProresContext; - -static void permute(uint8_t *dst, const uint8_t *src, const uint8_t permutation[64]) -{ - int i; - for (i = 0; i < 64; i++) - dst[i] = permutation[src[i]]; -} - -static av_always_inline void put_pixels(const DCTELEM *block, uint8_t *restrict pixels, int stride) -{ - int16_t *p = (int16_t*)pixels; - int i, j; - - stride >>= 1; - for(i = 0; i < 8; i++) { - for (j = 0; j < 8; j++) { - p[j] = av_clip(block[j], 4, 1019); - } - p += stride; - block += 8; - } -} - -static void idct_put(DCTELEM *block, uint8_t *restrict pixels, int stride) -{ - ff_simple_idct_10(block); - put_pixels(block, pixels, stride); -} - -static const uint8_t progressive_scan[64] = { - 0, 1, 8, 9, 2, 3, 10, 11, - 16, 17, 24, 25, 18, 19, 26, 27, - 4, 5, 12, 20, 13, 6, 7, 14, - 21, 28, 29, 22, 15, 23, 30, 31, - 32, 33, 40, 48, 41, 34, 35, 42, - 49, 56, 57, 50, 43, 36, 37, 44, - 51, 58, 59, 52, 45, 38, 39, 46, - 53, 60, 61, 54, 47, 55, 62, 63 -}; - -static const uint8_t interlaced_scan[64] = { - 0, 8, 1, 9, 16, 24, 17, 25, - 2, 10, 3, 11, 18, 26, 19, 27, - 32, 40, 33, 34, 41, 48, 56, 49, - 42, 35, 43, 50, 57, 58, 51, 59, - 4, 12, 5, 6, 13, 20, 28, 21, - 14, 7, 15, 22, 29, 36, 44, 37, - 30, 23, 31, 38, 45, 52, 60, 53, - 46, 39, 47, 54, 61, 62, 55, 63, -}; - -static av_cold int decode_init(AVCodecContext *avctx) -{ - ProresContext *ctx = avctx->priv_data; - - avctx->bits_per_raw_sample = 10; - - dsputil_init(&ctx->dsp, avctx); - - avctx->coded_frame = &ctx->frame; - ctx->frame.type = FF_I_TYPE; - ctx->frame.key_frame = 1; - - ctx->idct_put = idct_put; - memcpy(ctx->progressive_scan, progressive_scan, sizeof(progressive_scan)); - memcpy(ctx->interlaced_scan, interlaced_scan, sizeof(interlaced_scan)); - - return 0; -} - -static int decode_frame_header(ProresContext *ctx, const uint8_t *buf, - const int data_size, AVCodecContext *avctx) -{ - int hdr_size, width, height, flags; - int version; - const uint8_t *ptr; - const uint8_t *scan; - - hdr_size = AV_RB16(buf); - av_dlog(avctx, "header size %d\n", hdr_size); - if (hdr_size > data_size) { - av_log(avctx, AV_LOG_ERROR, "error, wrong header size\n"); - return -1; - } - - version = AV_RB16(buf + 2); - av_dlog(avctx, "%.4s version %d\n", buf+4, version); - if (version > 1) { - av_log(avctx, AV_LOG_ERROR, "unsupported version: %d\n", version); - return -1; - } - - width = AV_RB16(buf + 8); - height = AV_RB16(buf + 10); - if (width != avctx->width || height != avctx->height) { - av_log(avctx, AV_LOG_ERROR, "picture resolution change: %dx%d -> %dx%d\n", - avctx->width, avctx->height, width, height); - return -1; - } - - ctx->frame_type = (buf[12] >> 2) & 3; - - av_dlog(avctx, "frame type %d\n", ctx->frame_type); - - if (ctx->frame_type == 0) { - scan = progressive_scan; - ctx->scan = ctx->progressive_scan; // permuted - } else { - scan = interlaced_scan; - ctx->scan = ctx->interlaced_scan; // permuted - ctx->frame.interlaced_frame = 1; - ctx->frame.top_field_first = ctx->frame_type == 1; - } - - avctx->pix_fmt = ((buf[12] & 0xC0) == 0xC0) ? PIX_FMT_YUV444P10 : PIX_FMT_YUV422P10; - - ptr = buf + 20; - flags = buf[19]; - av_dlog(avctx, "flags %x\n", flags); - - if (flags & 2) { - permute(ctx->qmat_luma, scan, ptr); - ptr += 64; - } else { - memset(ctx->qmat_luma, 4, 64); - } - - if (flags & 1) { - permute(ctx->qmat_chroma, scan, ptr); - } else { - memset(ctx->qmat_chroma, 4, 64); - } - - return hdr_size; -} - -static int decode_picture_header(AVCodecContext *avctx, const uint8_t *buf, const int buf_size) -{ - ProresContext *ctx = avctx->priv_data; - int i, hdr_size, slice_count; - unsigned pic_data_size; - int log2_slice_mb_width, log2_slice_mb_height; - int slice_mb_count, mb_x, mb_y; - const uint8_t *data_ptr, *index_ptr; - - hdr_size = buf[0] >> 3; - if (hdr_size < 8 || hdr_size > buf_size) { - av_log(avctx, AV_LOG_ERROR, "error, wrong picture header size\n"); - return -1; - } - - pic_data_size = AV_RB32(buf + 1); - if (pic_data_size > buf_size) { - av_log(avctx, AV_LOG_ERROR, "error, wrong picture data size\n"); - return -1; - } - - log2_slice_mb_width = buf[7] >> 4; - log2_slice_mb_height = buf[7] & 0xF; - if (log2_slice_mb_width > 3 || log2_slice_mb_height) { - av_log(avctx, AV_LOG_ERROR, "unsupported slice resolution: %dx%d\n", - 1 << log2_slice_mb_width, 1 << log2_slice_mb_height); - return -1; - } - - ctx->mb_width = (avctx->width + 15) >> 4; - ctx->mb_height = (avctx->height + 15) >> 4; - - slice_count = AV_RB16(buf + 5); - - if (ctx->slice_count != slice_count || !ctx->slices) { - av_freep(&ctx->slices); - ctx->slices = av_mallocz(slice_count * sizeof(*ctx->slices)); - if (!ctx->slices) - return AVERROR(ENOMEM); - ctx->slice_count = slice_count; - } - - if (!slice_count) - return AVERROR(EINVAL); - - if (hdr_size + slice_count*2 > buf_size) { - av_log(avctx, AV_LOG_ERROR, "error, wrong slice count\n"); - return -1; - } - - // parse slice information - index_ptr = buf + hdr_size; - data_ptr = index_ptr + slice_count*2; - - slice_mb_count = 1 << log2_slice_mb_width; - mb_x = 0; - mb_y = 0; - - for (i = 0; i < slice_count; i++) { - SliceContext *slice = &ctx->slices[i]; - - slice->data = data_ptr; - data_ptr += AV_RB16(index_ptr + i*2); - - while (ctx->mb_width - mb_x < slice_mb_count) - slice_mb_count >>= 1; - - slice->mb_x = mb_x; - slice->mb_y = mb_y; - slice->mb_count = slice_mb_count; - slice->data_size = data_ptr - slice->data; - - if (slice->data_size < 6) { - av_log(avctx, AV_LOG_ERROR, "error, wrong slice data size\n"); - return -1; - } - - mb_x += slice_mb_count; - if (mb_x == ctx->mb_width) { - slice_mb_count = 1 << log2_slice_mb_width; - mb_x = 0; - mb_y++; - } - if (data_ptr > buf + buf_size) { - av_log(avctx, AV_LOG_ERROR, "error, slice out of bounds\n"); - return -1; - } - } - - return pic_data_size; -} - -#define DECODE_CODEWORD(val, codebook) \ - do { \ - unsigned int rice_order, exp_order, switch_bits; \ - unsigned int q, buf, bits; \ - \ - UPDATE_CACHE(re, gb); \ - buf = GET_CACHE(re, gb); \ - \ - /* number of bits to switch between rice and exp golomb */ \ - switch_bits = codebook & 3; \ - rice_order = codebook >> 5; \ - exp_order = (codebook >> 2) & 7; \ - \ - q = 31-av_log2(buf); \ - \ - if (q > switch_bits) { /* exp golomb */ \ - bits = exp_order - switch_bits + (q<<1); \ - val = SHOW_UBITS(re, gb, bits) - (1 << exp_order) + \ - ((switch_bits + 1) << rice_order); \ - SKIP_BITS(re, gb, bits); \ - } else if (rice_order) { \ - SKIP_BITS(re, gb, q+1); \ - val = (q << rice_order) + SHOW_UBITS(re, gb, rice_order); \ - SKIP_BITS(re, gb, rice_order); \ - } else { \ - val = q; \ - SKIP_BITS(re, gb, q+1); \ - } \ - } while (0); \ - -#define TOSIGNED(x) (((x) >> 1) ^ (-((x) & 1))) - -#define FIRST_DC_CB 0xB8 - -static const uint8_t dc_codebook[7] = { 0x04, 0x28, 0x28, 0x4D, 0x4D, 0x70, 0x70}; - -static av_always_inline void decode_dc_coeffs(GetBitContext *gb, DCTELEM *out, - int blocks_per_slice, const int *qmat) -{ - DCTELEM prev_dc; - int code, i, sign; - - OPEN_READER(re, gb); - - DECODE_CODEWORD(code, FIRST_DC_CB); - prev_dc = TOSIGNED(code); - out[0] = 4096 + ((prev_dc * qmat[0]) >> 2); - - out += 64; // dc coeff for the next block - - code = 5; - sign = 0; - for (i = 1; i < blocks_per_slice; i++, out += 64) { - DECODE_CODEWORD(code, dc_codebook[FFMIN(code, 6)]); - if(code) sign ^= -(code & 1); - else sign = 0; - prev_dc += (((code + 1) >> 1) ^ sign) - sign; - out[0] = 4096 + ((prev_dc * qmat[0]) >> 2); - } - CLOSE_READER(re, gb); -} - -// adaptive codebook switching lut according to previous run/level values -static const uint8_t run_to_cb[16] = { 0x06, 0x06, 0x05, 0x05, 0x04, 0x29, 0x29, 0x29, 0x29, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x4C }; -static const uint8_t lev_to_cb[10] = { 0x04, 0x0A, 0x05, 0x06, 0x04, 0x28, 0x28, 0x28, 0x28, 0x4C }; - -static av_always_inline void decode_ac_coeffs(AVCodecContext *avctx, GetBitContext *gb, - DCTELEM *out, int blocks_per_slice, - const int *qmat) -{ - ProresContext *ctx = avctx->priv_data; - int block_mask, sign; - unsigned pos, run, level; - int max_coeffs, i, bits_left; - int log2_block_count = av_log2(blocks_per_slice); - - OPEN_READER(re, gb); - - run = 4; - level = 2; - - max_coeffs = 64 << log2_block_count; - block_mask = blocks_per_slice - 1; - - for (pos = block_mask;;) { - bits_left = gb->size_in_bits - (((uint8_t*)re_buffer_ptr - gb->buffer)*8 - 32 + re_bit_count); - if (!bits_left || (bits_left < 32 && !SHOW_UBITS(re, gb, bits_left))) - break; - - DECODE_CODEWORD(run, run_to_cb[FFMIN(run, 15)]); - pos += run + 1; - if (pos >= max_coeffs) { - av_log(avctx, AV_LOG_ERROR, "ac tex damaged %d, %d\n", pos, max_coeffs); - return; - } - - DECODE_CODEWORD(level, lev_to_cb[FFMIN(level, 9)]); - level += 1; - - i = pos >> log2_block_count; - - sign = SHOW_SBITS(re, gb, 1); - SKIP_BITS(re, gb, 1); - out[((pos & block_mask) << 6) + ctx->scan[i]] = (((level ^ sign) - sign) * qmat[i]) >> 2; - } - - CLOSE_READER(re, gb); -} - -static void decode_slice_luma(AVCodecContext *avctx, SliceContext *slice, - uint8_t *dst, int dst_stride, - const uint8_t *buf, unsigned buf_size, - const int *qmat) -{ - ProresContext *ctx = avctx->priv_data; - LOCAL_ALIGNED_16(DCTELEM, blocks, [8*4*64]); - DCTELEM *block; - GetBitContext gb; - int i, blocks_per_slice = slice->mb_count<<2; - - for (i = 0; i < blocks_per_slice; i++) - ctx->dsp.clear_block(blocks+(i<<6)); - - init_get_bits(&gb, buf, buf_size << 3); - - decode_dc_coeffs(&gb, blocks, blocks_per_slice, qmat); - decode_ac_coeffs(avctx, &gb, blocks, blocks_per_slice, qmat); - - block = blocks; - - for (i = 0; i < slice->mb_count; i++) { - ctx->idct_put(block+(0<<6), dst, dst_stride); - ctx->idct_put(block+(1<<6), dst+16, dst_stride); - ctx->idct_put(block+(2<<6), dst+8*dst_stride, dst_stride); - ctx->idct_put(block+(3<<6), dst+8*dst_stride+16, dst_stride); - block += 4*64; - dst += 32; - } - -} - -static void decode_slice_chroma(AVCodecContext *avctx, SliceContext *slice, - uint8_t *dst, int dst_stride, - const uint8_t *buf, unsigned buf_size, - const int *qmat, int log2_blocks_per_mb) -{ - ProresContext *ctx = avctx->priv_data; - LOCAL_ALIGNED_16(DCTELEM, blocks, [8*4*64]); - DCTELEM *block; - GetBitContext gb; - int i, j, blocks_per_slice = slice->mb_count << log2_blocks_per_mb; - - for (i = 0; i < blocks_per_slice; i++) - ctx->dsp.clear_block(blocks+(i<<6)); - - init_get_bits(&gb, buf, buf_size << 3); - - decode_dc_coeffs(&gb, blocks, blocks_per_slice, qmat); - decode_ac_coeffs(avctx, &gb, blocks, blocks_per_slice, qmat); - - block = blocks; - for (i = 0; i < slice->mb_count; i++) { - for (j = 0; j < log2_blocks_per_mb; j++) { - ctx->idct_put(block+(0<<6), dst, dst_stride); - ctx->idct_put(block+(1<<6), dst+8*dst_stride, dst_stride); - block += 2*64; - dst += 16; - } - } -} - -static int decode_slice_thread(AVCodecContext *avctx, void *arg, int jobnr, int threadnr) -{ - ProresContext *ctx = avctx->priv_data; - SliceContext *slice = &ctx->slices[jobnr]; - const uint8_t *buf = slice->data; - AVFrame *pic = avctx->coded_frame; - int i, hdr_size, qscale, log2_chroma_blocks_per_mb; - int luma_stride, chroma_stride; - int y_data_size, u_data_size, v_data_size; - uint8_t *dest_y, *dest_u, *dest_v; - int qmat_luma_scaled[64]; - int qmat_chroma_scaled[64]; - int mb_x_shift; - - //av_log(avctx, AV_LOG_INFO, "slice %d mb width %d mb x %d y %d\n", - // jobnr, slice->mb_count, slice->mb_x, slice->mb_y); - - // slice header - hdr_size = buf[0] >> 3; - qscale = av_clip(buf[1], 1, 224); - qscale = qscale > 128 ? qscale - 96 << 2: qscale; - y_data_size = AV_RB16(buf + 2); - u_data_size = AV_RB16(buf + 4); - v_data_size = slice->data_size - y_data_size - u_data_size - hdr_size; - if (hdr_size > 7) v_data_size = AV_RB16(buf + 6); - - if (y_data_size < 0 || u_data_size < 0 || v_data_size < 0) { - av_log(avctx, AV_LOG_ERROR, "invalid plane data size\n"); - return -1; - } - - buf += hdr_size; - - for (i = 0; i < 64; i++) { - qmat_luma_scaled[i] = ctx->qmat_luma[i] * qscale; - qmat_chroma_scaled[i] = ctx->qmat_chroma[i] * qscale; - } - - if (ctx->frame_type == 0) { - luma_stride = pic->linesize[0]; - chroma_stride = pic->linesize[1]; - } else { - luma_stride = pic->linesize[0] << 1; - chroma_stride = pic->linesize[1] << 1; - } - - if (avctx->pix_fmt == PIX_FMT_YUV444P10) { - mb_x_shift = 5; - log2_chroma_blocks_per_mb = 2; - } else { - mb_x_shift = 4; - log2_chroma_blocks_per_mb = 1; - } - - dest_y = pic->data[0] + (slice->mb_y << 4) * luma_stride + (slice->mb_x << 5); - dest_u = pic->data[1] + (slice->mb_y << 4) * chroma_stride + (slice->mb_x << mb_x_shift); - dest_v = pic->data[2] + (slice->mb_y << 4) * chroma_stride + (slice->mb_x << mb_x_shift); - - if (ctx->frame_type && ctx->first_field ^ ctx->frame.top_field_first) { - dest_y += pic->linesize[0]; - dest_u += pic->linesize[1]; - dest_v += pic->linesize[2]; - } - - decode_slice_luma(avctx, slice, dest_y, luma_stride, - buf, y_data_size, qmat_luma_scaled); - - if (!(avctx->flags & CODEC_FLAG_GRAY)) { - decode_slice_chroma(avctx, slice, dest_u, chroma_stride, - buf + y_data_size, u_data_size, - qmat_chroma_scaled, log2_chroma_blocks_per_mb); - decode_slice_chroma(avctx, slice, dest_v, chroma_stride, - buf + y_data_size + u_data_size, v_data_size, - qmat_chroma_scaled, log2_chroma_blocks_per_mb); - } - - return 0; -} - -static int decode_picture(AVCodecContext *avctx) -{ - ProresContext *ctx = avctx->priv_data; - int i, threads_ret[ctx->slice_count]; - - avctx->execute2(avctx, decode_slice_thread, NULL, threads_ret, ctx->slice_count); - - for (i = 0; i < ctx->slice_count; i++) - if (threads_ret[i] < 0) - return threads_ret[i]; - - return 0; -} - -static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, - AVPacket *avpkt) -{ - ProresContext *ctx = avctx->priv_data; - AVFrame *frame = avctx->coded_frame; - const uint8_t *buf = avpkt->data; - int buf_size = avpkt->size; - int frame_hdr_size, pic_size; - - if (buf_size < 28 || AV_RL32(buf + 4) != AV_RL32("icpf")) { - av_log(avctx, AV_LOG_ERROR, "invalid frame header\n"); - return -1; - } - - ctx->first_field = 1; - - buf += 8; - buf_size -= 8; - - frame_hdr_size = decode_frame_header(ctx, buf, buf_size, avctx); - if (frame_hdr_size < 0) - return -1; - - buf += frame_hdr_size; - buf_size -= frame_hdr_size; - - decode_picture: - pic_size = decode_picture_header(avctx, buf, buf_size); - if (pic_size < 0) { - av_log(avctx, AV_LOG_ERROR, "error decoding picture header\n"); - return -1; - } - - if (frame->data[0]) - avctx->release_buffer(avctx, frame); - - if (avctx->get_buffer(avctx, frame) < 0) - return -1; - - if (decode_picture(avctx)) { - av_log(avctx, AV_LOG_ERROR, "error decoding picture\n"); - return -1; - } - - buf += pic_size; - buf_size -= pic_size; - - if (ctx->frame_type && buf_size > 0 && ctx->first_field) { - ctx->first_field = 0; - goto decode_picture; - } - - *data_size = sizeof(AVFrame); - *(AVFrame*)data = *frame; - - return avpkt->size; -} - -static av_cold int decode_close(AVCodecContext *avctx) -{ - ProresContext *ctx = avctx->priv_data; - - AVFrame *frame = avctx->coded_frame; - if (frame->data[0]) - avctx->release_buffer(avctx, frame); - av_freep(&ctx->slices); - - return 0; -} - -AVCodec ff_prores_gpl_decoder = { - .name = "prores_gpl", - .type = AVMEDIA_TYPE_VIDEO, - .id = CODEC_ID_PRORES, - .priv_data_size = sizeof(ProresContext), - .init = decode_init, - .close = decode_close, - .decode = decode_frame, - .long_name = NULL_IF_CONFIG_SMALL("ProRes"), - .capabilities = CODEC_CAP_SLICE_THREADS, -}; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/proresdec.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/proresdec.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/proresdec.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/proresdec.h 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2010-2011 Maxim Poliakovski + * Copyright (c) 2010-2011 Elvis Presley + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; + * version 2 of the License. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_PRORESDEC_H +#define AVCODEC_PRORESDEC_H + +#include "dsputil.h" +#include "proresdsp.h" + +typedef struct { + const uint8_t *data; + unsigned mb_x; + unsigned mb_y; + unsigned mb_count; + unsigned data_size; +} SliceContext; + +typedef struct { + DSPContext dsp; + ProresDSPContext prodsp; + AVFrame frame; + int frame_type; ///< 0 = progressive, 1 = tff, 2 = bff + uint8_t qmat_luma[64]; + uint8_t qmat_chroma[64]; + SliceContext *slices; + int slice_count; ///< number of slices in the current picture + unsigned mb_width; ///< width of the current picture in mb + unsigned mb_height; ///< height of the current picture in mb + uint8_t progressive_scan[64]; + uint8_t interlaced_scan[64]; + const uint8_t *scan; + int first_field; +} ProresContext; + +#endif /* AVCODEC_PRORESDEC_H */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/proresdec_lgpl.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/proresdec_lgpl.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/proresdec_lgpl.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/proresdec_lgpl.c 2011-11-04 12:38:27.000000000 +0000 @@ -34,17 +34,19 @@ #include "libavutil/intmath.h" #include "avcodec.h" -#include "dsputil.h" +#include "proresdsp.h" #include "get_bits.h" -#define BITS_PER_SAMPLE 10 ///< output precision of that decoder -#define BIAS (1 << (BITS_PER_SAMPLE - 1)) ///< bias value for converting signed pixels into unsigned ones -#define CLIP_MIN (1 << (BITS_PER_SAMPLE - 8)) ///< minimum value for clipping resulting pixels -#define CLIP_MAX (1 << BITS_PER_SAMPLE) - CLIP_MIN - 1 ///< maximum value for clipping resulting pixels - +typedef struct { + const uint8_t *index; ///< pointers to the data of this slice + int slice_num; + int x_pos, y_pos; + int slice_width; + DECLARE_ALIGNED(16, DCTELEM, blocks[8 * 4 * 64]); +} ProresThreadData; typedef struct { - DSPContext dsp; + ProresDSPContext dsp; AVFrame picture; ScanTable scantable; int scantable_type; ///< -1 = uninitialized, 0 = progressive, 1/2 = interlaced @@ -57,9 +59,9 @@ int prev_slice_sf; ///< scalefactor of the previous decoded slice DECLARE_ALIGNED(16, int16_t, qmat_luma_scaled[64]); DECLARE_ALIGNED(16, int16_t, qmat_chroma_scaled[64]); - DECLARE_ALIGNED(16, DCTELEM, blocks[8 * 4 * 64]); int total_slices; ///< total number of slices in a picture - const uint8_t **slice_data_index; ///< array of pointers to the data of each slice + ProresThreadData *slice_data; + int pic_num; int chroma_factor; int mb_chroma_factor; int num_chroma_blocks; ///< number of chrominance blocks in a macroblock @@ -69,6 +71,7 @@ int slice_height_factor; int num_x_mbs; int num_y_mbs; + int alpha_info; } ProresContext; @@ -100,12 +103,10 @@ ProresContext *ctx = avctx->priv_data; ctx->total_slices = 0; - ctx->slice_data_index = 0; - - avctx->pix_fmt = PIX_FMT_YUV422P10; // set default pixel format + ctx->slice_data = NULL; - avctx->bits_per_raw_sample = BITS_PER_SAMPLE; - dsputil_init(&ctx->dsp, avctx); + avctx->bits_per_raw_sample = PRORES_BITS_PER_SAMPLE; + ff_proresdsp_init(&ctx->dsp, avctx); avctx->coded_frame = &ctx->picture; avcodec_get_frame_defaults(&ctx->picture); @@ -187,6 +188,10 @@ ctx->picture.top_field_first = ctx->frame_type & 1; } + ctx->alpha_info = buf[17] & 0xf; + if (ctx->alpha_info) + av_log_missing_feature(avctx, "alpha channel", 0); + ctx->qmat_changed = 0; ptr = buf + 20; flags = buf[19]; @@ -271,9 +276,9 @@ } if (ctx->total_slices != num_slices) { - av_freep(&ctx->slice_data_index); - ctx->slice_data_index = av_malloc((num_slices + 1) * sizeof(uint8_t*)); - if (!ctx->slice_data_index) + av_freep(&ctx->slice_data); + ctx->slice_data = av_malloc((num_slices + 1) * sizeof(ctx->slice_data[0])); + if (!ctx->slice_data) return AVERROR(ENOMEM); ctx->total_slices = num_slices; } @@ -288,10 +293,10 @@ data_ptr = index_ptr + num_slices * 2; for (i = 0; i < num_slices; i++) { - ctx->slice_data_index[i] = data_ptr; + ctx->slice_data[i].index = data_ptr; data_ptr += AV_RB16(index_ptr + i * 2); } - ctx->slice_data_index[i] = data_ptr; + ctx->slice_data[i].index = data_ptr; if (data_ptr > buf + data_size) { av_log(avctx, AV_LOG_ERROR, "out of slice data\n"); @@ -449,52 +454,11 @@ } -#define CLIP_AND_BIAS(x) (av_clip((x) + BIAS, CLIP_MIN, CLIP_MAX)) - -/** - * Add bias value, clamp and output pixels of a slice - */ -static void put_pixels(const DCTELEM *in, uint16_t *out, int stride, - int mbs_per_slice, int blocks_per_mb) -{ - int mb, x, y, src_offset, dst_offset; - const DCTELEM *src1, *src2; - uint16_t *dst1, *dst2; - - src1 = in; - src2 = in + (blocks_per_mb << 5); - dst1 = out; - dst2 = out + (stride << 3); - - for (mb = 0; mb < mbs_per_slice; mb++) { - for (y = 0, dst_offset = 0; y < 8; y++, dst_offset += stride) { - for (x = 0; x < 8; x++) { - src_offset = (y << 3) + x; - - dst1[dst_offset + x] = CLIP_AND_BIAS(src1[src_offset]); - dst2[dst_offset + x] = CLIP_AND_BIAS(src2[src_offset]); - - if (blocks_per_mb > 2) { - dst1[dst_offset + x + 8] = - CLIP_AND_BIAS(src1[src_offset + 64]); - dst2[dst_offset + x + 8] = - CLIP_AND_BIAS(src2[src_offset + 64]); - } - } - } - - src1 += blocks_per_mb << 6; - src2 += blocks_per_mb << 6; - dst1 += blocks_per_mb << 2; - dst2 += blocks_per_mb << 2; - } -} - - /** * Decode a slice plane (luma or chroma). */ -static void decode_slice_plane(ProresContext *ctx, const uint8_t *buf, +static void decode_slice_plane(ProresContext *ctx, ProresThreadData *td, + const uint8_t *buf, int data_size, uint16_t *out_ptr, int linesize, int mbs_per_slice, int blocks_per_mb, int plane_size_factor, @@ -502,43 +466,47 @@ { GetBitContext gb; DCTELEM *block_ptr; - int i, blk_num, blocks_per_slice; + int mb_num, blocks_per_slice; blocks_per_slice = mbs_per_slice * blocks_per_mb; - memset(ctx->blocks, 0, 8 * 4 * 64 * sizeof(*ctx->blocks)); + memset(td->blocks, 0, 8 * 4 * 64 * sizeof(*td->blocks)); init_get_bits(&gb, buf, data_size << 3); - decode_dc_coeffs(&gb, ctx->blocks, blocks_per_slice); + decode_dc_coeffs(&gb, td->blocks, blocks_per_slice); - decode_ac_coeffs(&gb, ctx->blocks, blocks_per_slice, + decode_ac_coeffs(&gb, td->blocks, blocks_per_slice, plane_size_factor, ctx->scantable.permutated); /* inverse quantization, inverse transform and output */ - block_ptr = ctx->blocks; - - for (blk_num = 0; blk_num < blocks_per_slice; blk_num++, block_ptr += 64) { - /* TODO: the correct solution shoud be (block_ptr[i] * qmat[i]) >> 1 - * and the input of the inverse transform should be scaled by 2 - * in order to avoid rounding errors. - * Due to the fact the existing Libav transforms are incompatible with - * that input I temporally introduced the coarse solution below... */ - for (i = 0; i < 64; i++) - block_ptr[i] = (block_ptr[i] * qmat[i]) >> 2; + block_ptr = td->blocks; - ctx->dsp.idct(block_ptr); + for (mb_num = 0; mb_num < mbs_per_slice; mb_num++, out_ptr += blocks_per_mb * 4) { + ctx->dsp.idct_put(out_ptr, linesize, block_ptr, qmat); + block_ptr += 64; + if (blocks_per_mb > 2) { + ctx->dsp.idct_put(out_ptr + 8, linesize, block_ptr, qmat); + block_ptr += 64; + } + ctx->dsp.idct_put(out_ptr + linesize * 4, linesize, block_ptr, qmat); + block_ptr += 64; + if (blocks_per_mb > 2) { + ctx->dsp.idct_put(out_ptr + linesize * 4 + 8, linesize, block_ptr, qmat); + block_ptr += 64; + } } - - put_pixels(ctx->blocks, out_ptr, linesize >> 1, mbs_per_slice, - blocks_per_mb); } -static int decode_slice(ProresContext *ctx, int pic_num, int slice_num, - int mb_x_pos, int mb_y_pos, int mbs_per_slice, - AVCodecContext *avctx) +static int decode_slice(AVCodecContext *avctx, ProresThreadData *td) { + ProresContext *ctx = avctx->priv_data; + int mb_x_pos = td->x_pos; + int mb_y_pos = td->y_pos; + int pic_num = ctx->pic_num; + int slice_num = td->slice_num; + int mbs_per_slice = td->slice_width; const uint8_t *buf; uint8_t *y_data, *u_data, *v_data; AVFrame *pic = avctx->coded_frame; @@ -546,8 +514,8 @@ int slice_data_size, hdr_size, y_data_size, u_data_size, v_data_size; int y_linesize, u_linesize, v_linesize; - buf = ctx->slice_data_index[slice_num]; - slice_data_size = ctx->slice_data_index[slice_num + 1] - buf; + buf = ctx->slice_data[slice_num].index; + slice_data_size = ctx->slice_data[slice_num + 1].index - buf; slice_width_factor = av_log2(mbs_per_slice); @@ -578,9 +546,11 @@ hdr_size = buf[0] >> 3; y_data_size = AV_RB16(buf + 2); u_data_size = AV_RB16(buf + 4); - v_data_size = slice_data_size - y_data_size - u_data_size - hdr_size; + v_data_size = hdr_size > 7 ? AV_RB16(buf + 6) : + slice_data_size - y_data_size - u_data_size - hdr_size; - if (v_data_size < 0 || hdr_size < 6) { + if (hdr_size + y_data_size + u_data_size + v_data_size > slice_data_size || + v_data_size < 0 || hdr_size < 6) { av_log(avctx, AV_LOG_ERROR, "invalid data size\n"); return AVERROR_INVALIDDATA; } @@ -593,20 +563,20 @@ if (ctx->qmat_changed || sf != ctx->prev_slice_sf) { ctx->prev_slice_sf = sf; for (i = 0; i < 64; i++) { - ctx->qmat_luma_scaled[i] = ctx->qmat_luma[i] * sf; - ctx->qmat_chroma_scaled[i] = ctx->qmat_chroma[i] * sf; + ctx->qmat_luma_scaled[ctx->dsp.idct_permutation[i]] = ctx->qmat_luma[i] * sf; + ctx->qmat_chroma_scaled[ctx->dsp.idct_permutation[i]] = ctx->qmat_chroma[i] * sf; } } /* decode luma plane */ - decode_slice_plane(ctx, buf + hdr_size, y_data_size, + decode_slice_plane(ctx, td, buf + hdr_size, y_data_size, (uint16_t*) (y_data + (mb_y_pos << 4) * y_linesize + (mb_x_pos << 5)), y_linesize, mbs_per_slice, 4, slice_width_factor + 2, ctx->qmat_luma_scaled); /* decode U chroma plane */ - decode_slice_plane(ctx, buf + hdr_size + y_data_size, u_data_size, + decode_slice_plane(ctx, td, buf + hdr_size + y_data_size, u_data_size, (uint16_t*) (u_data + (mb_y_pos << 4) * u_linesize + (mb_x_pos << ctx->mb_chroma_factor)), u_linesize, mbs_per_slice, ctx->num_chroma_blocks, @@ -614,7 +584,7 @@ ctx->qmat_chroma_scaled); /* decode V chroma plane */ - decode_slice_plane(ctx, buf + hdr_size + y_data_size + u_data_size, + decode_slice_plane(ctx, td, buf + hdr_size + y_data_size + u_data_size, v_data_size, (uint16_t*) (v_data + (mb_y_pos << 4) * v_linesize + (mb_x_pos << ctx->mb_chroma_factor)), @@ -633,6 +603,7 @@ slice_num = 0; + ctx->pic_num = pic_num; for (y_pos = 0; y_pos < ctx->num_y_mbs; y_pos++) { slice_width = 1 << ctx->slice_width_factor; @@ -641,15 +612,18 @@ while (ctx->num_x_mbs - x_pos < slice_width) slice_width >>= 1; - if (decode_slice(ctx, pic_num, slice_num, x_pos, y_pos, - slice_width, avctx) < 0) - return -1; + ctx->slice_data[slice_num].slice_num = slice_num; + ctx->slice_data[slice_num].x_pos = x_pos; + ctx->slice_data[slice_num].y_pos = y_pos; + ctx->slice_data[slice_num].slice_width = slice_width; slice_num++; } } - return 0; + return avctx->execute(avctx, (void *) decode_slice, + ctx->slice_data, NULL, slice_num, + sizeof(ctx->slice_data[0])); } @@ -712,7 +686,7 @@ if (ctx->picture.data[0]) avctx->release_buffer(avctx, &ctx->picture); - av_freep(&ctx->slice_data_index); + av_freep(&ctx->slice_data); return 0; } @@ -726,6 +700,6 @@ .init = decode_init, .close = decode_close, .decode = decode_frame, - .capabilities = CODEC_CAP_DR1, + .capabilities = CODEC_CAP_DR1 | CODEC_CAP_SLICE_THREADS, .long_name = NULL_IF_CONFIG_SMALL("Apple ProRes (iCodec Pro)") }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/proresdsp.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/proresdsp.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/proresdsp.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/proresdsp.c 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,63 @@ +/* + * Apple ProRes compatible decoder + * + * Copyright (c) 2010-2011 Maxim Poliakovski + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "proresdsp.h" +#include "simple_idct.h" + +#define BIAS (1 << (PRORES_BITS_PER_SAMPLE - 1)) ///< bias value for converting signed pixels into unsigned ones +#define CLIP_MIN (1 << (PRORES_BITS_PER_SAMPLE - 8)) ///< minimum value for clipping resulting pixels +#define CLIP_MAX (1 << PRORES_BITS_PER_SAMPLE) - CLIP_MIN - 1 ///< maximum value for clipping resulting pixels + +#define CLIP_AND_BIAS(x) (av_clip((x) + BIAS, CLIP_MIN, CLIP_MAX)) + +/** + * Add bias value, clamp and output pixels of a slice + */ +static void put_pixels(uint16_t *dst, int stride, const DCTELEM *in) +{ + int x, y, src_offset, dst_offset; + + for (y = 0, dst_offset = 0; y < 8; y++, dst_offset += stride) { + for (x = 0; x < 8; x++) { + src_offset = (y << 3) + x; + + dst[dst_offset + x] = CLIP_AND_BIAS(in[src_offset]); + } + } +} + +static void prores_idct_put_c(uint16_t *out, int linesize, DCTELEM *block, const int16_t *qmat) +{ + ff_prores_idct(block, qmat); + put_pixels(out, linesize >> 1, block); +} + +void ff_proresdsp_init(ProresDSPContext *dsp, AVCodecContext *avctx) +{ + dsp->idct_put = prores_idct_put_c; + dsp->idct_permutation_type = FF_NO_IDCT_PERM; + + if (HAVE_MMX) ff_proresdsp_x86_init(dsp, avctx); + + ff_init_scantable_permutation(dsp->idct_permutation, + dsp->idct_permutation_type); +} diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/proresdsp.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/proresdsp.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/proresdsp.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/proresdsp.h 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,40 @@ +/* + * Apple ProRes compatible decoder + * + * Copyright (c) 2010-2011 Maxim Poliakovski + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_PRORESDSP_H +#define AVCODEC_PRORESDSP_H + +#include "dsputil.h" + +#define PRORES_BITS_PER_SAMPLE 10 ///< output precision of prores decoder + +typedef struct { + int idct_permutation_type; + uint8_t idct_permutation[64]; + void (* idct_put) (uint16_t *out, int linesize, DCTELEM *block, const int16_t *qmat); +} ProresDSPContext; + +void ff_proresdsp_init(ProresDSPContext *dsp, AVCodecContext *avctx); + +void ff_proresdsp_x86_init(ProresDSPContext *dsp, AVCodecContext *avctx); + +#endif /* AVCODEC_PRORESDSP_H */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/proresenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/proresenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/proresenc.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/proresenc.c 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,599 @@ +/* + * Apple ProRes encoder + * + * Copyright (c) 2011 Anatoliy Wasserman + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file libavcodec/proresenc.c + * Known FOURCCs: 'apch' (HQ), 'apcn' (SD), 'apcs' (LT), 'acpo' (Proxy) + */ + +#include "avcodec.h" +#include "put_bits.h" +#include "bytestream.h" +#include "dsputil.h" + +#define DEFAULT_SLICE_MB_WIDTH 8 + +#define FF_PROFILE_PRORES_PROXY 0 +#define FF_PROFILE_PRORES_LT 1 +#define FF_PROFILE_PRORES_STANDARD 2 +#define FF_PROFILE_PRORES_HQ 3 + +static const AVProfile profiles[] = { + { FF_PROFILE_PRORES_PROXY, "apco"}, + { FF_PROFILE_PRORES_LT, "apcs"}, + { FF_PROFILE_PRORES_STANDARD, "apcn"}, + { FF_PROFILE_PRORES_HQ, "apch"}, + { FF_PROFILE_UNKNOWN } +}; + +static const int qp_start_table[4] = { 4, 1, 1, 1 }; +static const int qp_end_table[4] = { 8, 9, 6, 6 }; +static const int bitrate_table[5] = { 1000, 2100, 3500, 5400 }; + +static const uint8_t progressive_scan[64] = { + 0, 1, 8, 9, 2, 3, 10, 11, + 16, 17, 24, 25, 18, 19, 26, 27, + 4, 5, 12, 20, 13, 6, 7, 14, + 21, 28, 29, 22, 15, 23, 30, 31, + 32, 33, 40, 48, 41, 34, 35, 42, + 49, 56, 57, 50, 43, 36, 37, 44, + 51, 58, 59, 52, 45, 38, 39, 46, + 53, 60, 61, 54, 47, 55, 62, 63 +}; + +static const uint8_t QMAT_LUMA[4][64] = { + { + 4, 7, 9, 11, 13, 14, 15, 63, + 7, 7, 11, 12, 14, 15, 63, 63, + 9, 11, 13, 14, 15, 63, 63, 63, + 11, 11, 13, 14, 63, 63, 63, 63, + 11, 13, 14, 63, 63, 63, 63, 63, + 13, 14, 63, 63, 63, 63, 63, 63, + 13, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63 + }, { + 4, 5, 6, 7, 9, 11, 13, 15, + 5, 5, 7, 8, 11, 13, 15, 17, + 6, 7, 9, 11, 13, 15, 15, 17, + 7, 7, 9, 11, 13, 15, 17, 19, + 7, 9, 11, 13, 14, 16, 19, 23, + 9, 11, 13, 14, 16, 19, 23, 29, + 9, 11, 13, 15, 17, 21, 28, 35, + 11, 13, 16, 17, 21, 28, 35, 41 + }, { + 4, 4, 5, 5, 6, 7, 7, 9, + 4, 4, 5, 6, 7, 7, 9, 9, + 5, 5, 6, 7, 7, 9, 9, 10, + 5, 5, 6, 7, 7, 9, 9, 10, + 5, 6, 7, 7, 8, 9, 10, 12, + 6, 7, 7, 8, 9, 10, 12, 15, + 6, 7, 7, 9, 10, 11, 14, 17, + 7, 7, 9, 10, 11, 14, 17, 21 + }, { + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 5, + 4, 4, 4, 4, 4, 4, 5, 5, + 4, 4, 4, 4, 4, 5, 5, 6, + 4, 4, 4, 4, 5, 5, 6, 7, + 4, 4, 4, 4, 5, 6, 7, 7 + } +}; + +static const uint8_t QMAT_CHROMA[4][64] = { + { + 4, 7, 9, 11, 13, 14, 63, 63, + 7, 7, 11, 12, 14, 63, 63, 63, + 9, 11, 13, 14, 63, 63, 63, 63, + 11, 11, 13, 14, 63, 63, 63, 63, + 11, 13, 14, 63, 63, 63, 63, 63, + 13, 14, 63, 63, 63, 63, 63, 63, + 13, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63 + }, { + 4, 5, 6, 7, 9, 11, 13, 15, + 5, 5, 7, 8, 11, 13, 15, 17, + 6, 7, 9, 11, 13, 15, 15, 17, + 7, 7, 9, 11, 13, 15, 17, 19, + 7, 9, 11, 13, 14, 16, 19, 23, + 9, 11, 13, 14, 16, 19, 23, 29, + 9, 11, 13, 15, 17, 21, 28, 35, + 11, 13, 16, 17, 21, 28, 35, 41 + }, { + 4, 4, 5, 5, 6, 7, 7, 9, + 4, 4, 5, 6, 7, 7, 9, 9, + 5, 5, 6, 7, 7, 9, 9, 10, + 5, 5, 6, 7, 7, 9, 9, 10, + 5, 6, 7, 7, 8, 9, 10, 12, + 6, 7, 7, 8, 9, 10, 12, 15, + 6, 7, 7, 9, 10, 11, 14, 17, + 7, 7, 9, 10, 11, 14, 17, 21 + }, { + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 4, 5, + 4, 4, 4, 4, 4, 4, 5, 5, + 4, 4, 4, 4, 4, 5, 5, 6, + 4, 4, 4, 4, 5, 5, 6, 7, + 4, 4, 4, 4, 5, 6, 7, 7 + } +}; + + +typedef struct { + uint8_t* fill_y; + uint8_t* fill_u; + uint8_t* fill_v; + + int qmat_luma[16][64]; + int qmat_chroma[16][64]; +} ProresContext; + +static void encode_codeword(PutBitContext *pb, int val, int codebook) +{ + unsigned int rice_order, exp_order, switch_bits, first_exp, exp, zeros, + mask; + + /* number of bits to switch between rice and exp golomb */ + switch_bits = codebook & 3; + rice_order = codebook >> 5; + exp_order = (codebook >> 2) & 7; + + first_exp = ((switch_bits + 1) << rice_order); + + if (val >= first_exp) { /* exp golomb */ + val -= first_exp; + val += (1 << exp_order); + exp = av_log2(val); + zeros = exp - exp_order + switch_bits + 1; + put_bits(pb, zeros, 0); + put_bits(pb, 1, 1); + put_bits(pb, exp, val); + } else if (rice_order) { + mask = (1 << rice_order) - 1; + put_bits(pb, (val >> rice_order), 0); + put_bits(pb, 1, 1); + put_bits(pb, rice_order, val & mask); + } else { + put_bits(pb, val, 0); + put_bits(pb, 1, 1); + } +} + +#define QSCALE(qmat,ind,val) ((val) / (qmat[ind])) +#define TO_GOLOMB(val) ((val << 1) ^ (val >> 31)) +#define DIFF_SIGN(val, sign) ((val >> 31) ^ sign) +#define IS_NEGATIVE(val) (((val >> 31) ^ -1) + 1) +#define TO_GOLOMB2(val,sign) (val==0 ? 0 : (val << 1) + sign) + +static av_always_inline int get_level(int val) +{ + int sign = (val >> 31); + return (val ^ sign) - sign; +} + +#define FIRST_DC_CB 0xB8 + +static const uint8_t dc_codebook[7] = { 0x04, 0x28, 0x28, 0x4D, 0x4D, 0x70, 0x70}; + +static void encode_dc_coeffs(PutBitContext *pb, DCTELEM *in, + int blocks_per_slice, int *qmat) +{ + int prev_dc, code; + int i, sign, idx; + int new_dc, delta, diff_sign, new_code; + + prev_dc = QSCALE(qmat, 0, in[0] - 16384); + code = TO_GOLOMB(prev_dc); + encode_codeword(pb, code, FIRST_DC_CB); + + code = 5; sign = 0; idx = 64; + for (i = 1; i < blocks_per_slice; i++, idx += 64) { + new_dc = QSCALE(qmat, 0, in[idx] - 16384); + delta = new_dc - prev_dc; + diff_sign = DIFF_SIGN(delta, sign); + new_code = TO_GOLOMB2(get_level(delta), diff_sign); + + encode_codeword(pb, new_code, dc_codebook[FFMIN(code, 6)]); + + code = new_code; + sign = delta >> 31; + prev_dc = new_dc; + } +} + +static const uint8_t run_to_cb[16] = { 0x06, 0x06, 0x05, 0x05, 0x04, 0x29, + 0x29, 0x29, 0x29, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x4C }; +static const uint8_t lev_to_cb[10] = { 0x04, 0x0A, 0x05, 0x06, 0x04, 0x28, + 0x28, 0x28, 0x28, 0x4C }; + +static void encode_ac_coeffs(AVCodecContext *avctx, PutBitContext *pb, + DCTELEM *in, int blocks_per_slice, int *qmat) +{ + int prev_run = 4; + int prev_level = 2; + + int run = 0, level, code; + for (int i = 1; i < 64; i++) { + int indp = progressive_scan[i]; + for (int j = 0; j < blocks_per_slice; j++) { + int val = QSCALE(qmat, indp, in[(j << 6) + indp]); + if (val) { + encode_codeword(pb, run, run_to_cb[FFMIN(prev_run, 15)]); + + prev_run = run; + run = 0; + level = get_level(val); + code = level - 1; + + encode_codeword(pb, code, lev_to_cb[FFMIN(prev_level, 9)]); + + prev_level = level; + + put_bits(pb, 1, IS_NEGATIVE(val)); + } else { + ++run; + } + } + } +} + +static void get(uint8_t *pixels, int stride, DCTELEM* block) +{ + int16_t *p = (int16_t*)pixels; + int i, j; + + stride >>= 1; + for (i = 0; i < 8; i++) { + for (j = 0; j < 8; j++) { + block[j] = p[j]; + } + p += stride; + block += 8; + } +} + +static void fdct_get(uint8_t *pixels, int stride, DCTELEM* block) +{ + get(pixels, stride, block); + ff_jpeg_fdct_islow_10(block); +} + +static int encode_slice_plane(AVCodecContext *avctx, int mb_count, + uint8_t *src, int src_stride, uint8_t *buf, unsigned buf_size, + int *qmat, int chroma) +{ + DECLARE_ALIGNED(16, DCTELEM, blocks)[DEFAULT_SLICE_MB_WIDTH << 8], *block; + int i, blocks_per_slice; + PutBitContext pb; + + block = blocks; + for (i = 0; i < mb_count; i++) { + fdct_get(src, src_stride, block + (0 << 6)); + fdct_get(src + 8 * src_stride, src_stride, block + ((2 - chroma) << 6)); + if (!chroma) { + fdct_get(src + 16, src_stride, block + (1 << 6)); + fdct_get(src + 16 + 8 * src_stride, src_stride, block + (3 << 6)); + } + + block += (256 >> chroma); + src += (32 >> chroma); + } + + blocks_per_slice = mb_count << (2 - chroma); + init_put_bits(&pb, buf, buf_size << 3); + + encode_dc_coeffs(&pb, blocks, blocks_per_slice, qmat); + encode_ac_coeffs(avctx, &pb, blocks, blocks_per_slice, qmat); + + flush_put_bits(&pb); + return put_bits_ptr(&pb) - pb.buf; +} + +static av_always_inline unsigned encode_slice_data(AVCodecContext *avctx, + uint8_t *dest_y, uint8_t *dest_u, uint8_t *dest_v, int luma_stride, + int chroma_stride, unsigned mb_count, uint8_t *buf, unsigned data_size, + unsigned* y_data_size, unsigned* u_data_size, unsigned* v_data_size, + int qp) +{ + ProresContext* ctx = avctx->priv_data; + + *y_data_size = encode_slice_plane(avctx, mb_count, dest_y, luma_stride, + buf, data_size, ctx->qmat_luma[qp - 1], 0); + + if (!(avctx->flags & CODEC_FLAG_GRAY)) { + *u_data_size = encode_slice_plane(avctx, mb_count, dest_u, + chroma_stride, buf + *y_data_size, data_size - *y_data_size, + ctx->qmat_chroma[qp - 1], 1); + + *v_data_size = encode_slice_plane(avctx, mb_count, dest_v, + chroma_stride, buf + *y_data_size + *u_data_size, + data_size - *y_data_size - *u_data_size, + ctx->qmat_chroma[qp - 1], 1); + } + + return *y_data_size + *u_data_size + *v_data_size; +} + +static void subimage_with_fill(uint16_t *src, unsigned x, unsigned y, + unsigned stride, unsigned width, unsigned height, uint16_t *dst, + unsigned dst_width, unsigned dst_height) +{ + + int box_width = FFMIN(width - x, dst_width); + int box_height = FFMIN(height - y, dst_height); + int i, j, src_stride = stride >> 1; + uint16_t last_pix, *last_line; + + src += y * src_stride + x; + for (i = 0; i < box_height; ++i) { + for (j = 0; j < box_width; ++j) { + dst[j] = src[j]; + } + last_pix = dst[j - 1]; + for (; j < dst_width; j++) + dst[j] = last_pix; + src += src_stride; + dst += dst_width; + } + last_line = dst - dst_width; + for (; i < dst_height; i++) { + for (j = 0; j < dst_width; ++j) { + dst[j] = last_line[j]; + } + dst += dst_width; + } +} + +static int encode_slice(AVCodecContext *avctx, AVFrame *pic, int mb_x, + int mb_y, unsigned mb_count, uint8_t *buf, unsigned data_size, + int unsafe, int *qp) +{ + int luma_stride, chroma_stride; + int hdr_size = 6, slice_size; + uint8_t *dest_y, *dest_u, *dest_v; + unsigned y_data_size = 0, u_data_size = 0, v_data_size = 0; + ProresContext* ctx = avctx->priv_data; + int tgt_bits = (mb_count * bitrate_table[avctx->profile]) >> 2; + int low_bytes = (tgt_bits - (tgt_bits >> 3)) >> 3; // 12% bitrate fluctuation + int high_bytes = (tgt_bits + (tgt_bits >> 3)) >> 3; + + luma_stride = pic->linesize[0]; + chroma_stride = pic->linesize[1]; + + dest_y = pic->data[0] + (mb_y << 4) * luma_stride + (mb_x << 5); + dest_u = pic->data[1] + (mb_y << 4) * chroma_stride + (mb_x << 4); + dest_v = pic->data[2] + (mb_y << 4) * chroma_stride + (mb_x << 4); + + if (unsafe) { + + subimage_with_fill((uint16_t *) pic->data[0], mb_x << 4, mb_y << 4, + luma_stride, avctx->width, avctx->height, + (uint16_t *) ctx->fill_y, mb_count << 4, 16); + subimage_with_fill((uint16_t *) pic->data[1], mb_x << 3, mb_y << 4, + chroma_stride, avctx->width >> 1, avctx->height, + (uint16_t *) ctx->fill_u, mb_count << 3, 16); + subimage_with_fill((uint16_t *) pic->data[2], mb_x << 3, mb_y << 4, + chroma_stride, avctx->width >> 1, avctx->height, + (uint16_t *) ctx->fill_v, mb_count << 3, 16); + + encode_slice_data(avctx, ctx->fill_y, ctx->fill_u, ctx->fill_v, + mb_count << 5, mb_count << 4, mb_count, buf + hdr_size, + data_size - hdr_size, &y_data_size, &u_data_size, &v_data_size, + *qp); + } else { + slice_size = encode_slice_data(avctx, dest_y, dest_u, dest_v, + luma_stride, chroma_stride, mb_count, buf + hdr_size, + data_size - hdr_size, &y_data_size, &u_data_size, &v_data_size, + *qp); + + if (slice_size > high_bytes && *qp < qp_end_table[avctx->profile]) { + do { + *qp += 1; + slice_size = encode_slice_data(avctx, dest_y, dest_u, dest_v, + luma_stride, chroma_stride, mb_count, buf + hdr_size, + data_size - hdr_size, &y_data_size, &u_data_size, + &v_data_size, *qp); + } while (slice_size > high_bytes && *qp < qp_end_table[avctx->profile]); + } else if (slice_size < low_bytes && *qp + > qp_start_table[avctx->profile]) { + do { + *qp -= 1; + slice_size = encode_slice_data(avctx, dest_y, dest_u, dest_v, + luma_stride, chroma_stride, mb_count, buf + hdr_size, + data_size - hdr_size, &y_data_size, &u_data_size, + &v_data_size, *qp); + } while (slice_size < low_bytes && *qp > qp_start_table[avctx->profile]); + } + } + + buf[0] = hdr_size << 3; + buf[1] = *qp; + AV_WB16(buf + 2, y_data_size); + AV_WB16(buf + 4, u_data_size); + + return hdr_size + y_data_size + u_data_size + v_data_size; +} + +static int prores_encode_picture(AVCodecContext *avctx, AVFrame *pic, + uint8_t *buf, const int buf_size) +{ + int mb_width = (avctx->width + 15) >> 4; + int mb_height = (avctx->height + 15) >> 4; + int hdr_size, sl_size; + int mb_y, sl_data_size, qp; + int unsafe_bot, unsafe_right; + uint8_t *sl_data, *sl_data_sizes; + int slice_per_line = 0, rem = mb_width; + + for (int i = av_log2(DEFAULT_SLICE_MB_WIDTH); i >= 0; --i) { + slice_per_line += rem >> i; + rem &= (1 << i) - 1; + } + + qp = qp_start_table[avctx->profile]; + hdr_size = 8; sl_data_size = buf_size - hdr_size; + sl_data_sizes = buf + hdr_size; + sl_data = sl_data_sizes + (slice_per_line * mb_height * 2); + for (mb_y = 0; mb_y < mb_height; mb_y++) { + int mb_x = 0; + int slice_mb_count = DEFAULT_SLICE_MB_WIDTH; + while (mb_x < mb_width) { + while (mb_width - mb_x < slice_mb_count) + slice_mb_count >>= 1; + + unsafe_bot = (avctx->height & 0xf) && (mb_y == mb_height - 1); + unsafe_right = (avctx->width & 0xf) && (mb_x + slice_mb_count == mb_width); + + sl_size = encode_slice(avctx, pic, mb_x, mb_y, slice_mb_count, + sl_data, sl_data_size, unsafe_bot || unsafe_right, &qp); + + bytestream_put_be16(&sl_data_sizes, sl_size); + sl_data += sl_size; + sl_data_size -= sl_size; + mb_x += slice_mb_count; + } + } + + buf[0] = hdr_size << 3; + AV_WB32(buf + 1, sl_data - buf); + AV_WB16(buf + 5, slice_per_line * mb_height); + buf[7] = av_log2(DEFAULT_SLICE_MB_WIDTH) << 4; + + return sl_data - buf; +} + +static int prores_encode_frame(AVCodecContext *avctx, unsigned char *buf, + int buf_size, void *data) +{ + AVFrame *pic = data; + + int header_size = 148; + int pic_size = prores_encode_picture(avctx, pic, buf + header_size + 8, + buf_size - header_size - 8); + + bytestream_put_be32(&buf, pic_size + 8 + header_size); + bytestream_put_buffer(&buf, "icpf", 4); + + bytestream_put_be16(&buf, header_size); + bytestream_put_be16(&buf, 0); + bytestream_put_buffer(&buf, "fmpg", 4); + bytestream_put_be16(&buf, pic->width); + bytestream_put_be16(&buf, pic->height); + *buf++ = 0x83; // {10}(422){00}{00}(frame){11} + *buf++ = 0; + *buf++ = 2; + *buf++ = 2; + *buf++ = 6; + *buf++ = 32; + *buf++ = 0; + *buf++ = 3; + + bytestream_put_buffer(&buf, QMAT_LUMA[avctx->profile], 64); + bytestream_put_buffer(&buf, QMAT_CHROMA[avctx->profile], 64); + + return pic_size + 8 + header_size; +} + +static void scale_mat(const uint8_t* src, int* dst, int scale) +{ + int i; + for (i = 0; i < 64; i++) + dst[i] = src[i] * scale; +} + +static av_cold int prores_encode_init(AVCodecContext *avctx) +{ + int i; + ProresContext* ctx = avctx->priv_data; + + if (avctx->pix_fmt != PIX_FMT_YUV422P10) { + av_log(avctx, AV_LOG_ERROR, "need YUV422P10\n"); + return -1; + } + if (avctx->width & 0x1) { + av_log(avctx, AV_LOG_ERROR, + "frame width needs to be multiple of 2\n"); + return -1; + } + + if ((avctx->height & 0xf) || (avctx->width & 0xf)) { + ctx->fill_y = av_malloc(4 * (DEFAULT_SLICE_MB_WIDTH << 8)); + if (!ctx->fill_y) + return AVERROR(ENOMEM); + ctx->fill_u = ctx->fill_y + (DEFAULT_SLICE_MB_WIDTH << 9); + ctx->fill_v = ctx->fill_u + (DEFAULT_SLICE_MB_WIDTH << 8); + } + + if (avctx->profile == FF_PROFILE_UNKNOWN) { + avctx->profile = FF_PROFILE_PRORES_STANDARD; + av_log(avctx, AV_LOG_INFO, + "encoding with ProRes standard (apcn) profile\n"); + + } else if (avctx->profile < FF_PROFILE_PRORES_PROXY + || avctx->profile > FF_PROFILE_PRORES_HQ) { + av_log( + avctx, + AV_LOG_ERROR, + "unknown profile %d, use [0 - apco, 1 - apcs, 2 - apcn (default), 3 - apch]\n", + avctx->profile); + return -1; + } + + avctx->codec_tag = AV_RL32((const uint8_t*)profiles[avctx->profile].name); + + for (i = 1; i <= 16; i++) { + scale_mat(QMAT_LUMA[avctx->profile] , ctx->qmat_luma[i - 1] , i); + scale_mat(QMAT_CHROMA[avctx->profile], ctx->qmat_chroma[i - 1], i); + } + + avctx->coded_frame = avcodec_alloc_frame(); + avctx->coded_frame->key_frame = 1; + avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; + + return 0; +} + +static av_cold int prores_encode_close(AVCodecContext *avctx) +{ + ProresContext* ctx = avctx->priv_data; + av_freep(&avctx->coded_frame); + av_freep(&ctx->fill_y); + + return 0; +} + +AVCodec ff_prores_encoder = { + .name = "prores", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_PRORES, + .priv_data_size = sizeof(ProresContext), + .init = prores_encode_init, + .close = prores_encode_close, + .encode = prores_encode_frame, + .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV422P10, PIX_FMT_NONE}, + .long_name = NULL_IF_CONFIG_SMALL("Apple ProRes"), + .capabilities = 0, + .profiles = profiles +}; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/pthread.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/pthread.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/pthread.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/pthread.c 2011-11-04 12:38:27.000000000 +0000 @@ -29,12 +29,17 @@ * @see doc/multithreading.txt */ -#include - +#include "config.h" #include "avcodec.h" #include "internal.h" #include "thread.h" +#if HAVE_PTHREADS +#include +#elif HAVE_W32THREADS +#include "w32pthreads.h" +#endif + typedef int (action_func)(AVCodecContext *c, void *arg); typedef int (action_func2)(AVCodecContext *c, void *arg, int jobnr, int threadnr); @@ -333,6 +338,9 @@ dst->height = src->height; dst->pix_fmt = src->pix_fmt; + dst->coded_width = src->coded_width; + dst->coded_height = src->coded_height; + dst->has_b_frames = src->has_b_frames; dst->idct_algo = src->idct_algo; dst->slice_count = src->slice_count; @@ -635,7 +643,7 @@ park_frame_worker_threads(fctx, thread_count); - if (fctx->prev_thread) + if (fctx->prev_thread && fctx->prev_thread != fctx->threads) update_context_from_thread(fctx->threads->avctx, fctx->prev_thread->avctx, 0); fctx->die = 1; @@ -678,6 +686,7 @@ av_freep(&fctx->threads); pthread_mutex_destroy(&fctx->buffer_mutex); av_freep(&avctx->thread_opaque); + avctx->has_b_frames -= avctx->thread_count - 1; } static int frame_thread_init(AVCodecContext *avctx) @@ -902,6 +911,10 @@ return -1; } +#if HAVE_W32THREADS + w32thread_init(); +#endif + if (avctx->codec) { validate_thread_parameters(avctx); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ptx.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ptx.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ptx.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ptx.c 2011-11-04 12:38:27.000000000 +0000 @@ -60,7 +60,6 @@ avctx->pix_fmt = PIX_FMT_RGB555; - if (buf_end - buf < offset) return AVERROR_INVALIDDATA; if (offset != 0x2c) diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/put_bits.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/put_bits.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/put_bits.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/put_bits.h 2011-11-04 12:38:27.000000000 +0000 @@ -78,7 +78,8 @@ static inline void flush_put_bits(PutBitContext *s) { #ifndef BITSTREAM_WRITER_LE - s->bit_buf<<= s->bit_left; + if (s->bit_left < 32) + s->bit_buf<<= s->bit_left; #endif while (s->bit_left < 32) { /* XXX: should test end of buffer */ @@ -96,14 +97,14 @@ } #ifdef BITSTREAM_WRITER_LE -#define align_put_bits align_put_bits_unsupported_here +#define avpriv_align_put_bits align_put_bits_unsupported_here #define ff_put_string ff_put_string_unsupported_here -#define ff_copy_bits ff_copy_bits_unsupported_here +#define avpriv_copy_bits avpriv_copy_bits_unsupported_here #else /** * Pad the bitstream with zeros up to the next byte boundary. */ -void align_put_bits(PutBitContext *s); +void avpriv_align_put_bits(PutBitContext *s); /** * Put the string string in the bitstream. @@ -117,7 +118,7 @@ * * @param length the number of bits of src to copy */ -void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length); +void avpriv_copy_bits(PutBitContext *pb, const uint8_t *src, int length); #endif /** diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/qdm2_tablegen.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/qdm2_tablegen.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/qdm2_tablegen.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/qdm2_tablegen.h 2011-11-04 12:38:27.000000000 +0000 @@ -90,7 +90,7 @@ static av_cold void init_noise_samples(void) { int i; - int random_seed = 0; + unsigned random_seed = 0; float delta = 1.0 / 16384.0; for (i = 0; i < 128;i++) { random_seed = random_seed * 214013 + 2531011; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/qtrle.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/qtrle.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/qtrle.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/qtrle.c 2011-11-04 12:38:27.000000000 +0000 @@ -127,6 +127,7 @@ while (lines_to_change--) { CHECK_STREAM_PTR(2); pixel_ptr = row_ptr + (num_pixels * (s->buf[stream_ptr++] - 1)); + CHECK_PIXEL_PTR(0); /* make sure pixel_ptr is positive */ while ((rle_code = (signed char)s->buf[stream_ptr++]) != -1) { if (rle_code == 0) { @@ -183,6 +184,7 @@ while (lines_to_change--) { CHECK_STREAM_PTR(2); pixel_ptr = row_ptr + (4 * (s->buf[stream_ptr++] - 1)); + CHECK_PIXEL_PTR(0); /* make sure pixel_ptr is positive */ while ((rle_code = (signed char)s->buf[stream_ptr++]) != -1) { if (rle_code == 0) { @@ -236,6 +238,7 @@ while (lines_to_change--) { CHECK_STREAM_PTR(2); pixel_ptr = row_ptr + (s->buf[stream_ptr++] - 1) * 2; + CHECK_PIXEL_PTR(0); /* make sure pixel_ptr is positive */ while ((rle_code = (signed char)s->buf[stream_ptr++]) != -1) { if (rle_code == 0) { @@ -285,6 +288,7 @@ while (lines_to_change--) { CHECK_STREAM_PTR(2); pixel_ptr = row_ptr + (s->buf[stream_ptr++] - 1) * 3; + CHECK_PIXEL_PTR(0); /* make sure pixel_ptr is positive */ while ((rle_code = (signed char)s->buf[stream_ptr++]) != -1) { if (rle_code == 0) { @@ -336,6 +340,7 @@ while (lines_to_change--) { CHECK_STREAM_PTR(2); pixel_ptr = row_ptr + (s->buf[stream_ptr++] - 1) * 4; + CHECK_PIXEL_PTR(0); /* make sure pixel_ptr is positive */ while ((rle_code = (signed char)s->buf[stream_ptr++]) != -1) { if (rle_code == 0) { @@ -464,6 +469,8 @@ stream_ptr += 4; height = AV_RB16(&s->buf[stream_ptr]); stream_ptr += 4; + if (height > s->avctx->height - start_line) + goto done; } else { start_line = 0; height = s->avctx->height; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ra144.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ra144.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ra144.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ra144.c 2011-11-04 12:38:27.000000000 +0000 @@ -1544,22 +1544,22 @@ int ff_eval_refl(int *refl, const int16_t *coefs, AVCodecContext *avctx) { int b, i, j; - int buffer1[10]; - int buffer2[10]; + int buffer1[LPC_ORDER]; + int buffer2[LPC_ORDER]; int *bp1 = buffer1; int *bp2 = buffer2; - for (i=0; i < 10; i++) + for (i=0; i < LPC_ORDER; i++) buffer2[i] = coefs[i]; - refl[9] = bp2[9]; + refl[LPC_ORDER-1] = bp2[LPC_ORDER-1]; - if ((unsigned) bp2[9] + 0x1000 > 0x1fff) { + if ((unsigned) bp2[LPC_ORDER-1] + 0x1000 > 0x1fff) { av_log(avctx, AV_LOG_ERROR, "Overflow. Broken sample?\n"); return 1; } - for (i=8; i >= 0; i--) { + for (i = LPC_ORDER-2; i >= 0; i--) { b = 0x1000-((bp2[i+1] * bp2[i+1]) >> 12); if (!b) @@ -1584,12 +1584,12 @@ */ void ff_eval_coefs(int *coefs, const int *refl) { - int buffer[10]; + int buffer[LPC_ORDER]; int *b1 = buffer; int *b2 = coefs; int i, j; - for (i=0; i < 10; i++) { + for (i=0; i < LPC_ORDER; i++) { b1[i] = refl[i] << 4; for (j=0; j < i; j++) @@ -1598,7 +1598,7 @@ FFSWAP(int *, b1, b2); } - for (i=0; i < 10; i++) + for (i=0; i < LPC_ORDER; i++) coefs[i] >>= 4; } @@ -1606,7 +1606,7 @@ { int i; - for (i=0; i < 10; i++) + for (i = 0; i < LPC_ORDER; i++) *out++ = *inp++; } @@ -1629,9 +1629,9 @@ { int i; unsigned int res = 0x10000; - int b = 10; + int b = LPC_ORDER; - for (i=0; i < 10; i++) { + for (i = 0; i < LPC_ORDER; i++) { res = (((0x1000000 - data[i]*data[i]) >> 12) * res) >> 12; if (res == 0) @@ -1648,13 +1648,13 @@ int ff_interp(RA144Context *ractx, int16_t *out, int a, int copyold, int energy) { - int work[10]; + int work[LPC_ORDER]; int b = NBLOCKS - a; int i; // Interpolate block coefficients from the this frame's forth block and // last frame's forth block. - for (i=0; i<10; i++) + for (i = 0; i < LPC_ORDER; i++) out[i] = (a * ractx->lpc_coef[0][i] + b * ractx->lpc_coef[1][i])>> 2; if (ff_eval_refl(work, out, ractx->avctx)) { @@ -1690,7 +1690,7 @@ int cba_idx, int cb1_idx, int cb2_idx, int gval, int gain) { - uint16_t buffer_a[40]; + uint16_t buffer_a[BLOCKSIZE]; uint16_t *block; int m[3]; @@ -1711,10 +1711,10 @@ ff_add_wav(block, gain, cba_idx, m, cba_idx? buffer_a: NULL, ff_cb1_vects[cb1_idx], ff_cb2_vects[cb2_idx]); - memcpy(ractx->curr_sblock, ractx->curr_sblock + 40, - 10*sizeof(*ractx->curr_sblock)); + memcpy(ractx->curr_sblock, ractx->curr_sblock + BLOCKSIZE, + LPC_ORDER*sizeof(*ractx->curr_sblock)); - if (ff_celp_lp_synthesis_filter(ractx->curr_sblock + 10, lpc_coefs, - block, BLOCKSIZE, 10, 1, 0, 0xfff)) - memset(ractx->curr_sblock, 0, 50*sizeof(*ractx->curr_sblock)); + if (ff_celp_lp_synthesis_filter(ractx->curr_sblock + LPC_ORDER, lpc_coefs, + block, BLOCKSIZE, LPC_ORDER, 1, 0, 0xfff)) + memset(ractx->curr_sblock, 0, (LPC_ORDER+BLOCKSIZE)*sizeof(*ractx->curr_sblock)); } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ra144dec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ra144dec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ra144dec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ra144dec.c 2011-11-04 12:38:27.000000000 +0000 @@ -59,29 +59,33 @@ { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; - static const uint8_t sizes[10] = {6, 5, 5, 4, 4, 3, 3, 3, 3, 2}; - unsigned int refl_rms[4]; // RMS of the reflection coefficients - uint16_t block_coefs[4][10]; // LPC coefficients of each sub-block - unsigned int lpc_refl[10]; // LPC reflection coefficients of the frame + static const uint8_t sizes[LPC_ORDER] = {6, 5, 5, 4, 4, 3, 3, 3, 3, 2}; + unsigned int refl_rms[NBLOCKS]; // RMS of the reflection coefficients + uint16_t block_coefs[NBLOCKS][LPC_ORDER]; // LPC coefficients of each sub-block + unsigned int lpc_refl[LPC_ORDER]; // LPC reflection coefficients of the frame int i, j; + int out_size; int16_t *data = vdata; unsigned int energy; RA144Context *ractx = avctx->priv_data; GetBitContext gb; - if (*data_size < 2*160) - return -1; + out_size = NBLOCKS * BLOCKSIZE * av_get_bytes_per_sample(avctx->sample_fmt); + if (*data_size < out_size) { + av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); + return AVERROR(EINVAL); + } - if(buf_size < 20) { + if(buf_size < FRAMESIZE) { av_log(avctx, AV_LOG_ERROR, "Frame too small (%d bytes). Truncated file?\n", buf_size); *data_size = 0; return buf_size; } - init_get_bits(&gb, buf, 20 * 8); + init_get_bits(&gb, buf, FRAMESIZE * 8); - for (i=0; i<10; i++) + for (i = 0; i < LPC_ORDER; i++) lpc_refl[i] = ff_lpc_refl_cb[i][get_bits(&gb, sizes[i])]; ff_eval_coefs(ractx->lpc_coef[0], lpc_refl); @@ -98,7 +102,7 @@ ff_int_to_int16(block_coefs[3], ractx->lpc_coef[0]); - for (i=0; i < 4; i++) { + for (i=0; i < NBLOCKS; i++) { do_output_subblock(ractx, block_coefs[i], refl_rms[i], &gb); for (j=0; j < BLOCKSIZE; j++) @@ -110,8 +114,8 @@ FFSWAP(unsigned int *, ractx->lpc_coef[0], ractx->lpc_coef[1]); - *data_size = 2*160; - return 20; + *data_size = out_size; + return FRAMESIZE; } AVCodec ff_ra_144_decoder = { diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ra288.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ra288.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ra288.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ra288.c 2011-11-04 12:38:27.000000000 +0000 @@ -31,6 +31,9 @@ #define MAX_BACKWARD_FILTER_LEN 40 #define MAX_BACKWARD_FILTER_NONREC 35 +#define RA288_BLOCK_SIZE 5 +#define RA288_BLOCKS_PER_FRAME 32 + typedef struct { float sp_lpc[36]; ///< LPC coefficients for speech data (spec: A) float gain_lpc[10]; ///< LPC coefficients for gain (spec: GB) @@ -165,7 +168,7 @@ const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; float *out = data; - int i, j; + int i, j, out_size; RA288Context *ractx = avctx->priv_data; GetBitContext gb; @@ -176,18 +179,22 @@ return 0; } - if (*data_size < 32*5*4) - return -1; + out_size = RA288_BLOCK_SIZE * RA288_BLOCKS_PER_FRAME * + av_get_bytes_per_sample(avctx->sample_fmt); + if (*data_size < out_size) { + av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); + return AVERROR(EINVAL); + } init_get_bits(&gb, buf, avctx->block_align * 8); - for (i=0; i < 32; i++) { + for (i=0; i < RA288_BLOCKS_PER_FRAME; i++) { float gain = amptable[get_bits(&gb, 3)]; int cb_coef = get_bits(&gb, 6 + (i&1)); decode(ractx, gain, cb_coef); - for (j=0; j < 5; j++) + for (j=0; j < RA288_BLOCK_SIZE; j++) *(out++) = ractx->sp_hist[70 + 36 + j]; if ((i & 7) == 3) { @@ -199,7 +206,7 @@ } } - *data_size = (char *)out - (char *)data; + *data_size = out_size; return avctx->block_align; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ratecontrol.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ratecontrol.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/ratecontrol.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/ratecontrol.c 2011-11-04 12:38:27.000000000 +0000 @@ -537,8 +537,8 @@ const float border_masking = s->avctx->border_masking; float bits_sum= 0.0; float cplx_sum= 0.0; - float cplx_tab[s->mb_num]; - float bits_tab[s->mb_num]; + float *cplx_tab = av_malloc(s->mb_num * sizeof(*cplx_tab)); + float *bits_tab = av_malloc(s->mb_num * sizeof(*bits_tab)); const int qmin= s->avctx->mb_lmin; const int qmax= s->avctx->mb_lmax; Picture * const pic= &s->current_picture; @@ -639,6 +639,9 @@ //printf("%2d%3d ", intq, ff_sqrt(s->mc_mb_var[i])); s->lambda_table[mb_xy]= intq; } + + av_free(cplx_tab); + av_free(bits_tab); } void ff_get_2pass_fcode(MpegEncContext *s){ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/rawdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/rawdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/rawdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/rawdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -42,7 +42,7 @@ } RawVideoContext; static const AVOption options[]={ -{"top", "top field first", offsetof(RawVideoContext, tff), FF_OPT_TYPE_INT, {.dbl = -1}, -1, 1, AV_OPT_FLAG_DECODING_PARAM|AV_OPT_FLAG_VIDEO_PARAM}, +{"top", "top field first", offsetof(RawVideoContext, tff), AV_OPT_TYPE_INT, {.dbl = -1}, -1, 1, AV_OPT_FLAG_DECODING_PARAM|AV_OPT_FLAG_VIDEO_PARAM}, {NULL} }; static const AVClass class = { "rawdec", NULL, options, LIBAVUTIL_VERSION_INT }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/resample2.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/resample2.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/resample2.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/resample2.c 2011-11-04 12:38:27.000000000 +0000 @@ -207,8 +207,10 @@ memcpy(&c->filter_bank[c->filter_length*phase_count+1], c->filter_bank, (c->filter_length-1)*sizeof(FELEM)); c->filter_bank[c->filter_length*phase_count]= c->filter_bank[c->filter_length - 1]; - c->src_incr= out_rate; - c->ideal_dst_incr= c->dst_incr= in_rate * phase_count; + if(!av_reduce(&c->src_incr, &c->dst_incr, out_rate, in_rate * (int64_t)phase_count, INT32_MAX/2)) + goto error; + c->ideal_dst_incr= c->dst_incr; + c->index= -phase_count*((c->filter_length-1)/2); return c; @@ -246,10 +248,9 @@ dst[dst_index] = src[index2>>32]; index2 += incr; } - frac += dst_index * dst_incr_frac; index += dst_index * dst_incr; - index += frac / c->src_incr; - frac %= c->src_incr; + index += (frac + dst_index * (int64_t)dst_incr_frac) / c->src_incr; + frac = (frac + dst_index * (int64_t)dst_incr_frac) % c->src_incr; }else{ for(dst_index=0; dst_index < dst_size; dst_index++){ FELEM *filter= c->filter_bank + c->filter_length*(index & c->phase_mask); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/resample.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/resample.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/resample.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/resample.c 2011-11-04 12:38:27.000000000 +0000 @@ -265,7 +265,6 @@ } } -#define TAPS 16 s->resample_context = av_resample_init(output_rate, input_rate, filter_length, log2_phase_count, linear, cutoff); @@ -326,9 +325,9 @@ if (s->sample_fmt[1] != AV_SAMPLE_FMT_S16) { output_bak = output; - if (!s->buffer_size[1] || s->buffer_size[1] < lenout) { + if (!s->buffer_size[1] || s->buffer_size[1] < 2*lenout) { av_free(s->buffer[1]); - s->buffer_size[1] = lenout; + s->buffer_size[1] = 2*lenout; s->buffer[1] = av_malloc(s->buffer_size[1]); if (!s->buffer[1]) { av_log(s->resample_context, AV_LOG_ERROR, "Could not allocate buffer\n"); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/rpza.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/rpza.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/rpza.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/rpza.c 2011-11-04 12:38:27.000000000 +0000 @@ -30,8 +30,8 @@ * Note that this decoder reads big endian RGB555 pixel values from the * bytestream, arranges them in the host's endian order, and outputs * them to the final rendered map in the same host endian order. This is - * intended behavior as the ffmpeg documentation states that RGB555 pixels - * shall be stored in native CPU endianness. + * intended behavior as the libavcodec documentation states that RGB555 + * pixels shall be stored in native CPU endianness. */ #include diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/rv10enc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/rv10enc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/rv10enc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/rv10enc.c 2011-11-04 12:38:27.000000000 +0000 @@ -32,7 +32,7 @@ { int full_frame= 0; - align_put_bits(&s->pb); + avpriv_align_put_bits(&s->pb); put_bits(&s->pb, 1, 1); /* marker */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/rv30dsp.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/rv30dsp.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/rv30dsp.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/rv30dsp.c 2011-11-04 12:38:27.000000000 +0000 @@ -253,6 +253,9 @@ RV30_MC(avg_, 16) av_cold void ff_rv30dsp_init(RV34DSPContext *c, DSPContext* dsp) { + + ff_rv34dsp_init(c, dsp); + c->put_pixels_tab[0][ 0] = dsp->put_h264_qpel_pixels_tab[0][0]; c->put_pixels_tab[0][ 1] = put_rv30_tpel16_mc10_c; c->put_pixels_tab[0][ 2] = put_rv30_tpel16_mc20_c; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/rv34.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/rv34.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/rv34.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/rv34.c 2011-11-04 12:38:27.000000000 +0000 @@ -171,82 +171,6 @@ /** @} */ // vlc group - -/** - * @name RV30/40 inverse transform functions - * @{ - */ - -static av_always_inline void rv34_row_transform(int temp[16], DCTELEM *block) -{ - int i; - - for(i = 0; i < 4; i++){ - const int z0 = 13*(block[i+8*0] + block[i+8*2]); - const int z1 = 13*(block[i+8*0] - block[i+8*2]); - const int z2 = 7* block[i+8*1] - 17*block[i+8*3]; - const int z3 = 17* block[i+8*1] + 7*block[i+8*3]; - - temp[4*i+0] = z0 + z3; - temp[4*i+1] = z1 + z2; - temp[4*i+2] = z1 - z2; - temp[4*i+3] = z0 - z3; - } -} - -/** - * Real Video 3.0/4.0 inverse transform - * Code is almost the same as in SVQ3, only scaling is different. - */ -static void rv34_inv_transform(DCTELEM *block){ - int temp[16]; - int i; - - rv34_row_transform(temp, block); - - for(i = 0; i < 4; i++){ - const int z0 = 13*(temp[4*0+i] + temp[4*2+i]) + 0x200; - const int z1 = 13*(temp[4*0+i] - temp[4*2+i]) + 0x200; - const int z2 = 7* temp[4*1+i] - 17*temp[4*3+i]; - const int z3 = 17* temp[4*1+i] + 7*temp[4*3+i]; - - block[i*8+0] = (z0 + z3) >> 10; - block[i*8+1] = (z1 + z2) >> 10; - block[i*8+2] = (z1 - z2) >> 10; - block[i*8+3] = (z0 - z3) >> 10; - } - -} - -/** - * RealVideo 3.0/4.0 inverse transform for DC block - * - * Code is almost the same as rv34_inv_transform() - * but final coefficients are multiplied by 1.5 and have no rounding. - */ -static void rv34_inv_transform_noround(DCTELEM *block){ - int temp[16]; - int i; - - rv34_row_transform(temp, block); - - for(i = 0; i < 4; i++){ - const int z0 = 13*(temp[4*0+i] + temp[4*2+i]); - const int z1 = 13*(temp[4*0+i] - temp[4*2+i]); - const int z2 = 7* temp[4*1+i] - 17*temp[4*3+i]; - const int z3 = 17* temp[4*1+i] + 7*temp[4*3+i]; - - block[i*8+0] = ((z0 + z3) * 3) >> 11; - block[i*8+1] = ((z1 + z2) * 3) >> 11; - block[i*8+2] = ((z1 - z2) * 3) >> 11; - block[i*8+3] = ((z0 - z3) * 3) >> 11; - } - -} - -/** @} */ // transform - - /** * @name RV30/40 4x4 block decoding functions * @{ @@ -1226,7 +1150,7 @@ memset(block16, 0, sizeof(block16)); rv34_decode_block(block16, gb, r->cur_vlcs, 3, 0); rv34_dequant4x4_16x16(block16, rv34_qscale_tab[luma_dc_quant],rv34_qscale_tab[s->qscale]); - rv34_inv_transform_noround(block16); + r->rdsp.rv34_inv_transform_tab[1](block16); } for(i = 0; i < 16; i++, cbp >>= 1){ @@ -1238,7 +1162,7 @@ rv34_dequant4x4(s->block[blknum] + blkoff, rv34_qscale_tab[s->qscale],rv34_qscale_tab[s->qscale]); if(r->is16) //FIXME: optimize s->block[blknum][blkoff] = block16[(i & 3) | ((i & 0xC) << 1)]; - rv34_inv_transform(s->block[blknum] + blkoff); + r->rdsp.rv34_inv_transform_tab[0](s->block[blknum] + blkoff); } if(r->block_type == RV34_MB_P_MIX16x16) r->cur_vlcs = choose_vlc_set(r->si.quant, r->si.vlc_set, 1); @@ -1248,7 +1172,7 @@ blkoff = ((i & 1) << 2) + ((i & 2) << 4); rv34_decode_block(s->block[blknum] + blkoff, gb, r->cur_vlcs, r->chroma_vlc, 1); rv34_dequant4x4(s->block[blknum] + blkoff, rv34_qscale_tab[rv34_chroma_quant[1][s->qscale]],rv34_qscale_tab[rv34_chroma_quant[0][s->qscale]]); - rv34_inv_transform(s->block[blknum] + blkoff); + r->rdsp.rv34_inv_transform_tab[0](s->block[blknum] + blkoff); } if (IS_INTRA(s->current_picture_ptr->f.mb_type[mb_pos])) rv34_output_macroblock(r, intra_types, cbp2, r->is16); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/rv34dsp.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/rv34dsp.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/rv34dsp.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/rv34dsp.c 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,106 @@ +/* + * RV30/40 decoder common dsp functions + * Copyright (c) 2007 Mike Melanson, Konstantin Shishkov + * Copyright (c) 2011 Janne Grunau + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * RV30/40 decoder common dsp functions + */ +#include "dsputil.h" +#include "rv34dsp.h" + +/** + * @name RV30/40 inverse transform functions + * @{ + */ + +static av_always_inline void rv34_row_transform(int temp[16], DCTELEM *block) +{ + int i; + + for(i = 0; i < 4; i++){ + const int z0 = 13*(block[i+8*0] + block[i+8*2]); + const int z1 = 13*(block[i+8*0] - block[i+8*2]); + const int z2 = 7* block[i+8*1] - 17*block[i+8*3]; + const int z3 = 17* block[i+8*1] + 7*block[i+8*3]; + + temp[4*i+0] = z0 + z3; + temp[4*i+1] = z1 + z2; + temp[4*i+2] = z1 - z2; + temp[4*i+3] = z0 - z3; + } +} + +/** + * Real Video 3.0/4.0 inverse transform + * Code is almost the same as in SVQ3, only scaling is different. + */ +static void rv34_inv_transform_c(DCTELEM *block){ + int temp[16]; + int i; + + rv34_row_transform(temp, block); + + for(i = 0; i < 4; i++){ + const int z0 = 13*(temp[4*0+i] + temp[4*2+i]) + 0x200; + const int z1 = 13*(temp[4*0+i] - temp[4*2+i]) + 0x200; + const int z2 = 7* temp[4*1+i] - 17*temp[4*3+i]; + const int z3 = 17* temp[4*1+i] + 7*temp[4*3+i]; + + block[i*8+0] = (z0 + z3) >> 10; + block[i*8+1] = (z1 + z2) >> 10; + block[i*8+2] = (z1 - z2) >> 10; + block[i*8+3] = (z0 - z3) >> 10; + } +} + +/** + * RealVideo 3.0/4.0 inverse transform for DC block + * + * Code is almost the same as rv34_inv_transform() + * but final coefficients are multiplied by 1.5 and have no rounding. + */ +static void rv34_inv_transform_noround_c(DCTELEM *block){ + int temp[16]; + int i; + + rv34_row_transform(temp, block); + + for(i = 0; i < 4; i++){ + const int z0 = 13*(temp[4*0+i] + temp[4*2+i]); + const int z1 = 13*(temp[4*0+i] - temp[4*2+i]); + const int z2 = 7* temp[4*1+i] - 17*temp[4*3+i]; + const int z3 = 17* temp[4*1+i] + 7*temp[4*3+i]; + + block[i*8+0] = ((z0 + z3) * 3) >> 11; + block[i*8+1] = ((z1 + z2) * 3) >> 11; + block[i*8+2] = ((z1 - z2) * 3) >> 11; + block[i*8+3] = ((z0 - z3) * 3) >> 11; + } +} + +/** @} */ // transform + + +av_cold void ff_rv34dsp_init(RV34DSPContext *c, DSPContext* dsp) { + c->rv34_inv_transform_tab[0] = rv34_inv_transform_c; + c->rv34_inv_transform_tab[1] = rv34_inv_transform_noround_c; +} diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/rv34dsp.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/rv34dsp.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/rv34dsp.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/rv34dsp.h 2011-11-04 12:38:27.000000000 +0000 @@ -34,15 +34,19 @@ uint8_t *src2/*align width (8 or 16)*/, int w1, int w2, int stride); +typedef void (*rv34_inv_transform_func)(DCTELEM *block); + typedef struct RV34DSPContext { qpel_mc_func put_pixels_tab[4][16]; qpel_mc_func avg_pixels_tab[4][16]; h264_chroma_mc_func put_chroma_pixels_tab[3]; h264_chroma_mc_func avg_chroma_pixels_tab[3]; rv40_weight_func rv40_weight_pixels_tab[2]; + rv34_inv_transform_func rv34_inv_transform_tab[2]; } RV34DSPContext; void ff_rv30dsp_init(RV34DSPContext *c, DSPContext* dsp); +void ff_rv34dsp_init(RV34DSPContext *c, DSPContext* dsp); void ff_rv40dsp_init(RV34DSPContext *c, DSPContext* dsp); void ff_rv40dsp_init_x86(RV34DSPContext *c, DSPContext *dsp); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/rv34_parser.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/rv34_parser.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/rv34_parser.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/rv34_parser.c 2011-11-04 12:38:27.000000000 +0000 @@ -78,18 +78,16 @@ #ifdef CONFIG_RV30_PARSER AVCodecParser ff_rv30_parser = { - { CODEC_ID_RV30 }, - sizeof(RV34ParseContext), - NULL, - rv34_parse, + .codec_ids = { CODEC_ID_RV30 }, + .priv_data_size = sizeof(RV34ParseContext), + .parser_parse = rv34_parse, }; #endif #ifdef CONFIG_RV40_PARSER AVCodecParser ff_rv40_parser = { - { CODEC_ID_RV40 }, - sizeof(RV34ParseContext), - NULL, - rv34_parse, + .codec_ids = { CODEC_ID_RV40 }, + .priv_data_size = sizeof(RV34ParseContext), + .parser_parse = rv34_parse, }; #endif diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/rv40dsp.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/rv40dsp.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/rv40dsp.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/rv40dsp.c 2011-11-04 12:38:27.000000000 +0000 @@ -295,6 +295,9 @@ RV40_WEIGHT_FUNC(8) av_cold void ff_rv40dsp_init(RV34DSPContext *c, DSPContext* dsp) { + + ff_rv34dsp_init(c, dsp); + c->put_pixels_tab[0][ 0] = dsp->put_h264_qpel_pixels_tab[0][0]; c->put_pixels_tab[0][ 1] = put_rv40_qpel16_mc10_c; c->put_pixels_tab[0][ 2] = dsp->put_h264_qpel_pixels_tab[0][2]; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/shorten.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/shorten.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/shorten.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/shorten.c 2011-11-04 12:38:27.000000000 +0000 @@ -28,6 +28,7 @@ #include #include "avcodec.h" +#include "bytestream.h" #include "get_bits.h" #include "golomb.h" @@ -69,6 +70,9 @@ #define FN_ZERO 8 #define FN_VERBATIM 9 +/** indicates if the FN_* command is audio or non-audio */ +static const uint8_t is_audio_command[10] = { 1, 1, 1, 1, 0, 0, 0, 1, 1, 0 }; + #define VERBATIM_CKSIZE_SIZE 5 #define VERBATIM_BYTE_SIZE 8 #define CANONICAL_HEADER_SIZE 44 @@ -98,6 +102,8 @@ int blocksize; int bitindex; int32_t lpcqoffset; + int got_header; + int got_quit_command; } ShortenContext; static av_cold int shorten_decode_init(AVCodecContext * avctx) @@ -113,6 +119,7 @@ { int i, chan; int *coeffs; + void *tmp_ptr; for (chan=0; chanchannels; chan++) { if(FFMAX(1, s->nmean) >= UINT_MAX/sizeof(int32_t)){ @@ -124,9 +131,15 @@ return -1; } - s->offset[chan] = av_realloc(s->offset[chan], sizeof(int32_t)*FFMAX(1, s->nmean)); - - s->decoded[chan] = av_realloc(s->decoded[chan], sizeof(int32_t)*(s->blocksize + s->nwrap)); + tmp_ptr = av_realloc(s->offset[chan], sizeof(int32_t)*FFMAX(1, s->nmean)); + if (!tmp_ptr) + return AVERROR(ENOMEM); + s->offset[chan] = tmp_ptr; + + tmp_ptr = av_realloc(s->decoded[chan], sizeof(int32_t)*(s->blocksize + s->nwrap)); + if (!tmp_ptr) + return AVERROR(ENOMEM); + s->decoded[chan] = tmp_ptr; for (i=0; inwrap; i++) s->decoded[chan][i] = 0; s->decoded[chan] += s->nwrap; @@ -181,47 +194,37 @@ s->offset[chan][i] = mean; } -static inline int get_le32(GetBitContext *gb) +static int decode_wave_header(AVCodecContext *avctx, const uint8_t *header, + int header_size) { - return av_bswap32(get_bits_long(gb, 32)); -} - -static inline short get_le16(GetBitContext *gb) -{ - return av_bswap16(get_bits_long(gb, 16)); -} - -static int decode_wave_header(AVCodecContext *avctx, uint8_t *header, int header_size) -{ - GetBitContext hb; int len; short wave_format; - init_get_bits(&hb, header, header_size*8); - if (get_le32(&hb) != MKTAG('R','I','F','F')) { + + if (bytestream_get_le32(&header) != MKTAG('R','I','F','F')) { av_log(avctx, AV_LOG_ERROR, "missing RIFF tag\n"); return -1; } - skip_bits_long(&hb, 32); /* chunk_size */ + header += 4; /* chunk size */; - if (get_le32(&hb) != MKTAG('W','A','V','E')) { + if (bytestream_get_le32(&header) != MKTAG('W','A','V','E')) { av_log(avctx, AV_LOG_ERROR, "missing WAVE tag\n"); return -1; } - while (get_le32(&hb) != MKTAG('f','m','t',' ')) { - len = get_le32(&hb); - skip_bits(&hb, 8*len); + while (bytestream_get_le32(&header) != MKTAG('f','m','t',' ')) { + len = bytestream_get_le32(&header); + header += len; } - len = get_le32(&hb); + len = bytestream_get_le32(&header); if (len < 16) { av_log(avctx, AV_LOG_ERROR, "fmt chunk was too short\n"); return -1; } - wave_format = get_le16(&hb); + wave_format = bytestream_get_le16(&header); switch (wave_format) { case WAVE_FORMAT_PCM: @@ -231,11 +234,11 @@ return -1; } - avctx->channels = get_le16(&hb); - avctx->sample_rate = get_le32(&hb); - avctx->bit_rate = get_le32(&hb) * 8; - avctx->block_align = get_le16(&hb); - avctx->bits_per_coded_sample = get_le16(&hb); + header += 2; // skip channels (already got from shorten header) + avctx->sample_rate = bytestream_get_le32(&header); + header += 4; // skip bit rate (represents original uncompressed bit rate) + header += 2; // skip block align (not needed) + avctx->bits_per_coded_sample = bytestream_get_le16(&header); if (avctx->bits_per_coded_sample != 16) { av_log(avctx, AV_LOG_ERROR, "unsupported number of bits per sample\n"); @@ -253,26 +256,142 @@ int i, chan; for (i=0; icoeffs; + int pred_order, sum, qshift, init_sum, i, j; + const int *coeffs; - for (i=0; igb, LPCQUANT); + if (command == FN_QLPC) { + /* read/validate prediction order */ + pred_order = get_ur_golomb_shorten(&s->gb, LPCQSIZE); + if (pred_order > s->nwrap) { + av_log(s->avctx, AV_LOG_ERROR, "invalid pred_order %d\n", pred_order); + return AVERROR(EINVAL); + } + /* read LPC coefficients */ + for (i=0; icoeffs[i] = get_sr_golomb_shorten(&s->gb, LPCQUANT); + coeffs = s->coeffs; + + qshift = LPCQUANT; + } else { + /* fixed LPC coeffs */ + pred_order = command; + coeffs = fixed_coeffs[pred_order-1]; + qshift = 0; + } + + /* subtract offset from previous samples to use in prediction */ + if (command == FN_QLPC && coffset) + for (i = -pred_order; i < 0; i++) + s->decoded[channel][i] -= coffset; + /* decode residual and do LPC prediction */ + init_sum = pred_order ? (command == FN_QLPC ? s->lpcqoffset : 0) : coffset; for (i=0; i < s->blocksize; i++) { - sum = s->lpcqoffset; + sum = init_sum; for (j=0; jdecoded[channel][i-j-1]; - s->decoded[channel][i] = get_sr_golomb_shorten(&s->gb, residual_size) + (sum >> LPCQUANT); + s->decoded[channel][i] = get_sr_golomb_shorten(&s->gb, residual_size) + (sum >> qshift); } + + /* add offset to current samples */ + if (command == FN_QLPC && coffset) + for (i = 0; i < s->blocksize; i++) + s->decoded[channel][i] += coffset; + + return 0; } +static int read_header(ShortenContext *s) +{ + int i, ret; + int maxnlpc = 0; + /* shorten signature */ + if (get_bits_long(&s->gb, 32) != AV_RB32("ajkg")) { + av_log(s->avctx, AV_LOG_ERROR, "missing shorten magic 'ajkg'\n"); + return -1; + } + + s->lpcqoffset = 0; + s->blocksize = DEFAULT_BLOCK_SIZE; + s->channels = 1; + s->nmean = -1; + s->version = get_bits(&s->gb, 8); + s->internal_ftype = get_uint(s, TYPESIZE); + + s->channels = get_uint(s, CHANSIZE); + if (s->channels > MAX_CHANNELS) { + av_log(s->avctx, AV_LOG_ERROR, "too many channels: %d\n", s->channels); + return -1; + } + s->avctx->channels = s->channels; + + /* get blocksize if version > 0 */ + if (s->version > 0) { + int skip_bytes, blocksize; + + blocksize = get_uint(s, av_log2(DEFAULT_BLOCK_SIZE)); + if (!blocksize || blocksize > MAX_BLOCKSIZE) { + av_log(s->avctx, AV_LOG_ERROR, "invalid or unsupported block size: %d\n", + blocksize); + return AVERROR(EINVAL); + } + s->blocksize = blocksize; + + maxnlpc = get_uint(s, LPCQSIZE); + s->nmean = get_uint(s, 0); + + skip_bytes = get_uint(s, NSKIPSIZE); + for (i=0; igb, 8); + } + } + s->nwrap = FFMAX(NWRAP, maxnlpc); + + if ((ret = allocate_buffers(s)) < 0) + return ret; + + init_offset(s); + + if (s->version > 1) + s->lpcqoffset = V2LPCQOFFSET; + + if (get_ur_golomb_shorten(&s->gb, FNSIZE) != FN_VERBATIM) { + av_log(s->avctx, AV_LOG_ERROR, "missing verbatim section at beginning of stream\n"); + return -1; + } + + s->header_size = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE); + if (s->header_size >= OUT_BUFFER_SIZE || s->header_size < CANONICAL_HEADER_SIZE) { + av_log(s->avctx, AV_LOG_ERROR, "header is wrong size: %d\n", s->header_size); + return -1; + } + + for (i=0; iheader_size; i++) + s->header[i] = (char)get_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE); + + if (decode_wave_header(s->avctx, s->header, s->header_size) < 0) + return -1; + + s->cur_chan = 0; + s->bitshift = 0; + + s->got_header = 1; + + return 0; +} static int shorten_decode_frame(AVCodecContext *avctx, void *data, int *data_size, @@ -283,226 +402,189 @@ ShortenContext *s = avctx->priv_data; int i, input_buf_size = 0; int16_t *samples = data; + int ret; + + /* allocate internal bitstream buffer */ if(s->max_framesize == 0){ + void *tmp_ptr; s->max_framesize= 1024; // should hopefully be enough for the first header - s->bitstream= av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, s->max_framesize); + tmp_ptr = av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, + s->max_framesize); + if (!tmp_ptr) { + av_log(avctx, AV_LOG_ERROR, "error allocating bitstream buffer\n"); + return AVERROR(ENOMEM); + } + s->bitstream = tmp_ptr; } + /* append current packet data to bitstream buffer */ if(1 && s->max_framesize){//FIXME truncated buf_size= FFMIN(buf_size, s->max_framesize - s->bitstream_size); input_buf_size= buf_size; if(s->bitstream_index + s->bitstream_size + buf_size > s->allocated_bitstream_size){ - // printf("memmove\n"); memmove(s->bitstream, &s->bitstream[s->bitstream_index], s->bitstream_size); s->bitstream_index=0; } - memcpy(&s->bitstream[s->bitstream_index + s->bitstream_size], buf, buf_size); + if (buf) + memcpy(&s->bitstream[s->bitstream_index + s->bitstream_size], buf, buf_size); buf= &s->bitstream[s->bitstream_index]; buf_size += s->bitstream_size; s->bitstream_size= buf_size; - if(buf_size < s->max_framesize){ + /* do not decode until buffer has at least max_framesize bytes or + the end of the file has been reached */ + if (buf_size < s->max_framesize && avpkt->data) { *data_size = 0; return input_buf_size; } } + /* init and position bitstream reader */ init_get_bits(&s->gb, buf, buf_size*8); skip_bits(&s->gb, s->bitindex); - if (!s->blocksize) - { - int maxnlpc = 0; - /* shorten signature */ - if (get_bits_long(&s->gb, 32) != AV_RB32("ajkg")) { - av_log(s->avctx, AV_LOG_ERROR, "missing shorten magic 'ajkg'\n"); - return -1; - } - - s->lpcqoffset = 0; - s->blocksize = DEFAULT_BLOCK_SIZE; - s->channels = 1; - s->nmean = -1; - s->version = get_bits(&s->gb, 8); - s->internal_ftype = get_uint(s, TYPESIZE); - - s->channels = get_uint(s, CHANSIZE); - if (s->channels > MAX_CHANNELS) { - av_log(s->avctx, AV_LOG_ERROR, "too many channels: %d\n", s->channels); - return -1; - } - - /* get blocksize if version > 0 */ - if (s->version > 0) { - int skip_bytes; - s->blocksize = get_uint(s, av_log2(DEFAULT_BLOCK_SIZE)); - maxnlpc = get_uint(s, LPCQSIZE); - s->nmean = get_uint(s, 0); - - skip_bytes = get_uint(s, NSKIPSIZE); - for (i=0; igb, 8); - } - } - s->nwrap = FFMAX(NWRAP, maxnlpc); - - if (allocate_buffers(s)) - return -1; - init_offset(s); - - if (s->version > 1) - s->lpcqoffset = V2LPCQOFFSET; + /* process header or next subblock */ + if (!s->got_header) { + if ((ret = read_header(s)) < 0) + return ret; + *data_size = 0; + goto finish_frame; + } + + /* if quit command was read previously, don't decode anything */ + if (s->got_quit_command) { + *data_size = 0; + return avpkt->size; + } - if (get_ur_golomb_shorten(&s->gb, FNSIZE) != FN_VERBATIM) { - av_log(s->avctx, AV_LOG_ERROR, "missing verbatim section at beginning of stream\n"); - return -1; - } + s->cur_chan = 0; + while (s->cur_chan < s->channels) { + int cmd; + int len; - s->header_size = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE); - if (s->header_size >= OUT_BUFFER_SIZE || s->header_size < CANONICAL_HEADER_SIZE) { - av_log(s->avctx, AV_LOG_ERROR, "header is wrong size: %d\n", s->header_size); - return -1; + if (get_bits_left(&s->gb) < 3+FNSIZE) { + *data_size = 0; + break; } - for (i=0; iheader_size; i++) - s->header[i] = (char)get_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE); - - if (decode_wave_header(avctx, s->header, s->header_size) < 0) - return -1; - - s->cur_chan = 0; - s->bitshift = 0; - } - else - { - int cmd; - int len; cmd = get_ur_golomb_shorten(&s->gb, FNSIZE); - switch (cmd) { - case FN_ZERO: - case FN_DIFF0: - case FN_DIFF1: - case FN_DIFF2: - case FN_DIFF3: - case FN_QLPC: - { - int residual_size = 0; - int channel = s->cur_chan; - int32_t coffset; - if (cmd != FN_ZERO) { - residual_size = get_ur_golomb_shorten(&s->gb, ENERGYSIZE); - /* this is a hack as version 0 differed in defintion of get_sr_golomb_shorten */ - if (s->version == 0) - residual_size--; - } - if (s->nmean == 0) - coffset = s->offset[channel][0]; - else { - int32_t sum = (s->version < 2) ? 0 : s->nmean / 2; - for (i=0; inmean; i++) - sum += s->offset[channel][i]; - coffset = sum / s->nmean; - if (s->version >= 2) - coffset >>= FFMIN(1, s->bitshift); - } - switch (cmd) { - case FN_ZERO: - for (i=0; iblocksize; i++) - s->decoded[channel][i] = 0; - break; - case FN_DIFF0: - for (i=0; iblocksize; i++) - s->decoded[channel][i] = get_sr_golomb_shorten(&s->gb, residual_size) + coffset; - break; - case FN_DIFF1: - for (i=0; iblocksize; i++) - s->decoded[channel][i] = get_sr_golomb_shorten(&s->gb, residual_size) + s->decoded[channel][i - 1]; - break; - case FN_DIFF2: - for (i=0; iblocksize; i++) - s->decoded[channel][i] = get_sr_golomb_shorten(&s->gb, residual_size) + 2*s->decoded[channel][i-1] - - s->decoded[channel][i-2]; - break; - case FN_DIFF3: - for (i=0; iblocksize; i++) - s->decoded[channel][i] = get_sr_golomb_shorten(&s->gb, residual_size) + 3*s->decoded[channel][i-1] - - 3*s->decoded[channel][i-2] - + s->decoded[channel][i-3]; - break; - case FN_QLPC: - { - int pred_order = get_ur_golomb_shorten(&s->gb, LPCQSIZE); - if (pred_order > s->nwrap) { - av_log(avctx, AV_LOG_ERROR, - "invalid pred_order %d\n", - pred_order); - return -1; - } - for (i=0; idecoded[channel][i - pred_order] -= coffset; - decode_subframe_lpc(s, channel, residual_size, pred_order); - if (coffset != 0) - for (i=0; i < s->blocksize; i++) - s->decoded[channel][i] += coffset; - } + if (cmd > FN_VERBATIM) { + av_log(avctx, AV_LOG_ERROR, "unknown shorten function %d\n", cmd); + *data_size = 0; + break; + } + + if (!is_audio_command[cmd]) { + /* process non-audio command */ + switch (cmd) { + case FN_VERBATIM: + len = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE); + while (len--) { + get_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE); } - if (s->nmean > 0) { - int32_t sum = (s->version < 2) ? 0 : s->blocksize / 2; - for (i=0; iblocksize; i++) - sum += s->decoded[channel][i]; - - for (i=1; inmean; i++) - s->offset[channel][i-1] = s->offset[channel][i]; - - if (s->version < 2) - s->offset[channel][s->nmean - 1] = sum / s->blocksize; - else - s->offset[channel][s->nmean - 1] = (sum / s->blocksize) << s->bitshift; + break; + case FN_BITSHIFT: + s->bitshift = get_ur_golomb_shorten(&s->gb, BITSHIFTSIZE); + break; + case FN_BLOCKSIZE: { + int blocksize = get_uint(s, av_log2(s->blocksize)); + if (blocksize > s->blocksize) { + av_log(avctx, AV_LOG_ERROR, "Increasing block size is not supported\n"); + return AVERROR_PATCHWELCOME; } - for (i=-s->nwrap; i<0; i++) - s->decoded[channel][i] = s->decoded[channel][i + s->blocksize]; - - fix_bitshift(s, s->decoded[channel]); - - s->cur_chan++; - if (s->cur_chan == s->channels) { - samples = interleave_buffer(samples, s->channels, s->blocksize, s->decoded); - s->cur_chan = 0; - goto frame_done; + if (!blocksize || blocksize > MAX_BLOCKSIZE) { + av_log(avctx, AV_LOG_ERROR, "invalid or unsupported " + "block size: %d\n", blocksize); + return AVERROR(EINVAL); } + s->blocksize = blocksize; + break; } + case FN_QUIT: + s->got_quit_command = 1; + break; + } + if (cmd == FN_BLOCKSIZE || cmd == FN_QUIT) { + *data_size = 0; break; - case FN_VERBATIM: - len = get_ur_golomb_shorten(&s->gb, VERBATIM_CKSIZE_SIZE); - while (len--) { - get_ur_golomb_shorten(&s->gb, VERBATIM_BYTE_SIZE); - } - break; - case FN_BITSHIFT: - s->bitshift = get_ur_golomb_shorten(&s->gb, BITSHIFTSIZE); - break; - case FN_BLOCKSIZE: { - int blocksize = get_uint(s, av_log2(s->blocksize)); - if (blocksize > s->blocksize) { - av_log(avctx, AV_LOG_ERROR, "Increasing block size is not supported\n"); - return AVERROR_PATCHWELCOME; + } + } else { + /* process audio command */ + int residual_size = 0; + int channel = s->cur_chan; + int32_t coffset; + + /* get Rice code for residual decoding */ + if (cmd != FN_ZERO) { + residual_size = get_ur_golomb_shorten(&s->gb, ENERGYSIZE); + /* this is a hack as version 0 differed in defintion of get_sr_golomb_shorten */ + if (s->version == 0) + residual_size--; + } + + /* calculate sample offset using means from previous blocks */ + if (s->nmean == 0) + coffset = s->offset[channel][0]; + else { + int32_t sum = (s->version < 2) ? 0 : s->nmean / 2; + for (i=0; inmean; i++) + sum += s->offset[channel][i]; + coffset = sum / s->nmean; + if (s->version >= 2) + coffset >>= FFMIN(1, s->bitshift); + } + + /* decode samples for this channel */ + if (cmd == FN_ZERO) { + for (i=0; iblocksize; i++) + s->decoded[channel][i] = 0; + } else { + if ((ret = decode_subframe_lpc(s, cmd, channel, residual_size, coffset)) < 0) + return ret; + } + + /* update means with info from the current block */ + if (s->nmean > 0) { + int32_t sum = (s->version < 2) ? 0 : s->blocksize / 2; + for (i=0; iblocksize; i++) + sum += s->decoded[channel][i]; + + for (i=1; inmean; i++) + s->offset[channel][i-1] = s->offset[channel][i]; + + if (s->version < 2) + s->offset[channel][s->nmean - 1] = sum / s->blocksize; + else + s->offset[channel][s->nmean - 1] = (sum / s->blocksize) << s->bitshift; + } + + /* copy wrap samples for use with next block */ + for (i=-s->nwrap; i<0; i++) + s->decoded[channel][i] = s->decoded[channel][i + s->blocksize]; + + /* shift samples to add in unused zero bits which were removed + during encoding */ + fix_bitshift(s, s->decoded[channel]); + + /* if this is the last channel in the block, output the samples */ + s->cur_chan++; + if (s->cur_chan == s->channels) { + int out_size = s->blocksize * s->channels * + av_get_bytes_per_sample(avctx->sample_fmt); + if (*data_size < out_size) { + av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); + return AVERROR(EINVAL); } - s->blocksize = blocksize; - break; + samples = interleave_buffer(samples, s->channels, s->blocksize, s->decoded); + *data_size = out_size; } - case FN_QUIT: - *data_size = 0; - return buf_size; - default: - av_log(avctx, AV_LOG_ERROR, "unknown shorten function %d\n", cmd); - return -1; } } -frame_done: - *data_size = (int8_t *)samples - (int8_t *)data; + if (s->cur_chan < s->channels) + *data_size = 0; - // s->last_blocksize = s->blocksize; +finish_frame: s->bitindex = get_bits_count(&s->gb) - 8*((get_bits_count(&s->gb))/8); i= (get_bits_count(&s->gb))/8; if (i > buf_size) { @@ -534,13 +616,6 @@ return 0; } -static void shorten_flush(AVCodecContext *avctx){ - ShortenContext *s = avctx->priv_data; - - s->bitstream_size= - s->bitstream_index= 0; -} - AVCodec ff_shorten_decoder = { .name = "shorten", .type = AVMEDIA_TYPE_AUDIO, @@ -549,6 +624,6 @@ .init = shorten_decode_init, .close = shorten_decode_close, .decode = shorten_decode_frame, - .flush= shorten_flush, + .capabilities = CODEC_CAP_DELAY, .long_name= NULL_IF_CONFIG_SMALL("Shorten"), }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/simple_idct.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/simple_idct.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/simple_idct.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/simple_idct.c 2011-11-04 12:38:27.000000000 +0000 @@ -108,7 +108,7 @@ /* IDCT8 on each line */ for(i=0; i<8; i++) { - idctRowCondDC_8(block + i*8); + idctRowCondDC_8(block + i*8, 0); } /* IDCT4 and store */ @@ -183,7 +183,7 @@ /* IDCT8 on each line */ for(i=0; i<4; i++) { - idctRowCondDC_8(block + i*8); + idctRowCondDC_8(block + i*8, 0); } /* IDCT4 and store */ @@ -221,3 +221,17 @@ idct4col_add(dest + i, line_size, block + i); } } + +void ff_prores_idct(DCTELEM *block, const int16_t *qmat) +{ + int i; + + for (i = 0; i < 64; i++) + block[i] *= qmat[i]; + + for (i = 0; i < 8; i++) + idctRowCondDC_10(block + i*8, 2); + + for (i = 0; i < 8; i++) + idctSparseCol_10(block + i); +} diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/simple_idct.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/simple_idct.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/simple_idct.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/simple_idct.h 2011-11-04 12:38:27.000000000 +0000 @@ -38,6 +38,12 @@ void ff_simple_idct_put_10(uint8_t *dest, int line_size, DCTELEM *block); void ff_simple_idct_add_10(uint8_t *dest, int line_size, DCTELEM *block); void ff_simple_idct_10(DCTELEM *block); +/** + * Special version of ff_simple_idct_10() which does dequantization + * and scales by a factor of 2 more between the two IDCTs to account + * for larger scale of input coefficients. + */ +void ff_prores_idct(DCTELEM *block, const int16_t *qmat); void ff_simple_idct_mmx(int16_t *block); void ff_simple_idct_add_mmx(uint8_t *dest, int line_size, int16_t *block); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/simple_idct_template.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/simple_idct_template.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/simple_idct_template.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/simple_idct_template.c 2011-11-04 12:38:27.000000000 +0000 @@ -85,14 +85,19 @@ #endif -static inline void FUNC(idctRowCondDC)(DCTELEM *row) +static inline void FUNC(idctRowCondDC)(DCTELEM *row, int extra_shift) { int a0, a1, a2, a3, b0, b1, b2, b3; #if HAVE_FAST_64BIT #define ROW0_MASK (0xffffLL << 48 * HAVE_BIGENDIAN) if (((((uint64_t *)row)[0] & ~ROW0_MASK) | ((uint64_t *)row)[1]) == 0) { - uint64_t temp = (row[0] << DC_SHIFT) & 0xffff; + uint64_t temp; + if (DC_SHIFT - extra_shift > 0) { + temp = (row[0] << (DC_SHIFT - extra_shift)) & 0xffff; + } else { + temp = (row[0] >> (extra_shift - DC_SHIFT)) & 0xffff; + } temp += temp << 16; temp += temp << 32; ((uint64_t *)row)[0] = temp; @@ -104,7 +109,12 @@ ((uint32_t*)row)[2] | ((uint32_t*)row)[3] | row[1])) { - uint32_t temp = (row[0] << DC_SHIFT) & 0xffff; + uint32_t temp; + if (DC_SHIFT - extra_shift > 0) { + temp = (row[0] << (DC_SHIFT - extra_shift)) & 0xffff; + } else { + temp = (row[0] >> (extra_shift - DC_SHIFT)) & 0xffff; + } temp += temp << 16; ((uint32_t*)row)[0]=((uint32_t*)row)[1] = ((uint32_t*)row)[2]=((uint32_t*)row)[3] = temp; @@ -150,14 +160,14 @@ MAC(b3, -W1, row[7]); } - row[0] = (a0 + b0) >> ROW_SHIFT; - row[7] = (a0 - b0) >> ROW_SHIFT; - row[1] = (a1 + b1) >> ROW_SHIFT; - row[6] = (a1 - b1) >> ROW_SHIFT; - row[2] = (a2 + b2) >> ROW_SHIFT; - row[5] = (a2 - b2) >> ROW_SHIFT; - row[3] = (a3 + b3) >> ROW_SHIFT; - row[4] = (a3 - b3) >> ROW_SHIFT; + row[0] = (a0 + b0) >> (ROW_SHIFT + extra_shift); + row[7] = (a0 - b0) >> (ROW_SHIFT + extra_shift); + row[1] = (a1 + b1) >> (ROW_SHIFT + extra_shift); + row[6] = (a1 - b1) >> (ROW_SHIFT + extra_shift); + row[2] = (a2 + b2) >> (ROW_SHIFT + extra_shift); + row[5] = (a2 - b2) >> (ROW_SHIFT + extra_shift); + row[3] = (a3 + b3) >> (ROW_SHIFT + extra_shift); + row[4] = (a3 - b3) >> (ROW_SHIFT + extra_shift); } #define IDCT_COLS do { \ @@ -284,7 +294,7 @@ line_size /= sizeof(pixel); for (i = 0; i < 8; i++) - FUNC(idctRowCondDC)(block + i*8); + FUNC(idctRowCondDC)(block + i*8, 0); for (i = 0; i < 8; i++) FUNC(idctSparseColPut)(dest + i, line_size, block + i); @@ -298,7 +308,7 @@ line_size /= sizeof(pixel); for (i = 0; i < 8; i++) - FUNC(idctRowCondDC)(block + i*8); + FUNC(idctRowCondDC)(block + i*8, 0); for (i = 0; i < 8; i++) FUNC(idctSparseColAdd)(dest + i, line_size, block + i); @@ -309,7 +319,7 @@ int i; for (i = 0; i < 8; i++) - FUNC(idctRowCondDC)(block + i*8); + FUNC(idctRowCondDC)(block + i*8, 0); for (i = 0; i < 8; i++) FUNC(idctSparseCol)(block + i); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/sipr.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/sipr.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/sipr.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/sipr.c 2011-11-04 12:38:27.000000000 +0000 @@ -194,14 +194,16 @@ { int i, j; - parms->ma_pred_switch = get_bits(pgb, p->ma_predictor_bits); + if (p->ma_predictor_bits) + parms->ma_pred_switch = get_bits(pgb, p->ma_predictor_bits); for (i = 0; i < 5; i++) parms->vq_indexes[i] = get_bits(pgb, p->vq_indexes_bits[i]); for (i = 0; i < p->subframe_count; i++) { parms->pitch_delay[i] = get_bits(pgb, p->pitch_delay_bits[i]); - parms->gp_index[i] = get_bits(pgb, p->gp_index_bits); + if (p->gp_index_bits) + parms->gp_index[i] = get_bits(pgb, p->gp_index_bits); for (j = 0; j < p->number_of_fc_indexes; j++) parms->fc_indexes[i][j] = get_bits(pgb, p->fc_index_bits[j]); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/smacker.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/smacker.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/smacker.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/smacker.c 2011-11-04 12:38:27.000000000 +0000 @@ -560,6 +560,10 @@ static av_cold int smka_decode_init(AVCodecContext *avctx) { + if (avctx->channels < 1 || avctx->channels > 2) { + av_log(avctx, AV_LOG_ERROR, "invalid number of channels\n"); + return AVERROR(EINVAL); + } avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO; avctx->sample_fmt = avctx->bits_per_coded_sample == 8 ? AV_SAMPLE_FMT_U8 : AV_SAMPLE_FMT_S16; return 0; @@ -583,6 +587,11 @@ int bits, stereo; int pred[2] = {0, 0}; + if (buf_size <= 4) { + av_log(avctx, AV_LOG_ERROR, "packet is too small\n"); + return AVERROR(EINVAL); + } + unp_size = AV_RL32(buf); init_get_bits(&gb, buf + 4, (buf_size - 4) * 8); @@ -598,6 +607,14 @@ av_log(avctx, AV_LOG_ERROR, "Frame is too large to fit in buffer\n"); return -1; } + if (stereo ^ (avctx->channels != 1)) { + av_log(avctx, AV_LOG_ERROR, "channels mismatch\n"); + return AVERROR(EINVAL); + } + if (bits && avctx->sample_fmt == AV_SAMPLE_FMT_U8) { + av_log(avctx, AV_LOG_ERROR, "sample format mismatch\n"); + return AVERROR(EINVAL); + } memset(vlc, 0, sizeof(VLC) * 4); memset(h, 0, sizeof(HuffContext) * 4); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/snow.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/snow.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/snow.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/snow.c 2011-11-04 12:38:27.000000000 +0000 @@ -1609,8 +1609,6 @@ static void halfpel_interpol(SnowContext *s, uint8_t *halfpel[4][4], AVFrame *frame){ int p,x,y; - assert(!(s->avctx->flags & CODEC_FLAG_EMU_EDGE)); - for(p=0; p<3; p++){ int is_chroma= !!p; int w= s->avctx->width >>is_chroma; @@ -1667,7 +1665,7 @@ int w= s->avctx->width; //FIXME round up to x16 ? int h= s->avctx->height; - if(s->current_picture.data[0]){ + if (s->current_picture.data[0] && !(s->avctx->flags&CODEC_FLAG_EMU_EDGE)) { s->dsp.draw_edges(s->current_picture.data[0], s->current_picture.linesize[0], w , h , EDGE_WIDTH , EDGE_WIDTH , EDGE_TOP | EDGE_BOTTOM); @@ -3682,7 +3680,7 @@ #define OFFSET(x) offsetof(SnowContext, x) #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { - { "memc_only", "Only do ME/MC (I frames -> ref, P frame -> ME+MC).", OFFSET(memc_only), FF_OPT_TYPE_INT, { 0 }, 0, 1, VE }, + { "memc_only", "Only do ME/MC (I frames -> ref, P frame -> ME+MC).", OFFSET(memc_only), AV_OPT_TYPE_INT, { 0 }, 0, 1, VE }, { NULL }, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/sparc/dsputil_vis.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/sparc/dsputil_vis.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/sparc/dsputil_vis.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/sparc/dsputil_vis.c 2011-11-04 12:38:27.000000000 +0000 @@ -19,7 +19,7 @@ */ /* The *no_round* functions have been added by James A. Morrison, 2003,2004. - The vis code from libmpeg2 was adapted for ffmpeg by James A. Morrison. + The vis code from libmpeg2 was adapted for libavcodec by James A. Morrison. */ #include "config.h" diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/svq1enc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/svq1enc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/svq1enc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/svq1enc.c 2011-11-04 12:38:27.000000000 +0000 @@ -461,7 +461,7 @@ s->rd_total += score[best]; for(i=5; i>=0; i--){ - ff_copy_bits(&s->pb, reorder_buffer[best][i], count[best][i]); + avpriv_copy_bits(&s->pb, reorder_buffer[best][i], count[best][i]); } if(best==0){ s->dsp.put_pixels_tab[0][0](decoded, temp, stride, 16); @@ -540,7 +540,7 @@ return -1; } -// align_put_bits(&s->pb); +// avpriv_align_put_bits(&s->pb); while(put_bits_count(&s->pb) & 31) put_bits(&s->pb, 1, 0); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/tiffenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/tiffenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/tiffenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/tiffenc.c 2011-11-04 12:38:27.000000000 +0000 @@ -454,7 +454,7 @@ } static const AVOption options[]={ -{"dpi", "set the image resolution (in dpi)", offsetof(TiffEncoderContext, dpi), FF_OPT_TYPE_INT, {.dbl = 72}, 1, 0x10000, AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_ENCODING_PARAM}, +{"dpi", "set the image resolution (in dpi)", offsetof(TiffEncoderContext, dpi), AV_OPT_TYPE_INT, {.dbl = 72}, 1, 0x10000, AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_ENCODING_PARAM}, {NULL} }; static const AVClass class = { "tiff", av_default_item_name, options, LIBAVUTIL_VERSION_INT }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/timecode.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/timecode.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/timecode.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/timecode.h 2011-11-04 12:38:27.000000000 +0000 @@ -34,7 +34,7 @@ "timecode", "set timecode value following hh:mm:ss[:;.]ff format, " \ "use ';' or '.' before frame number for drop frame", \ offsetof(ctx, tc.str), \ - FF_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, flags + AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX, flags struct ff_timecode { char *str; ///< string following the hh:mm:ss[:;.]ff format diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/truemotion1data.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/truemotion1data.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/truemotion1data.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/truemotion1data.h 2011-11-04 12:38:27.000000000 +0000 @@ -2,9 +2,9 @@ * Duck Truemotion v1 Decoding Tables * * Data in this file was originally part of VpVision from On2 which is - * distributed under the GNU GPL. It is redistributed with ffmpeg under the - * GNU LGPL using the common understanding that data tables necessary for - * decoding algorithms are not necessarily licensable. + * distributed under the GNU GPL. It is redistributed with libavcodec under + * the GNU LGPL using the common understanding that data tables necessary + * for decoding algorithms are not necessarily copyrightable. * * This file is part of FFmpeg. * diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/truespeech.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/truespeech.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/truespeech.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/truespeech.c 2011-11-04 12:38:27.000000000 +0000 @@ -21,6 +21,8 @@ #include "libavutil/intreadwrite.h" #include "avcodec.h" +#include "dsputil.h" +#include "get_bits.h" #include "truespeech_data.h" /** @@ -32,7 +34,9 @@ * TrueSpeech decoder context */ typedef struct { + DSPContext dsp; /* input data */ + uint8_t buffer[32]; int16_t vector[8]; ///< input vector: 5/5/4/4/4/3/3/3 int offset1[2]; ///< 8-bit value, used in one copying offset int offset2[4]; ///< 7-bit value, encodes offsets for copying and for two-point filter @@ -54,100 +58,66 @@ static av_cold int truespeech_decode_init(AVCodecContext * avctx) { -// TSContext *c = avctx->priv_data; + TSContext *c = avctx->priv_data; + + if (avctx->channels != 1) { + av_log_ask_for_sample(avctx, "Unsupported channel count: %d\n", avctx->channels); + return AVERROR(EINVAL); + } avctx->sample_fmt = AV_SAMPLE_FMT_S16; + + dsputil_init(&c->dsp, avctx); + return 0; } static void truespeech_read_frame(TSContext *dec, const uint8_t *input) { - uint32_t t; - - /* first dword */ - t = AV_RL32(input); - input += 4; - - dec->flag = t & 1; - - dec->vector[0] = ts_codebook[0][(t >> 1) & 0x1F]; - dec->vector[1] = ts_codebook[1][(t >> 6) & 0x1F]; - dec->vector[2] = ts_codebook[2][(t >> 11) & 0xF]; - dec->vector[3] = ts_codebook[3][(t >> 15) & 0xF]; - dec->vector[4] = ts_codebook[4][(t >> 19) & 0xF]; - dec->vector[5] = ts_codebook[5][(t >> 23) & 0x7]; - dec->vector[6] = ts_codebook[6][(t >> 26) & 0x7]; - dec->vector[7] = ts_codebook[7][(t >> 29) & 0x7]; - - /* second dword */ - t = AV_RL32(input); - input += 4; - - dec->offset2[0] = (t >> 0) & 0x7F; - dec->offset2[1] = (t >> 7) & 0x7F; - dec->offset2[2] = (t >> 14) & 0x7F; - dec->offset2[3] = (t >> 21) & 0x7F; - - dec->offset1[0] = ((t >> 28) & 0xF) << 4; - - /* third dword */ - t = AV_RL32(input); - input += 4; - - dec->pulseval[0] = (t >> 0) & 0x3FFF; - dec->pulseval[1] = (t >> 14) & 0x3FFF; - - dec->offset1[1] = (t >> 28) & 0x0F; - - /* fourth dword */ - t = AV_RL32(input); - input += 4; - - dec->pulseval[2] = (t >> 0) & 0x3FFF; - dec->pulseval[3] = (t >> 14) & 0x3FFF; - - dec->offset1[1] |= ((t >> 28) & 0x0F) << 4; - - /* fifth dword */ - t = AV_RL32(input); - input += 4; - - dec->pulsepos[0] = (t >> 4) & 0x7FFFFFF; + GetBitContext gb; - dec->pulseoff[0] = (t >> 0) & 0xF; - - dec->offset1[0] |= (t >> 31) & 1; - - /* sixth dword */ - t = AV_RL32(input); - input += 4; - - dec->pulsepos[1] = (t >> 4) & 0x7FFFFFF; - - dec->pulseoff[1] = (t >> 0) & 0xF; - - dec->offset1[0] |= ((t >> 31) & 1) << 1; - - /* seventh dword */ - t = AV_RL32(input); - input += 4; - - dec->pulsepos[2] = (t >> 4) & 0x7FFFFFF; - - dec->pulseoff[2] = (t >> 0) & 0xF; - - dec->offset1[0] |= ((t >> 31) & 1) << 2; - - /* eighth dword */ - t = AV_RL32(input); - input += 4; - - dec->pulsepos[3] = (t >> 4) & 0x7FFFFFF; - - dec->pulseoff[3] = (t >> 0) & 0xF; - - dec->offset1[0] |= ((t >> 31) & 1) << 3; + dec->dsp.bswap_buf((uint32_t *)dec->buffer, (const uint32_t *)input, 8); + init_get_bits(&gb, dec->buffer, 32 * 8); + dec->vector[7] = ts_codebook[7][get_bits(&gb, 3)]; + dec->vector[6] = ts_codebook[6][get_bits(&gb, 3)]; + dec->vector[5] = ts_codebook[5][get_bits(&gb, 3)]; + dec->vector[4] = ts_codebook[4][get_bits(&gb, 4)]; + dec->vector[3] = ts_codebook[3][get_bits(&gb, 4)]; + dec->vector[2] = ts_codebook[2][get_bits(&gb, 4)]; + dec->vector[1] = ts_codebook[1][get_bits(&gb, 5)]; + dec->vector[0] = ts_codebook[0][get_bits(&gb, 5)]; + dec->flag = get_bits1(&gb); + + dec->offset1[0] = get_bits(&gb, 4) << 4; + dec->offset2[3] = get_bits(&gb, 7); + dec->offset2[2] = get_bits(&gb, 7); + dec->offset2[1] = get_bits(&gb, 7); + dec->offset2[0] = get_bits(&gb, 7); + + dec->offset1[1] = get_bits(&gb, 4); + dec->pulseval[1] = get_bits(&gb, 14); + dec->pulseval[0] = get_bits(&gb, 14); + + dec->offset1[1] |= get_bits(&gb, 4) << 4; + dec->pulseval[3] = get_bits(&gb, 14); + dec->pulseval[2] = get_bits(&gb, 14); + + dec->offset1[0] |= get_bits1(&gb); + dec->pulsepos[0] = get_bits_long(&gb, 27); + dec->pulseoff[0] = get_bits(&gb, 4); + + dec->offset1[0] |= get_bits1(&gb) << 1; + dec->pulsepos[1] = get_bits_long(&gb, 27); + dec->pulseoff[1] = get_bits(&gb, 4); + + dec->offset1[0] |= get_bits1(&gb) << 2; + dec->pulsepos[2] = get_bits_long(&gb, 27); + dec->pulseoff[2] = get_bits(&gb, 4); + + dec->offset1[0] |= get_bits1(&gb) << 3; + dec->pulsepos[3] = get_bits_long(&gb, 27); + dec->pulseoff[3] = get_bits(&gb, 4); } static void truespeech_correlate_filter(TSContext *dec) @@ -157,7 +127,7 @@ for(i = 0; i < 8; i++){ if(i > 0){ - memcpy(tmp, dec->cvector, i * 2); + memcpy(tmp, dec->cvector, i * sizeof(*tmp)); for(j = 0; j < i; j++) dec->cvector[j] = ((tmp[i - j - 1] * dec->vector[i]) + (dec->cvector[j] << 15) + 0x4000) >> 15; @@ -199,7 +169,7 @@ t = dec->offset2[quart]; if(t == 127){ - memset(dec->newvec, 0, 60 * 2); + memset(dec->newvec, 0, 60 * sizeof(*dec->newvec)); return; } for(i = 0; i < 146; i++) @@ -224,7 +194,7 @@ int16_t *ptr2; int coef; - memset(out, 0, 60 * 2); + memset(out, 0, 60 * sizeof(*out)); for(i = 0; i < 7; i++) { t = dec->pulseval[quart] & 3; dec->pulseval[quart] >>= 2; @@ -340,45 +310,45 @@ int i, j; short *samples = data; - int consumed = 0; - int16_t out_buf[240]; - int iterations; + int iterations, out_size; - if (!buf_size) - return 0; + iterations = buf_size / 32; - if (buf_size < 32) { + if (!iterations) { av_log(avctx, AV_LOG_ERROR, "Too small input buffer (%d bytes), need at least 32 bytes\n", buf_size); return -1; } - iterations = FFMIN(buf_size / 32, *data_size / 480); + + out_size = iterations * 240 * av_get_bytes_per_sample(avctx->sample_fmt); + if (*data_size < out_size) { + av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); + return AVERROR(EINVAL); + } + + memset(samples, 0, out_size); + for(j = 0; j < iterations; j++) { - truespeech_read_frame(c, buf + consumed); - consumed += 32; + truespeech_read_frame(c, buf); + buf += 32; truespeech_correlate_filter(c); truespeech_filters_merge(c); - memset(out_buf, 0, 240 * 2); for(i = 0; i < 4; i++) { truespeech_apply_twopoint_filter(c, i); - truespeech_place_pulses(c, out_buf + i * 60, i); - truespeech_update_filters(c, out_buf + i * 60, i); - truespeech_synth(c, out_buf + i * 60, i); + truespeech_place_pulses (c, samples, i); + truespeech_update_filters(c, samples, i); + truespeech_synth (c, samples, i); + samples += 60; } truespeech_save_prevvec(c); - - /* finally output decoded frame */ - for(i = 0; i < 240; i++) - *samples++ = out_buf[i]; - } - *data_size = consumed * 15; + *data_size = out_size; - return consumed; + return buf_size; } AVCodec ff_truespeech_decoder = { diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/tta.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/tta.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/tta.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/tta.c 2011-11-04 12:38:27.000000000 +0000 @@ -33,8 +33,8 @@ #include "avcodec.h" #include "get_bits.h" -#define FORMAT_INT 1 -#define FORMAT_FLOAT 3 +#define FORMAT_SIMPLE 1 +#define FORMAT_ENCRYPTED 2 #define MAX_ORDER 16 typedef struct TTAFilter { @@ -58,7 +58,7 @@ AVCodecContext *avctx; GetBitContext gb; - int flags, channels, bps, is_float, data_length; + int format, channels, bps, data_length; int frame_length, last_frame_length, total_frames; int32_t *decode_buffer; @@ -182,7 +182,7 @@ int ret = 0; // count ones - while(get_bits1(gb)) + while (get_bits_left(gb) > 0 && get_bits1(gb)) ret++; return ret; } @@ -213,58 +213,54 @@ { /* signature */ skip_bits(&s->gb, 32); -// if (get_bits_long(&s->gb, 32) != av_bswap32(AV_RL32("TTA1"))) { -// av_log(s->avctx, AV_LOG_ERROR, "Missing magic\n"); -// return -1; -// } - - s->flags = get_bits(&s->gb, 16); - if (s->flags != 1 && s->flags != 3) - { - av_log(s->avctx, AV_LOG_ERROR, "Invalid flags\n"); + + s->format = get_bits(&s->gb, 16); + if (s->format > 2) { + av_log(s->avctx, AV_LOG_ERROR, "Invalid format\n"); return -1; } - s->is_float = (s->flags == FORMAT_FLOAT); + if (s->format == FORMAT_ENCRYPTED) { + av_log_missing_feature(s->avctx, "Encrypted TTA", 0); + return AVERROR(EINVAL); + } avctx->channels = s->channels = get_bits(&s->gb, 16); if (s->channels > 1 && s->channels < 9) avctx->channel_layout = tta_channel_layouts[s->channels-2]; avctx->bits_per_coded_sample = get_bits(&s->gb, 16); s->bps = (avctx->bits_per_coded_sample + 7) / 8; avctx->sample_rate = get_bits_long(&s->gb, 32); - if(avctx->sample_rate > 1000000){ //prevent FRAME_TIME * avctx->sample_rate from overflowing and sanity check - av_log(avctx, AV_LOG_ERROR, "sample_rate too large\n"); - return -1; - } s->data_length = get_bits_long(&s->gb, 32); skip_bits(&s->gb, 32); // CRC32 of header - if (s->is_float) - { - avctx->sample_fmt = AV_SAMPLE_FMT_FLT; - av_log_ask_for_sample(s->avctx, "Unsupported sample format.\n"); - return -1; - } - else switch(s->bps) { - case 1: avctx->sample_fmt = AV_SAMPLE_FMT_U8; break; - case 2: avctx->sample_fmt = AV_SAMPLE_FMT_S16; break; - case 3: avctx->bits_per_coded_sample = 24; - case 4: avctx->sample_fmt = AV_SAMPLE_FMT_S32; break; - default: - av_log_ask_for_sample(s->avctx, - "Invalid/unsupported sample format.\n"); - return -1; + switch(s->bps) { + case 1: avctx->sample_fmt = AV_SAMPLE_FMT_U8; break; + case 2: + avctx->sample_fmt = AV_SAMPLE_FMT_S16; + avctx->bits_per_raw_sample = 16; + break; + case 3: + avctx->sample_fmt = AV_SAMPLE_FMT_S32; + avctx->bits_per_raw_sample = 24; + break; + //case 4: avctx->sample_fmt = AV_SAMPLE_FMT_S32; break; + default: + av_log(avctx, AV_LOG_ERROR, "Invalid/unsupported sample format.\n"); + return AVERROR_INVALIDDATA; } - // FIXME: horribly broken, but directly from reference source -#define FRAME_TIME 1.04489795918367346939 - s->frame_length = (int)(FRAME_TIME * avctx->sample_rate); + // prevent overflow + if (avctx->sample_rate > 0x7FFFFF) { + av_log(avctx, AV_LOG_ERROR, "sample_rate too large\n"); + return AVERROR(EINVAL); + } + s->frame_length = 256 * avctx->sample_rate / 245; s->last_frame_length = s->data_length % s->frame_length; s->total_frames = s->data_length / s->frame_length + (s->last_frame_length ? 1 : 0); - av_log(s->avctx, AV_LOG_DEBUG, "flags: %x chans: %d bps: %d rate: %d block: %d\n", - s->flags, avctx->channels, avctx->bits_per_coded_sample, avctx->sample_rate, + av_log(s->avctx, AV_LOG_DEBUG, "format: %d chans: %d bps: %d rate: %d block: %d\n", + s->format, avctx->channels, avctx->bits_per_coded_sample, avctx->sample_rate, avctx->block_align); av_log(s->avctx, AV_LOG_DEBUG, "data_length: %d frame_length: %d last: %d total: %d\n", s->data_length, s->frame_length, s->last_frame_length, s->total_frames); @@ -283,8 +279,10 @@ if (!s->decode_buffer) return AVERROR(ENOMEM); s->ch_ctx = av_malloc(avctx->channels * sizeof(*s->ch_ctx)); - if (!s->ch_ctx) + if (!s->ch_ctx) { + av_freep(&s->decode_buffer); return AVERROR(ENOMEM); + } } else { av_log(avctx, AV_LOG_ERROR, "Wrong extradata present\n"); return -1; @@ -300,114 +298,113 @@ const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; TTAContext *s = avctx->priv_data; - int i; + int i, out_size; + int cur_chan = 0, framelen = s->frame_length; + int32_t *p; init_get_bits(&s->gb, buf, buf_size*8); - { - int cur_chan = 0, framelen = s->frame_length; - int32_t *p; - if (*data_size < (framelen * s->channels * av_get_bits_per_sample_fmt(avctx->sample_fmt) / 8)) { - av_log(avctx, AV_LOG_ERROR, "Output buffer size is too small.\n"); - return -1; + // FIXME: seeking + s->total_frames--; + if (!s->total_frames && s->last_frame_length) + framelen = s->last_frame_length; + + out_size = framelen * s->channels * av_get_bytes_per_sample(avctx->sample_fmt); + if (*data_size < out_size) { + av_log(avctx, AV_LOG_ERROR, "Output buffer size is too small.\n"); + return -1; + } + + // decode directly to output buffer for 24-bit sample format + if (s->bps == 3) + s->decode_buffer = data; + + // init per channel states + for (i = 0; i < s->channels; i++) { + s->ch_ctx[i].predictor = 0; + ttafilter_init(&s->ch_ctx[i].filter, ttafilter_configs[s->bps-1][0], ttafilter_configs[s->bps-1][1]); + rice_init(&s->ch_ctx[i].rice, 10, 10); + } + + for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++) { + int32_t *predictor = &s->ch_ctx[cur_chan].predictor; + TTAFilter *filter = &s->ch_ctx[cur_chan].filter; + TTARice *rice = &s->ch_ctx[cur_chan].rice; + uint32_t unary, depth, k; + int32_t value; + + unary = tta_get_unary(&s->gb); + + if (unary == 0) { + depth = 0; + k = rice->k0; + } else { + depth = 1; + k = rice->k1; + unary--; } - // FIXME: seeking - s->total_frames--; - if (!s->total_frames && s->last_frame_length) - framelen = s->last_frame_length; - - // init per channel states - for (i = 0; i < s->channels; i++) { - s->ch_ctx[i].predictor = 0; - ttafilter_init(&s->ch_ctx[i].filter, ttafilter_configs[s->bps-1][0], ttafilter_configs[s->bps-1][1]); - rice_init(&s->ch_ctx[i].rice, 10, 10); - } - - for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++) { - int32_t *predictor = &s->ch_ctx[cur_chan].predictor; - TTAFilter *filter = &s->ch_ctx[cur_chan].filter; - TTARice *rice = &s->ch_ctx[cur_chan].rice; - uint32_t unary, depth, k; - int32_t value; - - unary = tta_get_unary(&s->gb); - - if (unary == 0) { - depth = 0; - k = rice->k0; - } else { - depth = 1; - k = rice->k1; - unary--; - } - if (get_bits_left(&s->gb) < k) - return -1; + if (get_bits_left(&s->gb) < k) + return -1; - if (k) { - if (k > MIN_CACHE_BITS) - return -1; - value = (unary << k) + get_bits(&s->gb, k); - } else - value = unary; - - // FIXME: copy paste from original - switch (depth) { - case 1: - rice->sum1 += value - (rice->sum1 >> 4); - if (rice->k1 > 0 && rice->sum1 < shift_16[rice->k1]) - rice->k1--; - else if(rice->sum1 > shift_16[rice->k1 + 1]) - rice->k1++; - value += shift_1[rice->k0]; - default: - rice->sum0 += value - (rice->sum0 >> 4); - if (rice->k0 > 0 && rice->sum0 < shift_16[rice->k0]) - rice->k0--; - else if(rice->sum0 > shift_16[rice->k0 + 1]) - rice->k0++; - } + if (k) { + if (k > MIN_CACHE_BITS) + return -1; + value = (unary << k) + get_bits(&s->gb, k); + } else + value = unary; + + // FIXME: copy paste from original + switch (depth) { + case 1: + rice->sum1 += value - (rice->sum1 >> 4); + if (rice->k1 > 0 && rice->sum1 < shift_16[rice->k1]) + rice->k1--; + else if(rice->sum1 > shift_16[rice->k1 + 1]) + rice->k1++; + value += shift_1[rice->k0]; + default: + rice->sum0 += value - (rice->sum0 >> 4); + if (rice->k0 > 0 && rice->sum0 < shift_16[rice->k0]) + rice->k0--; + else if(rice->sum0 > shift_16[rice->k0 + 1]) + rice->k0++; + } - // extract coded value + // extract coded value #define UNFOLD(x) (((x)&1) ? (++(x)>>1) : (-(x)>>1)) - *p = UNFOLD(value); + *p = UNFOLD(value); - // run hybrid filter - ttafilter_process(filter, p, 0); + // run hybrid filter + ttafilter_process(filter, p, 0); - // fixed order prediction + // fixed order prediction #define PRED(x, k) (int32_t)((((uint64_t)x << k) - x) >> k) - switch (s->bps) { - case 1: *p += PRED(*predictor, 4); break; - case 2: - case 3: *p += PRED(*predictor, 5); break; - case 4: *p += *predictor; break; - } - *predictor = *p; - - /*if ((get_bits_count(&s->gb)+7)/8 > buf_size) - { - av_log(NULL, AV_LOG_INFO, "overread!!\n"); - break; - }*/ + switch (s->bps) { + case 1: *p += PRED(*predictor, 4); break; + case 2: + case 3: *p += PRED(*predictor, 5); break; + case 4: *p += *predictor; break; + } + *predictor = *p; - // flip channels - if (cur_chan < (s->channels-1)) - cur_chan++; - else { - // decorrelate in case of stereo integer - if (!s->is_float && (s->channels > 1)) { - int32_t *r = p - 1; - for (*p += *r / 2; r > p - s->channels; r--) - *r = *(r + 1) - *r; - } - cur_chan = 0; + // flip channels + if (cur_chan < (s->channels-1)) + cur_chan++; + else { + // decorrelate in case of stereo integer + if (s->channels > 1) { + int32_t *r = p - 1; + for (*p += *r / 2; r > p - s->channels; r--) + *r = *(r + 1) - *r; } + cur_chan = 0; } + } - if (get_bits_left(&s->gb) < 32) - return -1; - skip_bits(&s->gb, 32); // frame crc + if (get_bits_left(&s->gb) < 32) + return -1; + skip_bits(&s->gb, 32); // frame crc // convert to output buffer switch(s->bps) { @@ -415,32 +412,29 @@ uint8_t *samples = data; for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++) *samples++ = *p + 0x80; - *data_size = samples - (uint8_t *)data; break; } case 2: { uint16_t *samples = data; - for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++) { -// *samples++ = (unsigned char)*p; -// *samples++ = (unsigned char)(*p >> 8); + for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++) *samples++ = *p; - } - *data_size = (uint8_t *)samples - (uint8_t *)data; break; } case 3: { + // shift samples for 24-bit sample format int32_t *samples = data; for (p = s->decode_buffer; p < s->decode_buffer + (framelen * s->channels); p++) - *samples++ = AV_RN32(p) << 8; - *data_size = (uint8_t *)samples - (uint8_t *)data; + *samples++ <<= 8; + // reset decode buffer + s->decode_buffer = NULL; break; } default: av_log(s->avctx, AV_LOG_ERROR, "Error, only 16bit samples supported!\n"); } - } -// return get_bits_count(&s->gb)+7)/8; + *data_size = out_size; + return buf_size; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/twinvq.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/twinvq.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/twinvq.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/twinvq.c 2011-11-04 12:38:27.000000000 +0000 @@ -822,7 +822,7 @@ const ModeTab *mtab = tctx->mtab; float *out = data; enum FrameType ftype; - int window_type; + int window_type, out_size; static const enum FrameType wtype_to_ftype_table[] = { FT_LONG, FT_LONG, FT_SHORT, FT_LONG, FT_MEDIUM, FT_LONG, FT_LONG, FT_MEDIUM, FT_MEDIUM @@ -831,8 +831,14 @@ if (buf_size*8 < avctx->bit_rate*mtab->size/avctx->sample_rate + 8) { av_log(avctx, AV_LOG_ERROR, "Frame too small (%d bytes). Truncated file?\n", buf_size); - *data_size = 0; - return buf_size; + return AVERROR(EINVAL); + } + + out_size = mtab->size * avctx->channels * + av_get_bytes_per_sample(avctx->sample_fmt); + if (*data_size < out_size) { + av_log(avctx, AV_LOG_ERROR, "output buffer is too small\n"); + return AVERROR(EINVAL); } init_get_bits(&gb, buf, buf_size * 8); @@ -857,7 +863,7 @@ return buf_size; } - *data_size = mtab->size*avctx->channels*4; + *data_size = out_size; return buf_size; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/txd.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/txd.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/txd.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/txd.c 2011-11-04 12:38:27.000000000 +0000 @@ -23,6 +23,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/imgutils.h" +#include "bytestream.h" #include "avcodec.h" #include "s3tc.h" @@ -42,6 +43,7 @@ static int txd_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; + const uint8_t *buf_end = avpkt->data + avpkt->size; TXDContext * const s = avctx->priv_data; AVFrame *picture = data; AVFrame * const p = &s->picture; @@ -52,6 +54,8 @@ const uint32_t *palette = (const uint32_t *)(cur + 88); uint32_t *pal; + if (buf_end - cur < 92) + return AVERROR_INVALIDDATA; version = AV_RL32(cur); d3d_format = AV_RL32(cur+76); w = AV_RL16(cur+80); @@ -69,6 +73,8 @@ if (depth == 8) { avctx->pix_fmt = PIX_FMT_PAL8; + if (buf_end - cur < 1024) + return AVERROR_INVALIDDATA; cur += 1024; } else if (depth == 16 || depth == 32) avctx->pix_fmt = PIX_FMT_RGB32; @@ -100,6 +106,8 @@ v = AV_RB32(palette+y); pal[y] = (v>>8) + (v<<24); } + if (buf_end - cur < w * h) + return AVERROR_INVALIDDATA; for (y=0; y 1; mipmap_count--) - cur += AV_RL32(cur) + 4; + for (; mipmap_count > 1 && buf_end - cur >= 4; mipmap_count--) { + uint32_t length = bytestream_get_le32(&cur); + if (buf_end - cur < length) + break; + cur += length; + } *picture = s->picture; *data_size = sizeof(AVPicture); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/utils.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/utils.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/utils.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/utils.c 2011-11-04 12:38:27.000000000 +0000 @@ -158,12 +158,15 @@ case PIX_FMT_YUV420P9BE: case PIX_FMT_YUV420P10LE: case PIX_FMT_YUV420P10BE: + case PIX_FMT_YUV422P9LE: + case PIX_FMT_YUV422P9BE: case PIX_FMT_YUV422P10LE: case PIX_FMT_YUV422P10BE: case PIX_FMT_YUV444P9LE: case PIX_FMT_YUV444P9BE: case PIX_FMT_YUV444P10LE: case PIX_FMT_YUV444P10BE: + case PIX_FMT_GBR24P: w_align= 16; //FIXME check for non mpeg style codecs and use less alignment h_align= 16; if(s->codec_id == CODEC_ID_MPEG2VIDEO || s->codec_id == CODEC_ID_MJPEG || s->codec_id == CODEC_ID_AMV || s->codec_id == CODEC_ID_THP || s->codec_id == CODEC_ID_H264 || s->codec_id == CODEC_ID_PRORES) @@ -221,7 +224,7 @@ #if HAVE_MMX if(s->codec_id == CODEC_ID_SVQ1 || s->codec_id == CODEC_ID_VP5 || s->codec_id == CODEC_ID_VP6 || s->codec_id == CODEC_ID_VP6F || - s->codec_id == CODEC_ID_VP6A) { + s->codec_id == CODEC_ID_VP6A || s->codec_id == CODEC_ID_DIRAC) { linesize_align[0] = linesize_align[1] = linesize_align[2] = 16; @@ -393,6 +396,7 @@ pic->width = s->width; pic->height = s->height; pic->format = s->pix_fmt; + pic->opaque = s->opaque; if(s->debug&FF_DEBUG_BUFFERS) av_log(s, AV_LOG_DEBUG, "default_get_buffer called on pic %p, %d buffers used\n", pic, s->internal_buffer_count); @@ -608,6 +612,16 @@ goto free_and_end; } avctx->frame_number = 0; +#if FF_API_ER + + av_log(avctx, AV_LOG_DEBUG, "err{or,}_recognition separate: %d; %d\n", + avctx->error_recognition, avctx->err_recognition); + /* FF_ER_CAREFUL (==1) implies AV_EF_CRCCHECK (== 1<<1 - 1), + FF_ER_COMPLIANT (==2) implies AV_EF_{CRCCHECK,BITSTREAM} (== 1<<2 - 1), et cetera} */ + avctx->err_recognition |= (1<<(avctx->error_recognition-(avctx->error_recognition>=FF_ER_VERY_AGGRESSIVE))) - 1; + av_log(avctx, AV_LOG_DEBUG, "err{or,}_recognition combined: %d; %d\n", + avctx->error_recognition, avctx->err_recognition); +#endif if (!HAVE_THREADS) av_log(avctx, AV_LOG_WARNING, "Warning: not compiled with thread support, using thread emulation\n"); @@ -797,7 +811,7 @@ if((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size || (avctx->active_thread_type&FF_THREAD_FRAME)){ av_packet_split_side_data(avpkt); avctx->pkt = avpkt; - if (HAVE_PTHREADS && avctx->active_thread_type&FF_THREAD_FRAME) + if (HAVE_THREADS && avctx->active_thread_type&FF_THREAD_FRAME) ret = ff_thread_decode_frame(avctx, picture, got_picture_ptr, avpkt); else { @@ -941,10 +955,21 @@ return 0; } +static enum CodecID remap_deprecated_codec_id(enum CodecID id) +{ + switch(id){ + case CODEC_ID_G723_1_DEPRECATED : return CODEC_ID_G723_1; + case CODEC_ID_G729_DEPRECATED : return CODEC_ID_G729; + case CODEC_ID_UTVIDEO_DEPRECATED: return CODEC_ID_UTVIDEO; + default : return id; + } +} + AVCodec *avcodec_find_encoder(enum CodecID id) { AVCodec *p, *experimental=NULL; p = first_avcodec; + id= remap_deprecated_codec_id(id); while (p) { if (p->encode != NULL && p->id == id) { if (p->capabilities & CODEC_CAP_EXPERIMENTAL && !experimental) { @@ -975,6 +1000,7 @@ { AVCodec *p, *experimental=NULL; p = first_avcodec; + id= remap_deprecated_codec_id(id); while (p) { if (p->decode != NULL && p->id == id) { if (p->capabilities & CODEC_CAP_EXPERIMENTAL && !experimental) { @@ -1183,7 +1209,7 @@ void avcodec_flush_buffers(AVCodecContext *avctx) { - if(HAVE_PTHREADS && avctx->active_thread_type&FF_THREAD_FRAME) + if(HAVE_THREADS && avctx->active_thread_type&FF_THREAD_FRAME) ff_thread_flush(avctx); else if(avctx->codec->flush) avctx->codec->flush(avctx); @@ -1363,7 +1389,7 @@ return 0; } -unsigned int ff_toupper4(unsigned int x) +unsigned int avpriv_toupper4(unsigned int x) { return toupper( x &0xFF) + (toupper((x>>8 )&0xFF)<<8 ) @@ -1371,7 +1397,7 @@ + (toupper((x>>24)&0xFF)<<24); } -#if !HAVE_PTHREADS +#if !HAVE_THREADS int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f) { @@ -1411,6 +1437,12 @@ enum AVMediaType avcodec_get_type(enum CodecID codec_id) { + AVCodec *c= avcodec_find_decoder(codec_id); + if(!c) + c= avcodec_find_encoder(codec_id); + if(c) + return c->type; + if (codec_id <= CODEC_ID_NONE) return AVMEDIA_TYPE_UNKNOWN; else if (codec_id < CODEC_ID_FIRST_AUDIO) diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/utvideo.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/utvideo.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/utvideo.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/utvideo.c 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,491 @@ +/* + * Ut Video decoder + * Copyright (c) 2011 Konstantin Shishkov + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * Ut Video decoder + */ + +#include + +#include "libavutil/intreadwrite.h" +#include "avcodec.h" +#include "bytestream.h" +#include "get_bits.h" +#include "dsputil.h" + +enum { + PRED_NONE = 0, + PRED_LEFT, + PRED_GRADIENT, + PRED_MEDIAN, +}; + +typedef struct UtvideoContext { + AVCodecContext *avctx; + AVFrame pic; + DSPContext dsp; + + uint32_t frame_info_size, flags, frame_info; + int planes; + int slices; + int compression; + int interlaced; + int frame_pred; + + uint8_t *slice_bits; + int slice_bits_size; +} UtvideoContext; + +typedef struct HuffEntry { + uint8_t sym; + uint8_t len; +} HuffEntry; + +static int huff_cmp(const void *a, const void *b) +{ + const HuffEntry *aa = a, *bb = b; + return (aa->len - bb->len)*256 + aa->sym - bb->sym; +} + +static int build_huff(const uint8_t *src, VLC *vlc, int *fsym) +{ + int i; + HuffEntry he[256]; + int last; + uint32_t codes[256]; + uint8_t bits[256]; + uint8_t syms[256]; + uint32_t code; + + *fsym = -1; + for (i = 0; i < 256; i++) { + he[i].sym = i; + he[i].len = *src++; + } + qsort(he, 256, sizeof(*he), huff_cmp); + + if (!he[0].len) { + *fsym = he[0].sym; + return 0; + } + if (he[0].len > 32) + return -1; + + last = 255; + while (he[last].len == 255 && last) + last--; + + code = 1; + for (i = last; i >= 0; i--) { + codes[i] = code >> (32 - he[i].len); + bits[i] = he[i].len; + syms[i] = he[i].sym; + code += 0x80000000u >> (he[i].len - 1); + } + + return init_vlc_sparse(vlc, FFMIN(he[last].len, 9), last + 1, + bits, sizeof(*bits), sizeof(*bits), + codes, sizeof(*codes), sizeof(*codes), + syms, sizeof(*syms), sizeof(*syms), 0); +} + +static int decode_plane(UtvideoContext *c, int plane_no, + uint8_t *dst, int step, int stride, + int width, int height, + const uint8_t *src, int src_size, int use_pred) +{ + int i, j, slice, pix; + int sstart, send; + VLC vlc; + GetBitContext gb; + int prev, fsym; + const int cmask = ~(!plane_no && c->avctx->pix_fmt == PIX_FMT_YUV420P); + + if (build_huff(src, &vlc, &fsym)) { + av_log(c->avctx, AV_LOG_ERROR, "Cannot build Huffman codes\n"); + return AVERROR_INVALIDDATA; + } + if (fsym >= 0) { // build_huff reported a symbol to fill slices with + send = 0; + for (slice = 0; slice < c->slices; slice++) { + uint8_t *dest; + + sstart = send; + send = (height * (slice + 1) / c->slices) & cmask; + dest = dst + sstart * stride; + + prev = 0x80; + for (j = sstart; j < send; j++) { + for (i = 0; i < width * step; i += step) { + pix = fsym; + if (use_pred) { + prev += pix; + pix = prev; + } + dest[i] = pix; + } + dest += stride; + } + } + return 0; + } + + src += 256; + src_size -= 256; + + send = 0; + for (slice = 0; slice < c->slices; slice++) { + uint8_t *dest; + int slice_data_start, slice_data_end, slice_size; + + sstart = send; + send = (height * (slice + 1) / c->slices) & cmask; + dest = dst + sstart * stride; + + // slice offset and size validation was done earlier + slice_data_start = slice ? AV_RL32(src + slice * 4 - 4) : 0; + slice_data_end = AV_RL32(src + slice * 4); + slice_size = slice_data_end - slice_data_start; + + if (!slice_size) { + for (j = sstart; j < send; j++) { + for (i = 0; i < width * step; i += step) + dest[i] = 0x80; + dest += stride; + } + continue; + } + + memcpy(c->slice_bits, src + slice_data_start + c->slices * 4, slice_size); + memset(c->slice_bits + slice_size, 0, FF_INPUT_BUFFER_PADDING_SIZE); + c->dsp.bswap_buf((uint32_t*)c->slice_bits, (uint32_t*)c->slice_bits, + (slice_data_end - slice_data_start + 3) >> 2); + init_get_bits(&gb, c->slice_bits, slice_size * 8); + + prev = 0x80; + for (j = sstart; j < send; j++) { + for (i = 0; i < width * step; i += step) { + if (get_bits_left(&gb) <= 0) { + av_log(c->avctx, AV_LOG_ERROR, "Slice decoding ran out of bits\n"); + goto fail; + } + pix = get_vlc2(&gb, vlc.table, vlc.bits, 4); + if (pix < 0) { + av_log(c->avctx, AV_LOG_ERROR, "Decoding error\n"); + goto fail; + } + if (use_pred) { + prev += pix; + pix = prev; + } + dest[i] = pix; + } + dest += stride; + } + if (get_bits_left(&gb) > 32) + av_log(c->avctx, AV_LOG_WARNING, "%d bits left after decoding slice\n", + get_bits_left(&gb)); + } + + free_vlc(&vlc); + + return 0; +fail: + free_vlc(&vlc); + return AVERROR_INVALIDDATA; +} + +static const int rgb_order[4] = { 1, 2, 0, 3 }; + +static void restore_rgb_planes(uint8_t *src, int step, int stride, int width, int height) +{ + int i, j; + uint8_t r, g, b; + + for (j = 0; j < height; j++) { + for (i = 0; i < width * step; i += step) { + r = src[i]; + g = src[i + 1]; + b = src[i + 2]; + src[i] = r + g - 0x80; + src[i + 2] = b + g - 0x80; + } + src += stride; + } +} + +static void restore_median(uint8_t *src, int step, int stride, + int width, int height, int slices, int rmode) +{ + int i, j, slice; + int A, B, C; + uint8_t *bsrc; + int slice_start, slice_height; + const int cmask = ~rmode; + + for (slice = 0; slice < slices; slice++) { + slice_start = ((slice * height) / slices) & cmask; + slice_height = ((((slice + 1) * height) / slices) & cmask) - slice_start; + + bsrc = src + slice_start * stride; + + // first line - left neighbour prediction + bsrc[0] += 0x80; + A = bsrc[0]; + for (i = step; i < width * step; i += step) { + bsrc[i] += A; + A = bsrc[i]; + } + bsrc += stride; + if (slice_height == 1) + continue; + // second line - first element has top predition, the rest uses median + C = bsrc[-stride]; + bsrc[0] += C; + A = bsrc[0]; + for (i = step; i < width * step; i += step) { + B = bsrc[i - stride]; + bsrc[i] += mid_pred(A, B, (uint8_t)(A + B - C)); + C = B; + A = bsrc[i]; + } + bsrc += stride; + // the rest of lines use continuous median prediction + for (j = 2; j < slice_height; j++) { + for (i = 0; i < width * step; i += step) { + B = bsrc[i - stride]; + bsrc[i] += mid_pred(A, B, (uint8_t)(A + B - C)); + C = B; + A = bsrc[i]; + } + bsrc += stride; + } + } +} + +static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) +{ + const uint8_t *buf = avpkt->data; + int buf_size = avpkt->size; + const uint8_t *buf_end = buf + buf_size; + UtvideoContext *c = avctx->priv_data; + const uint8_t *ptr; + int i, j; + const uint8_t *plane_start[5]; + int plane_size, max_slice_size = 0, slice_start, slice_end, slice_size; + int ret; + + if (c->pic.data[0]) + avctx->release_buffer(avctx, &c->pic); + + c->pic.reference = 1; + c->pic.buffer_hints = FF_BUFFER_HINTS_VALID; + if ((ret = avctx->get_buffer(avctx, &c->pic)) < 0) { + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); + return ret; + } + + /* parse plane structure to retrieve frame flags and validate slice offsets */ + ptr = buf; + for (i = 0; i < c->planes; i++) { + plane_start[i] = ptr; + if (buf_end - ptr < 256 + 4 * c->slices) { + av_log(avctx, AV_LOG_ERROR, "Insufficient data for a plane\n"); + return AVERROR_INVALIDDATA; + } + ptr += 256; + slice_start = 0; + slice_end = 0; + for (j = 0; j < c->slices; j++) { + slice_end = bytestream_get_le32(&ptr); + slice_size = slice_end - slice_start; + if (slice_size < 0) { + av_log(avctx, AV_LOG_ERROR, "Incorrect slice size\n"); + return AVERROR_INVALIDDATA; + } + slice_start = slice_end; + max_slice_size = FFMAX(max_slice_size, slice_size); + } + plane_size = slice_end; + if (buf_end - ptr < plane_size) { + av_log(avctx, AV_LOG_ERROR, "Plane size is bigger than available data\n"); + return AVERROR_INVALIDDATA; + } + ptr += plane_size; + } + plane_start[c->planes] = ptr; + if (buf_end - ptr < c->frame_info_size) { + av_log(avctx, AV_LOG_ERROR, "Not enough data for frame information\n"); + return AVERROR_INVALIDDATA; + } + c->frame_info = AV_RL32(ptr); + av_log(avctx, AV_LOG_DEBUG, "frame information flags %X\n", c->frame_info); + + c->frame_pred = (c->frame_info >> 8) & 3; + + if (c->frame_pred == PRED_GRADIENT) { + av_log_ask_for_sample(avctx, "Frame uses gradient prediction\n"); + return AVERROR_PATCHWELCOME; + } + + av_fast_malloc(&c->slice_bits, &c->slice_bits_size, + max_slice_size + FF_INPUT_BUFFER_PADDING_SIZE); + + if (!c->slice_bits) { + av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer\n"); + return AVERROR(ENOMEM); + } + + switch (c->avctx->pix_fmt) { + case PIX_FMT_RGB24: + case PIX_FMT_RGBA: + for (i = 0; i < c->planes; i++) { + ret = decode_plane(c, i, c->pic.data[0] + rgb_order[i], c->planes, + c->pic.linesize[0], avctx->width, avctx->height, + plane_start[i], plane_start[i + 1] - plane_start[i], + c->frame_pred == PRED_LEFT); + if (ret) + return ret; + if (c->frame_pred == PRED_MEDIAN) + restore_median(c->pic.data[0] + rgb_order[i], c->planes, + c->pic.linesize[0], avctx->width, avctx->height, + c->slices, 0); + } + restore_rgb_planes(c->pic.data[0], c->planes, c->pic.linesize[0], + avctx->width, avctx->height); + break; + case PIX_FMT_YUV420P: + for (i = 0; i < 3; i++) { + ret = decode_plane(c, i, c->pic.data[i], 1, + c->pic.linesize[i], avctx->width >> !!i, avctx->height >> !!i, + plane_start[i], plane_start[i + 1] - plane_start[i], + c->frame_pred == PRED_LEFT); + if (ret) + return ret; + if (c->frame_pred == PRED_MEDIAN) + restore_median(c->pic.data[i], 1, c->pic.linesize[i], + avctx->width >> !!i, avctx->height >> !!i, + c->slices, !i); + } + break; + case PIX_FMT_YUV422P: + for (i = 0; i < 3; i++) { + ret = decode_plane(c, i, c->pic.data[i], 1, + c->pic.linesize[i], avctx->width >> !!i, avctx->height, + plane_start[i], plane_start[i + 1] - plane_start[i], + c->frame_pred == PRED_LEFT); + if (ret) + return ret; + if (c->frame_pred == PRED_MEDIAN) + restore_median(c->pic.data[i], 1, c->pic.linesize[i], + avctx->width >> !!i, avctx->height, c->slices, 0); + } + break; + } + + *data_size = sizeof(AVFrame); + *(AVFrame*)data = c->pic; + + /* always report that the buffer was completely consumed */ + return buf_size; +} + +static av_cold int decode_init(AVCodecContext *avctx) +{ + UtvideoContext * const c = avctx->priv_data; + + c->avctx = avctx; + + dsputil_init(&c->dsp, avctx); + + if (avctx->extradata_size < 16) { + av_log(avctx, AV_LOG_ERROR, "Insufficient extradata size %d, should be at least 16\n", + avctx->extradata_size); + return AVERROR_INVALIDDATA; + } + + av_log(avctx, AV_LOG_DEBUG, "Encoder version %d.%d.%d.%d\n", + avctx->extradata[3], avctx->extradata[2], + avctx->extradata[1], avctx->extradata[0]); + av_log(avctx, AV_LOG_DEBUG, "Original format %X\n", AV_RB32(avctx->extradata + 4)); + c->frame_info_size = AV_RL32(avctx->extradata + 8); + c->flags = AV_RL32(avctx->extradata + 12); + + if (c->frame_info_size != 4) + av_log_ask_for_sample(avctx, "Frame info is not 4 bytes\n"); + av_log(avctx, AV_LOG_DEBUG, "Encoding parameters %08X\n", c->flags); + c->slices = (c->flags >> 24) + 1; + c->compression = c->flags & 1; + c->interlaced = c->flags & 0x800; + + c->slice_bits_size = 0; + + switch (avctx->codec_tag) { + case MKTAG('U', 'L', 'R', 'G'): + c->planes = 3; + avctx->pix_fmt = PIX_FMT_RGB24; + break; + case MKTAG('U', 'L', 'R', 'A'): + c->planes = 4; + avctx->pix_fmt = PIX_FMT_RGBA; + break; + case MKTAG('U', 'L', 'Y', '0'): + c->planes = 3; + avctx->pix_fmt = PIX_FMT_YUV420P; + break; + case MKTAG('U', 'L', 'Y', '2'): + c->planes = 3; + avctx->pix_fmt = PIX_FMT_YUV422P; + break; + default: + av_log(avctx, AV_LOG_ERROR, "Unknown Ut Video FOURCC provided (%08X)\n", + avctx->codec_tag); + return AVERROR_INVALIDDATA; + } + + return 0; +} + +static av_cold int decode_end(AVCodecContext *avctx) +{ + UtvideoContext * const c = avctx->priv_data; + + if (c->pic.data[0]) + avctx->release_buffer(avctx, &c->pic); + + av_freep(&c->slice_bits); + + return 0; +} + +AVCodec ff_utvideo_decoder = { + .name = "utvideo", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_UTVIDEO, + .priv_data_size = sizeof(UtvideoContext), + .init = decode_init, + .close = decode_end, + .decode = decode_frame, + .capabilities = CODEC_CAP_DR1, + .long_name = NULL_IF_CONFIG_SMALL("Ut Video"), +}; + diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/v210dec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/v210dec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/v210dec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/v210dec.c 2011-11-04 12:38:27.000000000 +0000 @@ -22,10 +22,34 @@ */ #include "avcodec.h" +#include "v210dec.h" #include "libavutil/bswap.h" +#define READ_PIXELS(a, b, c) \ + do { \ + val = av_le2ne32(*src++); \ + *a++ = val & 0x3FF; \ + *b++ = (val >> 10) & 0x3FF; \ + *c++ = (val >> 20) & 0x3FF; \ + } while (0) + +static void v210_planar_unpack_c(const uint32_t *src, uint16_t *y, uint16_t *u, uint16_t *v, int width) +{ + uint32_t val; + int i; + + for( i = 0; i < width-5; i += 6 ){ + READ_PIXELS(u, y, v); + READ_PIXELS(y, u, y); + READ_PIXELS(v, y, u); + READ_PIXELS(y, v, y); + } +} + static av_cold int decode_init(AVCodecContext *avctx) { + V210DecContext *s = avctx->priv_data; + if (avctx->width & 1) { av_log(avctx, AV_LOG_ERROR, "v210 needs even width\n"); return -1; @@ -35,18 +59,37 @@ avctx->coded_frame = avcodec_alloc_frame(); + s->unpack_frame = v210_planar_unpack_c; + + if (HAVE_MMX) + v210_x86_init(s); + return 0; } static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { - int h, w; + V210DecContext *s = avctx->priv_data; + + int h, w, stride, aligned_input; AVFrame *pic = avctx->coded_frame; const uint8_t *psrc = avpkt->data; uint16_t *y, *u, *v; - int aligned_width = ((avctx->width + 47) / 48) * 48; - int stride = aligned_width * 8 / 3; + + if (s->custom_stride ) + stride = s->custom_stride; + else { + int aligned_width = ((avctx->width + 47) / 48) * 48; + stride = aligned_width * 8 / 3; + } + + aligned_input = !((uintptr_t)psrc & 0xf) && !(stride & 0xf); + if (aligned_input != s->aligned_input) { + s->aligned_input = aligned_input; + if (HAVE_MMX) + v210_x86_init(s); + } if (pic->data[0]) avctx->release_buffer(avctx, pic); @@ -66,23 +109,18 @@ pic->pict_type = AV_PICTURE_TYPE_I; pic->key_frame = 1; -#define READ_PIXELS(a, b, c) \ - do { \ - val = av_le2ne32(*src++); \ - *a++ = val & 0x3FF; \ - *b++ = (val >> 10) & 0x3FF; \ - *c++ = (val >> 20) & 0x3FF; \ - } while (0) - for (h = 0; h < avctx->height; h++) { const uint32_t *src = (const uint32_t*)psrc; uint32_t val; - for (w = 0; w < avctx->width - 5; w += 6) { - READ_PIXELS(u, y, v); - READ_PIXELS(y, u, y); - READ_PIXELS(v, y, u); - READ_PIXELS(y, v, y); - } + + w = (avctx->width / 6) * 6; + s->unpack_frame(src, y, u, v, w); + + y += w; + u += w >> 1; + v += w >> 1; + src += (w << 1) / 3; + if (w < avctx->width - 1) { READ_PIXELS(u, y, v); @@ -120,13 +158,29 @@ return 0; } +#define V210DEC_FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM +static const AVOption v210dec_options[] = { + {"custom_stride", "Custom V210 stride", offsetof(V210DecContext, custom_stride), FF_OPT_TYPE_INT, + {.dbl = 0}, INT_MIN, INT_MAX, V210DEC_FLAGS}, + {NULL} +}; + +static const AVClass v210dec_class = { + "V210 Decoder", + av_default_item_name, + v210dec_options, + LIBAVUTIL_VERSION_INT, +}; + AVCodec ff_v210_decoder = { .name = "v210", .type = AVMEDIA_TYPE_VIDEO, .id = CODEC_ID_V210, + .priv_data_size = sizeof(V210DecContext), .init = decode_init, .close = decode_close, .decode = decode_frame, .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:2:2 10-bit"), + .priv_class = &v210dec_class, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/v210dec.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/v210dec.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/v210dec.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/v210dec.h 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,34 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_V210DEC_H +#define AVCODEC_V210DEC_H + +#include "libavutil/log.h" +#include "libavutil/opt.h" + +typedef struct { + AVClass *av_class; + int custom_stride; + int aligned_input; + void (*unpack_frame)(const uint32_t *src, uint16_t *y, uint16_t *u, uint16_t *v, int width); +} V210DecContext; + +void v210_x86_init(V210DecContext *s); + +#endif /* AVCODEC_V210DEC_H */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vc1.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vc1.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vc1.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vc1.c 2011-11-04 12:38:27.000000000 +0000 @@ -1,5 +1,6 @@ /* * VC-1 and WMV3 decoder common code + * Copyright (c) 2011 Mashiat Sarker Shakkhar * Copyright (c) 2006-2007 Konstantin Shishkov * Partly based on vc9.c (c) 2005 Anonymous, Alex Beregszaszi, Michael Niedermayer * @@ -25,6 +26,7 @@ * VC-1 and WMV3 decoder common code * */ + #include "internal.h" #include "dsputil.h" #include "avcodec.h" @@ -66,14 +68,16 @@ * @param[in] height Height of this buffer * @param[in] stride of this buffer */ -static void decode_rowskip(uint8_t* plane, int width, int height, int stride, GetBitContext *gb){ +static void decode_rowskip(uint8_t* plane, int width, int height, int stride, + GetBitContext *gb) +{ int x, y; - for (y=0; ys.mb_width; - height = v->s.mb_height; + width = v->s.mb_width; + height = v->s.mb_height >> v->field_mode; stride = v->s.mb_stride; invert = get_bits1(gb); imode = get_vlc2(gb, ff_vc1_imode_vlc.table, VC1_IMODE_VLC_BITS, 1); *raw_flag = 0; - switch (imode) - { + switch (imode) { case IMODE_RAW: //Data is actually read in the MB layer (same for all tests == "raw") *raw_flag = 1; //invert ignored return invert; case IMODE_DIFF2: case IMODE_NORM2: - if ((height * width) & 1) - { + if ((height * width) & 1) { *planep++ = get_bits1(gb); - offset = 1; + offset = 1; } - else offset = 0; + else + offset = 0; // decode bitplane as one long line for (y = offset; y < height * width; y += 2) { code = get_vlc2(gb, ff_vc1_norm2_vlc.table, VC1_NORM2_VLC_BITS, 1); *planep++ = code & 1; offset++; - if(offset == width) { - offset = 0; + if (offset == width) { + offset = 0; planep += stride - width; } *planep++ = code >> 1; offset++; - if(offset == width) { - offset = 0; + if (offset == width) { + offset = 0; planep += stride - width; } } break; case IMODE_DIFF6: case IMODE_NORM6: - if(!(height % 3) && (width % 3)) { // use 2x3 decoding - for(y = 0; y < height; y+= 3) { - for(x = width & 1; x < width; x += 2) { + if (!(height % 3) && (width % 3)) { // use 2x3 decoding + for (y = 0; y < height; y += 3) { + for (x = width & 1; x < width; x += 2) { code = get_vlc2(gb, ff_vc1_norm6_vlc.table, VC1_NORM6_VLC_BITS, 2); - if(code < 0){ + if (code < 0) { av_log(v->s.avctx, AV_LOG_DEBUG, "invalid NORM-6 VLC\n"); return -1; } - planep[x + 0] = (code >> 0) & 1; - planep[x + 1] = (code >> 1) & 1; - planep[x + 0 + stride] = (code >> 2) & 1; - planep[x + 1 + stride] = (code >> 3) & 1; + planep[x + 0] = (code >> 0) & 1; + planep[x + 1] = (code >> 1) & 1; + planep[x + 0 + stride] = (code >> 2) & 1; + planep[x + 1 + stride] = (code >> 3) & 1; planep[x + 0 + stride * 2] = (code >> 4) & 1; planep[x + 1 + stride * 2] = (code >> 5) & 1; } planep += stride * 3; } - if(width & 1) decode_colskip(data, 1, height, stride, &v->s.gb); + if (width & 1) + decode_colskip(data, 1, height, stride, &v->s.gb); } else { // 3x2 planep += (height & 1) * stride; - for(y = height & 1; y < height; y += 2) { - for(x = width % 3; x < width; x += 3) { + for (y = height & 1; y < height; y += 2) { + for (x = width % 3; x < width; x += 3) { code = get_vlc2(gb, ff_vc1_norm6_vlc.table, VC1_NORM6_VLC_BITS, 2); - if(code < 0){ + if (code < 0) { av_log(v->s.avctx, AV_LOG_DEBUG, "invalid NORM-6 VLC\n"); return -1; } - planep[x + 0] = (code >> 0) & 1; - planep[x + 1] = (code >> 1) & 1; - planep[x + 2] = (code >> 2) & 1; + planep[x + 0] = (code >> 0) & 1; + planep[x + 1] = (code >> 1) & 1; + planep[x + 2] = (code >> 2) & 1; planep[x + 0 + stride] = (code >> 3) & 1; planep[x + 1 + stride] = (code >> 4) & 1; planep[x + 2 + stride] = (code >> 5) & 1; @@ -192,8 +198,10 @@ planep += stride * 2; } x = width % 3; - if(x) decode_colskip(data , x, height , stride, &v->s.gb); - if(height & 1) decode_rowskip(data+x, width - x, 1, stride, &v->s.gb); + if (x) + decode_colskip(data, x, height, stride, &v->s.gb); + if (height & 1) + decode_rowskip(data + x, width - x, 1, stride, &v->s.gb); } break; case IMODE_ROWSKIP: @@ -202,33 +210,30 @@ case IMODE_COLSKIP: decode_colskip(data, width, height, stride, &v->s.gb); break; - default: break; + default: + break; } /* Applying diff operator */ - if (imode == IMODE_DIFF2 || imode == IMODE_DIFF6) - { + if (imode == IMODE_DIFF2 || imode == IMODE_DIFF6) { planep = data; planep[0] ^= invert; - for (x=1; xdquant == 2) - { + if (v->dquant == 2) { pqdiff = get_bits(gb, 3); - if (pqdiff == 7) v->altpq = get_bits(gb, 5); - else v->altpq = v->pq + pqdiff + 1; - } - else - { + if (pqdiff == 7) + v->altpq = get_bits(gb, 5); + else + v->altpq = v->pq + pqdiff + 1; + } else { v->dquantfrm = get_bits1(gb); - if ( v->dquantfrm ) - { + if (v->dquantfrm) { v->dqprofile = get_bits(gb, 2); - switch (v->dqprofile) - { + switch (v->dqprofile) { case DQPROFILE_SINGLE_EDGE: case DQPROFILE_DOUBLE_EDGES: v->dqsbedge = get_bits(gb, 2); break; case DQPROFILE_ALL_MBS: v->dqbilevel = get_bits1(gb); - if(!v->dqbilevel) + if (!v->dqbilevel) v->halfpq = 0; - default: break; //Forbidden ? + default: + break; //Forbidden ? } - if (v->dqbilevel || v->dqprofile != DQPROFILE_ALL_MBS) - { + if (v->dqbilevel || v->dqprofile != DQPROFILE_ALL_MBS) { pqdiff = get_bits(gb, 3); - if (pqdiff == 7) v->altpq = get_bits(gb, 5); - else v->altpq = v->pq + pqdiff + 1; + if (pqdiff == 7) + v->altpq = get_bits(gb, 5); + else + v->altpq = v->pq + pqdiff + 1; } } } @@ -291,25 +295,20 @@ { av_log(avctx, AV_LOG_DEBUG, "Header: %0X\n", show_bits(gb, 32)); v->profile = get_bits(gb, 2); - if (v->profile == PROFILE_COMPLEX) - { + if (v->profile == PROFILE_COMPLEX) { av_log(avctx, AV_LOG_WARNING, "WMV3 Complex Profile is not fully supported\n"); } - if (v->profile == PROFILE_ADVANCED) - { + if (v->profile == PROFILE_ADVANCED) { v->zz_8x4 = ff_vc1_adv_progressive_8x4_zz; v->zz_4x8 = ff_vc1_adv_progressive_4x8_zz; return decode_sequence_header_adv(v, gb); - } - else - { + } else { v->zz_8x4 = wmv2_scantableA; v->zz_4x8 = wmv2_scantableB; v->res_y411 = get_bits1(gb); v->res_sprite = get_bits1(gb); - if (v->res_y411) - { + if (v->res_y411) { av_log(avctx, AV_LOG_ERROR, "Old interlaced mode is not supported\n"); return -1; @@ -320,48 +319,45 @@ v->frmrtq_postproc = get_bits(gb, 3); //common // (bitrate-32kbps)/64kbps v->bitrtq_postproc = get_bits(gb, 5); //common - v->s.loop_filter = get_bits1(gb); //common - if(v->s.loop_filter == 1 && v->profile == PROFILE_SIMPLE) - { + v->s.loop_filter = get_bits1(gb); //common + if (v->s.loop_filter == 1 && v->profile == PROFILE_SIMPLE) { av_log(avctx, AV_LOG_ERROR, "LOOPFILTER shall not be enabled in Simple Profile\n"); } - if(v->s.avctx->skip_loop_filter >= AVDISCARD_ALL) + if (v->s.avctx->skip_loop_filter >= AVDISCARD_ALL) v->s.loop_filter = 0; - v->res_x8 = get_bits1(gb); //reserved - v->multires = get_bits1(gb); - v->res_fasttx = get_bits1(gb); - if (!v->res_fasttx) - { - v->vc1dsp.vc1_inv_trans_8x8 = ff_simple_idct_8; - v->vc1dsp.vc1_inv_trans_8x4 = ff_simple_idct84_add; - v->vc1dsp.vc1_inv_trans_4x8 = ff_simple_idct48_add; - v->vc1dsp.vc1_inv_trans_4x4 = ff_simple_idct44_add; + v->res_x8 = get_bits1(gb); //reserved + v->multires = get_bits1(gb); + v->res_fasttx = get_bits1(gb); + if (!v->res_fasttx) { + v->vc1dsp.vc1_inv_trans_8x8 = ff_simple_idct_8; + v->vc1dsp.vc1_inv_trans_8x4 = ff_simple_idct84_add; + v->vc1dsp.vc1_inv_trans_4x8 = ff_simple_idct48_add; + v->vc1dsp.vc1_inv_trans_4x4 = ff_simple_idct44_add; v->vc1dsp.vc1_inv_trans_8x8_dc = ff_simple_idct_add_8; v->vc1dsp.vc1_inv_trans_8x4_dc = ff_simple_idct84_add; v->vc1dsp.vc1_inv_trans_4x8_dc = ff_simple_idct48_add; v->vc1dsp.vc1_inv_trans_4x4_dc = ff_simple_idct44_add; } - v->fastuvmc = get_bits1(gb); //common - if (!v->profile && !v->fastuvmc) - { + v->fastuvmc = get_bits1(gb); //common + if (!v->profile && !v->fastuvmc) { av_log(avctx, AV_LOG_ERROR, "FASTUVMC unavailable in Simple Profile\n"); return -1; } - v->extended_mv = get_bits1(gb); //common + v->extended_mv = get_bits1(gb); //common if (!v->profile && v->extended_mv) { av_log(avctx, AV_LOG_ERROR, "Extended MVs unavailable in Simple Profile\n"); return -1; } - v->dquant = get_bits(gb, 2); //common - v->vstransform = get_bits1(gb); //common + v->dquant = get_bits(gb, 2); //common + v->vstransform = get_bits1(gb); //common - v->res_transtab = get_bits1(gb); + v->res_transtab = get_bits1(gb); if (v->res_transtab) { av_log(avctx, AV_LOG_ERROR, @@ -369,12 +365,11 @@ return -1; } - v->overlap = get_bits1(gb); //common + v->overlap = get_bits1(gb); //common v->s.resync_marker = get_bits1(gb); - v->rangered = get_bits1(gb); - if (v->rangered && v->profile == PROFILE_SIMPLE) - { + v->rangered = get_bits1(gb); + if (v->rangered && v->profile == PROFILE_SIMPLE) { av_log(avctx, AV_LOG_INFO, "RANGERED should be set to 0 in Simple Profile\n"); } @@ -399,8 +394,7 @@ } else { v->res_rtm_flag = get_bits1(gb); //reserved } - if (!v->res_rtm_flag) - { + if (!v->res_rtm_flag) { // av_log(avctx, AV_LOG_ERROR, // "0 for reserved RES_RTM_FLAG is forbidden\n"); av_log(avctx, AV_LOG_ERROR, @@ -408,17 +402,17 @@ //return -1; } //TODO: figure out what they mean (always 0x402F) - if(!v->res_fasttx) skip_bits(gb, 16); + if (!v->res_fasttx) + skip_bits(gb, 16); av_log(avctx, AV_LOG_DEBUG, - "Profile %i:\nfrmrtq_postproc=%i, bitrtq_postproc=%i\n" - "LoopFilter=%i, MultiRes=%i, FastUVMC=%i, Extended MV=%i\n" - "Rangered=%i, VSTransform=%i, Overlap=%i, SyncMarker=%i\n" - "DQuant=%i, Quantizer mode=%i, Max B frames=%i\n", - v->profile, v->frmrtq_postproc, v->bitrtq_postproc, - v->s.loop_filter, v->multires, v->fastuvmc, v->extended_mv, - v->rangered, v->vstransform, v->overlap, v->s.resync_marker, - v->dquant, v->quantizer_mode, avctx->max_b_frames - ); + "Profile %i:\nfrmrtq_postproc=%i, bitrtq_postproc=%i\n" + "LoopFilter=%i, MultiRes=%i, FastUVMC=%i, Extended MV=%i\n" + "Rangered=%i, VSTransform=%i, Overlap=%i, SyncMarker=%i\n" + "DQuant=%i, Quantizer mode=%i, Max B frames=%i\n", + v->profile, v->frmrtq_postproc, v->bitrtq_postproc, + v->s.loop_filter, v->multires, v->fastuvmc, v->extended_mv, + v->rangered, v->vstransform, v->overlap, v->s.resync_marker, + v->dquant, v->quantizer_mode, avctx->max_b_frames); return 0; } @@ -427,59 +421,56 @@ int w, h; v->res_rtm_flag = 1; v->level = get_bits(gb, 3); - if(v->level >= 5) - { + if (v->level >= 5) { av_log(v->s.avctx, AV_LOG_ERROR, "Reserved LEVEL %i\n",v->level); } v->chromaformat = get_bits(gb, 2); - if (v->chromaformat != 1) - { + if (v->chromaformat != 1) { av_log(v->s.avctx, AV_LOG_ERROR, "Only 4:2:0 chroma format supported\n"); return -1; } // (fps-2)/4 (->30) - v->frmrtq_postproc = get_bits(gb, 3); //common + v->frmrtq_postproc = get_bits(gb, 3); //common // (bitrate-32kbps)/64kbps - v->bitrtq_postproc = get_bits(gb, 5); //common - v->postprocflag = get_bits1(gb); //common + v->bitrtq_postproc = get_bits(gb, 5); //common + v->postprocflag = get_bits1(gb); //common w = (get_bits(gb, 12) + 1) << 1; h = (get_bits(gb, 12) + 1) << 1; avcodec_set_dimensions(v->s.avctx, w, h); - v->broadcast = get_bits1(gb); - v->interlace = get_bits1(gb); - v->tfcntrflag = get_bits1(gb); - v->finterpflag = get_bits1(gb); + v->broadcast = get_bits1(gb); + v->interlace = get_bits1(gb); + v->tfcntrflag = get_bits1(gb); + v->finterpflag = get_bits1(gb); skip_bits1(gb); // reserved av_log(v->s.avctx, AV_LOG_DEBUG, - "Advanced Profile level %i:\nfrmrtq_postproc=%i, bitrtq_postproc=%i\n" - "LoopFilter=%i, ChromaFormat=%i, Pulldown=%i, Interlace: %i\n" - "TFCTRflag=%i, FINTERPflag=%i\n", - v->level, v->frmrtq_postproc, v->bitrtq_postproc, - v->s.loop_filter, v->chromaformat, v->broadcast, v->interlace, - v->tfcntrflag, v->finterpflag - ); + "Advanced Profile level %i:\nfrmrtq_postproc=%i, bitrtq_postproc=%i\n" + "LoopFilter=%i, ChromaFormat=%i, Pulldown=%i, Interlace: %i\n" + "TFCTRflag=%i, FINTERPflag=%i\n", + v->level, v->frmrtq_postproc, v->bitrtq_postproc, + v->s.loop_filter, v->chromaformat, v->broadcast, v->interlace, + v->tfcntrflag, v->finterpflag); v->psf = get_bits1(gb); - if(v->psf) { //PsF, 6.1.13 + if (v->psf) { //PsF, 6.1.13 av_log(v->s.avctx, AV_LOG_ERROR, "Progressive Segmented Frame mode: not supported (yet)\n"); return -1; } v->s.max_b_frames = v->s.avctx->max_b_frames = 7; - if(get_bits1(gb)) { //Display Info - decoding is not affected by it + if (get_bits1(gb)) { //Display Info - decoding is not affected by it int w, h, ar = 0; av_log(v->s.avctx, AV_LOG_DEBUG, "Display extended info:\n"); w = get_bits(gb, 14) + 1; h = get_bits(gb, 14) + 1; av_log(v->s.avctx, AV_LOG_DEBUG, "Display dimensions: %ix%i\n", w, h); - if(get_bits1(gb)) + if (get_bits1(gb)) ar = get_bits(gb, 4); - if(ar && ar < 14){ + if (ar && ar < 14) { v->s.avctx->sample_aspect_ratio = ff_vc1_pixel_aspect[ar]; - }else if(ar == 15){ + } else if (ar == 15) { w = get_bits(gb, 8) + 1; h = get_bits(gb, 8) + 1; v->s.avctx->sample_aspect_ratio = (AVRational){w, h}; @@ -488,43 +479,45 @@ &v->s.avctx->sample_aspect_ratio.den, v->s.avctx->height * w, v->s.avctx->width * h, - 1<<30); + 1 << 30); } - av_log(v->s.avctx, AV_LOG_DEBUG, "Aspect: %i:%i\n", v->s.avctx->sample_aspect_ratio.num, v->s.avctx->sample_aspect_ratio.den); + av_log(v->s.avctx, AV_LOG_DEBUG, "Aspect: %i:%i\n", + v->s.avctx->sample_aspect_ratio.num, + v->s.avctx->sample_aspect_ratio.den); - if(get_bits1(gb)){ //framerate stuff - if(get_bits1(gb)) { + if (get_bits1(gb)) { //framerate stuff + if (get_bits1(gb)) { v->s.avctx->time_base.num = 32; v->s.avctx->time_base.den = get_bits(gb, 16) + 1; } else { int nr, dr; nr = get_bits(gb, 8); dr = get_bits(gb, 4); - if(nr && nr < 8 && dr && dr < 3){ + if (nr && nr < 8 && dr && dr < 3) { v->s.avctx->time_base.num = ff_vc1_fps_dr[dr - 1]; v->s.avctx->time_base.den = ff_vc1_fps_nr[nr - 1] * 1000; } } - if(v->broadcast) { // Pulldown may be present - v->s.avctx->time_base.den *= 2; + if (v->broadcast) { // Pulldown may be present + v->s.avctx->time_base.den *= 2; v->s.avctx->ticks_per_frame = 2; } } - if(get_bits1(gb)){ - v->color_prim = get_bits(gb, 8); + if (get_bits1(gb)) { + v->color_prim = get_bits(gb, 8); v->transfer_char = get_bits(gb, 8); - v->matrix_coef = get_bits(gb, 8); + v->matrix_coef = get_bits(gb, 8); } } v->hrd_param_flag = get_bits1(gb); - if(v->hrd_param_flag) { + if (v->hrd_param_flag) { int i; v->hrd_num_leaky_buckets = get_bits(gb, 5); skip_bits(gb, 4); //bitrate exponent skip_bits(gb, 4); //buffer size exponent - for(i = 0; i < v->hrd_num_leaky_buckets; i++) { + for (i = 0; i < v->hrd_num_leaky_buckets; i++) { skip_bits(gb, 16); //hrd_rate[n] skip_bits(gb, 16); //hrd_buffer[n] } @@ -537,20 +530,20 @@ int i; av_log(avctx, AV_LOG_DEBUG, "Entry point: %08X\n", show_bits_long(gb, 32)); - v->broken_link = get_bits1(gb); - v->closed_entry = get_bits1(gb); - v->panscanflag = get_bits1(gb); - v->refdist_flag = get_bits1(gb); - v->s.loop_filter = get_bits1(gb); - v->fastuvmc = get_bits1(gb); - v->extended_mv = get_bits1(gb); - v->dquant = get_bits(gb, 2); - v->vstransform = get_bits1(gb); - v->overlap = get_bits1(gb); + v->broken_link = get_bits1(gb); + v->closed_entry = get_bits1(gb); + v->panscanflag = get_bits1(gb); + v->refdist_flag = get_bits1(gb); + v->s.loop_filter = get_bits1(gb); + v->fastuvmc = get_bits1(gb); + v->extended_mv = get_bits1(gb); + v->dquant = get_bits(gb, 2); + v->vstransform = get_bits1(gb); + v->overlap = get_bits1(gb); v->quantizer_mode = get_bits(gb, 2); - if(v->hrd_param_flag){ - for(i = 0; i < v->hrd_num_leaky_buckets; i++) { + if (v->hrd_param_flag) { + for (i = 0; i < v->hrd_num_leaky_buckets; i++) { skip_bits(gb, 8); //hrd_full[n] } } @@ -560,23 +553,23 @@ int h = (get_bits(gb, 12)+1)<<1; avcodec_set_dimensions(avctx, w, h); } - if(v->extended_mv) + if (v->extended_mv) v->extended_dmv = get_bits1(gb); - if((v->range_mapy_flag = get_bits1(gb))) { + if ((v->range_mapy_flag = get_bits1(gb))) { av_log(avctx, AV_LOG_ERROR, "Luma scaling is not supported, expect wrong picture\n"); v->range_mapy = get_bits(gb, 3); } - if((v->range_mapuv_flag = get_bits1(gb))) { + if ((v->range_mapuv_flag = get_bits1(gb))) { av_log(avctx, AV_LOG_ERROR, "Chroma scaling is not supported, expect wrong picture\n"); v->range_mapuv = get_bits(gb, 3); } av_log(avctx, AV_LOG_DEBUG, "Entry point info:\n" - "BrokenLink=%i, ClosedEntry=%i, PanscanFlag=%i\n" - "RefDist=%i, Postproc=%i, FastUVMC=%i, ExtMV=%i\n" - "DQuant=%i, VSTransform=%i, Overlap=%i, Qmode=%i\n", - v->broken_link, v->closed_entry, v->panscanflag, v->refdist_flag, v->s.loop_filter, - v->fastuvmc, v->extended_mv, v->dquant, v->vstransform, v->overlap, v->quantizer_mode); + "BrokenLink=%i, ClosedEntry=%i, PanscanFlag=%i\n" + "RefDist=%i, Postproc=%i, FastUVMC=%i, ExtMV=%i\n" + "DQuant=%i, VSTransform=%i, Overlap=%i, Qmode=%i\n", + v->broken_link, v->closed_entry, v->panscanflag, v->refdist_flag, v->s.loop_filter, + v->fastuvmc, v->extended_mv, v->dquant, v->vstransform, v->overlap, v->quantizer_mode); return 0; } @@ -585,41 +578,48 @@ { int pqindex, lowquant, status; - if(v->finterpflag) v->interpfrm = get_bits1(gb); + if (v->finterpflag) + v->interpfrm = get_bits1(gb); skip_bits(gb, 2); //framecnt unused v->rangeredfrm = 0; - if (v->rangered) v->rangeredfrm = get_bits1(gb); + if (v->rangered) + v->rangeredfrm = get_bits1(gb); v->s.pict_type = get_bits1(gb); if (v->s.avctx->max_b_frames) { if (!v->s.pict_type) { - if (get_bits1(gb)) v->s.pict_type = AV_PICTURE_TYPE_I; - else v->s.pict_type = AV_PICTURE_TYPE_B; - } else v->s.pict_type = AV_PICTURE_TYPE_P; - } else v->s.pict_type = v->s.pict_type ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I; + if (get_bits1(gb)) + v->s.pict_type = AV_PICTURE_TYPE_I; + else + v->s.pict_type = AV_PICTURE_TYPE_B; + } else + v->s.pict_type = AV_PICTURE_TYPE_P; + } else + v->s.pict_type = v->s.pict_type ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I; v->bi_type = 0; - if(v->s.pict_type == AV_PICTURE_TYPE_B) { + if (v->s.pict_type == AV_PICTURE_TYPE_B) { v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1); - v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index]; - if(v->bfraction == 0) { + v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index]; + if (v->bfraction == 0) { v->s.pict_type = AV_PICTURE_TYPE_BI; } } - if(v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI) + if (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI) skip_bits(gb, 7); // skip buffer fullness - if(v->parse_only) + if (v->parse_only) return 0; /* calculate RND */ - if(v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI) + if (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI) v->rnd = 1; - if(v->s.pict_type == AV_PICTURE_TYPE_P) + if (v->s.pict_type == AV_PICTURE_TYPE_P) v->rnd ^= 1; /* Quantizer stuff */ pqindex = get_bits(gb, 5); - if(!pqindex) return -1; + if (!pqindex) + return -1; if (v->quantizer_mode == QUANT_FRAME_IMPLICIT) v->pq = ff_vc1_pquant_table[0][pqindex]; else @@ -631,63 +631,69 @@ if (v->quantizer_mode == QUANT_NON_UNIFORM) v->pquantizer = 0; v->pqindex = pqindex; - if (pqindex < 9) v->halfpq = get_bits1(gb); - else v->halfpq = 0; + if (pqindex < 9) + v->halfpq = get_bits1(gb); + else + v->halfpq = 0; if (v->quantizer_mode == QUANT_FRAME_EXPLICIT) v->pquantizer = get_bits1(gb); v->dquantfrm = 0; - if (v->extended_mv == 1) v->mvrange = get_unary(gb, 0, 3); + if (v->extended_mv == 1) + v->mvrange = get_unary(gb, 0, 3); v->k_x = v->mvrange + 9 + (v->mvrange >> 1); //k_x can be 9 10 12 13 v->k_y = v->mvrange + 8; //k_y can be 8 9 10 11 v->range_x = 1 << (v->k_x - 1); v->range_y = 1 << (v->k_y - 1); - if (v->multires && v->s.pict_type != AV_PICTURE_TYPE_B) v->respic = get_bits(gb, 2); + if (v->multires && v->s.pict_type != AV_PICTURE_TYPE_B) + v->respic = get_bits(gb, 2); - if(v->res_x8 && (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI)){ + if (v->res_x8 && (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI)) { v->x8_type = get_bits1(gb); - }else v->x8_type = 0; + } else + v->x8_type = 0; //av_log(v->s.avctx, AV_LOG_INFO, "%c Frame: QP=[%i]%i (+%i/2) %i\n", // (v->s.pict_type == AV_PICTURE_TYPE_P) ? 'P' : ((v->s.pict_type == AV_PICTURE_TYPE_I) ? 'I' : 'B'), pqindex, v->pq, v->halfpq, v->rangeredfrm); - if(v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_P) v->use_ic = 0; + if (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_P) + v->use_ic = 0; - switch(v->s.pict_type) { + switch (v->s.pict_type) { case AV_PICTURE_TYPE_P: - if (v->pq < 5) v->tt_index = 0; - else if(v->pq < 13) v->tt_index = 1; - else v->tt_index = 2; + if (v->pq < 5) v->tt_index = 0; + else if (v->pq < 13) v->tt_index = 1; + else v->tt_index = 2; lowquant = (v->pq > 12) ? 0 : 1; v->mv_mode = ff_vc1_mv_pmode_table[lowquant][get_unary(gb, 1, 4)]; - if (v->mv_mode == MV_PMODE_INTENSITY_COMP) - { + if (v->mv_mode == MV_PMODE_INTENSITY_COMP) { int scale, shift, i; v->mv_mode2 = ff_vc1_mv_pmode_table2[lowquant][get_unary(gb, 1, 3)]; v->lumscale = get_bits(gb, 6); v->lumshift = get_bits(gb, 6); - v->use_ic = 1; + v->use_ic = 1; /* fill lookup tables for intensity compensation */ - if(!v->lumscale) { + if (!v->lumscale) { scale = -64; shift = (255 - v->lumshift * 2) << 6; - if(v->lumshift > 31) + if (v->lumshift > 31) shift += 128 << 6; } else { scale = v->lumscale + 32; - if(v->lumshift > 31) + if (v->lumshift > 31) shift = (v->lumshift - 64) << 6; else shift = v->lumshift << 6; } - for(i = 0; i < 256; i++) { - v->luty[i] = av_clip_uint8((scale * i + shift + 32) >> 6); + for (i = 0; i < 256; i++) { + v->luty[i] = av_clip_uint8((scale * i + shift + 32) >> 6); v->lutuv[i] = av_clip_uint8((scale * (i - 128) + 128*64 + 32) >> 6); } } - if(v->mv_mode == MV_PMODE_1MV_HPEL || v->mv_mode == MV_PMODE_1MV_HPEL_BILIN) + v->qs_last = v->s.quarter_sample; + if (v->mv_mode == MV_PMODE_1MV_HPEL || v->mv_mode == MV_PMODE_1MV_HPEL_BILIN) v->s.quarter_sample = 0; - else if(v->mv_mode == MV_PMODE_INTENSITY_COMP) { - if(v->mv_mode2 == MV_PMODE_1MV_HPEL || v->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN) + else if (v->mv_mode == MV_PMODE_INTENSITY_COMP) { + if (v->mv_mode2 == MV_PMODE_1MV_HPEL || v->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN) v->s.quarter_sample = 0; else v->s.quarter_sample = 1; @@ -695,12 +701,12 @@ v->s.quarter_sample = 1; v->s.mspel = !(v->mv_mode == MV_PMODE_1MV_HPEL_BILIN || (v->mv_mode == MV_PMODE_INTENSITY_COMP && v->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN)); - if ((v->mv_mode == MV_PMODE_INTENSITY_COMP && - v->mv_mode2 == MV_PMODE_MIXED_MV) - || v->mv_mode == MV_PMODE_MIXED_MV) - { + if ((v->mv_mode == MV_PMODE_INTENSITY_COMP && + v->mv_mode2 == MV_PMODE_MIXED_MV) || + v->mv_mode == MV_PMODE_MIXED_MV) { status = bitplane_decoding(v->mv_type_mb_plane, &v->mv_type_is_raw, v); - if (status < 0) return -1; + if (status < 0) + return -1; av_log(v->s.avctx, AV_LOG_DEBUG, "MB MV Type plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); } else { @@ -708,7 +714,8 @@ memset(v->mv_type_mb_plane, 0, v->s.mb_stride * v->s.mb_height); } status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v); - if (status < 0) return -1; + if (status < 0) + return -1; av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); @@ -716,18 +723,15 @@ v->s.mv_table_index = get_bits(gb, 2); //but using ff_vc1_ tables v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(gb, 2)]; - if (v->dquant) - { + if (v->dquant) { av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n"); vop_dquant_decoding(v); } v->ttfrm = 0; //FIXME Is that so ? - if (v->vstransform) - { + if (v->vstransform) { v->ttmbf = get_bits1(gb); - if (v->ttmbf) - { + if (v->ttmbf) { v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)]; } } else { @@ -736,38 +740,38 @@ } break; case AV_PICTURE_TYPE_B: - if (v->pq < 5) v->tt_index = 0; - else if(v->pq < 13) v->tt_index = 1; - else v->tt_index = 2; + if (v->pq < 5) v->tt_index = 0; + else if (v->pq < 13) v->tt_index = 1; + else v->tt_index = 2; - v->mv_mode = get_bits1(gb) ? MV_PMODE_1MV : MV_PMODE_1MV_HPEL_BILIN; + v->mv_mode = get_bits1(gb) ? MV_PMODE_1MV : MV_PMODE_1MV_HPEL_BILIN; + v->qs_last = v->s.quarter_sample; v->s.quarter_sample = (v->mv_mode == MV_PMODE_1MV); - v->s.mspel = v->s.quarter_sample; + v->s.mspel = v->s.quarter_sample; status = bitplane_decoding(v->direct_mb_plane, &v->dmb_is_raw, v); - if (status < 0) return -1; + if (status < 0) + return -1; av_log(v->s.avctx, AV_LOG_DEBUG, "MB Direct Type plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v); - if (status < 0) return -1; + if (status < 0) + return -1; av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); v->s.mv_table_index = get_bits(gb, 2); - v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(gb, 2)]; + v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(gb, 2)]; - if (v->dquant) - { + if (v->dquant) { av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n"); vop_dquant_decoding(v); } v->ttfrm = 0; - if (v->vstransform) - { + if (v->vstransform) { v->ttmbf = get_bits1(gb); - if (v->ttmbf) - { + if (v->ttmbf) { v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)]; } } else { @@ -777,88 +781,157 @@ break; } - if(!v->x8_type) - { + if (!v->x8_type) { /* AC Syntax */ v->c_ac_table_index = decode012(gb); - if (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI) - { + if (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI) { v->y_ac_table_index = decode012(gb); } /* DC Syntax */ v->s.dc_table_index = get_bits1(gb); } - if(v->s.pict_type == AV_PICTURE_TYPE_BI) { + if (v->s.pict_type == AV_PICTURE_TYPE_BI) { v->s.pict_type = AV_PICTURE_TYPE_B; - v->bi_type = 1; + v->bi_type = 1; } return 0; } +/* fill lookup tables for intensity compensation */ +#define INIT_LUT(lumscale, lumshift, luty, lutuv) \ + if (!lumscale) { \ + scale = -64; \ + shift = (255 - lumshift * 2) << 6; \ + if (lumshift > 31) \ + shift += 128 << 6; \ + } else { \ + scale = lumscale + 32; \ + if (lumshift > 31) \ + shift = (lumshift - 64) << 6; \ + else \ + shift = lumshift << 6; \ + } \ + for (i = 0; i < 256; i++) { \ + luty[i] = av_clip_uint8((scale * i + shift + 32) >> 6); \ + lutuv[i] = av_clip_uint8((scale * (i - 128) + 128*64 + 32) >> 6); \ + } + int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) { int pqindex, lowquant; int status; + int mbmodetab, imvtab, icbptab, twomvbptab, fourmvbptab; /* useful only for debugging */ + int scale, shift, i; /* for initializing LUT for intensity compensation */ + v->numref=0; + v->fcm=0; + v->field_mode=0; v->p_frame_skipped = 0; + if (v->second_field) { + v->s.pict_type = (v->fptype & 1) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I; + if (v->fptype & 4) + v->s.pict_type = (v->fptype & 1) ? AV_PICTURE_TYPE_BI : AV_PICTURE_TYPE_B; + v->s.current_picture_ptr->f.pict_type = v->s.pict_type; + if (!v->pic_header_flag) + goto parse_common_info; + } - if(v->interlace){ + v->field_mode = 0; + if (v->interlace) { v->fcm = decode012(gb); - if(v->fcm){ - if(!v->warn_interlaced++) - av_log(v->s.avctx, AV_LOG_ERROR, "Interlaced frames/fields support is not implemented\n"); - return -1; + if (v->fcm) { + if (v->fcm == 2) + v->field_mode = 1; + if (!v->warn_interlaced++) + av_log(v->s.avctx, AV_LOG_ERROR, + "Interlaced frames/fields support is incomplete\n"); } + } else { + v->fcm = 0; } - switch(get_unary(gb, 0, 4)) { - case 0: - v->s.pict_type = AV_PICTURE_TYPE_P; - break; - case 1: - v->s.pict_type = AV_PICTURE_TYPE_B; - break; - case 2: - v->s.pict_type = AV_PICTURE_TYPE_I; - break; - case 3: - v->s.pict_type = AV_PICTURE_TYPE_BI; - break; - case 4: - v->s.pict_type = AV_PICTURE_TYPE_P; // skipped pic - v->p_frame_skipped = 1; - break; + + if (v->field_mode) { + v->fptype = get_bits(gb, 3); + v->s.pict_type = (v->fptype & 2) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I; + if (v->fptype & 4) // B-picture + v->s.pict_type = (v->fptype & 2) ? AV_PICTURE_TYPE_BI : AV_PICTURE_TYPE_B; + } else { + switch (get_unary(gb, 0, 4)) { + case 0: + v->s.pict_type = AV_PICTURE_TYPE_P; + break; + case 1: + v->s.pict_type = AV_PICTURE_TYPE_B; + break; + case 2: + v->s.pict_type = AV_PICTURE_TYPE_I; + break; + case 3: + v->s.pict_type = AV_PICTURE_TYPE_BI; + break; + case 4: + v->s.pict_type = AV_PICTURE_TYPE_P; // skipped pic + v->p_frame_skipped = 1; + break; + } } - if(v->tfcntrflag) + if (v->tfcntrflag) skip_bits(gb, 8); - if(v->broadcast) { - if(!v->interlace || v->psf) { + if (v->broadcast) { + if (!v->interlace || v->psf) { v->rptfrm = get_bits(gb, 2); } else { v->tff = get_bits1(gb); v->rff = get_bits1(gb); } } - if(v->panscanflag) { + if (v->panscanflag) { av_log_missing_feature(v->s.avctx, "Pan-scan", 0); //... } - if(v->p_frame_skipped) { + if (v->p_frame_skipped) { return 0; } v->rnd = get_bits1(gb); - if(v->interlace) + if (v->interlace) v->uvsamp = get_bits1(gb); - if(v->finterpflag) v->interpfrm = get_bits1(gb); - if(v->s.pict_type == AV_PICTURE_TYPE_B) { + if (v->field_mode) { + if (!v->refdist_flag) + v->refdist = 0; + else { + if ((v->s.pict_type != AV_PICTURE_TYPE_B) + && (v->s.pict_type != AV_PICTURE_TYPE_BI)) { + v->refdist = get_bits(gb, 2); + if (v->refdist == 3) + v->refdist += get_unary(gb, 0, 16); + } else { + v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1); + v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index]; + v->frfd = (v->bfraction * v->refdist) >> 8; + v->brfd = v->refdist - v->frfd - 1; + if (v->brfd < 0) + v->brfd = 0; + } + } + goto parse_common_info; + } + if (v->finterpflag) + v->interpfrm = get_bits1(gb); + if (v->s.pict_type == AV_PICTURE_TYPE_B) { v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1); - v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index]; - if(v->bfraction == 0) { + v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index]; + if (v->bfraction == 0) { v->s.pict_type = AV_PICTURE_TYPE_BI; /* XXX: should not happen here */ } } + + parse_common_info: + if (v->field_mode) + v->cur_field_type = !(v->tff ^ v->second_field); pqindex = get_bits(gb, 5); - if(!pqindex) return -1; + if (!pqindex) + return -1; v->pqindex = pqindex; if (v->quantizer_mode == QUANT_FRAME_IMPLICIT) v->pq = ff_vc1_pquant_table[0][pqindex]; @@ -871,118 +944,193 @@ if (v->quantizer_mode == QUANT_NON_UNIFORM) v->pquantizer = 0; v->pqindex = pqindex; - if (pqindex < 9) v->halfpq = get_bits1(gb); - else v->halfpq = 0; + if (pqindex < 9) + v->halfpq = get_bits1(gb); + else + v->halfpq = 0; if (v->quantizer_mode == QUANT_FRAME_EXPLICIT) v->pquantizer = get_bits1(gb); - if(v->postprocflag) + if (v->postprocflag) v->postproc = get_bits(gb, 2); - if(v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_P) v->use_ic = 0; + if (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_P) + v->use_ic = 0; - if(v->parse_only) + if (v->parse_only) return 0; - switch(v->s.pict_type) { + switch (v->s.pict_type) { case AV_PICTURE_TYPE_I: case AV_PICTURE_TYPE_BI: + if (v->fcm == 1) { //interlace frame picture + status = bitplane_decoding(v->fieldtx_plane, &v->fieldtx_is_raw, v); + if (status < 0) + return -1; + av_log(v->s.avctx, AV_LOG_DEBUG, "FIELDTX plane encoding: " + "Imode: %i, Invert: %i\n", status>>1, status&1); + } status = bitplane_decoding(v->acpred_plane, &v->acpred_is_raw, v); - if (status < 0) return -1; + if (status < 0) + return -1; av_log(v->s.avctx, AV_LOG_DEBUG, "ACPRED plane encoding: " - "Imode: %i, Invert: %i\n", status>>1, status&1); + "Imode: %i, Invert: %i\n", status>>1, status&1); v->condover = CONDOVER_NONE; - if(v->overlap && v->pq <= 8) { + if (v->overlap && v->pq <= 8) { v->condover = decode012(gb); - if(v->condover == CONDOVER_SELECT) { + if (v->condover == CONDOVER_SELECT) { status = bitplane_decoding(v->over_flags_plane, &v->overflg_is_raw, v); - if (status < 0) return -1; + if (status < 0) + return -1; av_log(v->s.avctx, AV_LOG_DEBUG, "CONDOVER plane encoding: " - "Imode: %i, Invert: %i\n", status>>1, status&1); + "Imode: %i, Invert: %i\n", status>>1, status&1); } } break; case AV_PICTURE_TYPE_P: - if (v->extended_mv) v->mvrange = get_unary(gb, 0, 3); - else v->mvrange = 0; + if (v->field_mode) { + v->numref = get_bits1(gb); + if (!v->numref) { + v->reffield = get_bits1(gb); + v->ref_field_type[0] = v->reffield ^ !v->cur_field_type; + } + } + if (v->extended_mv) + v->mvrange = get_unary(gb, 0, 3); + else + v->mvrange = 0; + if (v->interlace) { + if (v->extended_dmv) + v->dmvrange = get_unary(gb, 0, 3); + else + v->dmvrange = 0; + if (v->fcm == 1) { // interlaced frame picture + v->fourmvswitch = get_bits1(gb); + v->intcomp = get_bits1(gb); + if (v->intcomp) { + v->lumscale = get_bits(gb, 6); + v->lumshift = get_bits(gb, 6); + INIT_LUT(v->lumscale, v->lumshift, v->luty, v->lutuv); + } + status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v); + av_log(v->s.avctx, AV_LOG_DEBUG, "SKIPMB plane encoding: " + "Imode: %i, Invert: %i\n", status>>1, status&1); + mbmodetab = get_bits(gb, 2); + if (v->fourmvswitch) + v->mbmode_vlc = &ff_vc1_intfr_4mv_mbmode_vlc[mbmodetab]; + else + v->mbmode_vlc = &ff_vc1_intfr_non4mv_mbmode_vlc[mbmodetab]; + imvtab = get_bits(gb, 2); + v->imv_vlc = &ff_vc1_1ref_mvdata_vlc[imvtab]; + // interlaced p-picture cbpcy range is [1, 63] + icbptab = get_bits(gb, 3); + v->cbpcy_vlc = &ff_vc1_icbpcy_vlc[icbptab]; + twomvbptab = get_bits(gb, 2); + v->twomvbp_vlc = &ff_vc1_2mv_block_pattern_vlc[twomvbptab]; + if (v->fourmvswitch) { + fourmvbptab = get_bits(gb, 2); + v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[fourmvbptab]; + } + } + } v->k_x = v->mvrange + 9 + (v->mvrange >> 1); //k_x can be 9 10 12 13 v->k_y = v->mvrange + 8; //k_y can be 8 9 10 11 v->range_x = 1 << (v->k_x - 1); v->range_y = 1 << (v->k_y - 1); - if (v->pq < 5) v->tt_index = 0; - else if(v->pq < 13) v->tt_index = 1; - else v->tt_index = 2; - - lowquant = (v->pq > 12) ? 0 : 1; - v->mv_mode = ff_vc1_mv_pmode_table[lowquant][get_unary(gb, 1, 4)]; - if (v->mv_mode == MV_PMODE_INTENSITY_COMP) - { - int scale, shift, i; - v->mv_mode2 = ff_vc1_mv_pmode_table2[lowquant][get_unary(gb, 1, 3)]; - v->lumscale = get_bits(gb, 6); - v->lumshift = get_bits(gb, 6); - /* fill lookup tables for intensity compensation */ - if(!v->lumscale) { - scale = -64; - shift = (255 - v->lumshift * 2) << 6; - if(v->lumshift > 31) - shift += 128 << 6; - } else { - scale = v->lumscale + 32; - if(v->lumshift > 31) - shift = (v->lumshift - 64) << 6; - else - shift = v->lumshift << 6; - } - for(i = 0; i < 256; i++) { - v->luty[i] = av_clip_uint8((scale * i + shift + 32) >> 6); - v->lutuv[i] = av_clip_uint8((scale * (i - 128) + 128*64 + 32) >> 6); + if (v->pq < 5) + v->tt_index = 0; + else if (v->pq < 13) + v->tt_index = 1; + else + v->tt_index = 2; + if (v->fcm != 1) { + int mvmode; + mvmode = get_unary(gb, 1, 4); + lowquant = (v->pq > 12) ? 0 : 1; + v->mv_mode = ff_vc1_mv_pmode_table[lowquant][mvmode]; + if (v->mv_mode == MV_PMODE_INTENSITY_COMP) { + int mvmode2; + mvmode2 = get_unary(gb, 1, 3); + v->mv_mode2 = ff_vc1_mv_pmode_table2[lowquant][mvmode2]; + if (v->field_mode) + v->intcompfield = decode210(gb); + v->lumscale = get_bits(gb, 6); + v->lumshift = get_bits(gb, 6); + INIT_LUT(v->lumscale, v->lumshift, v->luty, v->lutuv); + if ((v->field_mode) && !v->intcompfield) { + v->lumscale2 = get_bits(gb, 6); + v->lumshift2 = get_bits(gb, 6); + INIT_LUT(v->lumscale2, v->lumshift2, v->luty2, v->lutuv2); + } + v->use_ic = 1; } - v->use_ic = 1; - } - if(v->mv_mode == MV_PMODE_1MV_HPEL || v->mv_mode == MV_PMODE_1MV_HPEL_BILIN) - v->s.quarter_sample = 0; - else if(v->mv_mode == MV_PMODE_INTENSITY_COMP) { - if(v->mv_mode2 == MV_PMODE_1MV_HPEL || v->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN) + v->qs_last = v->s.quarter_sample; + if (v->mv_mode == MV_PMODE_1MV_HPEL || v->mv_mode == MV_PMODE_1MV_HPEL_BILIN) v->s.quarter_sample = 0; - else + else if (v->mv_mode == MV_PMODE_INTENSITY_COMP) { + if (v->mv_mode2 == MV_PMODE_1MV_HPEL || v->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN) + v->s.quarter_sample = 0; + else + v->s.quarter_sample = 1; + } else v->s.quarter_sample = 1; - } else - v->s.quarter_sample = 1; - v->s.mspel = !(v->mv_mode == MV_PMODE_1MV_HPEL_BILIN || (v->mv_mode == MV_PMODE_INTENSITY_COMP && v->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN)); - - if ((v->mv_mode == MV_PMODE_INTENSITY_COMP && + v->s.mspel = !(v->mv_mode == MV_PMODE_1MV_HPEL_BILIN + || (v->mv_mode == MV_PMODE_INTENSITY_COMP + && v->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN)); + } + if (v->fcm == 0) { // progressive + if ((v->mv_mode == MV_PMODE_INTENSITY_COMP && v->mv_mode2 == MV_PMODE_MIXED_MV) - || v->mv_mode == MV_PMODE_MIXED_MV) - { - status = bitplane_decoding(v->mv_type_mb_plane, &v->mv_type_is_raw, v); - if (status < 0) return -1; - av_log(v->s.avctx, AV_LOG_DEBUG, "MB MV Type plane encoding: " + || v->mv_mode == MV_PMODE_MIXED_MV) { + status = bitplane_decoding(v->mv_type_mb_plane, &v->mv_type_is_raw, v); + if (status < 0) + return -1; + av_log(v->s.avctx, AV_LOG_DEBUG, "MB MV Type plane encoding: " + "Imode: %i, Invert: %i\n", status>>1, status&1); + } else { + v->mv_type_is_raw = 0; + memset(v->mv_type_mb_plane, 0, v->s.mb_stride * v->s.mb_height); + } + status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v); + if (status < 0) + return -1; + av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); - } else { - v->mv_type_is_raw = 0; - memset(v->mv_type_mb_plane, 0, v->s.mb_stride * v->s.mb_height); - } - status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v); - if (status < 0) return -1; - av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: " - "Imode: %i, Invert: %i\n", status>>1, status&1); - /* Hopefully this is correct for P frames */ - v->s.mv_table_index = get_bits(gb, 2); //but using ff_vc1_ tables - v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(gb, 2)]; - if (v->dquant) - { + /* Hopefully this is correct for P frames */ + v->s.mv_table_index = get_bits(gb, 2); //but using ff_vc1_ tables + v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(gb, 2)]; + } else if (v->fcm == 1) { // frame interlaced + v->qs_last = v->s.quarter_sample; + v->s.quarter_sample = 1; + v->s.mspel = 1; + } else { // field interlaced + mbmodetab = get_bits(gb, 3); + imvtab = get_bits(gb, 2 + v->numref); + if (!v->numref) + v->imv_vlc = &ff_vc1_1ref_mvdata_vlc[imvtab]; + else + v->imv_vlc = &ff_vc1_2ref_mvdata_vlc[imvtab]; + icbptab = get_bits(gb, 3); + v->cbpcy_vlc = &ff_vc1_icbpcy_vlc[icbptab]; + if ((v->mv_mode == MV_PMODE_INTENSITY_COMP && + v->mv_mode2 == MV_PMODE_MIXED_MV) || v->mv_mode == MV_PMODE_MIXED_MV) { + fourmvbptab = get_bits(gb, 2); + v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[fourmvbptab]; + v->mbmode_vlc = &ff_vc1_if_mmv_mbmode_vlc[mbmodetab]; + } else { + v->mbmode_vlc = &ff_vc1_if_1mv_mbmode_vlc[mbmodetab]; + } + } + if (v->dquant) { av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n"); vop_dquant_decoding(v); } v->ttfrm = 0; //FIXME Is that so ? - if (v->vstransform) - { + if (v->vstransform) { v->ttmbf = get_bits1(gb); - if (v->ttmbf) - { + if (v->ttmbf) { v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)]; } } else { @@ -991,45 +1139,84 @@ } break; case AV_PICTURE_TYPE_B: - if (v->extended_mv) v->mvrange = get_unary(gb, 0, 3); - else v->mvrange = 0; - v->k_x = v->mvrange + 9 + (v->mvrange >> 1); //k_x can be 9 10 12 13 - v->k_y = v->mvrange + 8; //k_y can be 8 9 10 11 + // TODO: implement interlaced frame B picture decoding + if (v->fcm == 1) + return -1; + if (v->extended_mv) + v->mvrange = get_unary(gb, 0, 3); + else + v->mvrange = 0; + v->k_x = v->mvrange + 9 + (v->mvrange >> 1); //k_x can be 9 10 12 13 + v->k_y = v->mvrange + 8; //k_y can be 8 9 10 11 v->range_x = 1 << (v->k_x - 1); v->range_y = 1 << (v->k_y - 1); - if (v->pq < 5) v->tt_index = 0; - else if(v->pq < 13) v->tt_index = 1; - else v->tt_index = 2; - - v->mv_mode = get_bits1(gb) ? MV_PMODE_1MV : MV_PMODE_1MV_HPEL_BILIN; - v->s.quarter_sample = (v->mv_mode == MV_PMODE_1MV); - v->s.mspel = v->s.quarter_sample; - - status = bitplane_decoding(v->direct_mb_plane, &v->dmb_is_raw, v); - if (status < 0) return -1; - av_log(v->s.avctx, AV_LOG_DEBUG, "MB Direct Type plane encoding: " - "Imode: %i, Invert: %i\n", status>>1, status&1); - status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v); - if (status < 0) return -1; - av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: " - "Imode: %i, Invert: %i\n", status>>1, status&1); + if (v->pq < 5) + v->tt_index = 0; + else if (v->pq < 13) + v->tt_index = 1; + else + v->tt_index = 2; - v->s.mv_table_index = get_bits(gb, 2); - v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(gb, 2)]; + if (v->field_mode) { + int mvmode; + av_log(v->s.avctx, AV_LOG_ERROR, "B Fields do not work currently\n"); + return -1; + if (v->extended_dmv) + v->dmvrange = get_unary(gb, 0, 3); + mvmode = get_unary(gb, 1, 3); + lowquant = (v->pq > 12) ? 0 : 1; + v->mv_mode = ff_vc1_mv_pmode_table2[lowquant][mvmode]; + v->qs_last = v->s.quarter_sample; + v->s.quarter_sample = (v->mv_mode == MV_PMODE_1MV || v->mv_mode == MV_PMODE_MIXED_MV); + v->s.mspel = !(v->mv_mode == MV_PMODE_1MV_HPEL_BILIN || v->mv_mode == MV_PMODE_1MV_HPEL); + status = bitplane_decoding(v->forward_mb_plane, &v->fmb_is_raw, v); + if (status < 0) + return -1; + av_log(v->s.avctx, AV_LOG_DEBUG, "MB Forward Type plane encoding: " + "Imode: %i, Invert: %i\n", status>>1, status&1); + mbmodetab = get_bits(gb, 3); + if (v->mv_mode == MV_PMODE_MIXED_MV) + v->mbmode_vlc = &ff_vc1_if_mmv_mbmode_vlc[mbmodetab]; + else + v->mbmode_vlc = &ff_vc1_if_1mv_mbmode_vlc[mbmodetab]; + imvtab = get_bits(gb, 3); + v->imv_vlc = &ff_vc1_2ref_mvdata_vlc[imvtab]; + icbptab = get_bits(gb, 3); + v->cbpcy_vlc = &ff_vc1_icbpcy_vlc[icbptab]; + if (v->mv_mode == MV_PMODE_MIXED_MV) { + fourmvbptab = get_bits(gb, 2); + v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[fourmvbptab]; + } + v->numref = 1; // interlaced field B pictures are always 2-ref + } else { + v->mv_mode = get_bits1(gb) ? MV_PMODE_1MV : MV_PMODE_1MV_HPEL_BILIN; + v->qs_last = v->s.quarter_sample; + v->s.quarter_sample = (v->mv_mode == MV_PMODE_1MV); + v->s.mspel = v->s.quarter_sample; + status = bitplane_decoding(v->direct_mb_plane, &v->dmb_is_raw, v); + if (status < 0) + return -1; + av_log(v->s.avctx, AV_LOG_DEBUG, "MB Direct Type plane encoding: " + "Imode: %i, Invert: %i\n", status>>1, status&1); + status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v); + if (status < 0) + return -1; + av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: " + "Imode: %i, Invert: %i\n", status>>1, status&1); + v->s.mv_table_index = get_bits(gb, 2); + v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(gb, 2)]; + } - if (v->dquant) - { + if (v->dquant) { av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n"); vop_dquant_decoding(v); } v->ttfrm = 0; - if (v->vstransform) - { + if (v->vstransform) { v->ttmbf = get_bits1(gb); - if (v->ttmbf) - { + if (v->ttmbf) { v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)]; } } else { @@ -1041,19 +1228,19 @@ /* AC Syntax */ v->c_ac_table_index = decode012(gb); - if (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI) - { + if (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI) { v->y_ac_table_index = decode012(gb); } /* DC Syntax */ v->s.dc_table_index = get_bits1(gb); - if ((v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI) && v->dquant) { + if ((v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI) + && v->dquant) { av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n"); vop_dquant_decoding(v); } v->bi_type = 0; - if(v->s.pict_type == AV_PICTURE_TYPE_BI) { + if (v->s.pict_type == AV_PICTURE_TYPE_BI) { v->s.pict_type = AV_PICTURE_TYPE_B; v->bi_type = 1; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vc1data.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vc1data.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vc1data.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vc1data.c 2011-11-04 12:38:27.000000000 +0000 @@ -1,5 +1,6 @@ /* * VC-1 and WMV3 decoder + * copyright (c) 2011 Mashiat Sarker Shakkhar * copyright (c) 2006 Konstantin Shishkov * (c) 2005 anonymous, Alex Beregszaszi, Michael Niedermayer * @@ -31,38 +32,70 @@ /** Table for conversion between TTBLK and TTMB */ const int ff_vc1_ttblk_to_tt[3][8] = { - { TT_8X4, TT_4X8, TT_8X8, TT_4X4, TT_8X4_TOP, TT_8X4_BOTTOM, TT_4X8_RIGHT, TT_4X8_LEFT }, - { TT_8X8, TT_4X8_RIGHT, TT_4X8_LEFT, TT_4X4, TT_8X4, TT_4X8, TT_8X4_BOTTOM, TT_8X4_TOP }, - { TT_8X8, TT_4X8, TT_4X4, TT_8X4_BOTTOM, TT_4X8_RIGHT, TT_4X8_LEFT, TT_8X4, TT_8X4_TOP } + { TT_8X4, TT_4X8, TT_8X8, TT_4X4, TT_8X4_TOP, TT_8X4_BOTTOM, TT_4X8_RIGHT, TT_4X8_LEFT }, + { TT_8X8, TT_4X8_RIGHT, TT_4X8_LEFT, TT_4X4, TT_8X4, TT_4X8, TT_8X4_BOTTOM, TT_8X4_TOP }, + { TT_8X8, TT_4X8, TT_4X4, TT_8X4_BOTTOM, TT_4X8_RIGHT, TT_4X8_LEFT, TT_8X4, TT_8X4_TOP } }; const int ff_vc1_ttfrm_to_tt[4] = { TT_8X8, TT_8X4, TT_4X8, TT_4X4 }; /** MV P mode - the 5th element is only used for mode 1 */ const uint8_t ff_vc1_mv_pmode_table[2][5] = { - { MV_PMODE_1MV_HPEL_BILIN, MV_PMODE_1MV, MV_PMODE_1MV_HPEL, MV_PMODE_INTENSITY_COMP, MV_PMODE_MIXED_MV }, - { MV_PMODE_1MV, MV_PMODE_MIXED_MV, MV_PMODE_1MV_HPEL, MV_PMODE_INTENSITY_COMP, MV_PMODE_1MV_HPEL_BILIN } + { MV_PMODE_1MV_HPEL_BILIN, MV_PMODE_1MV, MV_PMODE_1MV_HPEL, MV_PMODE_INTENSITY_COMP, MV_PMODE_MIXED_MV }, + { MV_PMODE_1MV, MV_PMODE_MIXED_MV, MV_PMODE_1MV_HPEL, MV_PMODE_INTENSITY_COMP, MV_PMODE_1MV_HPEL_BILIN } }; const uint8_t ff_vc1_mv_pmode_table2[2][4] = { - { MV_PMODE_1MV_HPEL_BILIN, MV_PMODE_1MV, MV_PMODE_1MV_HPEL, MV_PMODE_MIXED_MV }, - { MV_PMODE_1MV, MV_PMODE_MIXED_MV, MV_PMODE_1MV_HPEL, MV_PMODE_1MV_HPEL_BILIN } + { MV_PMODE_1MV_HPEL_BILIN, MV_PMODE_1MV, MV_PMODE_1MV_HPEL, MV_PMODE_MIXED_MV }, + { MV_PMODE_1MV, MV_PMODE_MIXED_MV, MV_PMODE_1MV_HPEL, MV_PMODE_1MV_HPEL_BILIN } +}; + +/* MBMODE table for interlaced frame P-picture */ +const uint8_t ff_vc1_mbmode_intfrp[2][15][4] = { + { /* 1: 4-MV, 0: non-4-MV */ + /* Type, FIELDTX, 1-MV Differential present, Residuals (CBP) present */ + /* Table 164 - Table 167 */ + { MV_PMODE_INTFR_1MV , 0, 1, 1 }, + { MV_PMODE_INTFR_1MV , 1, 1, 1 }, + { MV_PMODE_INTFR_1MV , 0, 1, 0 }, + { MV_PMODE_INTFR_1MV , 0, 0, 1 }, + { MV_PMODE_INTFR_1MV , 1, 0, 1 }, + { MV_PMODE_INTFR_2MV_FIELD, 0, 0, 1 }, + { MV_PMODE_INTFR_2MV_FIELD, 1, 0, 1 }, + { MV_PMODE_INTFR_2MV_FIELD, 0, 0, 0 }, + { MV_PMODE_INTFR_INTRA , 0, 0, 0 } + }, + { + /* Table 160 - Table 163 */ + { MV_PMODE_INTFR_1MV , 0, 1, 1 }, + { MV_PMODE_INTFR_1MV , 1, 1, 1 }, + { MV_PMODE_INTFR_1MV , 0, 1, 0 }, + { MV_PMODE_INTFR_1MV , 0, 0, 1 }, + { MV_PMODE_INTFR_1MV , 1, 0, 1 }, + { MV_PMODE_INTFR_2MV_FIELD, 0, 0, 1 }, + { MV_PMODE_INTFR_2MV_FIELD, 1, 0, 1 }, + { MV_PMODE_INTFR_2MV_FIELD, 0, 0, 0 }, + { MV_PMODE_INTFR_4MV , 0, 0, 1 }, + { MV_PMODE_INTFR_4MV , 1, 0, 1 }, + { MV_PMODE_INTFR_4MV , 0, 0, 0 }, + { MV_PMODE_INTFR_4MV_FIELD, 0, 0, 1 }, + { MV_PMODE_INTFR_4MV_FIELD, 1, 0, 1 }, + { MV_PMODE_INTFR_4MV_FIELD, 0, 0, 0 }, + { MV_PMODE_INTFR_INTRA , 0, 0, 0 } + } }; const int ff_vc1_fps_nr[5] = { 24, 25, 30, 50, 60 }, - ff_vc1_fps_dr[2] = { 1000, 1001 }; + ff_vc1_fps_dr[2] = { 1000, 1001 }; const uint8_t ff_vc1_pquant_table[3][32] = { - { /* Implicit quantizer */ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 6, 7, 8, 9, 10, 11, 12, - 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 27, 29, 31 - }, - { /* Explicit quantizer, pquantizer uniform */ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 - }, - { /* Explicit quantizer, pquantizer non-uniform */ - 0, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 29, 31 - } + /* Implicit quantizer */ + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 27, 29, 31 }, + /* Explicit quantizer, pquantizer uniform */ + { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 }, + /* Explicit quantizer, pquantizer non-uniform */ + { 0, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 29, 31 } }; /** @name VC-1 VLC tables and defines @@ -84,38 +117,57 @@ VLC ff_vc1_mv_diff_vlc[4]; #define VC1_CBPCY_P_VLC_BITS 9 //14 VLC ff_vc1_cbpcy_p_vlc[4]; +#define VC1_ICBPCY_VLC_BITS 9 +VLC ff_vc1_icbpcy_vlc[8]; #define VC1_4MV_BLOCK_PATTERN_VLC_BITS 6 VLC ff_vc1_4mv_block_pattern_vlc[4]; +#define VC1_2MV_BLOCK_PATTERN_VLC_BITS 3 +VLC ff_vc1_2mv_block_pattern_vlc[4]; #define VC1_TTBLK_VLC_BITS 5 VLC ff_vc1_ttblk_vlc[3]; #define VC1_SUBBLKPAT_VLC_BITS 6 VLC ff_vc1_subblkpat_vlc[3]; +#define VC1_INTFR_4MV_MBMODE_VLC_BITS 9 +VLC ff_vc1_intfr_4mv_mbmode_vlc[4]; +#define VC1_INTFR_NON4MV_MBMODE_VLC_BITS 6 +VLC ff_vc1_intfr_non4mv_mbmode_vlc[4]; +#define VC1_IF_MMV_MBMODE_VLC_BITS 5 +VLC ff_vc1_if_mmv_mbmode_vlc[8]; +#define VC1_IF_1MV_MBMODE_VLC_BITS 5 +VLC ff_vc1_if_1mv_mbmode_vlc[8]; +#define VC1_1REF_MVDATA_VLC_BITS 9 +VLC ff_vc1_1ref_mvdata_vlc[4]; +#define VC1_2REF_MVDATA_VLC_BITS 9 +VLC ff_vc1_2ref_mvdata_vlc[8]; VLC ff_vc1_ac_coeff_table[8]; + +#define VC1_IF_MBMODE_VLC_BITS 5 // as a placeholder for VC1_IF_MMV_MBMODE_VLC_BITS + // or VC1_IF_1MV_MBMODE_VLC_BITS since they are the same //@} -#if B_FRACTION_DEN==840 //original bfraction from vc9data.h, not conforming to standard +#if B_FRACTION_DEN == 840 // original bfraction from vc9data.h, not conforming to standard /* bfraction is fractional, we scale to the GCD 3*5*7*8 = 840 */ const int16_t ff_vc1_bfraction_lut[23] = { - 420 /*1/2*/, 280 /*1/3*/, 560 /*2/3*/, 210 /*1/4*/, - 630 /*3/4*/, 168 /*1/5*/, 336 /*2/5*/, - 504 /*3/5*/, 672 /*4/5*/, 140 /*1/6*/, 700 /*5/6*/, - 120 /*1/7*/, 240 /*2/7*/, 360 /*3/7*/, 480 /*4/7*/, - 600 /*5/7*/, 720 /*6/7*/, 105 /*1/8*/, 315 /*3/8*/, - 525 /*5/8*/, 735 /*7/8*/, - -1 /*inv.*/, 0 /*BI fm*/ + 420 /*1/2*/, 280 /*1/3*/, 560 /*2/3*/, 210 /*1/4*/, + 630 /*3/4*/, 168 /*1/5*/, 336 /*2/5*/, + 504 /*3/5*/, 672 /*4/5*/, 140 /*1/6*/, 700 /*5/6*/, + 120 /*1/7*/, 240 /*2/7*/, 360 /*3/7*/, 480 /*4/7*/, + 600 /*5/7*/, 720 /*6/7*/, 105 /*1/8*/, 315 /*3/8*/, + 525 /*5/8*/, 735 /*7/8*/, + -1 /*inv.*/, 0 /*BI fm*/ }; #else /* pre-computed scales for all bfractions and base=256 */ const int16_t ff_vc1_bfraction_lut[23] = { - 128 /*1/2*/, 85 /*1/3*/, 170 /*2/3*/, 64 /*1/4*/, - 192 /*3/4*/, 51 /*1/5*/, 102 /*2/5*/, - 153 /*3/5*/, 204 /*4/5*/, 43 /*1/6*/, 215 /*5/6*/, - 37 /*1/7*/, 74 /*2/7*/, 111 /*3/7*/, 148 /*4/7*/, - 185 /*5/7*/, 222 /*6/7*/, 32 /*1/8*/, 96 /*3/8*/, - 160 /*5/8*/, 224 /*7/8*/, - -1 /*inv.*/, 0 /*BI fm*/ + 128 /*1/2*/, 85 /*1/3*/, 170 /*2/3*/, 64 /*1/4*/, + 192 /*3/4*/, 51 /*1/5*/, 102 /*2/5*/, + 153 /*3/5*/, 204 /*4/5*/, 43 /*1/6*/, 215 /*5/6*/, + 37 /*1/7*/, 74 /*2/7*/, 111 /*3/7*/, 148 /*4/7*/, + 185 /*5/7*/, 222 /*6/7*/, 32 /*1/8*/, 96 /*3/8*/, + 160 /*5/8*/, 224 /*7/8*/, + -1 /*inv.*/, 0 /*BI fm*/ }; #endif @@ -129,81 +181,473 @@ 7, 7 }; const uint8_t ff_vc1_bfraction_codes[23] = { - 0, 1, 2, 3, - 4, 5, 6, - 112, 113, 114, 115, - 116, 117, 118, 119, - 120, 121, 122, 123, - 124, 125, - 126, 127 + 0, 1, 2, 3, + 4, 5, 6, + 112, 113, 114, 115, + 116, 117, 118, 119, + 120, 121, 122, 123, + 124, 125, + 126, 127 }; //Same as H.264 -const AVRational ff_vc1_pixel_aspect[16]={ - {0, 1}, - {1, 1}, - {12, 11}, - {10, 11}, - {16, 11}, - {40, 33}, - {24, 11}, - {20, 11}, - {32, 11}, - {80, 33}, - {18, 11}, - {15, 11}, - {64, 33}, - {160, 99}, - {0, 1}, - {0, 1} +const AVRational ff_vc1_pixel_aspect[16] = { + { 0, 1 }, + { 1, 1 }, + { 12, 11 }, + { 10, 11 }, + { 16, 11 }, + { 40, 33 }, + { 24, 11 }, + { 20, 11 }, + { 32, 11 }, + { 80, 33 }, + { 18, 11 }, + { 15, 11 }, + { 64, 33 }, + { 160, 99 }, + { 0, 1 }, + { 0, 1 } }; /* BitPlane IMODE - such a small table... */ const uint8_t ff_vc1_imode_codes[7] = { - 0, 2, 1, 3, 1, 2, 3 + 0, 2, 1, 3, 1, 2, 3 }; const uint8_t ff_vc1_imode_bits[7] = { - 4, 2, 3, 2, 4, 3, 3 + 4, 2, 3, 2, 4, 3, 3 }; /* Normal-2 imode */ const uint8_t ff_vc1_norm2_codes[4] = { - 0, 4, 5, 3 + 0, 4, 5, 3 }; const uint8_t ff_vc1_norm2_bits[4] = { - 1, 3, 3, 2 + 1, 3, 3, 2 }; const uint16_t ff_vc1_norm6_codes[64] = { -0x001, 0x002, 0x003, 0x000, 0x004, 0x001, 0x002, 0x047, 0x005, 0x003, 0x004, 0x04B, 0x005, 0x04D, 0x04E, 0x30E, -0x006, 0x006, 0x007, 0x053, 0x008, 0x055, 0x056, 0x30D, 0x009, 0x059, 0x05A, 0x30C, 0x05C, 0x30B, 0x30A, 0x037, -0x007, 0x00A, 0x00B, 0x043, 0x00C, 0x045, 0x046, 0x309, 0x00D, 0x049, 0x04A, 0x308, 0x04C, 0x307, 0x306, 0x036, -0x00E, 0x051, 0x052, 0x305, 0x054, 0x304, 0x303, 0x035, 0x058, 0x302, 0x301, 0x034, 0x300, 0x033, 0x032, 0x007, + 0x001, 0x002, 0x003, 0x000, 0x004, 0x001, 0x002, 0x047, 0x005, 0x003, 0x004, 0x04B, 0x005, 0x04D, 0x04E, 0x30E, + 0x006, 0x006, 0x007, 0x053, 0x008, 0x055, 0x056, 0x30D, 0x009, 0x059, 0x05A, 0x30C, 0x05C, 0x30B, 0x30A, 0x037, + 0x007, 0x00A, 0x00B, 0x043, 0x00C, 0x045, 0x046, 0x309, 0x00D, 0x049, 0x04A, 0x308, 0x04C, 0x307, 0x306, 0x036, + 0x00E, 0x051, 0x052, 0x305, 0x054, 0x304, 0x303, 0x035, 0x058, 0x302, 0x301, 0x034, 0x300, 0x033, 0x032, 0x007, }; const uint8_t ff_vc1_norm6_bits[64] = { - 1, 4, 4, 8, 4, 8, 8, 10, 4, 8, 8, 10, 8, 10, 10, 13, - 4, 8, 8, 10, 8, 10, 10, 13, 8, 10, 10, 13, 10, 13, 13, 9, - 4, 8, 8, 10, 8, 10, 10, 13, 8, 10, 10, 13, 10, 13, 13, 9, - 8, 10, 10, 13, 10, 13, 13, 9, 10, 13, 13, 9, 13, 9, 9, 6, + 1, 4, 4, 8, 4, 8, 8, 10, 4, 8, 8, 10, 8, 10, 10, 13, + 4, 8, 8, 10, 8, 10, 10, 13, 8, 10, 10, 13, 10, 13, 13, 9, + 4, 8, 8, 10, 8, 10, 10, 13, 8, 10, 10, 13, 10, 13, 13, 9, + 8, 10, 10, 13, 10, 13, 13, 9, 10, 13, 13, 9, 13, 9, 9, 6, }; /* 4MV Block pattern VLC tables */ const uint8_t ff_vc1_4mv_block_pattern_codes[4][16] = { - { 14, 58, 59, 25, 12, 26, 15, 15, 13, 24, 27, 0, 28, 1, 2, 2}, - { 8, 18, 19, 4, 20, 5, 30, 11, 21, 31, 6, 12, 7, 13, 14, 0}, - { 15, 6, 7, 2, 8, 3, 28, 9, 10, 29, 4, 11, 5, 12, 13, 0}, - { 0, 11, 12, 4, 13, 5, 30, 16, 14, 31, 6, 17, 7, 18, 19, 10} + { 14, 58, 59, 25, 12, 26, 15, 15, 13, 24, 27, 0, 28, 1, 2, 2 }, + { 8, 18, 19, 4, 20, 5, 30, 11, 21, 31, 6, 12, 7, 13, 14, 0 }, + { 15, 6, 7, 2, 8, 3, 28, 9, 10, 29, 4, 11, 5, 12, 13, 0 }, + { 0, 11, 12, 4, 13, 5, 30, 16, 14, 31, 6, 17, 7, 18, 19, 10 } }; const uint8_t ff_vc1_4mv_block_pattern_bits[4][16] = { - { 5, 6, 6, 5, 5, 5, 5, 4, 5, 5, 5, 3, 5, 3, 3, 2}, - { 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 4, 4, 4, 4, 4, 2}, - { 4, 4, 4, 4, 4, 4, 5, 4, 4, 5, 4, 4, 4, 4, 4, 3}, - { 2, 4, 4, 4, 4, 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 4} + { 5, 6, 6, 5, 5, 5, 5, 4, 5, 5, 5, 3, 5, 3, 3, 2 }, + { 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 4, 4, 4, 4, 4, 2 }, + { 4, 4, 4, 4, 4, 4, 5, 4, 4, 5, 4, 4, 4, 4, 4, 3 }, + { 2, 4, 4, 4, 4, 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 4 } +}; + +/* 2MV Block pattern VLC tables */ +const uint8_t ff_vc1_2mv_block_pattern_codes[4][4] = { + { 2, 1, 0, 3 }, { 1, 0, 2, 3 }, { 2, 0, 3, 1 }, { 1, 3, 2, 0 } +}; + +const uint8_t ff_vc1_2mv_block_pattern_bits[4][4] = { + { 2, 2, 2, 2 }, { 1, 2, 3, 3 }, { 3, 2, 3, 1 }, { 1, 3, 3, 2 } +}; + +/* Interlaced frame picture 4MV MBMODE VLC tables (p. 246, p. 360) */ +const uint16_t ff_vc1_intfr_4mv_mbmode_codes[4][15] = { + { 22, 17, 0, 47, 32, 10, 1, 3, 67, 133, 132, 92, 19, 93, 18 }, + { 3, 45, 0, 7, 23, 6, 1, 2, 10, 39, 44, 8, 18, 77, 76 }, + { 15, 6, 28, 9, 41, 6, 2, 15, 14, 8, 40, 29, 0, 21, 11 }, + { 7, 198, 1, 2, 193, 13, 25, 0, 97, 1599, 98, 398, 798, 192, 1598 } +}; + +const uint8_t ff_vc1_intfr_4mv_mbmode_bits[4][15] = { + { 5, 5, 2, 6, 6, 4, 2, 2, 7, 8, 8, 7, 5, 7, 5 }, + { 3, 6, 3, 3, 5, 3, 3, 3, 4, 6, 6, 4, 5, 7, 7 }, + { 4, 3, 5, 5, 7, 4, 2, 5, 5, 5, 7, 5, 2, 6, 5 }, + { 4, 9, 1, 3, 9, 5, 6, 2, 8, 12, 8, 10, 11, 9, 12 } +}; + +/* Interlaced frame picture NON-4MV MBMODE VLC tables (p. 363) */ +const uint8_t ff_vc1_intfr_non4mv_mbmode_codes[4][9] = { + { 9, 22, 0, 17, 16, 10, 1, 3, 23 }, + { 7, 0, 5, 2, 1, 1, 6, 3, 4 }, + { 1, 0, 10, 23, 44, 8, 3, 9, 45 }, + { 7, 97, 1, 2, 49, 13, 25, 0, 96 } +}; + +const uint8_t ff_vc1_intfr_non4mv_mbmode_bits[4][9] = { + { 4, 5, 2, 5, 5, 4, 2, 2, 5 }, + { 3, 4, 6, 2, 3, 2, 3, 5, 6 }, + { 2, 2, 4, 5, 6, 4, 2, 4, 6 }, + { 4, 8, 1, 3, 7, 5, 6, 2, 8 } +}; + +/* Interlaced field picture MBMODE VLC tables (p. 356 - 11.4.1, 11.4.2) */ +/* mixed-MV */ +const uint8_t ff_vc1_if_mmv_mbmode_codes[8][8] = { + { 16, 17, 3, 3, 0, 5, 9, 2 }, + { 8, 9, 3, 6, 7, 0, 5, 2 }, + { 16, 17, 5, 3, 0, 3, 9, 2 }, + { 56, 57, 15, 4, 5, 6, 29, 0 }, + { 52, 53, 27, 14, 15, 2, 12, 0 }, + { 56, 57, 29, 5, 6, 0, 15, 4 }, + { 16, 17, 6, 7, 0, 1, 9, 5 }, + { 56, 57, 0, 5, 6, 29, 4, 15 } +}; +const uint8_t ff_vc1_if_mmv_mbmode_bits[8][8] = { + { 6, 6, 2, 3, 2, 4, 5, 2 }, + { 5, 5, 3, 3, 3, 2, 4, 2 }, + { 6, 6, 4, 3, 2, 2, 5, 2 }, + { 6, 6, 4, 3, 3, 3, 5, 1 }, + { 6, 6, 5, 4, 4, 2, 4, 1 }, + { 6, 6, 5, 3, 3, 1, 4, 3 }, + { 5, 5, 3, 3, 2, 2, 4, 3 }, + { 6, 6, 1, 3, 3, 5, 3, 4 } +}; +/* 1MV */ +const uint8_t ff_vc1_if_1mv_mbmode_codes[8][6] = { + { 0, 1, 1, 1, 1, 1 }, + { 0, 1, 1, 1, 1, 1 }, + { 16, 17, 3, 0, 9, 5 }, + { 20, 21, 3, 11, 0, 4 }, + { 4, 5, 2, 3, 3, 0 }, + { 4, 5, 3, 2, 0, 3 }, + { 0, 1, 1, 1, 1, 1 }, + { 16, 17, 9, 5, 3, 0 } +}; +const uint8_t ff_vc1_if_1mv_mbmode_bits[8][6] = { + { 5, 5, 1, 3, 2, 4 }, + { 5, 5, 1, 2, 3, 4 }, + { 5, 5, 2, 1, 4, 3 }, + { 5, 5, 2, 4, 1, 3 }, + { 4, 4, 2, 3, 2, 2 }, + { 4, 4, 3, 2, 2, 2 }, + { 5, 5, 3, 4, 1, 2 }, + { 5, 5, 4, 3, 2, 1 } +}; + +/* Interlaced frame/field picture MVDATA VLC tables */ + +/* 1-reference tables */ +const uint32_t ff_vc1_1ref_mvdata_codes[4][72] = { /* uint32_t may be too big */ + { + 0x00005, 0x0000C, 0x0001E, 0x00012, 0x0000C, 0x00034, 0x00075, 0x00070, + 0x00000, 0x00008, 0x0001B, 0x00008, 0x0001D, 0x0007C, 0x000D6, 0x001DE, + 0x001AF, 0x00005, 0x0001B, 0x00026, 0x0001E, 0x00012, 0x00076, 0x0004D, + 0x001F6, 0x001F4, 0x00039, 0x0007F, 0x00027, 0x0006A, 0x00071, 0x00035, + 0x00071, 0x00068, 0x001DC, 0x00027, 0x00073, 0x000FF, 0x000E8, 0x000E9, + 0x0007E, 0x001F9, 0x001F5, 0x001FD, 0x0003E, 0x001CA, 0x003F9, 0x0004C, + 0x00069, 0x001FA, 0x001DF, 0x001F7, 0x00070, 0x001DD, 0x00E4D, 0x00727, + 0x00392, 0x001C8, 0x001CB, 0x003F8, 0x001AE, 0x001F8, 0x001FB, 0x0E4CE, + 0x0E4CF, 0x07260, 0x07261, 0x07262, 0x07263, 0x07264, 0x07265, 0x07266 + }, + { + 0x00007, 0x00001, 0x00007, 0x00016, 0x00001, 0x00045, 0x00018, 0x002B6, + 0x00006, 0x00004, 0x00017, 0x00010, 0x00029, 0x0002C, 0x0015A, 0x00066, + 0x0019E, 0x00009, 0x00028, 0x00017, 0x00000, 0x0002A, 0x00004, 0x0005B, + 0x000B5, 0x000CE, 0x00006, 0x00044, 0x0000F, 0x00046, 0x0000E, 0x000AC, + 0x00032, 0x00037, 0x011EB, 0x0000A, 0x0001A, 0x0011F, 0x00016, 0x00014, + 0x0002B, 0x00168, 0x00055, 0x023D5, 0x00057, 0x0002F, 0x00036, 0x0002E, + 0x00169, 0x00054, 0x0047B, 0x0019F, 0x02B7D, 0x0008E, 0x00ADE, 0x00479, + 0x0056E, 0x008F4, 0x015BF, 0x00478, 0x023D4, 0x0ADF1, 0x056F9, 0xADF0E, + 0xADF0F, 0x56F80, 0x56F81, 0x56F82, 0x56F83, 0x56F84, 0x56F85, 0x56F86 + }, + { + 0x00002, 0x00006, 0x00007, 0x0000D, 0x00007, 0x00030, 0x000FF, 0x001F0, + 0x00002, 0x00000, 0x00005, 0x00019, 0x0001E, 0x00007, 0x00063, 0x000FD, + 0x00023, 0x0000E, 0x0001B, 0x0001A, 0x00006, 0x00009, 0x00018, 0x000C5, + 0x00033, 0x001F1, 0x00002, 0x003FB, 0x001F3, 0x00022, 0x001FC, 0x00042, + 0x00623, 0x00083, 0x00620, 0x0007D, 0x00040, 0x00043, 0x003E4, 0x003E5, + 0x00191, 0x00FE9, 0x00105, 0x00208, 0x000FC, 0x00624, 0x00622, 0x00190, + 0x00626, 0x007F5, 0x00C4B, 0x01FD0, 0x0104D, 0x00065, 0x00C42, 0x000C9, + 0x00627, 0x00C43, 0x00C4A, 0x0104E, 0x01FD1, 0x0104F, 0x00412, 0x104CE, + 0x104CF, 0x08260, 0x08261, 0x08262, 0x08263, 0x08264, 0x08265, 0x08266 + }, + { + 0x0000D, 0x00001, 0x00004, 0x00000, 0x00017, 0x00005, 0x0007F, 0x0004D, + 0x00003, 0x00011, 0x0003E, 0x0003B, 0x00017, 0x00067, 0x0004A, 0x000C3, + 0x000F2, 0x0000A, 0x0002C, 0x00032, 0x0003D, 0x00015, 0x00028, 0x00093, + 0x000CC, 0x00096, 0x00003, 0x00075, 0x00020, 0x0002D, 0x00021, 0x00029, + 0x00090, 0x001D0, 0x001FB, 0x0001C, 0x0004C, 0x00060, 0x00009, 0x00008, + 0x0002D, 0x0009F, 0x001FA, 0x0013D, 0x00031, 0x000FC, 0x00058, 0x00092, + 0x000F0, 0x000F1, 0x000CD, 0x00185, 0x00165, 0x0004E, 0x00091, 0x000E9, + 0x00184, 0x001D1, 0x001E6, 0x00097, 0x001E7, 0x000B3, 0x0013C, 0x0164E, + 0x0164F, 0x00B20, 0x00B21, 0x00B22, 0x00B23, 0x00B24, 0x00B25, 0x00B26 + } }; -const uint8_t wmv3_dc_scale_table[32]={ - 0, 2, 4, 8, 8, 8, 9, 9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18,19,19,20,20,21,21 +const uint8_t ff_vc1_1ref_mvdata_bits[4][72] = { + { + 3, 4, 5, 5, 5, 6, 7, 7, 2, 4, 5, 5, 6, 7, 8, 9, 9, 4, + 6, 6, 6, 6, 7, 8, 9, 9, 6, 8, 7, 7, 7, 7, 8, 8, 9, 6, + 8, 8, 8, 8, 8, 9, 9, 9, 7, 10, 10, 8, 8, 9, 9, 9, 8, 9, + 13, 12, 11, 10, 10, 10, 9, 9, 9, 17, 17, 16, 16, 16, 16, 16, 16, 16 + }, + { + 3, 3, 4, 5, 5, 7, 8, 10, 3, 4, 5, 5, 6, 7, 9, 10, 12, 4, + 6, 6, 5, 6, 6, 8, 9, 11, 4, 7, 7, 7, 7, 8, 9, 9, 13, 5, + 8, 9, 8, 8, 9, 10, 10, 14, 7, 9, 9, 9, 10, 10, 11, 12, 14, 8, + 12, 11, 11, 12, 13, 11, 14, 16, 15, 20, 20, 19, 19, 19, 19, 19, 19, 19 + }, + { + 3, 4, 4, 4, 5, 6, 8, 9, 2, 4, 5, 5, 5, 6, 7, 8, 8, 4, + 7, 7, 6, 6, 7, 8, 8, 9, 5, 10, 9, 8, 9, 9, 11, 10, 11, 7, + 9, 9, 10, 10, 11, 12, 11, 12, 8, 11, 11, 11, 11, 11, 12, 13, 15, 9, + 12, 10, 11, 12, 12, 15, 13, 15, 13, 19, 19, 18, 18, 18, 18, 18, 18, 18 + }, + { + 4, 4, 4, 4, 5, 5, 7, 7, 3, 5, 6, 6, 6, 7, 7, 8, 8, 4, + 6, 6, 6, 6, 7, 8, 8, 8, 4, 7, 6, 6, 6, 7, 8, 9, 9, 5, + 7, 7, 6, 6, 7, 8, 9, 9, 6, 8, 8, 8, 8, 8, 8, 9, 10, 7, + 8, 8, 9, 9, 9, 8, 9, 9, 9, 14, 14, 13, 13, 13, 13, 13, 13, 13 + } +}; + +/* 2-reference tables */ +const uint32_t ff_vc1_2ref_mvdata_codes[8][126] = { /* table 132 - table 139 */ + { + 0x0000C, 0x0001C, 0x0000B, 0x00000, 0x0000E, 0x0002A, 0x00050, 0x00368, + 0x00002, 0x0001A, 0x00004, 0x0003A, 0x0001D, 0x0006C, 0x000EF, 0x001BC, + 0x0015F, 0x0000F, 0x00003, 0x0001C, 0x0000D, 0x0000B, 0x0003E, 0x000A7, + 0x00146, 0x00199, 0x00006, 0x0001F, 0x00004, 0x0003C, 0x00007, 0x001BE, + 0x0008B, 0x0002C, 0x007B3, 0x00005, 0x000DB, 0x00056, 0x000EC, 0x00052, + 0x001BD, 0x00078, 0x000CF, 0x00573, 0x00009, 0x00023, 0x000ED, 0x00018, + 0x00006, 0x00044, 0x000F5, 0x00079, 0x006D2, 0x0006E, 0x0002B, 0x0015D, + 0x00017, 0x0037F, 0x00144, 0x000CE, 0x00028, 0x000AB, 0x00010, 0x001B5, + 0x000F7, 0x000A6, 0x0007B, 0x00028, 0x001ED, 0x001E9, 0x006FD, 0x00004, + 0x000F5, 0x00029, 0x0028A, 0x0028B, 0x0028F, 0x00DF9, 0x00335, 0x01E85, + 0x000EE, 0x002BD, 0x0002B, 0x003D8, 0x003D1, 0x00198, 0x001E9, 0x0051D, + 0x000B4, 0x0003F, 0x00455, 0x0022B, 0x00229, 0x00451, 0x00578, 0x007B2, + 0x00570, 0x00155, 0x00032, 0x003D0, 0x00054, 0x006D3, 0x00571, 0x00454, + 0x00334, 0x01BF1, 0x000B7, 0x00029, 0x01E84, 0x0016C, 0x0019B, 0x01BF0, + 0x00579, 0x00F43, 0x000B5, 0x008A1, 0x0002A, 0x0016D, 0x008A0, 0x007A0, + 0x003D1, 0x00AE5, 0x00154, 0x00AE4, 0x00A39, 0x00A38 + }, + { + 0x00003, 0x00009, 0x00016, 0x00010, 0x000D7, 0x00335, 0x00574, 0x00555, + 0x00000, 0x0001D, 0x00009, 0x00017, 0x0002C, 0x000AD, 0x00374, 0x006B3, + 0x00577, 0x0000F, 0x00018, 0x0000A, 0x0002E, 0x00022, 0x0017C, 0x00E7B, + 0x01B89, 0x015D8, 0x00008, 0x00034, 0x0006D, 0x00023, 0x001C2, 0x00376, + 0x002D3, 0x01C4A, 0x0330A, 0x00014, 0x0006A, 0x00072, 0x0006C, 0x000E3, + 0x0019B, 0x0073F, 0x01CF0, 0x00B41, 0x00032, 0x000E6, 0x000E0, 0x000CF, + 0x000AB, 0x0019C, 0x002AB, 0x00E2B, 0x015D9, 0x0006F, 0x001C3, 0x000AF, + 0x000BF, 0x000AC, 0x0017D, 0x006E3, 0x00E29, 0x01984, 0x00054, 0x000B5, + 0x0017A, 0x001AD, 0x00199, 0x00178, 0x00358, 0x002D2, 0x01C4B, 0x0005B, + 0x002A8, 0x00331, 0x00388, 0x0038B, 0x00370, 0x00713, 0x00CC3, 0x01CF1, + 0x001B9, 0x005EF, 0x00738, 0x002F2, 0x0033B, 0x002B9, 0x006EB, 0x00570, + 0x00E24, 0x0039D, 0x005A2, 0x005A3, 0x00E7D, 0x005EE, 0x00739, 0x00554, + 0x00AA5, 0x00AA4, 0x00377, 0x01CF5, 0x00BCE, 0x00E79, 0x00660, 0x00674, + 0x006EA, 0x00E7C, 0x00D65, 0x002F6, 0x015DA, 0x01B88, 0x005A1, 0x01CF4, + 0x005E6, 0x00E28, 0x00575, 0x00D64, 0x00334, 0x0330B, 0x015DB, 0x00B40, + 0x00BCF, 0x00DC5, 0x00E2A, 0x00675, 0x00571, 0x00553 + }, + { + 0x00004, 0x00002, 0x00010, 0x00003, 0x00017, 0x00045, 0x0003E, 0x0007E, + 0x00003, 0x00002, 0x00028, 0x0001E, 0x00015, 0x00047, 0x00002, 0x0014D, + 0x00060, 0x0000B, 0x00026, 0x00024, 0x00014, 0x00032, 0x0006F, 0x000C3, + 0x00531, 0x006E5, 0x00015, 0x0003F, 0x0002D, 0x00001, 0x0013E, 0x000DD, + 0x000F6, 0x00305, 0x00331, 0x0000E, 0x00003, 0x00034, 0x00033, 0x0001A, + 0x0014A, 0x000C5, 0x000F4, 0x006E4, 0x00001, 0x0003C, 0x0007D, 0x0008D, + 0x0009D, 0x00031, 0x0006E, 0x00296, 0x000CD, 0x00025, 0x00149, 0x00032, + 0x00089, 0x00036, 0x00088, 0x0006F, 0x00003, 0x0031D, 0x0000E, 0x001AA, + 0x0027E, 0x00061, 0x0014E, 0x0014F, 0x00067, 0x000FF, 0x00183, 0x00036, + 0x00357, 0x000F5, 0x000C6, 0x000C2, 0x00299, 0x00119, 0x00231, 0x00350, + 0x0002C, 0x0018F, 0x00530, 0x00297, 0x00004, 0x001B8, 0x000C0, 0x0027A, + 0x00311, 0x0009C, 0x00621, 0x00199, 0x0031C, 0x000F7, 0x003E3, 0x00356, + 0x00189, 0x00005, 0x0006B, 0x008C2, 0x00330, 0x004FF, 0x004F0, 0x00351, + 0x004F2, 0x001F2, 0x00373, 0x00000, 0x00C41, 0x008C3, 0x009EC, 0x003E2, + 0x00304, 0x004F7, 0x004F1, 0x001F0, 0x00148, 0x00C40, 0x009ED, 0x008C0, + 0x008C1, 0x004F3, 0x004FE, 0x000FE, 0x001F3, 0x001A9 + }, + { + 0x00000, 0x00004, 0x0002F, 0x00052, 0x00010, 0x000AD, 0x0050B, 0x00190, + 0x00003, 0x00016, 0x00007, 0x0000D, 0x000BB, 0x00173, 0x000C9, 0x0050F, + 0x0172C, 0x00003, 0x00011, 0x00005, 0x00043, 0x00023, 0x0004B, 0x0032E, + 0x02E5B, 0x00482, 0x00009, 0x0002A, 0x00014, 0x0002A, 0x00108, 0x005CA, + 0x0065A, 0x02136, 0x02132, 0x0000B, 0x00013, 0x00041, 0x000B8, 0x00174, + 0x00100, 0x014DA, 0x0404E, 0x01437, 0x0002B, 0x00085, 0x000A7, 0x000A0, + 0x0014C, 0x0029A, 0x0032C, 0x02133, 0x0142A, 0x00051, 0x00284, 0x000AC, + 0x00102, 0x00045, 0x00044, 0x0081B, 0x0065E, 0x00CB7, 0x00018, 0x0050C, + 0x00212, 0x002E4, 0x00203, 0x00094, 0x00122, 0x0081A, 0x00655, 0x00033, + 0x002BA, 0x00246, 0x00242, 0x00A6E, 0x0040C, 0x00808, 0x02134, 0x0404F, + 0x00175, 0x00405, 0x00247, 0x0012A, 0x00A14, 0x002BB, 0x00191, 0x0084F, + 0x01438, 0x000AF, 0x00B97, 0x00483, 0x0143B, 0x0032B, 0x00243, 0x0142B, + 0x00958, 0x029BF, 0x00049, 0x00A6C, 0x014DB, 0x004AD, 0x014DE, 0x0084E, + 0x01434, 0x00257, 0x02E5A, 0x00207, 0x01435, 0x01439, 0x00CB6, 0x0143A, + 0x00194, 0x00654, 0x02135, 0x0537C, 0x0015C, 0x00240, 0x01012, 0x0537D, + 0x00959, 0x01098, 0x01436, 0x0065F, 0x02026, 0x02137 + }, + { + 0x00005, 0x00019, 0x00016, 0x00011, 0x0003E, 0x0005E, 0x000EF, 0x000E2, + 0x00000, 0x00039, 0x0002B, 0x00026, 0x00028, 0x00012, 0x000C2, 0x000ED, + 0x0011D, 0x0000D, 0x00031, 0x0002A, 0x00025, 0x00020, 0x0005C, 0x001ED, + 0x0024D, 0x00770, 0x00006, 0x0007A, 0x00060, 0x0004F, 0x00048, 0x00039, + 0x00186, 0x00213, 0x00EC6, 0x0000F, 0x00026, 0x0005F, 0x00075, 0x00070, + 0x00027, 0x001DB, 0x003C6, 0x0078F, 0x0003F, 0x000A6, 0x000F0, 0x0003A, + 0x00052, 0x0004E, 0x000E3, 0x001D9, 0x0030F, 0x00010, 0x001DD, 0x000A7, + 0x000F7, 0x00022, 0x00092, 0x003C4, 0x002EF, 0x00762, 0x00079, 0x0008F, + 0x001DA, 0x00087, 0x000E8, 0x000BA, 0x00176, 0x000EE, 0x003B0, 0x00085, + 0x00119, 0x0030E, 0x00108, 0x001D2, 0x0010C, 0x00773, 0x00424, 0x00434, + 0x00071, 0x005DD, 0x001C1, 0x003A7, 0x00127, 0x0008D, 0x0021B, 0x007B2, + 0x001DF, 0x003D8, 0x00764, 0x00EE4, 0x003B3, 0x0074D, 0x001D8, 0x005DC, + 0x0084A, 0x00499, 0x003C5, 0x01D8E, 0x00765, 0x00435, 0x00771, 0x001C2, + 0x00118, 0x003BC, 0x00381, 0x00387, 0x07B33, 0x01097, 0x01096, 0x01ECD, + 0x00E99, 0x00F1C, 0x00F1D, 0x00EE5, 0x0011C, 0x07B32, 0x03D98, 0x01D8F, + 0x00E98, 0x00F67, 0x003BD, 0x00380, 0x00498, 0x00386 + }, + { + 0x0000D, 0x00010, 0x0002E, 0x00039, 0x0000D, 0x00074, 0x000ED, 0x000B6, + 0x00001, 0x00002, 0x00000, 0x00030, 0x00029, 0x00070, 0x000F3, 0x0008C, + 0x00166, 0x00009, 0x00033, 0x00078, 0x00006, 0x000C4, 0x0000B, 0x00163, + 0x000CC, 0x005BE, 0x0001F, 0x0002F, 0x00064, 0x00018, 0x000C6, 0x0000A, + 0x00162, 0x002C0, 0x00EF3, 0x00007, 0x0000F, 0x000E3, 0x000CA, 0x000B2, + 0x0018F, 0x003AE, 0x0075F, 0x00C51, 0x00015, 0x00047, 0x000EE, 0x000E2, + 0x000EA, 0x00009, 0x0016A, 0x002C3, 0x0059D, 0x0003D, 0x00008, 0x001D9, + 0x00032, 0x0000E, 0x0016E, 0x0032C, 0x0065B, 0x0196B, 0x00002, 0x0000F, + 0x001D8, 0x0008D, 0x000B4, 0x001E4, 0x00067, 0x00317, 0x00794, 0x00022, + 0x003BE, 0x00315, 0x00034, 0x00037, 0x002DE, 0x0006C, 0x00EFE, 0x0066C, + 0x00028, 0x003CB, 0x003AC, 0x00035, 0x0016B, 0x003BD, 0x002C1, 0x0062C, + 0x01DFE, 0x0000E, 0x0059E, 0x005BF, 0x000DA, 0x00629, 0x00584, 0x00EB7, + 0x00B0A, 0x0066D, 0x0000C, 0x0077E, 0x0059C, 0x00778, 0x0075E, 0x0075A, + 0x0062D, 0x00337, 0x00334, 0x00197, 0x01E57, 0x01DE4, 0x0196A, 0x01E56, + 0x00C50, 0x00B3F, 0x01E54, 0x00B0B, 0x0018E, 0x001B6, 0x01E55, 0x00CB4, + 0x00B3E, 0x00EB6, 0x01DE5, 0x01DFF, 0x00335, 0x001B7 + }, + { + 0x00001, 0x0000B, 0x00019, 0x0006F, 0x0002A, 0x00075, 0x007EB, 0x00163, + 0x00001, 0x0000E, 0x0001A, 0x0003E, 0x0001C, 0x0002D, 0x00164, 0x007EC, + 0x00165, 0x00004, 0x00006, 0x00036, 0x0007F, 0x000AE, 0x00158, 0x0015C, + 0x0056D, 0xFD510, 0x00000, 0x00004, 0x0007B, 0x000F3, 0x0003B, 0x007ED, + 0x002B3, 0x002CC, 0x0056E, 0x00018, 0x0003E, 0x00017, 0x0001E, 0x000AF, + 0x003F7, 0x0056F, 0x002CD, 0xFD511, 0x00014, 0x000AD, 0x000AA, 0x00014, + 0x000A8, 0x00153, 0x000E8, 0x001FE, 0x00DCF, 0x00078, 0x001B8, 0x00152, + 0x000FE, 0x002B1, 0x0015D, 0x00160, 0xFD512, 0xFD513, 0x0007A, 0x002B0, + 0x001E5, 0x000E9, 0x000FC, 0x006E6, 0x00DC8, 0x00584, 0xFD514, 0x000AB, + 0x00DDE, 0x00159, 0x003F4, 0x00DC9, 0x00DCA, 0x001FA, 0xFD515, 0xFD516, + 0x000FC, 0x001FF, 0x001E4, 0x000AF, 0x0015A, 0x00167, 0x00DCB, 0x00585, + 0xFD517, 0x003F7, 0x03F55, 0xFD518, 0x00DDC, 0x00586, 0x03F56, 0xFD519, + 0x03F57, 0xFD51A, 0x001BA, 0x00587, 0x00588, 0x00DDF, 0x002B2, 0xFD51B, + 0x00DCE, 0x003F6, 0xFD51C, 0x00FD4, 0xFD51D, 0xFD51E, 0xFD51F, 0x7EA80, + 0x7EA81, 0x0056C, 0x7EA82, 0x7EA83, 0x00376, 0x00589, 0x0058A, 0x7EA84, + 0x7EA85, 0x00DDD, 0x7EA86, 0x7EA87, 0x0058B, 0x07EA9 + }, + { + 0x00003, 0x0000E, 0x0000F, 0x0007E, 0x00062, 0x000C6, 0x00CD9, 0x0063E, + 0x00002, 0x00002, 0x00000, 0x00018, 0x0000C, 0x00069, 0x00039, 0x00707, + 0x00C7E, 0x00002, 0x0000D, 0x0001B, 0x0000F, 0x0019A, 0x00647, 0x01A37, + 0x346C4, 0x0346D, 0x00001, 0x0001E, 0x0007F, 0x0000A, 0x000E1, 0x00661, + 0x00CE4, 0x346C5, 0x346C6, 0x0001D, 0x00030, 0x0000D, 0x000CB, 0x00199, + 0x00320, 0x0008E, 0x0652E, 0x346C7, 0x0003E, 0x00039, 0x00035, 0x00033, + 0x0019F, 0x001C0, 0x00CDA, 0x346C8, 0x346C9, 0x0000B, 0x000D0, 0x0019E, + 0x00022, 0x00038, 0x0018E, 0x0031E, 0x03294, 0x0023C, 0x00032, 0x00012, + 0x00013, 0x00071, 0x0019D, 0x00020, 0x00C87, 0x00CC0, 0x346CA, 0x00338, + 0x00653, 0x001A2, 0x0032A, 0x00322, 0x00CE7, 0x00084, 0x0011F, 0x346CB, + 0x00325, 0x00649, 0x0032B, 0x00077, 0x00648, 0x00642, 0x00C86, 0x00C8C, + 0x346CC, 0x0003A, 0x019B7, 0x00043, 0x00327, 0x0008C, 0x0008D, 0x00C8D, + 0x346CD, 0x346CE, 0x00337, 0x00CE5, 0x00085, 0x00326, 0x00347, 0x00CA4, + 0x00C7F, 0x00D1A, 0x346CF, 0x00328, 0x1A360, 0x1A361, 0x00CD8, 0x0068C, + 0x03295, 0x03296, 0x0652F, 0x066D8, 0x00331, 0x00706, 0x0023D, 0x00076, + 0x00CC1, 0x00382, 0x00CE6, 0x066D9, 0x066DA, 0x066DB + } +}; + +const uint8_t ff_vc1_2ref_mvdata_bits[8][126] = { + { + 4, 5, 5, 5, 6, 7, 8, 10, 2, 5, 5, 6, 6, 7, 8, 9, + 10, 4, 5, 6, 6, 7, 8, 9, 10, 11, 4, 6, 6, 7, 7, 9, + 9, 10, 12, 5, 8, 8, 8, 8, 9, 9, 10, 12, 5, 7, 8, 7, + 7, 8, 9, 9, 11, 7, 9, 10, 9, 10, 10, 10, 10, 12, 6, 9, + 9, 9, 9, 9, 10, 10, 11, 7, 10, 10, 11, 11, 11, 12, 12, 14, + 8, 11, 10, 11, 11, 11, 11, 12, 12, 8, 12, 11, 11, 12, 12, 12, + 12, 13, 8, 12, 11, 11, 12, 12, 12, 13, 12, 9, 14, 13, 11, 13, + 12, 13, 12, 13, 9, 13, 13, 12, 12, 13, 13, 13, 13, 13 + }, + { + 3, 4, 5, 6, 8, 10, 11, 11, 2, 5, 5, 6, 7, 8, 10, 11, + 11, 4, 5, 5, 6, 7, 9, 12, 13, 13, 4, 6, 7, 7, 9, 10, + 11, 13, 14, 5, 7, 7, 7, 8, 9, 11, 13, 13, 6, 8, 8, 8, + 8, 9, 10, 12, 13, 7, 9, 8, 8, 8, 9, 11, 12, 13, 7, 9, + 9, 9, 9, 9, 10, 11, 13, 8, 10, 10, 10, 10, 10, 11, 12, 13, + 9, 11, 11, 10, 10, 10, 11, 11, 12, 10, 12, 12, 12, 11, 11, 11, + 12, 12, 10, 13, 12, 12, 11, 11, 11, 12, 12, 10, 13, 13, 12, 13, + 11, 12, 11, 12, 10, 14, 13, 13, 12, 12, 12, 11, 11, 11 + }, + { + 4, 4, 5, 5, 6, 7, 8, 9, 2, 5, 6, 6, 6, 7, 7, 9, + 9, 4, 6, 6, 6, 7, 8, 9, 11, 12, 5, 7, 7, 7, 9, 9, + 10, 11, 12, 5, 7, 7, 7, 7, 9, 9, 10, 12, 5, 8, 8, 8, + 8, 8, 9, 10, 10, 6, 9, 8, 8, 8, 8, 9, 9, 11, 6, 10, + 10, 9, 9, 9, 9, 10, 10, 7, 11, 10, 9, 9, 10, 9, 10, 11, + 7, 10, 11, 10, 10, 10, 9, 10, 11, 8, 12, 11, 11, 10, 11, 11, + 10, 10, 8, 12, 12, 11, 11, 11, 11, 10, 11, 8, 13, 12, 12, 11, + 11, 11, 11, 10, 9, 13, 12, 12, 12, 11, 11, 10, 10, 10 + }, + { + 3, 4, 6, 7, 7, 9, 11, 11, 2, 5, 5, 6, 8, 9, 10, 11, + 13, 3, 5, 5, 7, 8, 9, 12, 14, 13, 4, 6, 6, 7, 9, 11, + 13, 14, 14, 5, 7, 7, 8, 9, 9, 13, 15, 13, 6, 8, 8, 8, + 9, 10, 12, 14, 13, 7, 10, 9, 9, 9, 9, 12, 13, 14, 7, 11, + 10, 10, 10, 10, 11, 12, 13, 8, 11, 12, 12, 12, 11, 12, 14, 15, + 9, 11, 12, 11, 12, 11, 11, 12, 13, 9, 12, 13, 13, 12, 12, 13, + 14, 14, 9, 12, 13, 13, 13, 12, 13, 12, 14, 10, 13, 13, 14, 13, + 11, 13, 14, 15, 10, 12, 13, 15, 14, 13, 13, 13, 14, 14 + }, + { + 4, 5, 5, 5, 6, 7, 8, 8, 2, 6, 6, 6, 6, 6, 8, 9, + 10, 4, 6, 6, 6, 6, 7, 9, 10, 11, 4, 7, 7, 7, 7, 7, + 9, 10, 12, 5, 7, 7, 7, 7, 7, 9, 10, 11, 6, 8, 8, 7, + 7, 7, 8, 9, 10, 6, 9, 8, 8, 7, 8, 10, 10, 11, 7, 9, + 9, 8, 8, 8, 9, 9, 10, 8, 10, 10, 9, 9, 9, 11, 11, 11, + 8, 11, 10, 10, 9, 9, 10, 11, 10, 10, 12, 12, 11, 11, 10, 11, + 12, 11, 10, 13, 12, 11, 11, 10, 10, 11, 11, 11, 15, 13, 13, 13, + 12, 12, 12, 12, 10, 15, 14, 13, 12, 12, 11, 11, 11, 11 + }, + { + 4, 5, 6, 6, 6, 7, 8, 8, 2, 4, 5, 6, 6, 7, 8, 8, + 9, 4, 6, 7, 7, 8, 8, 9, 10, 11, 5, 6, 7, 7, 8, 8, + 9, 10, 12, 5, 7, 8, 8, 8, 9, 10, 11, 12, 5, 7, 8, 8, + 8, 8, 9, 10, 11, 6, 8, 9, 8, 8, 9, 10, 11, 13, 5, 8, + 9, 8, 8, 9, 9, 10, 11, 6, 10, 10, 9, 9, 10, 10, 12, 13, + 6, 10, 10, 9, 9, 10, 10, 11, 13, 7, 11, 11, 11, 11, 11, 12, + 12, 13, 7, 11, 11, 11, 11, 11, 11, 12, 12, 9, 13, 13, 13, 13, + 12, 12, 13, 12, 9, 12, 13, 12, 12, 12, 13, 13, 12, 12 + }, + { + 3, 5, 6, 8, 9, 10, 12, 12, 1, 5, 6, 7, 8, 9, 12, 12, + 12, 4, 6, 7, 8, 9, 12, 12, 14, 21, 4, 6, 8, 9, 9, 12, + 13, 13, 14, 6, 9, 8, 8, 9, 13, 14, 13, 21, 6, 9, 9, 8, + 9, 10, 11, 12, 13, 8, 10, 10, 11, 11, 12, 12, 21, 21, 8, 11, + 10, 11, 11, 12, 13, 14, 21, 9, 13, 10, 11, 13, 13, 12, 21, 21, + 9, 12, 10, 11, 12, 12, 13, 14, 21, 11, 15, 21, 13, 14, 15, 21, + 15, 21, 10, 14, 14, 13, 13, 21, 13, 13, 21, 13, 21, 21, 21, 20, + 20, 14, 20, 20, 11, 14, 14, 20, 20, 13, 20, 20, 14, 16 + }, + { + 2, 5, 6, 8, 9, 10, 13, 13, 2, 4, 5, 6, 8, 9, 10, 13, + 14, 3, 5, 7, 8, 10, 12, 15, 20, 16, 4, 6, 8, 8, 10, 12, + 13, 20, 20, 7, 8, 8, 9, 10, 11, 12, 16, 20, 7, 8, 8, 8, + 10, 11, 13, 20, 20, 8, 10, 10, 10, 10, 11, 12, 15, 14, 8, 9, + 9, 9, 10, 10, 13, 13, 20, 11, 12, 11, 11, 11, 13, 12, 13, 20, + 11, 12, 11, 11, 12, 12, 13, 13, 20, 10, 14, 11, 11, 12, 12, 13, + 20, 20, 11, 13, 12, 11, 12, 13, 14, 14, 20, 11, 19, 19, 13, 13, + 15, 15, 16, 16, 11, 13, 14, 11, 13, 12, 13, 16, 16, 16 + } +}; + +const uint8_t wmv3_dc_scale_table[32] = { + 0, 2, 4, 8, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, + 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21 }; /* P-Picture CBPCY VLC tables */ @@ -262,6 +706,141 @@ } }; +/* Interlaced CBPCY VLC tables (Table 124 - Table 131) */ +const uint16_t ff_vc1_icbpcy_p_codes[8][63] = { + { + 0x2F1A, 0x2F1B, 0x178C, 0x0090, 0x02A8, 0x02A9, 0x0BC7, 0x0091, + 0x02AA, 0x02AB, 0x05E0, 0x004A, 0x0096, 0x0097, 0x00BD, 0x0092, + 0x02AC, 0x02AD, 0x05E1, 0x0098, 0x0132, 0x0133, 0x0179, 0x0134, + 0x026A, 0x026B, 0x02FC, 0x004E, 0x0040, 0x0041, 0x002B, 0x0093, + 0x02AE, 0x02AF, 0x05E2, 0x0136, 0x026E, 0x026F, 0x02FD, 0x009E, + 0x013E, 0x013F, 0x017F, 0x0050, 0x0042, 0x0043, 0x002C, 0x0051, + 0x00A4, 0x00A5, 0x00BE, 0x0053, 0x0044, 0x0045, 0x002D, 0x0054, + 0x0046, 0x0047, 0x002E, 0x0003, 0x0000, 0x0001, 0x0001 + }, + { + 0x0041, 0x0042, 0x0100, 0x0043, 0x0088, 0x0089, 0x0101, 0x0045, + 0x008C, 0x008D, 0x0102, 0x0010, 0x0022, 0x0023, 0x0024, 0x0047, + 0x0010, 0x0011, 0x0103, 0x0025, 0x0058, 0x0059, 0x005A, 0x005B, + 0x005A, 0x005B, 0x005C, 0x000C, 0x0030, 0x0031, 0x0019, 0x0009, + 0x0014, 0x0015, 0x002C, 0x005C, 0x005D, 0x005E, 0x005F, 0x0026, + 0x005D, 0x005E, 0x005F, 0x000D, 0x0034, 0x0035, 0x001B, 0x0014, + 0x0027, 0x002A, 0x002B, 0x000E, 0x0038, 0x0039, 0x001D, 0x000F, + 0x003C, 0x003D, 0x001F, 0x0005, 0x0009, 0x0000, 0x0003 + }, + { + 0x0032, 0x0033, 0x001A, 0x0026, 0x00E4, 0x00E5, 0x01E6, 0x0027, + 0x00E6, 0x00E7, 0x01E7, 0x000E, 0x0063, 0x006C, 0x0077, 0x0028, + 0x00E8, 0x00E9, 0x01E8, 0x007B, 0x00DA, 0x00DB, 0x00EC, 0x00F5, + 0x01B8, 0x01B9, 0x01DA, 0x0021, 0x004B, 0x0054, 0x002B, 0x0029, + 0x00EA, 0x00EB, 0x01E9, 0x004A, 0x01BA, 0x01BB, 0x01DB, 0x0020, + 0x00DE, 0x00DF, 0x00F2, 0x0022, 0x0055, 0x0058, 0x002D, 0x000F, + 0x0070, 0x0071, 0x0078, 0x0023, 0x0059, 0x005C, 0x002F, 0x0024, + 0x005D, 0x0062, 0x0030, 0x0002, 0x001F, 0x0006, 0x0000 + }, + { + 0x0028, 0x0029, 0x009D, 0x0000, 0x01EA, 0x01EB, 0x01EC, 0x0001, + 0x01ED, 0x01EE, 0x01EF, 0x0005, 0x00F0, 0x00F1, 0x003B, 0x0002, + 0x01F0, 0x01F1, 0x01F2, 0x003F, 0x015C, 0x015D, 0x0099, 0x0010, + 0x03D0, 0x03D1, 0x0130, 0x000F, 0x009E, 0x009F, 0x00FB, 0x0003, + 0x01F3, 0x01F4, 0x01F5, 0x0011, 0x03D2, 0x03D3, 0x0131, 0x0009, + 0x015E, 0x015F, 0x009C, 0x0010, 0x00A8, 0x00A9, 0x0038, 0x0006, + 0x00F2, 0x00F3, 0x004D, 0x0011, 0x00AA, 0x00AB, 0x0039, 0x0012, + 0x00AC, 0x00AD, 0x003A, 0x0006, 0x0016, 0x0017, 0x000E + }, + { + 0x003C, 0x003D, 0x001F, 0x000A, 0x0061, 0x0062, 0x0002, 0x000B, + 0x0063, 0x0064, 0x0003, 0x0007, 0x0003, 0x0004, 0x000B, 0x000C, + 0x0065, 0x0066, 0x0004, 0x0012, 0x000A, 0x000B, 0x0014, 0x001B, + 0x0018, 0x0019, 0x0034, 0x002C, 0x0067, 0x0068, 0x0035, 0x000D, + 0x0069, 0x006C, 0x0005, 0x0060, 0x001A, 0x001B, 0x0035, 0x0013, + 0x000E, 0x000F, 0x0015, 0x002D, 0x006D, 0x006E, 0x0038, 0x0008, + 0x0008, 0x0009, 0x000C, 0x002E, 0x006F, 0x0072, 0x003A, 0x002F, + 0x0073, 0x0000, 0x003B, 0x0007, 0x0014, 0x0015, 0x0004 + }, + { + 0x0038, 0x0039, 0x009D, 0x000A, 0x0091, 0x0092, 0x0093, 0x000B, + 0x0094, 0x0095, 0x0096, 0x0003, 0x00EE, 0x00EF, 0x0036, 0x000C, + 0x0097, 0x0098, 0x0099, 0x0008, 0x01E4, 0x01E5, 0x006A, 0x0018, + 0x03CC, 0x03CD, 0x00D6, 0x000E, 0x009E, 0x009F, 0x00F5, 0x000D, + 0x009A, 0x009B, 0x009C, 0x0019, 0x03CE, 0x03CF, 0x00D7, 0x0009, + 0x01E8, 0x01E9, 0x0090, 0x000F, 0x00E8, 0x00E9, 0x00F6, 0x0005, + 0x00F0, 0x00F1, 0x0037, 0x0010, 0x00EA, 0x00EB, 0x00F7, 0x0011, + 0x00EC, 0x00ED, 0x0034, 0x0000, 0x003E, 0x003F, 0x0002 + }, + { + 0x003C, 0x003D, 0x01CF, 0x0000, 0x00BF, 0x00E0, 0x01FC, 0x0001, + 0x00E1, 0x00E2, 0x01FD, 0x0009, 0x01F1, 0x01F2, 0x01F3, 0x0002, + 0x00E3, 0x00E4, 0x01FE, 0x0011, 0x03EE, 0x03EF, 0x03F0, 0x0021, + 0x07E2, 0x07E3, 0x07E4, 0x0018, 0x03F7, 0x03FE, 0x03FF, 0x0003, + 0x00E5, 0x00E6, 0x0080, 0x002E, 0x07E5, 0x07E6, 0x07E7, 0x0016, + 0x03F4, 0x03F5, 0x03F6, 0x0019, 0x0102, 0x0103, 0x0104, 0x000A, + 0x01F4, 0x01F5, 0x01F6, 0x001A, 0x0105, 0x0106, 0x0107, 0x001B, + 0x0178, 0x0179, 0x01CE, 0x001D, 0x00BD, 0x00BE, 0x01F0 + }, + { + 0x0003, 0x0004, 0x01B6, 0x0004, 0x002E, 0x002F, 0x000E, 0x0005, + 0x0030, 0x0031, 0x000F, 0x0003, 0x000A, 0x000B, 0x0014, 0x0006, + 0x0032, 0x0033, 0x0010, 0x0005, 0x0030, 0x0031, 0x0032, 0x0009, + 0x0066, 0x0067, 0x0068, 0x001D, 0x01B7, 0x01B8, 0x01B9, 0x0007, + 0x0034, 0x0035, 0x0011, 0x0016, 0x0069, 0x006A, 0x006B, 0x000A, + 0x0036, 0x0037, 0x00D8, 0x001E, 0x01BA, 0x01BB, 0x01BC, 0x0004, + 0x0015, 0x0016, 0x0017, 0x001F, 0x01BD, 0x01BE, 0x01BF, 0x0000, + 0x0010, 0x0011, 0x0012, 0x001C, 0x00D9, 0x00DA, 0x0013 + } +}; + +const uint8_t ff_vc1_icbpcy_p_bits[8][63] = { + { + 15, 15, 14, 9, 11, 11, 13, 9, 11, 11, 12, 8, 9, 9, 9, 9, + 11, 11, 12, 9, 10, 10, 10, 10, 11, 11, 11, 8, 8, 8, 7, 9, + 11, 11, 12, 10, 11, 11, 11, 9, 10, 10, 10, 8, 8, 8, 7, 8, + 9, 9, 9, 8, 8, 8, 7, 8, 8, 8, 7, 3, 3, 3, 1 + }, + { + 7, 7, 9, 7, 8, 8, 9, 7, 8, 8, 9, 6, 7, 7, 7, 7, + 7, 7, 9, 7, 8, 8, 8, 8, 9, 9, 9, 6, 7, 7, 6, 6, + 7, 7, 8, 8, 9, 9, 9, 7, 8, 8, 8, 6, 7, 7, 6, 6, + 7, 7, 7, 6, 7, 7, 6, 6, 7, 7, 6, 3, 4, 3, 2 + }, + { + 6, 6, 5, 6, 8, 8, 9, 6, 8, 8, 9, 5, 7, 7, 7, 6, + 8, 8, 9, 7, 8, 8, 8, 8, 9, 9, 9, 6, 7, 7, 6, 6, + 8, 8, 9, 7, 9, 9, 9, 6, 8, 8, 8, 6, 7, 7, 6, 5, + 7, 7, 7, 6, 7, 7, 6, 6, 7, 7, 6, 3, 5, 4, 2 + }, + { + 6, 6, 8, 4, 9, 9, 9, 4, 9, 9, 9, 4, 8, 8, 7, 4, + 9, 9, 9, 6, 9, 9, 8, 6, 10, 10, 9, 5, 8, 8, 8, 4, + 9, 9, 9, 6, 10, 10, 9, 5, 9, 9, 8, 5, 8, 8, 7, 4, + 8, 8, 7, 5, 8, 8, 7, 5, 8, 8, 7, 3, 5, 5, 4 + }, + { + 6, 6, 5, 5, 7, 7, 7, 5, 7, 7, 7, 5, 6, 6, 6, 5, + 7, 7, 7, 6, 7, 7, 7, 7, 8, 8, 8, 6, 7, 7, 6, 5, + 7, 7, 7, 7, 8, 8, 8, 6, 7, 7, 7, 6, 7, 7, 6, 5, + 6, 6, 6, 6, 7, 7, 6, 6, 7, 6, 6, 4, 5, 5, 3 + }, + { + 6, 6, 8, 4, 8, 8, 8, 4, 8, 8, 8, 4, 8, 8, 7, 4, + 8, 8, 8, 5, 9, 9, 8, 6, 10, 10, 9, 5, 8, 8, 8, 4, + 8, 8, 8, 6, 10, 10, 9, 5, 9, 9, 8, 5, 8, 8, 8, 4, + 8, 8, 7, 5, 8, 8, 8, 5, 8, 8, 7, 3, 6, 6, 4 + }, + { + 6, 6, 9, 3, 8, 8, 9, 3, 8, 8, 9, 4, 9, 9, 9, 3, + 8, 8, 9, 5, 10, 10, 10, 6, 11, 11, 11, 5, 10, 10, 10, 3, + 8, 8, 8, 6, 11, 11, 11, 5, 10, 10, 10, 5, 9, 9, 9, 4, + 9, 9, 9, 5, 9, 9, 9, 5, 9, 9, 9, 5, 8, 8, 9 + }, + { + 6, 6, 10, 3, 7, 7, 7, 3, 7, 7, 7, 4, 8, 8, 8, 3, + 7, 7, 7, 5, 9, 9, 9, 6, 10, 10, 10, 6, 10, 10, 10, 3, + 7, 7, 7, 6, 10, 10, 10, 5, 9, 9, 9, 6, 10, 10, 10, 4, + 8, 8, 8, 6, 10, 10, 10, 5, 9, 9, 9, 6, 9, 9, 9 + } +}; + /* MacroBlock Transform Type: 7.1.3.11, p89 * 8x8:B * 8x4:B:btm 8x4:B:top 8x4:B:both, @@ -332,26 +911,26 @@ /* TTBLK (Transform Type per Block) tables */ const uint8_t ff_vc1_ttblk_codes[3][8] = { - { 0, 1, 3, 5, 16, 17, 18, 19}, - { 3, 0, 1, 2, 3, 5, 8, 9}, - { 1, 0, 1, 4, 6, 7, 10, 11} + { 0, 1, 3, 5, 16, 17, 18, 19 }, + { 3, 0, 1, 2, 3, 5, 8, 9 }, + { 1, 0, 1, 4, 6, 7, 10, 11 } }; const uint8_t ff_vc1_ttblk_bits[3][8] = { - { 2, 2, 2, 3, 5, 5, 5, 5}, - { 2, 3, 3, 3, 3, 3, 4, 4}, - { 2, 3, 3, 3, 3, 3, 4, 4} + { 2, 2, 2, 3, 5, 5, 5, 5 }, + { 2, 3, 3, 3, 3, 3, 4, 4 }, + { 2, 3, 3, 3, 3, 3, 4, 4 } }; /* SUBBLKPAT tables, p93-94, reordered */ const uint8_t ff_vc1_subblkpat_codes[3][15] = { - { 14, 12, 7, 11, 9, 26, 2, 10, 27, 8, 0, 6, 1, 15, 1}, - { 14, 0, 8, 15, 10, 4, 23, 13, 5, 9, 25, 3, 24, 22, 1}, - { 5, 6, 2, 2, 8, 0, 28, 3, 1, 3, 29, 1, 19, 18, 15} + { 14, 12, 7, 11, 9, 26, 2, 10, 27, 8, 0, 6, 1, 15, 1 }, + { 14, 0, 8, 15, 10, 4, 23, 13, 5, 9, 25, 3, 24, 22, 1 }, + { 5, 6, 2, 2, 8, 0, 28, 3, 1, 3, 29, 1, 19, 18, 15 } }; const uint8_t ff_vc1_subblkpat_bits[3][15] = { - { 5, 5, 5, 5, 5, 6, 4, 5, 6, 5, 4, 5, 4, 5, 1}, - { 4, 3, 4, 4, 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 2}, - { 3, 3, 4, 3, 4, 5, 5, 3, 5, 4, 5, 4, 5, 5, 4} + { 5, 5, 5, 5, 5, 6, 4, 5, 6, 5, 4, 5, 4, 5, 1}, + { 4, 3, 4, 4, 4, 5, 5, 4, 5, 4, 5, 4, 5, 5, 2}, + { 3, 3, 4, 3, 4, 5, 5, 3, 5, 4, 5, 4, 5, 5, 4} }; /* MV differential tables, p265 */ @@ -440,83 +1019,113 @@ /* DC differentials low+hi-mo, p217 are the same as in msmpeg4data .h */ /* Table 232 */ -const int8_t ff_vc1_simple_progressive_4x4_zz [16] = -{ - 0, 8, 16, 1, - 9, 24, 17, 2, - 10, 18, 25, 3, - 11, 26, 19, 27 -}; - -const int8_t ff_vc1_adv_progressive_8x4_zz [32] = /* Table 233 */ -{ - 0, 8, 1, 16, 2, 9, 10, 3, - 24, 17, 4, 11, 18, 12, 5, 19, - 25, 13, 20, 26, 27, 6, 21, 28, - 14, 22, 29, 7, 30, 15, 23, 31 -}; - -const int8_t ff_vc1_adv_progressive_4x8_zz [32] = /* Table 234 */ -{ - 0, 1, 8, 2, - 9, 16, 17, 24, - 10, 32, 25, 18, - 40, 3, 33, 26, - 48, 11, 56, 41, - 34, 49, 57, 42, - 19, 50, 27, 58, - 35, 43, 51, 59 -}; - -const int8_t ff_vc1_adv_interlaced_8x8_zz [64] = /* Table 235 */ -{ - 0, 8, 1, 16, 24, 9, 2, 32, - 40, 48, 56, 17, 10, 3, 25, 18, - 11, 4, 33, 41, 49, 57, 26, 34, - 42, 50, 58, 19, 12, 5, 27, 20, - 13, 6, 35, 28, 21, 14, 7, 15, - 22, 29, 36, 43, 51, 59, 60, 52, - 44, 37, 30, 23, 31, 38, 45, 53, - 61, 62, 54, 46, 39, 47, 55, 63 -}; - -const int8_t ff_vc1_adv_interlaced_8x4_zz [32] = /* Table 236 */ -{ - 0, 8, 16, 24, 1, 9, 2, 17, - 25, 10, 3, 18, 26, 4, 11, 19, - 12, 5, 13, 20, 27, 6, 21, 28, - 14, 22, 29, 7, 30, 15, 23, 31 -}; - -const int8_t ff_vc1_adv_interlaced_4x8_zz [32] = /* Table 237 */ -{ - 0, 1, 2, 8, - 16, 9, 24, 17, - 10, 3, 32, 40, - 48, 56, 25, 18, - 33, 26, 41, 34, - 49, 57, 11, 42, - 19, 50, 27, 58, - 35, 43, 51, 59 -}; - -const int8_t ff_vc1_adv_interlaced_4x4_zz [16] = /* Table 238 */ -{ - 0, 8, 16, 24, - 1, 9, 17, 2, - 25, 10, 18, 3, - 26, 11, 19, 27 +const int8_t ff_vc1_simple_progressive_4x4_zz [16] = { + 0, 8, 16, 1, + 9, 24, 17, 2, + 10, 18, 25, 3, + 11, 26, 19, 27 +}; + +const int8_t ff_vc1_adv_progressive_8x4_zz [32] = { /* Table 233 */ + 0, 8, 1, 16, 2, 9, 10, 3, + 24, 17, 4, 11, 18, 12, 5, 19, + 25, 13, 20, 26, 27, 6, 21, 28, + 14, 22, 29, 7, 30, 15, 23, 31 +}; + +const int8_t ff_vc1_adv_progressive_4x8_zz [32] = { /* Table 234 */ + 0, 1, 8, 2, + 9, 16, 17, 24, + 10, 32, 25, 18, + 40, 3, 33, 26, + 48, 11, 56, 41, + 34, 49, 57, 42, + 19, 50, 27, 58, + 35, 43, 51, 59 +}; + +const int8_t ff_vc1_adv_interlaced_8x8_zz [64] = { /* Table 235 */ + 0, 8, 1, 16, 24, 9, 2, 32, + 40, 48, 56, 17, 10, 3, 25, 18, + 11, 4, 33, 41, 49, 57, 26, 34, + 42, 50, 58, 19, 12, 5, 27, 20, + 13, 6, 35, 28, 21, 14, 7, 15, + 22, 29, 36, 43, 51, 59, 60, 52, + 44, 37, 30, 23, 31, 38, 45, 53, + 61, 62, 54, 46, 39, 47, 55, 63 +}; + +const int8_t ff_vc1_adv_interlaced_8x4_zz [32] = { /* Table 236 */ + 0, 8, 16, 24, 1, 9, 2, 17, + 25, 10, 3, 18, 26, 4, 11, 19, + 12, 5, 13, 20, 27, 6, 21, 28, + 14, 22, 29, 7, 30, 15, 23, 31 +}; + +const int8_t ff_vc1_adv_interlaced_4x8_zz [32] = { /* Table 237 */ + 0, 1, 2, 8, + 16, 9, 24, 17, + 10, 3, 32, 40, + 48, 56, 25, 18, + 33, 26, 41, 34, + 49, 57, 11, 42, + 19, 50, 27, 58, + 35, 43, 51, 59 +}; + +const int8_t ff_vc1_adv_interlaced_4x4_zz [16] = { /* Table 238 */ + 0, 8, 16, 24, + 1, 9, 17, 2, + 25, 10, 18, 3, + 26, 11, 19, 27 }; /* DQScale as specified in 8.1.3.9 - almost identical to 0x40000/i */ const int32_t ff_vc1_dqscale[63] = { -0x40000, 0x20000, 0x15555, 0x10000, 0xCCCD, 0xAAAB, 0x9249, 0x8000, - 0x71C7, 0x6666, 0x5D17, 0x5555, 0x4EC5, 0x4925, 0x4444, 0x4000, - 0x3C3C, 0x38E4, 0x35E5, 0x3333, 0x30C3, 0x2E8C, 0x2C86, 0x2AAB, - 0x28F6, 0x2762, 0x25ED, 0x2492, 0x234F, 0x2222, 0x2108, 0x2000, - 0x1F08, 0x1E1E, 0x1D42, 0x1C72, 0x1BAD, 0x1AF3, 0x1A42, 0x199A, - 0x18FA, 0x1862, 0x17D0, 0x1746, 0x16C1, 0x1643, 0x15CA, 0x1555, - 0x14E6, 0x147B, 0x1414, 0x13B1, 0x1352, 0x12F7, 0x129E, 0x1249, - 0x11F7, 0x11A8, 0x115B, 0x1111, 0x10C9, 0x1084, 0x1000 + 0x40000, 0x20000, 0x15555, 0x10000, 0xCCCD, 0xAAAB, 0x9249, 0x8000, + 0x71C7, 0x6666, 0x5D17, 0x5555, 0x4EC5, 0x4925, 0x4444, 0x4000, + 0x3C3C, 0x38E4, 0x35E5, 0x3333, 0x30C3, 0x2E8C, 0x2C86, 0x2AAB, + 0x28F6, 0x2762, 0x25ED, 0x2492, 0x234F, 0x2222, 0x2108, 0x2000, + 0x1F08, 0x1E1E, 0x1D42, 0x1C72, 0x1BAD, 0x1AF3, 0x1A42, 0x199A, + 0x18FA, 0x1862, 0x17D0, 0x1746, 0x16C1, 0x1643, 0x15CA, 0x1555, + 0x14E6, 0x147B, 0x1414, 0x13B1, 0x1352, 0x12F7, 0x129E, 0x1249, + 0x11F7, 0x11A8, 0x115B, 0x1111, 0x10C9, 0x1084, 0x1000 +}; + +/* P Interlaced field picture MV predictor scaling values (Table 114) */ +const uint16_t vc1_field_mvpred_scales[2][7][4] = { +// Refdist: +// 0 1 2 3 or greater + { // current field is first + { 128, 192, 213, 224 }, // SCALEOPP + { 512, 341, 307, 293 }, // SCALESAME1 + { 219, 236, 242, 245 }, // SCALESAME2 + { 32, 48, 53, 56 }, // SCALEZONE1_X + { 8, 12, 13, 14 }, // SCALEZONE1_Y + { 37, 20, 14, 11 }, // ZONE1OFFSET_X + { 10, 5, 4, 3 } // ZONE1OFFSET_Y + }, + { // current field is second + { 128, 64, 43, 32 }, // SCALEOPP + { 512, 1024, 1536, 2048 }, // SCALESAME1 + { 219, 204, 200, 198 }, // SCALESAME2 + { 32, 16, 11, 8 }, // SCALEZONE1_X + { 8, 4, 3, 2 }, // SCALEZONE1_Y + { 37, 52, 56, 58 }, // ZONE1OFFSET_X + { 10, 13, 14, 15 } // ZONE1OFFSET_Y + } +}; + +/* B Interlaced field picture backward MV predictor scaling values for first field (Table 115) */ +const uint16_t vc1_b_field_mvpred_scales[7][4] = { + // BRFD: + // 0 1 2 3 or greater + { 171, 205, 219, 228 }, // SCALESAME + { 384, 320, 299, 288 }, // SCALEOPP1 + { 230, 239, 244, 246 }, // SCALEOPP2 + { 43, 51, 55, 57 }, // SCALEZONE1_X + { 11, 13, 14, 14 }, // SCALEZONE1_Y + { 26, 17, 12, 10 }, // ZONE1OFFSET_X + { 7, 4, 3, 3 } // ZONE1OFFSET_Y }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vc1data.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vc1data.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vc1data.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vc1data.h 2011-11-04 12:38:27.000000000 +0000 @@ -44,6 +44,9 @@ extern const int ff_vc1_fps_nr[5], ff_vc1_fps_dr[2]; extern const uint8_t ff_vc1_pquant_table[3][32]; +/* MBMODE table for interlaced frame P-picture */ +extern const uint8_t ff_vc1_mbmode_intfrp[2][15][4]; + /** @name VC-1 VLC tables and defines * @todo TODO move this into the context */ @@ -63,14 +66,32 @@ extern VLC ff_vc1_mv_diff_vlc[4]; #define VC1_CBPCY_P_VLC_BITS 9 //14 extern VLC ff_vc1_cbpcy_p_vlc[4]; +#define VC1_ICBPCY_VLC_BITS 9 +extern VLC ff_vc1_icbpcy_vlc[8]; #define VC1_4MV_BLOCK_PATTERN_VLC_BITS 6 extern VLC ff_vc1_4mv_block_pattern_vlc[4]; +#define VC1_2MV_BLOCK_PATTERN_VLC_BITS 3 +extern VLC ff_vc1_2mv_block_pattern_vlc[4]; #define VC1_TTBLK_VLC_BITS 5 extern VLC ff_vc1_ttblk_vlc[3]; #define VC1_SUBBLKPAT_VLC_BITS 6 extern VLC ff_vc1_subblkpat_vlc[3]; +#define VC1_INTFR_4MV_MBMODE_VLC_BITS 9 +extern VLC ff_vc1_intfr_4mv_mbmode_vlc[4]; +#define VC1_INTFR_NON4MV_MBMODE_VLC_BITS 6 +extern VLC ff_vc1_intfr_non4mv_mbmode_vlc[4]; +#define VC1_IF_MMV_MBMODE_VLC_BITS 5 +extern VLC ff_vc1_if_mmv_mbmode_vlc[8]; +#define VC1_IF_1MV_MBMODE_VLC_BITS 5 +extern VLC ff_vc1_if_1mv_mbmode_vlc[8]; +#define VC1_1REF_MVDATA_VLC_BITS 9 +extern VLC ff_vc1_1ref_mvdata_vlc[4]; +#define VC1_2REF_MVDATA_VLC_BITS 9 +extern VLC ff_vc1_2ref_mvdata_vlc[8]; extern VLC ff_vc1_ac_coeff_table[8]; + +#define VC1_IF_MBMODE_VLC_BITS 5 //@} @@ -101,12 +122,20 @@ extern const uint8_t ff_vc1_4mv_block_pattern_codes[4][16]; extern const uint8_t ff_vc1_4mv_block_pattern_bits[4][16]; +/* 2MV Block pattern VLC tables */ +extern const uint8_t ff_vc1_2mv_block_pattern_codes[4][4]; +extern const uint8_t ff_vc1_2mv_block_pattern_bits[4][4]; + extern const uint8_t wmv3_dc_scale_table[32]; /* P-Picture CBPCY VLC tables */ extern const uint16_t ff_vc1_cbpcy_p_codes[4][64]; extern const uint8_t ff_vc1_cbpcy_p_bits[4][64]; +/* Interlaced CBPCY VLC tables (Table 124 - Table 131) */ +extern const uint16_t ff_vc1_icbpcy_p_codes[8][63]; +extern const uint8_t ff_vc1_icbpcy_p_bits[8][63]; + /* MacroBlock Transform Type: 7.1.3.11, p89 * 8x8:B * 8x4:B:btm 8x4:B:top 8x4:B:both, @@ -131,6 +160,26 @@ extern const uint16_t ff_vc1_mv_diff_codes[4][73]; extern const uint8_t ff_vc1_mv_diff_bits[4][73]; +/* Interlaced frame picture MBMODE VLC tables (p. 246, p. 360) */ +extern const uint16_t ff_vc1_intfr_4mv_mbmode_codes[4][15]; +extern const uint8_t ff_vc1_intfr_4mv_mbmode_bits[4][15]; +extern const uint8_t ff_vc1_intfr_non4mv_mbmode_codes[4][9]; +extern const uint8_t ff_vc1_intfr_non4mv_mbmode_bits[4][9]; + +/* Interlaced field picture MBMODE VLC tables (p. 356 - 11.4.1, 11.4.2) */ +extern const uint8_t ff_vc1_if_mmv_mbmode_codes[8][8]; +extern const uint8_t ff_vc1_if_mmv_mbmode_bits[8][8]; +extern const uint8_t ff_vc1_if_1mv_mbmode_codes[8][6]; +extern const uint8_t ff_vc1_if_1mv_mbmode_bits[8][6]; + +/* Interlaced frame/field picture MVDATA VLC tables */ +/* 1-reference tables */ +extern const uint32_t ff_vc1_1ref_mvdata_codes[4][72]; +extern const uint8_t ff_vc1_1ref_mvdata_bits[4][72]; +/* 2-reference tables */ +extern const uint32_t ff_vc1_2ref_mvdata_codes[8][126]; +extern const uint8_t ff_vc1_2ref_mvdata_bits[8][126]; + /* DC differentials low+hi-mo, p217 are the same as in msmpeg4data .h */ /* Scantables/ZZ scan are at 11.9 (p262) and 8.1.1.12 (p10) */ @@ -141,8 +190,14 @@ extern const int8_t ff_vc1_adv_interlaced_8x4_zz [32]; extern const int8_t ff_vc1_adv_interlaced_4x8_zz [32]; extern const int8_t ff_vc1_adv_interlaced_4x4_zz [16]; +extern const int8_t ff_vc1_intra_horz_8x8_zz [64]; +extern const int8_t ff_vc1_intra_vert_8x8_zz [64]; /* DQScale as specified in 8.1.3.9 - almost identical to 0x40000/i */ extern const int32_t ff_vc1_dqscale[63]; +/* P Interlaced field picture MV predictor scaling values (Table 114) */ +extern const uint16_t vc1_field_mvpred_scales[2][7][4]; +/* B Interlaced field picture backward MV predictor scaling values for first field (Table 115) */ +extern const uint16_t vc1_b_field_mvpred_scales[7][4]; #endif /* AVCODEC_VC1DATA_H */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vc1dec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vc1dec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vc1dec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vc1dec.c 2011-11-04 12:38:27.000000000 +0000 @@ -1,5 +1,6 @@ /* * VC-1 and WMV3 decoder + * Copyright (c) 2011 Mashiat Sarker Shakkhar * Copyright (c) 2006-2007 Konstantin Shishkov * Partly based on vc9.c (c) 2005 Anonymous, Alex Beregszaszi, Michael Niedermayer * @@ -23,8 +24,8 @@ /** * @file * VC-1 and WMV3 decoder - * */ + #include "internal.h" #include "dsputil.h" #include "avcodec.h" @@ -48,11 +49,19 @@ static const uint16_t vlc_offs[] = { - 0, 520, 552, 616, 1128, 1160, 1224, 1740, 1772, 1836, 1900, 2436, - 2986, 3050, 3610, 4154, 4218, 4746, 5326, 5390, 5902, 6554, 7658, 8620, - 9262, 10202, 10756, 11310, 12228, 15078 + 0, 520, 552, 616, 1128, 1160, 1224, 1740, 1772, 1836, 1900, 2436, + 2986, 3050, 3610, 4154, 4218, 4746, 5326, 5390, 5902, 6554, 7658, 8342, + 9304, 9988, 10630, 11234, 12174, 13006, 13560, 14232, 14786, 15432, 16350, 17522, + 20372, 21818, 22330, 22394, 23166, 23678, 23742, 24820, 25332, 25396, 26460, 26980, + 27048, 27592, 27600, 27608, 27616, 27624, 28224, 28258, 28290, 28802, 28834, 28866, + 29378, 29412, 29444, 29960, 29994, 30026, 30538, 30572, 30604, 31120, 31154, 31186, + 31714, 31746, 31778, 32306, 32340, 32372 }; +// offset tables for interlaced picture MVDATA decoding +static const int offset_table1[9] = { 0, 1, 2, 4, 8, 16, 32, 64, 128 }; +static const int offset_table2[9] = { 0, 1, 3, 7, 15, 31, 63, 127, 255 }; + /** * Init VC-1 specific tables and VC1Context members * @param v The VC1Context to initialize @@ -62,73 +71,123 @@ { static int done = 0; int i = 0; - static VLC_TYPE vlc_table[15078][2]; + static VLC_TYPE vlc_table[32372][2]; v->hrd_rate = v->hrd_buffer = NULL; /* VLC tables */ - if(!done) - { + if (!done) { INIT_VLC_STATIC(&ff_vc1_bfraction_vlc, VC1_BFRACTION_VLC_BITS, 23, - ff_vc1_bfraction_bits, 1, 1, - ff_vc1_bfraction_codes, 1, 1, 1 << VC1_BFRACTION_VLC_BITS); + ff_vc1_bfraction_bits, 1, 1, + ff_vc1_bfraction_codes, 1, 1, 1 << VC1_BFRACTION_VLC_BITS); INIT_VLC_STATIC(&ff_vc1_norm2_vlc, VC1_NORM2_VLC_BITS, 4, - ff_vc1_norm2_bits, 1, 1, - ff_vc1_norm2_codes, 1, 1, 1 << VC1_NORM2_VLC_BITS); + ff_vc1_norm2_bits, 1, 1, + ff_vc1_norm2_codes, 1, 1, 1 << VC1_NORM2_VLC_BITS); INIT_VLC_STATIC(&ff_vc1_norm6_vlc, VC1_NORM6_VLC_BITS, 64, - ff_vc1_norm6_bits, 1, 1, - ff_vc1_norm6_codes, 2, 2, 556); + ff_vc1_norm6_bits, 1, 1, + ff_vc1_norm6_codes, 2, 2, 556); INIT_VLC_STATIC(&ff_vc1_imode_vlc, VC1_IMODE_VLC_BITS, 7, - ff_vc1_imode_bits, 1, 1, - ff_vc1_imode_codes, 1, 1, 1 << VC1_IMODE_VLC_BITS); - for (i=0; i<3; i++) - { - ff_vc1_ttmb_vlc[i].table = &vlc_table[vlc_offs[i*3+0]]; - ff_vc1_ttmb_vlc[i].table_allocated = vlc_offs[i*3+1] - vlc_offs[i*3+0]; + ff_vc1_imode_bits, 1, 1, + ff_vc1_imode_codes, 1, 1, 1 << VC1_IMODE_VLC_BITS); + for (i = 0; i < 3; i++) { + ff_vc1_ttmb_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 0]]; + ff_vc1_ttmb_vlc[i].table_allocated = vlc_offs[i * 3 + 1] - vlc_offs[i * 3 + 0]; init_vlc(&ff_vc1_ttmb_vlc[i], VC1_TTMB_VLC_BITS, 16, ff_vc1_ttmb_bits[i], 1, 1, ff_vc1_ttmb_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); - ff_vc1_ttblk_vlc[i].table = &vlc_table[vlc_offs[i*3+1]]; - ff_vc1_ttblk_vlc[i].table_allocated = vlc_offs[i*3+2] - vlc_offs[i*3+1]; + ff_vc1_ttblk_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 1]]; + ff_vc1_ttblk_vlc[i].table_allocated = vlc_offs[i * 3 + 2] - vlc_offs[i * 3 + 1]; init_vlc(&ff_vc1_ttblk_vlc[i], VC1_TTBLK_VLC_BITS, 8, ff_vc1_ttblk_bits[i], 1, 1, ff_vc1_ttblk_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC); - ff_vc1_subblkpat_vlc[i].table = &vlc_table[vlc_offs[i*3+2]]; - ff_vc1_subblkpat_vlc[i].table_allocated = vlc_offs[i*3+3] - vlc_offs[i*3+2]; + ff_vc1_subblkpat_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 2]]; + ff_vc1_subblkpat_vlc[i].table_allocated = vlc_offs[i * 3 + 3] - vlc_offs[i * 3 + 2]; init_vlc(&ff_vc1_subblkpat_vlc[i], VC1_SUBBLKPAT_VLC_BITS, 15, ff_vc1_subblkpat_bits[i], 1, 1, ff_vc1_subblkpat_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC); } - for(i=0; i<4; i++) - { - ff_vc1_4mv_block_pattern_vlc[i].table = &vlc_table[vlc_offs[i*3+9]]; - ff_vc1_4mv_block_pattern_vlc[i].table_allocated = vlc_offs[i*3+10] - vlc_offs[i*3+9]; + for (i = 0; i < 4; i++) { + ff_vc1_4mv_block_pattern_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 9]]; + ff_vc1_4mv_block_pattern_vlc[i].table_allocated = vlc_offs[i * 3 + 10] - vlc_offs[i * 3 + 9]; init_vlc(&ff_vc1_4mv_block_pattern_vlc[i], VC1_4MV_BLOCK_PATTERN_VLC_BITS, 16, ff_vc1_4mv_block_pattern_bits[i], 1, 1, ff_vc1_4mv_block_pattern_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC); - ff_vc1_cbpcy_p_vlc[i].table = &vlc_table[vlc_offs[i*3+10]]; - ff_vc1_cbpcy_p_vlc[i].table_allocated = vlc_offs[i*3+11] - vlc_offs[i*3+10]; + ff_vc1_cbpcy_p_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 10]]; + ff_vc1_cbpcy_p_vlc[i].table_allocated = vlc_offs[i * 3 + 11] - vlc_offs[i * 3 + 10]; init_vlc(&ff_vc1_cbpcy_p_vlc[i], VC1_CBPCY_P_VLC_BITS, 64, ff_vc1_cbpcy_p_bits[i], 1, 1, ff_vc1_cbpcy_p_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); - ff_vc1_mv_diff_vlc[i].table = &vlc_table[vlc_offs[i*3+11]]; - ff_vc1_mv_diff_vlc[i].table_allocated = vlc_offs[i*3+12] - vlc_offs[i*3+11]; + ff_vc1_mv_diff_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 11]]; + ff_vc1_mv_diff_vlc[i].table_allocated = vlc_offs[i * 3 + 12] - vlc_offs[i * 3 + 11]; init_vlc(&ff_vc1_mv_diff_vlc[i], VC1_MV_DIFF_VLC_BITS, 73, ff_vc1_mv_diff_bits[i], 1, 1, ff_vc1_mv_diff_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); } - for(i=0; i<8; i++){ - ff_vc1_ac_coeff_table[i].table = &vlc_table[vlc_offs[i+21]]; - ff_vc1_ac_coeff_table[i].table_allocated = vlc_offs[i+22] - vlc_offs[i+21]; + for (i = 0; i < 8; i++) { + ff_vc1_ac_coeff_table[i].table = &vlc_table[vlc_offs[i * 2 + 21]]; + ff_vc1_ac_coeff_table[i].table_allocated = vlc_offs[i * 2 + 22] - vlc_offs[i * 2 + 21]; init_vlc(&ff_vc1_ac_coeff_table[i], AC_VLC_BITS, vc1_ac_sizes[i], &vc1_ac_tables[i][0][1], 8, 4, &vc1_ac_tables[i][0][0], 8, 4, INIT_VLC_USE_NEW_STATIC); + /* initialize interlaced MVDATA tables (2-Ref) */ + ff_vc1_2ref_mvdata_vlc[i].table = &vlc_table[vlc_offs[i * 2 + 22]]; + ff_vc1_2ref_mvdata_vlc[i].table_allocated = vlc_offs[i * 2 + 23] - vlc_offs[i * 2 + 22]; + init_vlc(&ff_vc1_2ref_mvdata_vlc[i], VC1_2REF_MVDATA_VLC_BITS, 126, + ff_vc1_2ref_mvdata_bits[i], 1, 1, + ff_vc1_2ref_mvdata_codes[i], 4, 4, INIT_VLC_USE_NEW_STATIC); + } + for (i = 0; i < 4; i++) { + /* initialize 4MV MBMODE VLC tables for interlaced frame P picture */ + ff_vc1_intfr_4mv_mbmode_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 37]]; + ff_vc1_intfr_4mv_mbmode_vlc[i].table_allocated = vlc_offs[i * 3 + 38] - vlc_offs[i * 3 + 37]; + init_vlc(&ff_vc1_intfr_4mv_mbmode_vlc[i], VC1_INTFR_4MV_MBMODE_VLC_BITS, 15, + ff_vc1_intfr_4mv_mbmode_bits[i], 1, 1, + ff_vc1_intfr_4mv_mbmode_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); + /* initialize NON-4MV MBMODE VLC tables for the same */ + ff_vc1_intfr_non4mv_mbmode_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 38]]; + ff_vc1_intfr_non4mv_mbmode_vlc[i].table_allocated = vlc_offs[i * 3 + 39] - vlc_offs[i * 3 + 38]; + init_vlc(&ff_vc1_intfr_non4mv_mbmode_vlc[i], VC1_INTFR_NON4MV_MBMODE_VLC_BITS, 9, + ff_vc1_intfr_non4mv_mbmode_bits[i], 1, 1, + ff_vc1_intfr_non4mv_mbmode_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC); + /* initialize interlaced MVDATA tables (1-Ref) */ + ff_vc1_1ref_mvdata_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 39]]; + ff_vc1_1ref_mvdata_vlc[i].table_allocated = vlc_offs[i * 3 + 40] - vlc_offs[i * 3 + 39]; + init_vlc(&ff_vc1_1ref_mvdata_vlc[i], VC1_1REF_MVDATA_VLC_BITS, 72, + ff_vc1_1ref_mvdata_bits[i], 1, 1, + ff_vc1_1ref_mvdata_codes[i], 4, 4, INIT_VLC_USE_NEW_STATIC); + } + for (i = 0; i < 4; i++) { + /* Initialize 2MV Block pattern VLC tables */ + ff_vc1_2mv_block_pattern_vlc[i].table = &vlc_table[vlc_offs[i + 49]]; + ff_vc1_2mv_block_pattern_vlc[i].table_allocated = vlc_offs[i + 50] - vlc_offs[i + 49]; + init_vlc(&ff_vc1_2mv_block_pattern_vlc[i], VC1_2MV_BLOCK_PATTERN_VLC_BITS, 4, + ff_vc1_2mv_block_pattern_bits[i], 1, 1, + ff_vc1_2mv_block_pattern_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC); + } + for (i = 0; i < 8; i++) { + /* Initialize interlaced CBPCY VLC tables (Table 124 - Table 131) */ + ff_vc1_icbpcy_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 53]]; + ff_vc1_icbpcy_vlc[i].table_allocated = vlc_offs[i * 3 + 54] - vlc_offs[i * 3 + 53]; + init_vlc(&ff_vc1_icbpcy_vlc[i], VC1_ICBPCY_VLC_BITS, 63, + ff_vc1_icbpcy_p_bits[i], 1, 1, + ff_vc1_icbpcy_p_codes[i], 2, 2, INIT_VLC_USE_NEW_STATIC); + /* Initialize interlaced field picture MBMODE VLC tables */ + ff_vc1_if_mmv_mbmode_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 54]]; + ff_vc1_if_mmv_mbmode_vlc[i].table_allocated = vlc_offs[i * 3 + 55] - vlc_offs[i * 3 + 54]; + init_vlc(&ff_vc1_if_mmv_mbmode_vlc[i], VC1_IF_MMV_MBMODE_VLC_BITS, 8, + ff_vc1_if_mmv_mbmode_bits[i], 1, 1, + ff_vc1_if_mmv_mbmode_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC); + ff_vc1_if_1mv_mbmode_vlc[i].table = &vlc_table[vlc_offs[i * 3 + 55]]; + ff_vc1_if_1mv_mbmode_vlc[i].table_allocated = vlc_offs[i * 3 + 56] - vlc_offs[i * 3 + 55]; + init_vlc(&ff_vc1_if_1mv_mbmode_vlc[i], VC1_IF_1MV_MBMODE_VLC_BITS, 6, + ff_vc1_if_1mv_mbmode_bits[i], 1, 1, + ff_vc1_if_1mv_mbmode_codes[i], 1, 1, INIT_VLC_USE_NEW_STATIC); } done = 1; } /* Other defaults */ - v->pq = -1; + v->pq = -1; v->mvrange = 0; /* 7.1.1.18, p80 */ return 0; @@ -162,6 +221,9 @@ static void vc1_put_signed_blocks_clamped(VC1Context *v) { MpegEncContext *s = &v->s; + int topleft_mb_pos, top_mb_pos; + int stride_y, fieldtx; + int v_dist; /* The put pixels loop is always one MB row behind the decoding loop, * because we can only put pixels when overlap filtering is done, and @@ -172,18 +234,22 @@ * of the right MB edge, we need the next MB present. */ if (!s->first_slice_line) { if (s->mb_x) { + topleft_mb_pos = (s->mb_y - 1) * s->mb_stride + s->mb_x - 1; + fieldtx = v->fieldtx_plane[topleft_mb_pos]; + stride_y = (s->linesize) << fieldtx; + v_dist = (16 - fieldtx) >> (fieldtx == 0); s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][0], s->dest[0] - 16 * s->linesize - 16, - s->linesize); + stride_y); s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][1], s->dest[0] - 16 * s->linesize - 8, - s->linesize); + stride_y); s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][2], - s->dest[0] - 8 * s->linesize - 16, - s->linesize); + s->dest[0] - v_dist * s->linesize - 16, + stride_y); s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][3], - s->dest[0] - 8 * s->linesize - 8, - s->linesize); + s->dest[0] - v_dist * s->linesize - 8, + stride_y); s->dsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][4], s->dest[1] - 8 * s->uvlinesize - 8, s->uvlinesize); @@ -192,18 +258,22 @@ s->uvlinesize); } if (s->mb_x == s->mb_width - 1) { + top_mb_pos = (s->mb_y - 1) * s->mb_stride + s->mb_x; + fieldtx = v->fieldtx_plane[top_mb_pos]; + stride_y = s->linesize << fieldtx; + v_dist = fieldtx ? 15 : 8; s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][0], s->dest[0] - 16 * s->linesize, - s->linesize); + stride_y); s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][1], s->dest[0] - 16 * s->linesize + 8, - s->linesize); + stride_y); s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][2], - s->dest[0] - 8 * s->linesize, - s->linesize); + s->dest[0] - v_dist * s->linesize, + stride_y); s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][3], - s->dest[0] - 8 * s->linesize + 8, - s->linesize); + s->dest[0] - v_dist * s->linesize + 8, + stride_y); s->dsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][4], s->dest[1] - 8 * s->uvlinesize, s->uvlinesize); @@ -232,17 +302,17 @@ if (!s->first_slice_line) { v->vc1dsp.vc1_v_loop_filter16(s->dest[0], s->linesize, pq); if (s->mb_x) - v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 16*s->linesize, s->linesize, pq); - v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 16*s->linesize+8, s->linesize, pq); - for(j = 0; j < 2; j++){ - v->vc1dsp.vc1_v_loop_filter8(s->dest[j+1], s->uvlinesize, pq); + v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 16 * s->linesize, s->linesize, pq); + v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 16 * s->linesize + 8, s->linesize, pq); + for (j = 0; j < 2; j++) { + v->vc1dsp.vc1_v_loop_filter8(s->dest[j + 1], s->uvlinesize, pq); if (s->mb_x) - v->vc1dsp.vc1_h_loop_filter8(s->dest[j+1]-8*s->uvlinesize, s->uvlinesize, pq); + v->vc1dsp.vc1_h_loop_filter8(s->dest[j + 1] - 8 * s->uvlinesize, s->uvlinesize, pq); } } - v->vc1dsp.vc1_v_loop_filter16(s->dest[0] + 8*s->linesize, s->linesize, pq); + v->vc1dsp.vc1_v_loop_filter16(s->dest[0] + 8 * s->linesize, s->linesize, pq); - if (s->mb_y == s->end_mb_y-1) { + if (s->mb_y == s->end_mb_y - 1) { if (s->mb_x) { v->vc1dsp.vc1_h_loop_filter16(s->dest[0], s->linesize, pq); v->vc1dsp.vc1_h_loop_filter8(s->dest[1], s->uvlinesize, pq); @@ -267,10 +337,10 @@ if (s->mb_x >= 2) v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 32 * s->linesize - 16, s->linesize, pq); v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 32 * s->linesize - 8, s->linesize, pq); - for(j = 0; j < 2; j++) { - v->vc1dsp.vc1_v_loop_filter8(s->dest[j+1] - 8 * s->uvlinesize - 8, s->uvlinesize, pq); + for (j = 0; j < 2; j++) { + v->vc1dsp.vc1_v_loop_filter8(s->dest[j + 1] - 8 * s->uvlinesize - 8, s->uvlinesize, pq); if (s->mb_x >= 2) { - v->vc1dsp.vc1_h_loop_filter8(s->dest[j+1] - 16 * s->uvlinesize - 8, s->uvlinesize, pq); + v->vc1dsp.vc1_h_loop_filter8(s->dest[j + 1] - 16 * s->uvlinesize - 8, s->uvlinesize, pq); } } } @@ -284,10 +354,10 @@ if (s->mb_x) v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 32 * s->linesize, s->linesize, pq); v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 32 * s->linesize + 8, s->linesize, pq); - for(j = 0; j < 2; j++) { - v->vc1dsp.vc1_v_loop_filter8(s->dest[j+1] - 8 * s->uvlinesize, s->uvlinesize, pq); + for (j = 0; j < 2; j++) { + v->vc1dsp.vc1_v_loop_filter8(s->dest[j + 1] - 8 * s->uvlinesize, s->uvlinesize, pq); if (s->mb_x >= 2) { - v->vc1dsp.vc1_h_loop_filter8(s->dest[j+1] - 16 * s->uvlinesize, s->uvlinesize, pq); + v->vc1dsp.vc1_h_loop_filter8(s->dest[j + 1] - 16 * s->uvlinesize, s->uvlinesize, pq); } } } @@ -300,8 +370,8 @@ v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 16 * s->linesize - 16, s->linesize, pq); v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 16 * s->linesize - 8, s->linesize, pq); if (s->mb_x >= 2) { - for(j = 0; j < 2; j++) { - v->vc1dsp.vc1_h_loop_filter8(s->dest[j+1] - 8 * s->uvlinesize - 8, s->uvlinesize, pq); + for (j = 0; j < 2; j++) { + v->vc1dsp.vc1_h_loop_filter8(s->dest[j + 1] - 8 * s->uvlinesize - 8, s->uvlinesize, pq); } } } @@ -311,8 +381,8 @@ v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 16 * s->linesize, s->linesize, pq); v->vc1dsp.vc1_h_loop_filter16(s->dest[0] - 16 * s->linesize + 8, s->linesize, pq); if (s->mb_x) { - for(j = 0; j < 2; j++) { - v->vc1dsp.vc1_h_loop_filter8(s->dest[j+1] - 8 * s->uvlinesize, s->uvlinesize, pq); + for (j = 0; j < 2; j++) { + v->vc1dsp.vc1_h_loop_filter8(s->dest[j + 1] - 8 * s->uvlinesize, s->uvlinesize, pq); } } } @@ -337,14 +407,14 @@ * running the V overlap. Therefore, the V overlap makes us trail by one * MB col and the H overlap filter makes us trail by one MB row. This * is reflected in the time at which we run the put_pixels loop. */ - if(v->condover == CONDOVER_ALL || v->pq >= 9 || v->over_flags_plane[mb_pos]) { - if(s->mb_x && (v->condover == CONDOVER_ALL || v->pq >= 9 || - v->over_flags_plane[mb_pos - 1])) { + if (v->condover == CONDOVER_ALL || v->pq >= 9 || v->over_flags_plane[mb_pos]) { + if (s->mb_x && (v->condover == CONDOVER_ALL || v->pq >= 9 || + v->over_flags_plane[mb_pos - 1])) { v->vc1dsp.vc1_h_s_overlap(v->block[v->left_blk_idx][1], v->block[v->cur_blk_idx][0]); v->vc1dsp.vc1_h_s_overlap(v->block[v->left_blk_idx][3], v->block[v->cur_blk_idx][2]); - if(!(s->flags & CODEC_FLAG_GRAY)) { + if (!(s->flags & CODEC_FLAG_GRAY)) { v->vc1dsp.vc1_h_s_overlap(v->block[v->left_blk_idx][4], v->block[v->cur_blk_idx][4]); v->vc1dsp.vc1_h_s_overlap(v->block[v->left_blk_idx][5], @@ -357,13 +427,13 @@ v->block[v->cur_blk_idx][3]); if (s->mb_x == s->mb_width - 1) { - if(!s->first_slice_line && (v->condover == CONDOVER_ALL || v->pq >= 9 || - v->over_flags_plane[mb_pos - s->mb_stride])) { + if (!s->first_slice_line && (v->condover == CONDOVER_ALL || v->pq >= 9 || + v->over_flags_plane[mb_pos - s->mb_stride])) { v->vc1dsp.vc1_v_s_overlap(v->block[v->top_blk_idx][2], v->block[v->cur_blk_idx][0]); v->vc1dsp.vc1_v_s_overlap(v->block[v->top_blk_idx][3], v->block[v->cur_blk_idx][1]); - if(!(s->flags & CODEC_FLAG_GRAY)) { + if (!(s->flags & CODEC_FLAG_GRAY)) { v->vc1dsp.vc1_v_s_overlap(v->block[v->top_blk_idx][4], v->block[v->cur_blk_idx][4]); v->vc1dsp.vc1_v_s_overlap(v->block[v->top_blk_idx][5], @@ -377,13 +447,13 @@ } } if (s->mb_x && (v->condover == CONDOVER_ALL || v->over_flags_plane[mb_pos - 1])) { - if(!s->first_slice_line && (v->condover == CONDOVER_ALL || v->pq >= 9 || - v->over_flags_plane[mb_pos - s->mb_stride - 1])) { + if (!s->first_slice_line && (v->condover == CONDOVER_ALL || v->pq >= 9 || + v->over_flags_plane[mb_pos - s->mb_stride - 1])) { v->vc1dsp.vc1_v_s_overlap(v->block[v->topleft_blk_idx][2], v->block[v->left_blk_idx][0]); v->vc1dsp.vc1_v_s_overlap(v->block[v->topleft_blk_idx][3], v->block[v->left_blk_idx][1]); - if(!(s->flags & CODEC_FLAG_GRAY)) { + if (!(s->flags & CODEC_FLAG_GRAY)) { v->vc1dsp.vc1_v_s_overlap(v->block[v->topleft_blk_idx][4], v->block[v->left_blk_idx][4]); v->vc1dsp.vc1_v_s_overlap(v->block[v->topleft_blk_idx][5], @@ -403,371 +473,669 @@ static void vc1_mc_1mv(VC1Context *v, int dir) { MpegEncContext *s = &v->s; - DSPContext *dsp = &v->s.dsp; + DSPContext *dsp = &v->s.dsp; uint8_t *srcY, *srcU, *srcV; int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y; - - if(!v->s.last_picture.f.data[0])return; + int off, off_uv; + int v_edge_pos = s->v_edge_pos >> v->field_mode; + if (!v->field_mode && !v->s.last_picture.f.data[0]) + return; mx = s->mv[dir][0][0]; my = s->mv[dir][0][1]; // store motion vectors for further use in B frames - if(s->pict_type == AV_PICTURE_TYPE_P) { - s->current_picture.f.motion_val[1][s->block_index[0]][0] = mx; - s->current_picture.f.motion_val[1][s->block_index[0]][1] = my; + if (s->pict_type == AV_PICTURE_TYPE_P) { + s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][0] = mx; + s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][1] = my; } + uvmx = (mx + ((mx & 3) == 3)) >> 1; uvmy = (my + ((my & 3) == 3)) >> 1; v->luma_mv[s->mb_x][0] = uvmx; v->luma_mv[s->mb_x][1] = uvmy; - if(v->fastuvmc) { - uvmx = uvmx + ((uvmx<0)?(uvmx&1):-(uvmx&1)); - uvmy = uvmy + ((uvmy<0)?(uvmy&1):-(uvmy&1)); - } - if(!dir) { - srcY = s->last_picture.f.data[0]; - srcU = s->last_picture.f.data[1]; - srcV = s->last_picture.f.data[2]; + + if (v->field_mode && + v->cur_field_type != v->ref_field_type[dir]) { + my = my - 2 + 4 * v->cur_field_type; + uvmy = uvmy - 2 + 4 * v->cur_field_type; + } + + if (v->fastuvmc && (v->fcm != 1)) { // fastuvmc shall be ignored for interlaced frame picture + uvmx = uvmx + ((uvmx < 0) ? (uvmx & 1) : -(uvmx & 1)); + uvmy = uvmy + ((uvmy < 0) ? (uvmy & 1) : -(uvmy & 1)); + } + if (v->field_mode) { // interlaced field picture + if (!dir) { + if ((v->cur_field_type != v->ref_field_type[dir]) && v->cur_field_type) { + srcY = s->current_picture.f.data[0]; + srcU = s->current_picture.f.data[1]; + srcV = s->current_picture.f.data[2]; + } else { + srcY = s->last_picture.f.data[0]; + srcU = s->last_picture.f.data[1]; + srcV = s->last_picture.f.data[2]; + } + } else { + srcY = s->next_picture.f.data[0]; + srcU = s->next_picture.f.data[1]; + srcV = s->next_picture.f.data[2]; + } } else { - srcY = s->next_picture.f.data[0]; - srcU = s->next_picture.f.data[1]; - srcV = s->next_picture.f.data[2]; + if (!dir) { + srcY = s->last_picture.f.data[0]; + srcU = s->last_picture.f.data[1]; + srcV = s->last_picture.f.data[2]; + } else { + srcY = s->next_picture.f.data[0]; + srcU = s->next_picture.f.data[1]; + srcV = s->next_picture.f.data[2]; + } } - src_x = s->mb_x * 16 + (mx >> 2); - src_y = s->mb_y * 16 + (my >> 2); - uvsrc_x = s->mb_x * 8 + (uvmx >> 2); - uvsrc_y = s->mb_y * 8 + (uvmy >> 2); + src_x = s->mb_x * 16 + (mx >> 2); + src_y = s->mb_y * 16 + (my >> 2); + uvsrc_x = s->mb_x * 8 + (uvmx >> 2); + uvsrc_y = s->mb_y * 8 + (uvmy >> 2); - if(v->profile != PROFILE_ADVANCED){ + if (v->profile != PROFILE_ADVANCED) { src_x = av_clip( src_x, -16, s->mb_width * 16); src_y = av_clip( src_y, -16, s->mb_height * 16); uvsrc_x = av_clip(uvsrc_x, -8, s->mb_width * 8); uvsrc_y = av_clip(uvsrc_y, -8, s->mb_height * 8); - }else{ + } else { src_x = av_clip( src_x, -17, s->avctx->coded_width); src_y = av_clip( src_y, -18, s->avctx->coded_height + 1); uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width >> 1); uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1); } - srcY += src_y * s->linesize + src_x; + srcY += src_y * s->linesize + src_x; srcU += uvsrc_y * s->uvlinesize + uvsrc_x; srcV += uvsrc_y * s->uvlinesize + uvsrc_x; + if (v->field_mode && v->ref_field_type[dir]) { + srcY += s->current_picture_ptr->f.linesize[0]; + srcU += s->current_picture_ptr->f.linesize[1]; + srcV += s->current_picture_ptr->f.linesize[2]; + } + /* for grayscale we should not try to read from unknown area */ - if(s->flags & CODEC_FLAG_GRAY) { + if (s->flags & CODEC_FLAG_GRAY) { srcU = s->edge_emu_buffer + 18 * s->linesize; srcV = s->edge_emu_buffer + 18 * s->linesize; } - if(v->rangeredfrm || (v->mv_mode == MV_PMODE_INTENSITY_COMP) - || (unsigned)(src_x - s->mspel) > s->h_edge_pos - (mx&3) - 16 - s->mspel*3 - || (unsigned)(src_y - s->mspel) > s->v_edge_pos - (my&3) - 16 - s->mspel*3){ - uint8_t *uvbuf= s->edge_emu_buffer + 19 * s->linesize; + if (v->rangeredfrm || (v->mv_mode == MV_PMODE_INTENSITY_COMP) + || (unsigned)(src_x - s->mspel) > s->h_edge_pos - (mx&3) - 16 - s->mspel * 3 + || (unsigned)(src_y - s->mspel) > v_edge_pos - (my&3) - 16 - s->mspel * 3) { + uint8_t *uvbuf = s->edge_emu_buffer + 19 * s->linesize; srcY -= s->mspel * (1 + s->linesize); - s->dsp.emulated_edge_mc(s->edge_emu_buffer, srcY, s->linesize, 17+s->mspel*2, 17+s->mspel*2, - src_x - s->mspel, src_y - s->mspel, s->h_edge_pos, s->v_edge_pos); + s->dsp.emulated_edge_mc(s->edge_emu_buffer, srcY, s->linesize, + 17 + s->mspel * 2, 17 + s->mspel * 2, + src_x - s->mspel, src_y - s->mspel, + s->h_edge_pos, v_edge_pos); srcY = s->edge_emu_buffer; - s->dsp.emulated_edge_mc(uvbuf , srcU, s->uvlinesize, 8+1, 8+1, - uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, s->v_edge_pos >> 1); - s->dsp.emulated_edge_mc(uvbuf + 16, srcV, s->uvlinesize, 8+1, 8+1, - uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, s->v_edge_pos >> 1); + s->dsp.emulated_edge_mc(uvbuf , srcU, s->uvlinesize, 8 + 1, 8 + 1, + uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, v_edge_pos >> 1); + s->dsp.emulated_edge_mc(uvbuf + 16, srcV, s->uvlinesize, 8 + 1, 8 + 1, + uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, v_edge_pos >> 1); srcU = uvbuf; srcV = uvbuf + 16; /* if we deal with range reduction we need to scale source blocks */ - if(v->rangeredfrm) { + if (v->rangeredfrm) { int i, j; uint8_t *src, *src2; src = srcY; - for(j = 0; j < 17 + s->mspel*2; j++) { - for(i = 0; i < 17 + s->mspel*2; i++) src[i] = ((src[i] - 128) >> 1) + 128; + for (j = 0; j < 17 + s->mspel * 2; j++) { + for (i = 0; i < 17 + s->mspel * 2; i++) + src[i] = ((src[i] - 128) >> 1) + 128; src += s->linesize; } - src = srcU; src2 = srcV; - for(j = 0; j < 9; j++) { - for(i = 0; i < 9; i++) { - src[i] = ((src[i] - 128) >> 1) + 128; + src = srcU; + src2 = srcV; + for (j = 0; j < 9; j++) { + for (i = 0; i < 9; i++) { + src[i] = ((src[i] - 128) >> 1) + 128; src2[i] = ((src2[i] - 128) >> 1) + 128; } - src += s->uvlinesize; + src += s->uvlinesize; src2 += s->uvlinesize; } } /* if we deal with intensity compensation we need to scale source blocks */ - if(v->mv_mode == MV_PMODE_INTENSITY_COMP) { + if (v->mv_mode == MV_PMODE_INTENSITY_COMP) { int i, j; uint8_t *src, *src2; src = srcY; - for(j = 0; j < 17 + s->mspel*2; j++) { - for(i = 0; i < 17 + s->mspel*2; i++) src[i] = v->luty[src[i]]; + for (j = 0; j < 17 + s->mspel * 2; j++) { + for (i = 0; i < 17 + s->mspel * 2; i++) + src[i] = v->luty[src[i]]; src += s->linesize; } - src = srcU; src2 = srcV; - for(j = 0; j < 9; j++) { - for(i = 0; i < 9; i++) { - src[i] = v->lutuv[src[i]]; + src = srcU; + src2 = srcV; + for (j = 0; j < 9; j++) { + for (i = 0; i < 9; i++) { + src[i] = v->lutuv[src[i]]; src2[i] = v->lutuv[src2[i]]; } - src += s->uvlinesize; + src += s->uvlinesize; src2 += s->uvlinesize; } } srcY += s->mspel * (1 + s->linesize); } - if(s->mspel) { + if (v->field_mode && v->cur_field_type) { + off = s->current_picture_ptr->f.linesize[0]; + off_uv = s->current_picture_ptr->f.linesize[1]; + } else { + off = 0; + off_uv = 0; + } + if (s->mspel) { dxy = ((my & 3) << 2) | (mx & 3); - v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] , srcY , s->linesize, v->rnd); - v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + 8, srcY + 8, s->linesize, v->rnd); + v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + off , srcY , s->linesize, v->rnd); + v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + off + 8, srcY + 8, s->linesize, v->rnd); srcY += s->linesize * 8; - v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + 8 * s->linesize , srcY , s->linesize, v->rnd); - v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + 8 * s->linesize + 8, srcY + 8, s->linesize, v->rnd); + v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + off + 8 * s->linesize , srcY , s->linesize, v->rnd); + v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + off + 8 * s->linesize + 8, srcY + 8, s->linesize, v->rnd); } else { // hpel mc - always used for luma dxy = (my & 2) | ((mx & 2) >> 1); - - if(!v->rnd) - dsp->put_pixels_tab[0][dxy](s->dest[0], srcY, s->linesize, 16); + if (!v->rnd) + dsp->put_pixels_tab[0][dxy](s->dest[0] + off, srcY, s->linesize, 16); else - dsp->put_no_rnd_pixels_tab[0][dxy](s->dest[0], srcY, s->linesize, 16); + dsp->put_no_rnd_pixels_tab[0][dxy](s->dest[0] + off, srcY, s->linesize, 16); } - if(s->flags & CODEC_FLAG_GRAY) return; + if (s->flags & CODEC_FLAG_GRAY) return; /* Chroma MC always uses qpel bilinear */ - uvmx = (uvmx&3)<<1; - uvmy = (uvmy&3)<<1; - if(!v->rnd){ - dsp->put_h264_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy); - dsp->put_h264_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy); - }else{ - v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy); - v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy); + uvmx = (uvmx & 3) << 1; + uvmy = (uvmy & 3) << 1; + if (!v->rnd) { + dsp->put_h264_chroma_pixels_tab[0](s->dest[1] + off_uv, srcU, s->uvlinesize, 8, uvmx, uvmy); + dsp->put_h264_chroma_pixels_tab[0](s->dest[2] + off_uv, srcV, s->uvlinesize, 8, uvmx, uvmy); + } else { + v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1] + off_uv, srcU, s->uvlinesize, 8, uvmx, uvmy); + v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2] + off_uv, srcV, s->uvlinesize, 8, uvmx, uvmy); + } +} + +static inline int median4(int a, int b, int c, int d) +{ + if (a < b) { + if (c < d) return (FFMIN(b, d) + FFMAX(a, c)) / 2; + else return (FFMIN(b, c) + FFMAX(a, d)) / 2; + } else { + if (c < d) return (FFMIN(a, d) + FFMAX(b, c)) / 2; + else return (FFMIN(a, c) + FFMAX(b, d)) / 2; } } /** Do motion compensation for 4-MV macroblock - luminance block */ -static void vc1_mc_4mv_luma(VC1Context *v, int n) +static void vc1_mc_4mv_luma(VC1Context *v, int n, int dir) { MpegEncContext *s = &v->s; DSPContext *dsp = &v->s.dsp; uint8_t *srcY; int dxy, mx, my, src_x, src_y; int off; + int fieldmv = (v->fcm == 1) ? v->blk_mv_type[s->block_index[n]] : 0; + int v_edge_pos = s->v_edge_pos >> v->field_mode; - if(!v->s.last_picture.f.data[0])return; - mx = s->mv[0][n][0]; - my = s->mv[0][n][1]; - srcY = s->last_picture.f.data[0]; + if (!v->field_mode && !v->s.last_picture.f.data[0]) + return; - off = s->linesize * 4 * (n&2) + (n&1) * 8; + mx = s->mv[dir][n][0]; + my = s->mv[dir][n][1]; - src_x = s->mb_x * 16 + (n&1) * 8 + (mx >> 2); - src_y = s->mb_y * 16 + (n&2) * 4 + (my >> 2); + if (!dir) { + if (v->field_mode) { + if ((v->cur_field_type != v->ref_field_type[dir]) && v->cur_field_type) + srcY = s->current_picture.f.data[0]; + else + srcY = s->last_picture.f.data[0]; + } else + srcY = s->last_picture.f.data[0]; + } else + srcY = s->next_picture.f.data[0]; - if(v->profile != PROFILE_ADVANCED){ - src_x = av_clip( src_x, -16, s->mb_width * 16); - src_y = av_clip( src_y, -16, s->mb_height * 16); - }else{ - src_x = av_clip( src_x, -17, s->avctx->coded_width); - src_y = av_clip( src_y, -18, s->avctx->coded_height + 1); + if (v->field_mode) { + if (v->cur_field_type != v->ref_field_type[dir]) + my = my - 2 + 4 * v->cur_field_type; + } + + if (s->pict_type == AV_PICTURE_TYPE_P && n == 3 && v->field_mode) { + int same_count = 0, opp_count = 0, k; + int chosen_mv[2][4][2], f; + int tx, ty; + for (k = 0; k < 4; k++) { + f = v->mv_f[0][s->block_index[k] + v->blocks_off]; + chosen_mv[f][f ? opp_count : same_count][0] = s->mv[0][k][0]; + chosen_mv[f][f ? opp_count : same_count][1] = s->mv[0][k][1]; + opp_count += f; + same_count += 1 - f; + } + f = opp_count > same_count; + switch (f ? opp_count : same_count) { + case 4: + tx = median4(chosen_mv[f][0][0], chosen_mv[f][1][0], + chosen_mv[f][2][0], chosen_mv[f][3][0]); + ty = median4(chosen_mv[f][0][1], chosen_mv[f][1][1], + chosen_mv[f][2][1], chosen_mv[f][3][1]); + break; + case 3: + tx = mid_pred(chosen_mv[f][0][0], chosen_mv[f][1][0], chosen_mv[f][2][0]); + ty = mid_pred(chosen_mv[f][0][1], chosen_mv[f][1][1], chosen_mv[f][2][1]); + break; + case 2: + tx = (chosen_mv[f][0][0] + chosen_mv[f][1][0]) / 2; + ty = (chosen_mv[f][0][1] + chosen_mv[f][1][1]) / 2; + break; + } + s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][0] = tx; + s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][1] = ty; + for (k = 0; k < 4; k++) + v->mv_f[1][s->block_index[k] + v->blocks_off] = f; + } + + if (v->fcm == 1) { // not sure if needed for other types of picture + int qx, qy; + int width = s->avctx->coded_width; + int height = s->avctx->coded_height >> 1; + qx = (s->mb_x * 16) + (mx >> 2); + qy = (s->mb_y * 8) + (my >> 3); + + if (qx < -17) + mx -= 4 * (qx + 17); + else if (qx > width) + mx -= 4 * (qx - width); + if (qy < -18) + my -= 8 * (qy + 18); + else if (qy > height + 1) + my -= 8 * (qy - height - 1); + } + + if ((v->fcm == 1) && fieldmv) + off = ((n > 1) ? s->linesize : 0) + (n & 1) * 8; + else + off = s->linesize * 4 * (n & 2) + (n & 1) * 8; + if (v->field_mode && v->cur_field_type) + off += s->current_picture_ptr->f.linesize[0]; + + src_x = s->mb_x * 16 + (n & 1) * 8 + (mx >> 2); + if (!fieldmv) + src_y = s->mb_y * 16 + (n & 2) * 4 + (my >> 2); + else + src_y = s->mb_y * 16 + ((n > 1) ? 1 : 0) + (my >> 2); + + if (v->profile != PROFILE_ADVANCED) { + src_x = av_clip(src_x, -16, s->mb_width * 16); + src_y = av_clip(src_y, -16, s->mb_height * 16); + } else { + src_x = av_clip(src_x, -17, s->avctx->coded_width); + if (v->fcm == 1) { + if (src_y & 1) + src_y = av_clip(src_y, -17, s->avctx->coded_height + 1); + else + src_y = av_clip(src_y, -18, s->avctx->coded_height); + } else { + src_y = av_clip(src_y, -18, s->avctx->coded_height + 1); + } } srcY += src_y * s->linesize + src_x; + if (v->field_mode && v->ref_field_type[dir]) + srcY += s->current_picture_ptr->f.linesize[0]; - if(v->rangeredfrm || (v->mv_mode == MV_PMODE_INTENSITY_COMP) - || (unsigned)(src_x - s->mspel) > s->h_edge_pos - (mx&3) - 8 - s->mspel*2 - || (unsigned)(src_y - s->mspel) > s->v_edge_pos - (my&3) - 8 - s->mspel*2){ - srcY -= s->mspel * (1 + s->linesize); - s->dsp.emulated_edge_mc(s->edge_emu_buffer, srcY, s->linesize, 9+s->mspel*2, 9+s->mspel*2, - src_x - s->mspel, src_y - s->mspel, s->h_edge_pos, s->v_edge_pos); + if (fieldmv && !(src_y & 1)) + v_edge_pos--; + if (fieldmv && (src_y & 1) && src_y < 4) + src_y--; + if (v->rangeredfrm || (v->mv_mode == MV_PMODE_INTENSITY_COMP) + || (unsigned)(src_x - s->mspel) > s->h_edge_pos - (mx & 3) - 8 - s->mspel * 2 + || (unsigned)(src_y - (s->mspel << fieldmv)) > v_edge_pos - (my & 3) - ((8 + s->mspel * 2) << fieldmv)) { + srcY -= s->mspel * (1 + (s->linesize << fieldmv)); + /* check emulate edge stride and offset */ + s->dsp.emulated_edge_mc(s->edge_emu_buffer, srcY, s->linesize, + 9 + s->mspel * 2, (9 + s->mspel * 2) << fieldmv, + src_x - s->mspel, src_y - (s->mspel << fieldmv), + s->h_edge_pos, v_edge_pos); srcY = s->edge_emu_buffer; /* if we deal with range reduction we need to scale source blocks */ - if(v->rangeredfrm) { + if (v->rangeredfrm) { int i, j; uint8_t *src; src = srcY; - for(j = 0; j < 9 + s->mspel*2; j++) { - for(i = 0; i < 9 + s->mspel*2; i++) src[i] = ((src[i] - 128) >> 1) + 128; - src += s->linesize; + for (j = 0; j < 9 + s->mspel * 2; j++) { + for (i = 0; i < 9 + s->mspel * 2; i++) + src[i] = ((src[i] - 128) >> 1) + 128; + src += s->linesize << fieldmv; } } /* if we deal with intensity compensation we need to scale source blocks */ - if(v->mv_mode == MV_PMODE_INTENSITY_COMP) { + if (v->mv_mode == MV_PMODE_INTENSITY_COMP) { int i, j; uint8_t *src; src = srcY; - for(j = 0; j < 9 + s->mspel*2; j++) { - for(i = 0; i < 9 + s->mspel*2; i++) src[i] = v->luty[src[i]]; - src += s->linesize; + for (j = 0; j < 9 + s->mspel * 2; j++) { + for (i = 0; i < 9 + s->mspel * 2; i++) + src[i] = v->luty[src[i]]; + src += s->linesize << fieldmv; } } - srcY += s->mspel * (1 + s->linesize); + srcY += s->mspel * (1 + (s->linesize << fieldmv)); } - if(s->mspel) { + if (s->mspel) { dxy = ((my & 3) << 2) | (mx & 3); - v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + off, srcY, s->linesize, v->rnd); + v->vc1dsp.put_vc1_mspel_pixels_tab[dxy](s->dest[0] + off, srcY, s->linesize << fieldmv, v->rnd); } else { // hpel mc - always used for luma dxy = (my & 2) | ((mx & 2) >> 1); - if(!v->rnd) + if (!v->rnd) dsp->put_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize, 8); else dsp->put_no_rnd_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize, 8); } } -static inline int median4(int a, int b, int c, int d) +static av_always_inline int get_chroma_mv(int *mvx, int *mvy, int *a, int flag, int *tx, int *ty) { - if(a < b) { - if(c < d) return (FFMIN(b, d) + FFMAX(a, c)) / 2; - else return (FFMIN(b, c) + FFMAX(a, d)) / 2; + int idx, i; + static const int count[16] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4}; + + idx = ((a[3] != flag) << 3) + | ((a[2] != flag) << 2) + | ((a[1] != flag) << 1) + | (a[0] != flag); + if (!idx) { + *tx = median4(mvx[0], mvx[1], mvx[2], mvx[3]); + *ty = median4(mvy[0], mvy[1], mvy[2], mvy[3]); + return 4; + } else if (count[idx] == 1) { + switch (idx) { + case 0x1: + *tx = mid_pred(mvx[1], mvx[2], mvx[3]); + *ty = mid_pred(mvy[1], mvy[2], mvy[3]); + return 3; + case 0x2: + *tx = mid_pred(mvx[0], mvx[2], mvx[3]); + *ty = mid_pred(mvy[0], mvy[2], mvy[3]); + return 3; + case 0x4: + *tx = mid_pred(mvx[0], mvx[1], mvx[3]); + *ty = mid_pred(mvy[0], mvy[1], mvy[3]); + return 3; + case 0x8: + *tx = mid_pred(mvx[0], mvx[1], mvx[2]); + *ty = mid_pred(mvy[0], mvy[1], mvy[2]); + return 3; + } + } else if (count[idx] == 2) { + int t1 = 0, t2 = 0; + for (i = 0; i < 3; i++) + if (!a[i]) { + t1 = i; + break; + } + for (i = t1 + 1; i < 4; i++) + if (!a[i]) { + t2 = i; + break; + } + *tx = (mvx[t1] + mvx[t2]) / 2; + *ty = (mvy[t1] + mvy[t2]) / 2; + return 2; } else { - if(c < d) return (FFMIN(a, d) + FFMAX(b, c)) / 2; - else return (FFMIN(a, c) + FFMAX(b, d)) / 2; + return 0; } + return -1; } - /** Do motion compensation for 4-MV macroblock - both chroma blocks */ -static void vc1_mc_4mv_chroma(VC1Context *v) +static void vc1_mc_4mv_chroma(VC1Context *v, int dir) { MpegEncContext *s = &v->s; - DSPContext *dsp = &v->s.dsp; + DSPContext *dsp = &v->s.dsp; uint8_t *srcU, *srcV; int uvmx, uvmy, uvsrc_x, uvsrc_y; - int i, idx, tx = 0, ty = 0; - int mvx[4], mvy[4], intra[4]; - static const int count[16] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4}; + int k, tx = 0, ty = 0; + int mvx[4], mvy[4], intra[4], mv_f[4]; + int valid_count; + int chroma_ref_type = v->cur_field_type, off = 0; + int v_edge_pos = s->v_edge_pos >> v->field_mode; - if(!v->s.last_picture.f.data[0])return; - if(s->flags & CODEC_FLAG_GRAY) return; + if (!v->field_mode && !v->s.last_picture.f.data[0]) + return; + if (s->flags & CODEC_FLAG_GRAY) + return; - for(i = 0; i < 4; i++) { - mvx[i] = s->mv[0][i][0]; - mvy[i] = s->mv[0][i][1]; - intra[i] = v->mb_type[0][s->block_index[i]]; + for (k = 0; k < 4; k++) { + mvx[k] = s->mv[dir][k][0]; + mvy[k] = s->mv[dir][k][1]; + intra[k] = v->mb_type[0][s->block_index[k]]; + if (v->field_mode) + mv_f[k] = v->mv_f[dir][s->block_index[k] + v->blocks_off]; } /* calculate chroma MV vector from four luma MVs */ - idx = (intra[3] << 3) | (intra[2] << 2) | (intra[1] << 1) | intra[0]; - if(!idx) { // all blocks are inter - tx = median4(mvx[0], mvx[1], mvx[2], mvx[3]); - ty = median4(mvy[0], mvy[1], mvy[2], mvy[3]); - } else if(count[idx] == 1) { // 3 inter blocks - switch(idx) { - case 0x1: - tx = mid_pred(mvx[1], mvx[2], mvx[3]); - ty = mid_pred(mvy[1], mvy[2], mvy[3]); - break; - case 0x2: - tx = mid_pred(mvx[0], mvx[2], mvx[3]); - ty = mid_pred(mvy[0], mvy[2], mvy[3]); - break; - case 0x4: - tx = mid_pred(mvx[0], mvx[1], mvx[3]); - ty = mid_pred(mvy[0], mvy[1], mvy[3]); - break; - case 0x8: - tx = mid_pred(mvx[0], mvx[1], mvx[2]); - ty = mid_pred(mvy[0], mvy[1], mvy[2]); - break; + if (!v->field_mode || (v->field_mode && !v->numref)) { + valid_count = get_chroma_mv(mvx, mvy, intra, 0, &tx, &ty); + if (!valid_count) { + s->current_picture.f.motion_val[1][s->block_index[0]][0] = 0; + s->current_picture.f.motion_val[1][s->block_index[0]][1] = 0; + v->luma_mv[s->mb_x][0] = v->luma_mv[s->mb_x][1] = 0; + return; //no need to do MC for intra blocks } - } else if(count[idx] == 2) { - int t1 = 0, t2 = 0; - for(i=0; i<3;i++) if(!intra[i]) {t1 = i; break;} - for(i= t1+1; i<4; i++)if(!intra[i]) {t2 = i; break;} - tx = (mvx[t1] + mvx[t2]) / 2; - ty = (mvy[t1] + mvy[t2]) / 2; } else { - s->current_picture.f.motion_val[1][s->block_index[0]][0] = 0; - s->current_picture.f.motion_val[1][s->block_index[0]][1] = 0; - v->luma_mv[s->mb_x][0] = v->luma_mv[s->mb_x][1] = 0; - return; //no need to do MC for inter blocks + int dominant = 0; + if (mv_f[0] + mv_f[1] + mv_f[2] + mv_f[3] > 2) + dominant = 1; + valid_count = get_chroma_mv(mvx, mvy, mv_f, dominant, &tx, &ty); + if (dominant) + chroma_ref_type = !v->cur_field_type; } - s->current_picture.f.motion_val[1][s->block_index[0]][0] = tx; s->current_picture.f.motion_val[1][s->block_index[0]][1] = ty; - uvmx = (tx + ((tx&3) == 3)) >> 1; - uvmy = (ty + ((ty&3) == 3)) >> 1; + uvmx = (tx + ((tx & 3) == 3)) >> 1; + uvmy = (ty + ((ty & 3) == 3)) >> 1; + v->luma_mv[s->mb_x][0] = uvmx; v->luma_mv[s->mb_x][1] = uvmy; - if(v->fastuvmc) { - uvmx = uvmx + ((uvmx<0)?(uvmx&1):-(uvmx&1)); - uvmy = uvmy + ((uvmy<0)?(uvmy&1):-(uvmy&1)); - } + + if (v->fastuvmc) { + uvmx = uvmx + ((uvmx < 0) ? (uvmx & 1) : -(uvmx & 1)); + uvmy = uvmy + ((uvmy < 0) ? (uvmy & 1) : -(uvmy & 1)); + } + // Field conversion bias + if (v->cur_field_type != chroma_ref_type) + uvmy += 2 - 4 * chroma_ref_type; uvsrc_x = s->mb_x * 8 + (uvmx >> 2); uvsrc_y = s->mb_y * 8 + (uvmy >> 2); - if(v->profile != PROFILE_ADVANCED){ - uvsrc_x = av_clip(uvsrc_x, -8, s->mb_width * 8); - uvsrc_y = av_clip(uvsrc_y, -8, s->mb_height * 8); - }else{ - uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width >> 1); - uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1); + if (v->profile != PROFILE_ADVANCED) { + uvsrc_x = av_clip(uvsrc_x, -8, s->mb_width * 8); + uvsrc_y = av_clip(uvsrc_y, -8, s->mb_height * 8); + } else { + uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width >> 1); + uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1); + } + + if (!dir) { + if (v->field_mode) { + if ((v->cur_field_type != chroma_ref_type) && v->cur_field_type) { + srcU = s->current_picture.f.data[1] + uvsrc_y * s->uvlinesize + uvsrc_x; + srcV = s->current_picture.f.data[2] + uvsrc_y * s->uvlinesize + uvsrc_x; + } else { + srcU = s->last_picture.f.data[1] + uvsrc_y * s->uvlinesize + uvsrc_x; + srcV = s->last_picture.f.data[2] + uvsrc_y * s->uvlinesize + uvsrc_x; + } + } else { + srcU = s->last_picture.f.data[1] + uvsrc_y * s->uvlinesize + uvsrc_x; + srcV = s->last_picture.f.data[2] + uvsrc_y * s->uvlinesize + uvsrc_x; + } + } else { + srcU = s->next_picture.f.data[1] + uvsrc_y * s->uvlinesize + uvsrc_x; + srcV = s->next_picture.f.data[2] + uvsrc_y * s->uvlinesize + uvsrc_x; } - srcU = s->last_picture.f.data[1] + uvsrc_y * s->uvlinesize + uvsrc_x; - srcV = s->last_picture.f.data[2] + uvsrc_y * s->uvlinesize + uvsrc_x; - if(v->rangeredfrm || (v->mv_mode == MV_PMODE_INTENSITY_COMP) - || (unsigned)uvsrc_x > (s->h_edge_pos >> 1) - 9 - || (unsigned)uvsrc_y > (s->v_edge_pos >> 1) - 9){ - s->dsp.emulated_edge_mc(s->edge_emu_buffer , srcU, s->uvlinesize, 8+1, 8+1, - uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, s->v_edge_pos >> 1); - s->dsp.emulated_edge_mc(s->edge_emu_buffer + 16, srcV, s->uvlinesize, 8+1, 8+1, - uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, s->v_edge_pos >> 1); + if (v->field_mode) { + if (chroma_ref_type) { + srcU += s->current_picture_ptr->f.linesize[1]; + srcV += s->current_picture_ptr->f.linesize[2]; + } + off = v->cur_field_type ? s->current_picture_ptr->f.linesize[1] : 0; + } + + if (v->rangeredfrm || (v->mv_mode == MV_PMODE_INTENSITY_COMP) + || (unsigned)uvsrc_x > (s->h_edge_pos >> 1) - 9 + || (unsigned)uvsrc_y > (v_edge_pos >> 1) - 9) { + s->dsp.emulated_edge_mc(s->edge_emu_buffer , srcU, s->uvlinesize, + 8 + 1, 8 + 1, uvsrc_x, uvsrc_y, + s->h_edge_pos >> 1, v_edge_pos >> 1); + s->dsp.emulated_edge_mc(s->edge_emu_buffer + 16, srcV, s->uvlinesize, + 8 + 1, 8 + 1, uvsrc_x, uvsrc_y, + s->h_edge_pos >> 1, v_edge_pos >> 1); srcU = s->edge_emu_buffer; srcV = s->edge_emu_buffer + 16; /* if we deal with range reduction we need to scale source blocks */ - if(v->rangeredfrm) { + if (v->rangeredfrm) { int i, j; uint8_t *src, *src2; - src = srcU; src2 = srcV; - for(j = 0; j < 9; j++) { - for(i = 0; i < 9; i++) { - src[i] = ((src[i] - 128) >> 1) + 128; + src = srcU; + src2 = srcV; + for (j = 0; j < 9; j++) { + for (i = 0; i < 9; i++) { + src[i] = ((src[i] - 128) >> 1) + 128; src2[i] = ((src2[i] - 128) >> 1) + 128; } - src += s->uvlinesize; + src += s->uvlinesize; src2 += s->uvlinesize; } } /* if we deal with intensity compensation we need to scale source blocks */ - if(v->mv_mode == MV_PMODE_INTENSITY_COMP) { + if (v->mv_mode == MV_PMODE_INTENSITY_COMP) { int i, j; uint8_t *src, *src2; - src = srcU; src2 = srcV; - for(j = 0; j < 9; j++) { - for(i = 0; i < 9; i++) { - src[i] = v->lutuv[src[i]]; + src = srcU; + src2 = srcV; + for (j = 0; j < 9; j++) { + for (i = 0; i < 9; i++) { + src[i] = v->lutuv[src[i]]; src2[i] = v->lutuv[src2[i]]; } - src += s->uvlinesize; + src += s->uvlinesize; src2 += s->uvlinesize; } } } /* Chroma MC always uses qpel bilinear */ - uvmx = (uvmx&3)<<1; - uvmy = (uvmy&3)<<1; - if(!v->rnd){ - dsp->put_h264_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy); - dsp->put_h264_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy); - }else{ - v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy); - v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy); + uvmx = (uvmx & 3) << 1; + uvmy = (uvmy & 3) << 1; + if (!v->rnd) { + dsp->put_h264_chroma_pixels_tab[0](s->dest[1] + off, srcU, s->uvlinesize, 8, uvmx, uvmy); + dsp->put_h264_chroma_pixels_tab[0](s->dest[2] + off, srcV, s->uvlinesize, 8, uvmx, uvmy); + } else { + v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1] + off, srcU, s->uvlinesize, 8, uvmx, uvmy); + v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2] + off, srcV, s->uvlinesize, 8, uvmx, uvmy); + } +} + +/** Do motion compensation for 4-MV field chroma macroblock (both U and V) + */ +static void vc1_mc_4mv_chroma4(VC1Context *v) +{ + MpegEncContext *s = &v->s; + DSPContext *dsp = &v->s.dsp; + uint8_t *srcU, *srcV; + int uvsrc_x, uvsrc_y; + int uvmx_field[4], uvmy_field[4]; + int i, off, tx, ty; + int fieldmv = v->blk_mv_type[s->block_index[0]]; + static const int s_rndtblfield[16] = { 0, 0, 1, 2, 4, 4, 5, 6, 2, 2, 3, 8, 6, 6, 7, 12 }; + int v_dist = fieldmv ? 1 : 4; // vertical offset for lower sub-blocks + int v_edge_pos = s->v_edge_pos >> 1; + + if (!v->s.last_picture.f.data[0]) + return; + if (s->flags & CODEC_FLAG_GRAY) + return; + + for (i = 0; i < 4; i++) { + tx = s->mv[0][i][0]; + uvmx_field[i] = (tx + ((tx & 3) == 3)) >> 1; + ty = s->mv[0][i][1]; + if (fieldmv) + uvmy_field[i] = (ty >> 4) * 8 + s_rndtblfield[ty & 0xF]; + else + uvmy_field[i] = (ty + ((ty & 3) == 3)) >> 1; + } + + for (i = 0; i < 4; i++) { + off = (i & 1) * 4 + ((i & 2) ? v_dist * s->uvlinesize : 0); + uvsrc_x = s->mb_x * 8 + (i & 1) * 4 + (uvmx_field[i] >> 2); + uvsrc_y = s->mb_y * 8 + ((i & 2) ? v_dist : 0) + (uvmy_field[i] >> 2); + // FIXME: implement proper pull-back (see vc1cropmv.c, vc1CROPMV_ChromaPullBack()) + uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width >> 1); + uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1); + srcU = s->last_picture.f.data[1] + uvsrc_y * s->uvlinesize + uvsrc_x; + srcV = s->last_picture.f.data[2] + uvsrc_y * s->uvlinesize + uvsrc_x; + uvmx_field[i] = (uvmx_field[i] & 3) << 1; + uvmy_field[i] = (uvmy_field[i] & 3) << 1; + + if (fieldmv && !(uvsrc_y & 1)) + v_edge_pos--; + if (fieldmv && (uvsrc_y & 1) && uvsrc_y < 2) + uvsrc_y--; + if ((v->mv_mode == MV_PMODE_INTENSITY_COMP) + || (unsigned)uvsrc_x > (s->h_edge_pos >> 1) - 5 + || (unsigned)uvsrc_y > v_edge_pos - (5 << fieldmv)) { + s->dsp.emulated_edge_mc(s->edge_emu_buffer, srcU, s->uvlinesize, + 5, (5 << fieldmv), uvsrc_x, uvsrc_y, + s->h_edge_pos >> 1, v_edge_pos); + s->dsp.emulated_edge_mc(s->edge_emu_buffer + 16, srcV, s->uvlinesize, + 5, (5 << fieldmv), uvsrc_x, uvsrc_y, + s->h_edge_pos >> 1, v_edge_pos); + srcU = s->edge_emu_buffer; + srcV = s->edge_emu_buffer + 16; + + /* if we deal with intensity compensation we need to scale source blocks */ + if (v->mv_mode == MV_PMODE_INTENSITY_COMP) { + int i, j; + uint8_t *src, *src2; + + src = srcU; + src2 = srcV; + for (j = 0; j < 5; j++) { + for (i = 0; i < 5; i++) { + src[i] = v->lutuv[src[i]]; + src2[i] = v->lutuv[src2[i]]; + } + src += s->uvlinesize << 1; + src2 += s->uvlinesize << 1; + } + } + } + if (!v->rnd) { + dsp->put_h264_chroma_pixels_tab[1](s->dest[1] + off, srcU, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]); + dsp->put_h264_chroma_pixels_tab[1](s->dest[2] + off, srcV, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]); + } else { + v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[1](s->dest[1] + off, srcU, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]); + v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[1](s->dest[2] + off, srcV, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]); + } } } @@ -783,37 +1151,34 @@ * @brief Get macroblock-level quantizer scale */ #define GET_MQUANT() \ - if (v->dquantfrm) \ - { \ - int edges = 0; \ - if (v->dqprofile == DQPROFILE_ALL_MBS) \ - { \ - if (v->dqbilevel) \ - { \ - mquant = (get_bits1(gb)) ? v->altpq : v->pq; \ - } \ - else \ - { \ - mqdiff = get_bits(gb, 3); \ - if (mqdiff != 7) mquant = v->pq + mqdiff; \ - else mquant = get_bits(gb, 5); \ - } \ - } \ - if(v->dqprofile == DQPROFILE_SINGLE_EDGE) \ - edges = 1 << v->dqsbedge; \ - else if(v->dqprofile == DQPROFILE_DOUBLE_EDGES) \ - edges = (3 << v->dqsbedge) % 15; \ - else if(v->dqprofile == DQPROFILE_FOUR_EDGES) \ - edges = 15; \ - if((edges&1) && !s->mb_x) \ - mquant = v->altpq; \ - if((edges&2) && s->first_slice_line) \ - mquant = v->altpq; \ - if((edges&4) && s->mb_x == (s->mb_width - 1)) \ - mquant = v->altpq; \ - if((edges&8) && s->mb_y == (s->mb_height - 1)) \ - mquant = v->altpq; \ - } + if (v->dquantfrm) { \ + int edges = 0; \ + if (v->dqprofile == DQPROFILE_ALL_MBS) { \ + if (v->dqbilevel) { \ + mquant = (get_bits1(gb)) ? v->altpq : v->pq; \ + } else { \ + mqdiff = get_bits(gb, 3); \ + if (mqdiff != 7) \ + mquant = v->pq + mqdiff; \ + else \ + mquant = get_bits(gb, 5); \ + } \ + } \ + if (v->dqprofile == DQPROFILE_SINGLE_EDGE) \ + edges = 1 << v->dqsbedge; \ + else if (v->dqprofile == DQPROFILE_DOUBLE_EDGES) \ + edges = (3 << v->dqsbedge) % 15; \ + else if (v->dqprofile == DQPROFILE_FOUR_EDGES) \ + edges = 15; \ + if ((edges&1) && !s->mb_x) \ + mquant = v->altpq; \ + if ((edges&2) && s->first_slice_line) \ + mquant = v->altpq; \ + if ((edges&4) && s->mb_x == (s->mb_width - 1)) \ + mquant = v->altpq; \ + if ((edges&8) && s->mb_y == (s->mb_height - 1)) \ + mquant = v->altpq; \ + } /** * @def GET_MVDATA(_dmv_x, _dmv_y) @@ -822,96 +1187,340 @@ * @param _dmv_x Horizontal differential for decoded MV * @param _dmv_y Vertical differential for decoded MV */ -#define GET_MVDATA(_dmv_x, _dmv_y) \ - index = 1 + get_vlc2(gb, ff_vc1_mv_diff_vlc[s->mv_table_index].table,\ - VC1_MV_DIFF_VLC_BITS, 2); \ - if (index > 36) \ - { \ - mb_has_coeffs = 1; \ - index -= 37; \ - } \ - else mb_has_coeffs = 0; \ - s->mb_intra = 0; \ - if (!index) { _dmv_x = _dmv_y = 0; } \ - else if (index == 35) \ - { \ - _dmv_x = get_bits(gb, v->k_x - 1 + s->quarter_sample); \ - _dmv_y = get_bits(gb, v->k_y - 1 + s->quarter_sample); \ - } \ - else if (index == 36) \ - { \ - _dmv_x = 0; \ - _dmv_y = 0; \ - s->mb_intra = 1; \ - } \ - else \ - { \ - index1 = index%6; \ - if (!s->quarter_sample && index1 == 5) val = 1; \ - else val = 0; \ - if(size_table[index1] - val > 0) \ - val = get_bits(gb, size_table[index1] - val); \ - else val = 0; \ - sign = 0 - (val&1); \ - _dmv_x = (sign ^ ((val>>1) + offset_table[index1])) - sign; \ - \ - index1 = index/6; \ - if (!s->quarter_sample && index1 == 5) val = 1; \ - else val = 0; \ - if(size_table[index1] - val > 0) \ - val = get_bits(gb, size_table[index1] - val); \ - else val = 0; \ - sign = 0 - (val&1); \ - _dmv_y = (sign ^ ((val>>1) + offset_table[index1])) - sign; \ - } +#define GET_MVDATA(_dmv_x, _dmv_y) \ + index = 1 + get_vlc2(gb, ff_vc1_mv_diff_vlc[s->mv_table_index].table, \ + VC1_MV_DIFF_VLC_BITS, 2); \ + if (index > 36) { \ + mb_has_coeffs = 1; \ + index -= 37; \ + } else \ + mb_has_coeffs = 0; \ + s->mb_intra = 0; \ + if (!index) { \ + _dmv_x = _dmv_y = 0; \ + } else if (index == 35) { \ + _dmv_x = get_bits(gb, v->k_x - 1 + s->quarter_sample); \ + _dmv_y = get_bits(gb, v->k_y - 1 + s->quarter_sample); \ + } else if (index == 36) { \ + _dmv_x = 0; \ + _dmv_y = 0; \ + s->mb_intra = 1; \ + } else { \ + index1 = index % 6; \ + if (!s->quarter_sample && index1 == 5) val = 1; \ + else val = 0; \ + if (size_table[index1] - val > 0) \ + val = get_bits(gb, size_table[index1] - val); \ + else val = 0; \ + sign = 0 - (val&1); \ + _dmv_x = (sign ^ ((val>>1) + offset_table[index1])) - sign; \ + \ + index1 = index / 6; \ + if (!s->quarter_sample && index1 == 5) val = 1; \ + else val = 0; \ + if (size_table[index1] - val > 0) \ + val = get_bits(gb, size_table[index1] - val); \ + else val = 0; \ + sign = 0 - (val & 1); \ + _dmv_y = (sign ^ ((val >> 1) + offset_table[index1])) - sign; \ + } + +static av_always_inline void get_mvdata_interlaced(VC1Context *v, int *dmv_x, + int *dmv_y, int *pred_flag) +{ + int index, index1; + int extend_x = 0, extend_y = 0; + GetBitContext *gb = &v->s.gb; + int bits, esc; + int val, sign; + const int* offs_tab; + + if (v->numref) { + bits = VC1_2REF_MVDATA_VLC_BITS; + esc = 125; + } else { + bits = VC1_1REF_MVDATA_VLC_BITS; + esc = 71; + } + switch (v->dmvrange) { + case 1: + extend_x = 1; + break; + case 2: + extend_y = 1; + break; + case 3: + extend_x = extend_y = 1; + break; + } + index = get_vlc2(gb, v->imv_vlc->table, bits, 3); + if (index == esc) { + *dmv_x = get_bits(gb, v->k_x); + *dmv_y = get_bits(gb, v->k_y); + if (v->numref) { + *pred_flag = *dmv_y & 1; + *dmv_y = (*dmv_y + *pred_flag) >> 1; + } + } + else { + if (extend_x) + offs_tab = offset_table2; + else + offs_tab = offset_table1; + index1 = (index + 1) % 9; + if (index1 != 0) { + val = get_bits(gb, index1 + extend_x); + sign = 0 -(val & 1); + *dmv_x = (sign ^ ((val >> 1) + offs_tab[index1])) - sign; + } else + *dmv_x = 0; + if (extend_y) + offs_tab = offset_table2; + else + offs_tab = offset_table1; + index1 = (index + 1) / 9; + if (index1 > v->numref) { + val = get_bits(gb, (index1 + (extend_y << v->numref)) >> v->numref); + sign = 0 - (val & 1); + *dmv_y = (sign ^ ((val >> 1) + offs_tab[index1 >> v->numref])) - sign; + } else + *dmv_y = 0; + if (v->numref) + *pred_flag = index1 & 1; + } +} + +static av_always_inline int scaleforsame_x(VC1Context *v, int n /* MV */, int dir) +{ + int scaledvalue, refdist; + int scalesame1, scalesame2; + int scalezone1_x, zone1offset_x; + int table_index = dir ^ v->second_field; + + if (v->s.pict_type != AV_PICTURE_TYPE_B) + refdist = v->refdist; + else + refdist = dir ? v->brfd : v->frfd; + if (refdist > 3) + refdist = 3; + scalesame1 = vc1_field_mvpred_scales[table_index][1][refdist]; + scalesame2 = vc1_field_mvpred_scales[table_index][2][refdist]; + scalezone1_x = vc1_field_mvpred_scales[table_index][3][refdist]; + zone1offset_x = vc1_field_mvpred_scales[table_index][5][refdist]; + + if (FFABS(n) > 255) + scaledvalue = n; + else { + if (FFABS(n) < scalezone1_x) + scaledvalue = (n * scalesame1) >> 8; + else { + if (n < 0) + scaledvalue = ((n * scalesame2) >> 8) - zone1offset_x; + else + scaledvalue = ((n * scalesame2) >> 8) + zone1offset_x; + } + } + return av_clip(scaledvalue, -v->range_x, v->range_x - 1); +} + +static av_always_inline int scaleforsame_y(VC1Context *v, int i, int n /* MV */, int dir) +{ + int scaledvalue, refdist; + int scalesame1, scalesame2; + int scalezone1_y, zone1offset_y; + int table_index = dir ^ v->second_field; + + if (v->s.pict_type != AV_PICTURE_TYPE_B) + refdist = v->refdist; + else + refdist = dir ? v->brfd : v->frfd; + if (refdist > 3) + refdist = 3; + scalesame1 = vc1_field_mvpred_scales[table_index][1][refdist]; + scalesame2 = vc1_field_mvpred_scales[table_index][2][refdist]; + scalezone1_y = vc1_field_mvpred_scales[table_index][4][refdist]; + zone1offset_y = vc1_field_mvpred_scales[table_index][6][refdist]; + + if (FFABS(n) > 63) + scaledvalue = n; + else { + if (FFABS(n) < scalezone1_y) + scaledvalue = (n * scalesame1) >> 8; + else { + if (n < 0) + scaledvalue = ((n * scalesame2) >> 8) - zone1offset_y; + else + scaledvalue = ((n * scalesame2) >> 8) + zone1offset_y; + } + } + + if (v->cur_field_type && !v->ref_field_type[dir]) + return av_clip(scaledvalue, -v->range_y / 2 + 1, v->range_y / 2); + else + return av_clip(scaledvalue, -v->range_y / 2, v->range_y / 2 - 1); +} + +static av_always_inline int scaleforopp_x(VC1Context *v, int n /* MV */) +{ + int scalezone1_x, zone1offset_x; + int scaleopp1, scaleopp2, brfd; + int scaledvalue; + + brfd = FFMIN(v->brfd, 3); + scalezone1_x = vc1_b_field_mvpred_scales[3][brfd]; + zone1offset_x = vc1_b_field_mvpred_scales[5][brfd]; + scaleopp1 = vc1_b_field_mvpred_scales[1][brfd]; + scaleopp2 = vc1_b_field_mvpred_scales[2][brfd]; + + if (FFABS(n) > 255) + scaledvalue = n; + else { + if (FFABS(n) < scalezone1_x) + scaledvalue = (n * scaleopp1) >> 8; + else { + if (n < 0) + scaledvalue = ((n * scaleopp2) >> 8) - zone1offset_x; + else + scaledvalue = ((n * scaleopp2) >> 8) + zone1offset_x; + } + } + return av_clip(scaledvalue, -v->range_x, v->range_x - 1); +} + +static av_always_inline int scaleforopp_y(VC1Context *v, int n /* MV */, int dir) +{ + int scalezone1_y, zone1offset_y; + int scaleopp1, scaleopp2, brfd; + int scaledvalue; + + brfd = FFMIN(v->brfd, 3); + scalezone1_y = vc1_b_field_mvpred_scales[4][brfd]; + zone1offset_y = vc1_b_field_mvpred_scales[6][brfd]; + scaleopp1 = vc1_b_field_mvpred_scales[1][brfd]; + scaleopp2 = vc1_b_field_mvpred_scales[2][brfd]; + + if (FFABS(n) > 63) + scaledvalue = n; + else { + if (FFABS(n) < scalezone1_y) + scaledvalue = (n * scaleopp1) >> 8; + else { + if (n < 0) + scaledvalue = ((n * scaleopp2) >> 8) - zone1offset_y; + else + scaledvalue = ((n * scaleopp2) >> 8) + zone1offset_y; + } + } + if (v->cur_field_type && !v->ref_field_type[dir]) { + return av_clip(scaledvalue, -v->range_y / 2 + 1, v->range_y / 2); + } else { + return av_clip(scaledvalue, -v->range_y / 2, v->range_y / 2 - 1); + } +} + +static av_always_inline int scaleforsame(VC1Context *v, int i, int n /* MV */, + int dim, int dir) +{ + int brfd, scalesame; + + if (v->s.pict_type != AV_PICTURE_TYPE_B || v->second_field || !dir) { + if (dim) + return scaleforsame_y(v, i, n, dir); + else + return scaleforsame_x(v, n, dir); + } + brfd = FFMIN(v->brfd, 3); + scalesame = vc1_b_field_mvpred_scales[0][brfd]; + + return n * scalesame >> 8; +} + +static av_always_inline int scaleforopp(VC1Context *v, int n /* MV */, + int dim, int dir) +{ + int refdist, scaleopp; + + if (v->s.pict_type == AV_PICTURE_TYPE_B && !v->second_field && dir == 1) { + if (dim) + return scaleforopp_y(v, n, dir); + else + return scaleforopp_x(v, n); + } + if (v->s.pict_type != AV_PICTURE_TYPE_B) + refdist = FFMIN(v->refdist, 3); + else + refdist = dir ? v->brfd : v->frfd; + scaleopp = vc1_field_mvpred_scales[dir ^ v->second_field][0][refdist]; + + return n * scaleopp >> 8; +} /** Predict and set motion vector */ -static inline void vc1_pred_mv(VC1Context *v, int n, int dmv_x, int dmv_y, int mv1, int r_x, int r_y, uint8_t* is_intra) +static inline void vc1_pred_mv(VC1Context *v, int n, int dmv_x, int dmv_y, + int mv1, int r_x, int r_y, uint8_t* is_intra, + int pred_flag, int dir) { MpegEncContext *s = &v->s; int xy, wrap, off = 0; int16_t *A, *B, *C; int px, py; int sum; - + int mixedmv_pic, num_samefield = 0, num_oppfield = 0; + int opposit, f; + int16_t samefield_pred[2], oppfield_pred[2]; + int16_t samefield_predA[2], oppfield_predA[2]; + int16_t samefield_predB[2], oppfield_predB[2]; + int16_t samefield_predC[2], oppfield_predC[2]; + int16_t *predA, *predC; + int a_valid, b_valid, c_valid; + int hybridmv_thresh, y_bias = 0; + + if (v->mv_mode == MV_PMODE_MIXED_MV || + ((v->mv_mode == MV_PMODE_INTENSITY_COMP) && (v->mv_mode2 == MV_PMODE_MIXED_MV))) + mixedmv_pic = 1; + else + mixedmv_pic = 0; /* scale MV difference to be quad-pel */ dmv_x <<= 1 - s->quarter_sample; dmv_y <<= 1 - s->quarter_sample; wrap = s->b8_stride; - xy = s->block_index[n]; + xy = s->block_index[n]; - if(s->mb_intra){ - s->mv[0][n][0] = s->current_picture.f.motion_val[0][xy][0] = 0; - s->mv[0][n][1] = s->current_picture.f.motion_val[0][xy][1] = 0; - s->current_picture.f.motion_val[1][xy][0] = 0; - s->current_picture.f.motion_val[1][xy][1] = 0; - if(mv1) { /* duplicate motion data for 1-MV block */ - s->current_picture.f.motion_val[0][xy + 1][0] = 0; - s->current_picture.f.motion_val[0][xy + 1][1] = 0; - s->current_picture.f.motion_val[0][xy + wrap][0] = 0; - s->current_picture.f.motion_val[0][xy + wrap][1] = 0; - s->current_picture.f.motion_val[0][xy + wrap + 1][0] = 0; - s->current_picture.f.motion_val[0][xy + wrap + 1][1] = 0; + if (s->mb_intra) { + s->mv[0][n][0] = s->current_picture.f.motion_val[0][xy + v->blocks_off][0] = 0; + s->mv[0][n][1] = s->current_picture.f.motion_val[0][xy + v->blocks_off][1] = 0; + s->current_picture.f.motion_val[1][xy + v->blocks_off][0] = 0; + s->current_picture.f.motion_val[1][xy + v->blocks_off][1] = 0; + if (mv1) { /* duplicate motion data for 1-MV block */ + s->current_picture.f.motion_val[0][xy + 1 + v->blocks_off][0] = 0; + s->current_picture.f.motion_val[0][xy + 1 + v->blocks_off][1] = 0; + s->current_picture.f.motion_val[0][xy + wrap + v->blocks_off][0] = 0; + s->current_picture.f.motion_val[0][xy + wrap + v->blocks_off][1] = 0; + s->current_picture.f.motion_val[0][xy + wrap + 1 + v->blocks_off][0] = 0; + s->current_picture.f.motion_val[0][xy + wrap + 1 + v->blocks_off][1] = 0; v->luma_mv[s->mb_x][0] = v->luma_mv[s->mb_x][1] = 0; - s->current_picture.f.motion_val[1][xy + 1][0] = 0; - s->current_picture.f.motion_val[1][xy + 1][1] = 0; - s->current_picture.f.motion_val[1][xy + wrap][0] = 0; - s->current_picture.f.motion_val[1][xy + wrap][1] = 0; - s->current_picture.f.motion_val[1][xy + wrap + 1][0] = 0; - s->current_picture.f.motion_val[1][xy + wrap + 1][1] = 0; + s->current_picture.f.motion_val[1][xy + 1 + v->blocks_off][0] = 0; + s->current_picture.f.motion_val[1][xy + 1 + v->blocks_off][1] = 0; + s->current_picture.f.motion_val[1][xy + wrap][0] = 0; + s->current_picture.f.motion_val[1][xy + wrap + v->blocks_off][1] = 0; + s->current_picture.f.motion_val[1][xy + wrap + 1 + v->blocks_off][0] = 0; + s->current_picture.f.motion_val[1][xy + wrap + 1 + v->blocks_off][1] = 0; } return; } - C = s->current_picture.f.motion_val[0][xy - 1]; - A = s->current_picture.f.motion_val[0][xy - wrap]; - if(mv1) - off = (s->mb_x == (s->mb_width - 1)) ? -1 : 2; - else { + C = s->current_picture.f.motion_val[dir][xy - 1 + v->blocks_off]; + A = s->current_picture.f.motion_val[dir][xy - wrap + v->blocks_off]; + if (mv1) { + if (v->field_mode && mixedmv_pic) + off = (s->mb_x == (s->mb_width - 1)) ? -2 : 2; + else + off = (s->mb_x == (s->mb_width - 1)) ? -1 : 2; + } else { //in 4-MV mode different blocks have different B predictor position - switch(n){ + switch (n) { case 0: off = (s->mb_x > 0) ? -1 : 1; break; @@ -925,79 +1534,434 @@ off = -1; } } - B = s->current_picture.f.motion_val[0][xy - wrap + off]; + B = s->current_picture.f.motion_val[dir][xy - wrap + off + v->blocks_off]; - if(!s->first_slice_line || (n==2 || n==3)) { // predictor A is not out of bounds - if(s->mb_width == 1) { - px = A[0]; - py = A[1]; + a_valid = !s->first_slice_line || (n == 2 || n == 3); + b_valid = a_valid && (s->mb_width > 1); + c_valid = s->mb_x || (n == 1 || n == 3); + if (v->field_mode) { + a_valid = a_valid && !is_intra[xy - wrap]; + b_valid = b_valid && !is_intra[xy - wrap + off]; + c_valid = c_valid && !is_intra[xy - 1]; + } + + if (a_valid) { + f = v->mv_f[dir][xy - wrap + v->blocks_off]; + num_oppfield += f; + num_samefield += 1 - f; + if (f) { + oppfield_predA[0] = A[0]; + oppfield_predA[1] = A[1]; + samefield_predA[0] = scaleforsame(v, 0, A[0], 0, dir); + samefield_predA[1] = scaleforsame(v, n, A[1], 1, dir); } else { - px = mid_pred(A[0], B[0], C[0]); - py = mid_pred(A[1], B[1], C[1]); + samefield_predA[0] = A[0]; + samefield_predA[1] = A[1]; + if (v->numref) + oppfield_predA[0] = scaleforopp(v, A[0], 0, dir); + if (v->numref) + oppfield_predA[1] = scaleforopp(v, A[1], 1, dir); } - } else if(s->mb_x || (n==1 || n==3)) { // predictor C is not out of bounds - px = C[0]; - py = C[1]; } else { - px = py = 0; + samefield_predA[0] = samefield_predA[1] = 0; + oppfield_predA[0] = oppfield_predA[1] = 0; } + if (c_valid) { + f = v->mv_f[dir][xy - 1 + v->blocks_off]; + num_oppfield += f; + num_samefield += 1 - f; + if (f) { + oppfield_predC[0] = C[0]; + oppfield_predC[1] = C[1]; + samefield_predC[0] = scaleforsame(v, 0, C[0], 0, dir); + samefield_predC[1] = scaleforsame(v, n, C[1], 1, dir); + } else { + samefield_predC[0] = C[0]; + samefield_predC[1] = C[1]; + if (v->numref) + oppfield_predC[0] = scaleforopp(v, C[0], 0, dir); + if (v->numref) + oppfield_predC[1] = scaleforopp(v, C[1], 1, dir); + } + } else { + samefield_predC[0] = samefield_predC[1] = 0; + oppfield_predC[0] = oppfield_predC[1] = 0; + } + if (b_valid) { + f = v->mv_f[dir][xy - wrap + off + v->blocks_off]; + num_oppfield += f; + num_samefield += 1 - f; + if (f) { + oppfield_predB[0] = B[0]; + oppfield_predB[1] = B[1]; + samefield_predB[0] = scaleforsame(v, 0, B[0], 0, dir); + samefield_predB[1] = scaleforsame(v, n, B[1], 1, dir); + } else { + samefield_predB[0] = B[0]; + samefield_predB[1] = B[1]; + if (v->numref) + oppfield_predB[0] = scaleforopp(v, B[0], 0, dir); + if (v->numref) + oppfield_predB[1] = scaleforopp(v, B[1], 1, dir); + } + } else { + samefield_predB[0] = samefield_predB[1] = 0; + oppfield_predB[0] = oppfield_predB[1] = 0; + } + + if (a_valid) { + samefield_pred[0] = samefield_predA[0]; + samefield_pred[1] = samefield_predA[1]; + oppfield_pred[0] = oppfield_predA[0]; + oppfield_pred[1] = oppfield_predA[1]; + } else if (c_valid) { + samefield_pred[0] = samefield_predC[0]; + samefield_pred[1] = samefield_predC[1]; + oppfield_pred[0] = oppfield_predC[0]; + oppfield_pred[1] = oppfield_predC[1]; + } else if (b_valid) { + samefield_pred[0] = samefield_predB[0]; + samefield_pred[1] = samefield_predB[1]; + oppfield_pred[0] = oppfield_predB[0]; + oppfield_pred[1] = oppfield_predB[1]; + } else { + samefield_pred[0] = samefield_pred[1] = 0; + oppfield_pred[0] = oppfield_pred[1] = 0; + } + + if (num_samefield + num_oppfield > 1) { + samefield_pred[0] = mid_pred(samefield_predA[0], samefield_predB[0], samefield_predC[0]); + samefield_pred[1] = mid_pred(samefield_predA[1], samefield_predB[1], samefield_predC[1]); + if (v->numref) + oppfield_pred[0] = mid_pred(oppfield_predA[0], oppfield_predB[0], oppfield_predC[0]); + if (v->numref) + oppfield_pred[1] = mid_pred(oppfield_predA[1], oppfield_predB[1], oppfield_predC[1]); + } + + if (v->field_mode) { + if (num_samefield <= num_oppfield) + opposit = 1 - pred_flag; + else + opposit = pred_flag; + } else + opposit = 0; + if (opposit) { + px = oppfield_pred[0]; + py = oppfield_pred[1]; + predA = oppfield_predA; + predC = oppfield_predC; + v->mv_f[dir][xy + v->blocks_off] = f = 1; + v->ref_field_type[dir] = !v->cur_field_type; + } else { + px = samefield_pred[0]; + py = samefield_pred[1]; + predA = samefield_predA; + predC = samefield_predC; + v->mv_f[dir][xy + v->blocks_off] = f = 0; + v->ref_field_type[dir] = v->cur_field_type; + } + /* Pullback MV as specified in 8.3.5.3.4 */ - { + if (!v->field_mode) { int qx, qy, X, Y; - qx = (s->mb_x << 6) + ((n==1 || n==3) ? 32 : 0); - qy = (s->mb_y << 6) + ((n==2 || n==3) ? 32 : 0); - X = (s->mb_width << 6) - 4; - Y = (s->mb_height << 6) - 4; - if(mv1) { - if(qx + px < -60) px = -60 - qx; - if(qy + py < -60) py = -60 - qy; + qx = (s->mb_x << 6) + ((n == 1 || n == 3) ? 32 : 0); + qy = (s->mb_y << 6) + ((n == 2 || n == 3) ? 32 : 0); + X = (s->mb_width << 6) - 4; + Y = (s->mb_height << 6) - 4; + if (mv1) { + if (qx + px < -60) px = -60 - qx; + if (qy + py < -60) py = -60 - qy; } else { - if(qx + px < -28) px = -28 - qx; - if(qy + py < -28) py = -28 - qy; + if (qx + px < -28) px = -28 - qx; + if (qy + py < -28) py = -28 - qy; } - if(qx + px > X) px = X - qx; - if(qy + py > Y) py = Y - qy; + if (qx + px > X) px = X - qx; + if (qy + py > Y) py = Y - qy; } - /* Calculate hybrid prediction as specified in 8.3.5.3.5 */ - if((!s->first_slice_line || (n==2 || n==3)) && (s->mb_x || (n==1 || n==3))) { - if(is_intra[xy - wrap]) - sum = FFABS(px) + FFABS(py); + + if (!v->field_mode || s->pict_type != AV_PICTURE_TYPE_B) { + /* Calculate hybrid prediction as specified in 8.3.5.3.5 (also 10.3.5.4.3.5) */ + if (v->field_mode && !s->quarter_sample) + hybridmv_thresh = 16; else - sum = FFABS(px - A[0]) + FFABS(py - A[1]); - if(sum > 32) { - if(get_bits1(&s->gb)) { - px = A[0]; - py = A[1]; + hybridmv_thresh = 32; + if (a_valid && c_valid) { + if (is_intra[xy - wrap]) + sum = FFABS(px) + FFABS(py); + else + sum = FFABS(px - predA[0]) + FFABS(py - predA[1]); + if (sum > hybridmv_thresh) { + if (get_bits1(&s->gb)) { // read HYBRIDPRED bit + px = predA[0]; + py = predA[1]; + } else { + px = predC[0]; + py = predC[1]; + } } else { - px = C[0]; - py = C[1]; + if (is_intra[xy - 1]) + sum = FFABS(px) + FFABS(py); + else + sum = FFABS(px - predC[0]) + FFABS(py - predC[1]); + if (sum > hybridmv_thresh) { + if (get_bits1(&s->gb)) { + px = predA[0]; + py = predA[1]; + } else { + px = predC[0]; + py = predC[1]; + } + } } + } + } + + if (v->field_mode && !s->quarter_sample) { + r_x <<= 1; + r_y <<= 1; + } + if (v->field_mode && v->numref) + r_y >>= 1; + if (v->field_mode && v->cur_field_type && v->ref_field_type[dir] == 0) + y_bias = 1; + /* store MV using signed modulus of MV range defined in 4.11 */ + s->mv[dir][n][0] = s->current_picture.f.motion_val[dir][xy + v->blocks_off][0] = ((px + dmv_x + r_x) & ((r_x << 1) - 1)) - r_x; + s->mv[dir][n][1] = s->current_picture.f.motion_val[dir][xy + v->blocks_off][1] = ((py + dmv_y + r_y - y_bias) & ((r_y << 1) - 1)) - r_y + y_bias; + if (mv1) { /* duplicate motion data for 1-MV block */ + s->current_picture.f.motion_val[dir][xy + 1 + v->blocks_off][0] = s->current_picture.f.motion_val[dir][xy + v->blocks_off][0]; + s->current_picture.f.motion_val[dir][xy + 1 + v->blocks_off][1] = s->current_picture.f.motion_val[dir][xy + v->blocks_off][1]; + s->current_picture.f.motion_val[dir][xy + wrap + v->blocks_off][0] = s->current_picture.f.motion_val[dir][xy + v->blocks_off][0]; + s->current_picture.f.motion_val[dir][xy + wrap + v->blocks_off][1] = s->current_picture.f.motion_val[dir][xy + v->blocks_off][1]; + s->current_picture.f.motion_val[dir][xy + wrap + 1 + v->blocks_off][0] = s->current_picture.f.motion_val[dir][xy + v->blocks_off][0]; + s->current_picture.f.motion_val[dir][xy + wrap + 1 + v->blocks_off][1] = s->current_picture.f.motion_val[dir][xy + v->blocks_off][1]; + v->mv_f[dir][xy + 1 + v->blocks_off] = v->mv_f[dir][xy + v->blocks_off]; + v->mv_f[dir][xy + wrap + v->blocks_off] = v->mv_f[dir][xy + wrap + 1 + v->blocks_off] = v->mv_f[dir][xy + v->blocks_off]; + } +} + +/** Predict and set motion vector for interlaced frame picture MBs + */ +static inline void vc1_pred_mv_intfr(VC1Context *v, int n, int dmv_x, int dmv_y, + int mvn, int r_x, int r_y, uint8_t* is_intra) +{ + MpegEncContext *s = &v->s; + int xy, wrap, off = 0; + int A[2], B[2], C[2]; + int px, py; + int a_valid = 0, b_valid = 0, c_valid = 0; + int field_a, field_b, field_c; // 0: same, 1: opposit + int total_valid, num_samefield, num_oppfield; + int pos_c, pos_b, n_adj; + + wrap = s->b8_stride; + xy = s->block_index[n]; + + if (s->mb_intra) { + s->mv[0][n][0] = s->current_picture.f.motion_val[0][xy][0] = 0; + s->mv[0][n][1] = s->current_picture.f.motion_val[0][xy][1] = 0; + s->current_picture.f.motion_val[1][xy][0] = 0; + s->current_picture.f.motion_val[1][xy][1] = 0; + if (mvn == 1) { /* duplicate motion data for 1-MV block */ + s->current_picture.f.motion_val[0][xy + 1][0] = 0; + s->current_picture.f.motion_val[0][xy + 1][1] = 0; + s->current_picture.f.motion_val[0][xy + wrap][0] = 0; + s->current_picture.f.motion_val[0][xy + wrap][1] = 0; + s->current_picture.f.motion_val[0][xy + wrap + 1][0] = 0; + s->current_picture.f.motion_val[0][xy + wrap + 1][1] = 0; + v->luma_mv[s->mb_x][0] = v->luma_mv[s->mb_x][1] = 0; + s->current_picture.f.motion_val[1][xy + 1][0] = 0; + s->current_picture.f.motion_val[1][xy + 1][1] = 0; + s->current_picture.f.motion_val[1][xy + wrap][0] = 0; + s->current_picture.f.motion_val[1][xy + wrap][1] = 0; + s->current_picture.f.motion_val[1][xy + wrap + 1][0] = 0; + s->current_picture.f.motion_val[1][xy + wrap + 1][1] = 0; + } + return; + } + + off = ((n == 0) || (n == 1)) ? 1 : -1; + /* predict A */ + if (s->mb_x || (n == 1) || (n == 3)) { + if ((v->blk_mv_type[xy]) // current block (MB) has a field MV + || (!v->blk_mv_type[xy] && !v->blk_mv_type[xy - 1])) { // or both have frame MV + A[0] = s->current_picture.f.motion_val[0][xy - 1][0]; + A[1] = s->current_picture.f.motion_val[0][xy - 1][1]; + a_valid = 1; + } else { // current block has frame mv and cand. has field MV (so average) + A[0] = (s->current_picture.f.motion_val[0][xy - 1][0] + + s->current_picture.f.motion_val[0][xy - 1 + off * wrap][0] + 1) >> 1; + A[1] = (s->current_picture.f.motion_val[0][xy - 1][1] + + s->current_picture.f.motion_val[0][xy - 1 + off * wrap][1] + 1) >> 1; + a_valid = 1; + } + if (!(n & 1) && v->is_intra[s->mb_x - 1]) { + a_valid = 0; + A[0] = A[1] = 0; + } + } else + A[0] = A[1] = 0; + /* Predict B and C */ + B[0] = B[1] = C[0] = C[1] = 0; + if (n == 0 || n == 1 || v->blk_mv_type[xy]) { + if (!s->first_slice_line) { + if (!v->is_intra[s->mb_x - s->mb_stride]) { + b_valid = 1; + n_adj = n | 2; + pos_b = s->block_index[n_adj] - 2 * wrap; + if (v->blk_mv_type[pos_b] && v->blk_mv_type[xy]) { + n_adj = (n & 2) | (n & 1); + } + B[0] = s->current_picture.f.motion_val[0][s->block_index[n_adj] - 2 * wrap][0]; + B[1] = s->current_picture.f.motion_val[0][s->block_index[n_adj] - 2 * wrap][1]; + if (v->blk_mv_type[pos_b] && !v->blk_mv_type[xy]) { + B[0] = (B[0] + s->current_picture.f.motion_val[0][s->block_index[n_adj ^ 2] - 2 * wrap][0] + 1) >> 1; + B[1] = (B[1] + s->current_picture.f.motion_val[0][s->block_index[n_adj ^ 2] - 2 * wrap][1] + 1) >> 1; + } + } + if (s->mb_width > 1) { + if (!v->is_intra[s->mb_x - s->mb_stride + 1]) { + c_valid = 1; + n_adj = 2; + pos_c = s->block_index[2] - 2 * wrap + 2; + if (v->blk_mv_type[pos_c] && v->blk_mv_type[xy]) { + n_adj = n & 2; + } + C[0] = s->current_picture.f.motion_val[0][s->block_index[n_adj] - 2 * wrap + 2][0]; + C[1] = s->current_picture.f.motion_val[0][s->block_index[n_adj] - 2 * wrap + 2][1]; + if (v->blk_mv_type[pos_c] && !v->blk_mv_type[xy]) { + C[0] = (1 + C[0] + (s->current_picture.f.motion_val[0][s->block_index[n_adj ^ 2] - 2 * wrap + 2][0])) >> 1; + C[1] = (1 + C[1] + (s->current_picture.f.motion_val[0][s->block_index[n_adj ^ 2] - 2 * wrap + 2][1])) >> 1; + } + if (s->mb_x == s->mb_width - 1) { + if (!v->is_intra[s->mb_x - s->mb_stride - 1]) { + c_valid = 1; + n_adj = 3; + pos_c = s->block_index[3] - 2 * wrap - 2; + if (v->blk_mv_type[pos_c] && v->blk_mv_type[xy]) { + n_adj = n | 1; + } + C[0] = s->current_picture.f.motion_val[0][s->block_index[n_adj] - 2 * wrap - 2][0]; + C[1] = s->current_picture.f.motion_val[0][s->block_index[n_adj] - 2 * wrap - 2][1]; + if (v->blk_mv_type[pos_c] && !v->blk_mv_type[xy]) { + C[0] = (1 + C[0] + s->current_picture.f.motion_val[0][s->block_index[1] - 2 * wrap - 2][0]) >> 1; + C[1] = (1 + C[1] + s->current_picture.f.motion_val[0][s->block_index[1] - 2 * wrap - 2][1]) >> 1; + } + } else + c_valid = 0; + } + } + } + } + } else { + pos_b = s->block_index[1]; + b_valid = 1; + B[0] = s->current_picture.f.motion_val[0][pos_b][0]; + B[1] = s->current_picture.f.motion_val[0][pos_b][1]; + pos_c = s->block_index[0]; + c_valid = 1; + C[0] = s->current_picture.f.motion_val[0][pos_c][0]; + C[1] = s->current_picture.f.motion_val[0][pos_c][1]; + } + + total_valid = a_valid + b_valid + c_valid; + // check if predictor A is out of bounds + if (!s->mb_x && !(n == 1 || n == 3)) { + A[0] = A[1] = 0; + } + // check if predictor B is out of bounds + if ((s->first_slice_line && v->blk_mv_type[xy]) || (s->first_slice_line && !(n & 2))) { + B[0] = B[1] = C[0] = C[1] = 0; + } + if (!v->blk_mv_type[xy]) { + if (s->mb_width == 1) { + px = B[0]; + py = B[1]; } else { - if(is_intra[xy - 1]) - sum = FFABS(px) + FFABS(py); - else - sum = FFABS(px - C[0]) + FFABS(py - C[1]); - if(sum > 32) { - if(get_bits1(&s->gb)) { + if (total_valid >= 2) { + px = mid_pred(A[0], B[0], C[0]); + py = mid_pred(A[1], B[1], C[1]); + } else if (total_valid) { + if (a_valid) { px = A[0]; py = A[1]; } + if (b_valid) { px = B[0]; py = B[1]; } + if (c_valid) { px = C[0]; py = C[1]; } + } else + px = py = 0; + } + } else { + if (a_valid) + field_a = (A[1] & 4) ? 1 : 0; + else + field_a = 0; + if (b_valid) + field_b = (B[1] & 4) ? 1 : 0; + else + field_b = 0; + if (c_valid) + field_c = (C[1] & 4) ? 1 : 0; + else + field_c = 0; + + num_oppfield = field_a + field_b + field_c; + num_samefield = total_valid - num_oppfield; + if (total_valid == 3) { + if ((num_samefield == 3) || (num_oppfield == 3)) { + px = mid_pred(A[0], B[0], C[0]); + py = mid_pred(A[1], B[1], C[1]); + } else if (num_samefield >= num_oppfield) { + /* take one MV from same field set depending on priority + the check for B may not be necessary */ + px = !field_a ? A[0] : B[0]; + py = !field_a ? A[1] : B[1]; + } else { + px = field_a ? A[0] : B[0]; + py = field_a ? A[1] : B[1]; + } + } else if (total_valid == 2) { + if (num_samefield >= num_oppfield) { + if (!field_a && a_valid) { px = A[0]; py = A[1]; - } else { + } else if (!field_b && b_valid) { + px = B[0]; + py = B[1]; + } else if (c_valid) { + px = C[0]; + py = C[1]; + } else px = py = 0; + } else { + if (field_a && a_valid) { + px = A[0]; + py = A[1]; + } else if (field_b && b_valid) { + px = B[0]; + py = B[1]; + } else if (c_valid) { px = C[0]; py = C[1]; } } - } + } else if (total_valid == 1) { + px = (a_valid) ? A[0] : ((b_valid) ? B[0] : C[0]); + py = (a_valid) ? A[1] : ((b_valid) ? B[1] : C[1]); + } else + px = py = 0; } + /* store MV using signed modulus of MV range defined in 4.11 */ s->mv[0][n][0] = s->current_picture.f.motion_val[0][xy][0] = ((px + dmv_x + r_x) & ((r_x << 1) - 1)) - r_x; s->mv[0][n][1] = s->current_picture.f.motion_val[0][xy][1] = ((py + dmv_y + r_y) & ((r_y << 1) - 1)) - r_y; - if(mv1) { /* duplicate motion data for 1-MV block */ - s->current_picture.f.motion_val[0][xy + 1][0] = s->current_picture.f.motion_val[0][xy][0]; - s->current_picture.f.motion_val[0][xy + 1][1] = s->current_picture.f.motion_val[0][xy][1]; - s->current_picture.f.motion_val[0][xy + wrap][0] = s->current_picture.f.motion_val[0][xy][0]; - s->current_picture.f.motion_val[0][xy + wrap][1] = s->current_picture.f.motion_val[0][xy][1]; + if (mvn == 1) { /* duplicate motion data for 1-MV block */ + s->current_picture.f.motion_val[0][xy + 1 ][0] = s->current_picture.f.motion_val[0][xy][0]; + s->current_picture.f.motion_val[0][xy + 1 ][1] = s->current_picture.f.motion_val[0][xy][1]; + s->current_picture.f.motion_val[0][xy + wrap ][0] = s->current_picture.f.motion_val[0][xy][0]; + s->current_picture.f.motion_val[0][xy + wrap ][1] = s->current_picture.f.motion_val[0][xy][1]; s->current_picture.f.motion_val[0][xy + wrap + 1][0] = s->current_picture.f.motion_val[0][xy][0]; s->current_picture.f.motion_val[0][xy + wrap + 1][1] = s->current_picture.f.motion_val[0][xy][1]; + } else if (mvn == 2) { /* duplicate motion data for 2-Field MV block */ + s->current_picture.f.motion_val[0][xy + 1][0] = s->current_picture.f.motion_val[0][xy][0]; + s->current_picture.f.motion_val[0][xy + 1][1] = s->current_picture.f.motion_val[0][xy][1]; + s->mv[0][n + 1][0] = s->mv[0][n][0]; + s->mv[0][n + 1][1] = s->mv[0][n][1]; } } @@ -1009,112 +1973,138 @@ DSPContext *dsp = &v->s.dsp; uint8_t *srcY, *srcU, *srcV; int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y; + int off, off_uv; + int v_edge_pos = s->v_edge_pos >> v->field_mode; - if(!v->s.next_picture.f.data[0])return; + if (!v->field_mode && !v->s.next_picture.f.data[0]) + return; - mx = s->mv[1][0][0]; - my = s->mv[1][0][1]; + mx = s->mv[1][0][0]; + my = s->mv[1][0][1]; uvmx = (mx + ((mx & 3) == 3)) >> 1; uvmy = (my + ((my & 3) == 3)) >> 1; - if(v->fastuvmc) { - uvmx = uvmx + ((uvmx<0)?-(uvmx&1):(uvmx&1)); - uvmy = uvmy + ((uvmy<0)?-(uvmy&1):(uvmy&1)); + if (v->field_mode) { + if (v->cur_field_type != v->ref_field_type[1]) + my = my - 2 + 4 * v->cur_field_type; + uvmy = uvmy - 2 + 4 * v->cur_field_type; + } + if (v->fastuvmc) { + uvmx = uvmx + ((uvmx < 0) ? -(uvmx & 1) : (uvmx & 1)); + uvmy = uvmy + ((uvmy < 0) ? -(uvmy & 1) : (uvmy & 1)); } srcY = s->next_picture.f.data[0]; srcU = s->next_picture.f.data[1]; srcV = s->next_picture.f.data[2]; - src_x = s->mb_x * 16 + (mx >> 2); - src_y = s->mb_y * 16 + (my >> 2); - uvsrc_x = s->mb_x * 8 + (uvmx >> 2); - uvsrc_y = s->mb_y * 8 + (uvmy >> 2); + src_x = s->mb_x * 16 + (mx >> 2); + src_y = s->mb_y * 16 + (my >> 2); + uvsrc_x = s->mb_x * 8 + (uvmx >> 2); + uvsrc_y = s->mb_y * 8 + (uvmy >> 2); - if(v->profile != PROFILE_ADVANCED){ + if (v->profile != PROFILE_ADVANCED) { src_x = av_clip( src_x, -16, s->mb_width * 16); src_y = av_clip( src_y, -16, s->mb_height * 16); uvsrc_x = av_clip(uvsrc_x, -8, s->mb_width * 8); uvsrc_y = av_clip(uvsrc_y, -8, s->mb_height * 8); - }else{ + } else { src_x = av_clip( src_x, -17, s->avctx->coded_width); src_y = av_clip( src_y, -18, s->avctx->coded_height + 1); uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width >> 1); uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1); } - srcY += src_y * s->linesize + src_x; + srcY += src_y * s->linesize + src_x; srcU += uvsrc_y * s->uvlinesize + uvsrc_x; srcV += uvsrc_y * s->uvlinesize + uvsrc_x; + if (v->field_mode && v->ref_field_type[1]) { + srcY += s->current_picture_ptr->f.linesize[0]; + srcU += s->current_picture_ptr->f.linesize[1]; + srcV += s->current_picture_ptr->f.linesize[2]; + } + /* for grayscale we should not try to read from unknown area */ - if(s->flags & CODEC_FLAG_GRAY) { + if (s->flags & CODEC_FLAG_GRAY) { srcU = s->edge_emu_buffer + 18 * s->linesize; srcV = s->edge_emu_buffer + 18 * s->linesize; } - if(v->rangeredfrm - || (unsigned)(src_x - s->mspel) > s->h_edge_pos - (mx&3) - 16 - s->mspel*3 - || (unsigned)(src_y - s->mspel) > s->v_edge_pos - (my&3) - 16 - s->mspel*3){ - uint8_t *uvbuf= s->edge_emu_buffer + 19 * s->linesize; + if (v->rangeredfrm + || (unsigned)(src_x - s->mspel) > s->h_edge_pos - (mx & 3) - 16 - s->mspel * 3 + || (unsigned)(src_y - s->mspel) > v_edge_pos - (my & 3) - 16 - s->mspel * 3) { + uint8_t *uvbuf = s->edge_emu_buffer + 19 * s->linesize; srcY -= s->mspel * (1 + s->linesize); - s->dsp.emulated_edge_mc(s->edge_emu_buffer, srcY, s->linesize, 17+s->mspel*2, 17+s->mspel*2, - src_x - s->mspel, src_y - s->mspel, s->h_edge_pos, s->v_edge_pos); + s->dsp.emulated_edge_mc(s->edge_emu_buffer, srcY, s->linesize, + 17 + s->mspel * 2, 17 + s->mspel * 2, + src_x - s->mspel, src_y - s->mspel, + s->h_edge_pos, v_edge_pos); srcY = s->edge_emu_buffer; - s->dsp.emulated_edge_mc(uvbuf , srcU, s->uvlinesize, 8+1, 8+1, - uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, s->v_edge_pos >> 1); - s->dsp.emulated_edge_mc(uvbuf + 16, srcV, s->uvlinesize, 8+1, 8+1, - uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, s->v_edge_pos >> 1); + s->dsp.emulated_edge_mc(uvbuf , srcU, s->uvlinesize, 8 + 1, 8 + 1, + uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, v_edge_pos >> 1); + s->dsp.emulated_edge_mc(uvbuf + 16, srcV, s->uvlinesize, 8 + 1, 8 + 1, + uvsrc_x, uvsrc_y, s->h_edge_pos >> 1, v_edge_pos >> 1); srcU = uvbuf; srcV = uvbuf + 16; /* if we deal with range reduction we need to scale source blocks */ - if(v->rangeredfrm) { + if (v->rangeredfrm) { int i, j; uint8_t *src, *src2; src = srcY; - for(j = 0; j < 17 + s->mspel*2; j++) { - for(i = 0; i < 17 + s->mspel*2; i++) src[i] = ((src[i] - 128) >> 1) + 128; + for (j = 0; j < 17 + s->mspel * 2; j++) { + for (i = 0; i < 17 + s->mspel * 2; i++) + src[i] = ((src[i] - 128) >> 1) + 128; src += s->linesize; } - src = srcU; src2 = srcV; - for(j = 0; j < 9; j++) { - for(i = 0; i < 9; i++) { - src[i] = ((src[i] - 128) >> 1) + 128; + src = srcU; + src2 = srcV; + for (j = 0; j < 9; j++) { + for (i = 0; i < 9; i++) { + src[i] = ((src[i] - 128) >> 1) + 128; src2[i] = ((src2[i] - 128) >> 1) + 128; } - src += s->uvlinesize; + src += s->uvlinesize; src2 += s->uvlinesize; } } srcY += s->mspel * (1 + s->linesize); } - if(s->mspel) { + if (v->field_mode && v->cur_field_type) { + off = s->current_picture_ptr->f.linesize[0]; + off_uv = s->current_picture_ptr->f.linesize[1]; + } else { + off = 0; + off_uv = 0; + } + + if (s->mspel) { dxy = ((my & 3) << 2) | (mx & 3); - v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] , srcY , s->linesize, v->rnd); - v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + 8, srcY + 8, s->linesize, v->rnd); + v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + off , srcY , s->linesize, v->rnd); + v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + off + 8, srcY + 8, s->linesize, v->rnd); srcY += s->linesize * 8; - v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + 8 * s->linesize , srcY , s->linesize, v->rnd); - v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + 8 * s->linesize + 8, srcY + 8, s->linesize, v->rnd); + v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + off + 8 * s->linesize , srcY , s->linesize, v->rnd); + v->vc1dsp.avg_vc1_mspel_pixels_tab[dxy](s->dest[0] + off + 8 * s->linesize + 8, srcY + 8, s->linesize, v->rnd); } else { // hpel mc dxy = (my & 2) | ((mx & 2) >> 1); - if(!v->rnd) - dsp->avg_pixels_tab[0][dxy](s->dest[0], srcY, s->linesize, 16); + if (!v->rnd) + dsp->avg_pixels_tab[0][dxy](s->dest[0] + off, srcY, s->linesize, 16); else - dsp->avg_no_rnd_pixels_tab[0][dxy](s->dest[0], srcY, s->linesize, 16); + dsp->avg_no_rnd_pixels_tab[0][dxy](s->dest[0] + off, srcY, s->linesize, 16); } - if(s->flags & CODEC_FLAG_GRAY) return; + if (s->flags & CODEC_FLAG_GRAY) return; /* Chroma MC always uses qpel blilinear */ - uvmx = (uvmx&3)<<1; - uvmy = (uvmy&3)<<1; - if(!v->rnd){ - dsp->avg_h264_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy); - dsp->avg_h264_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy); - }else{ - v->vc1dsp.avg_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy); - v->vc1dsp.avg_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy); + uvmx = (uvmx & 3) << 1; + uvmy = (uvmy & 3) << 1; + if (!v->rnd) { + dsp->avg_h264_chroma_pixels_tab[0](s->dest[1] + off_uv, srcU, s->uvlinesize, 8, uvmx, uvmy); + dsp->avg_h264_chroma_pixels_tab[0](s->dest[2] + off_uv, srcV, s->uvlinesize, 8, uvmx, uvmy); + } else { + v->vc1dsp.avg_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1] + off_uv, srcU, s->uvlinesize, 8, uvmx, uvmy); + v->vc1dsp.avg_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2] + off_uv, srcV, s->uvlinesize, 8, uvmx, uvmy); } } @@ -1123,47 +2113,67 @@ int n = bfrac; #if B_FRACTION_DEN==256 - if(inv) + if (inv) n -= 256; - if(!qs) + if (!qs) return 2 * ((value * n + 255) >> 9); return (value * n + 128) >> 8; #else - if(inv) + if (inv) n -= B_FRACTION_DEN; - if(!qs) + if (!qs) return 2 * ((value * n + B_FRACTION_DEN - 1) / (2 * B_FRACTION_DEN)); return (value * n + B_FRACTION_DEN/2) / B_FRACTION_DEN; #endif } +static av_always_inline int scale_mv_intfi(int value, int bfrac, int inv, + int qs, int qs_last) +{ + int n = bfrac; + + if (inv) + n -= 256; + n <<= !qs_last; + if (!qs) + return (value * n + 255) >> 9; + else + return (value * n + 128) >> 8; +} + /** Reconstruct motion vector for B-frame and do motion compensation */ -static inline void vc1_b_mc(VC1Context *v, int dmv_x[2], int dmv_y[2], int direct, int mode) +static inline void vc1_b_mc(VC1Context *v, int dmv_x[2], int dmv_y[2], + int direct, int mode) { - if(v->use_ic) { + if (v->use_ic) { v->mv_mode2 = v->mv_mode; - v->mv_mode = MV_PMODE_INTENSITY_COMP; + v->mv_mode = MV_PMODE_INTENSITY_COMP; } - if(direct) { + if (direct) { vc1_mc_1mv(v, 0); vc1_interp_mc(v); - if(v->use_ic) v->mv_mode = v->mv_mode2; + if (v->use_ic) + v->mv_mode = v->mv_mode2; return; } - if(mode == BMV_TYPE_INTERPOLATED) { + if (mode == BMV_TYPE_INTERPOLATED) { vc1_mc_1mv(v, 0); vc1_interp_mc(v); - if(v->use_ic) v->mv_mode = v->mv_mode2; + if (v->use_ic) + v->mv_mode = v->mv_mode2; return; } - if(v->use_ic && (mode == BMV_TYPE_BACKWARD)) v->mv_mode = v->mv_mode2; + if (v->use_ic && (mode == BMV_TYPE_BACKWARD)) + v->mv_mode = v->mv_mode2; vc1_mc_1mv(v, (mode == BMV_TYPE_BACKWARD)); - if(v->use_ic) v->mv_mode = v->mv_mode2; + if (v->use_ic) + v->mv_mode = v->mv_mode2; } -static inline void vc1_pred_b_mv(VC1Context *v, int dmv_x[2], int dmv_y[2], int direct, int mvtype) +static inline void vc1_pred_b_mv(VC1Context *v, int dmv_x[2], int dmv_y[2], + int direct, int mvtype) { MpegEncContext *s = &v->s; int xy, wrap, off = 0; @@ -1184,47 +2194,49 @@ wrap = s->b8_stride; xy = s->block_index[0]; - if(s->mb_intra) { - s->current_picture.f.motion_val[0][xy][0] = - s->current_picture.f.motion_val[0][xy][1] = - s->current_picture.f.motion_val[1][xy][0] = - s->current_picture.f.motion_val[1][xy][1] = 0; + if (s->mb_intra) { + s->current_picture.f.motion_val[0][xy + v->blocks_off][0] = + s->current_picture.f.motion_val[0][xy + v->blocks_off][1] = + s->current_picture.f.motion_val[1][xy + v->blocks_off][0] = + s->current_picture.f.motion_val[1][xy + v->blocks_off][1] = 0; return; } - s->mv[0][0][0] = scale_mv(s->next_picture.f.motion_val[1][xy][0], v->bfraction, 0, s->quarter_sample); - s->mv[0][0][1] = scale_mv(s->next_picture.f.motion_val[1][xy][1], v->bfraction, 0, s->quarter_sample); - s->mv[1][0][0] = scale_mv(s->next_picture.f.motion_val[1][xy][0], v->bfraction, 1, s->quarter_sample); - s->mv[1][0][1] = scale_mv(s->next_picture.f.motion_val[1][xy][1], v->bfraction, 1, s->quarter_sample); - - /* Pullback predicted motion vectors as specified in 8.4.5.4 */ - s->mv[0][0][0] = av_clip(s->mv[0][0][0], -60 - (s->mb_x << 6), (s->mb_width << 6) - 4 - (s->mb_x << 6)); - s->mv[0][0][1] = av_clip(s->mv[0][0][1], -60 - (s->mb_y << 6), (s->mb_height << 6) - 4 - (s->mb_y << 6)); - s->mv[1][0][0] = av_clip(s->mv[1][0][0], -60 - (s->mb_x << 6), (s->mb_width << 6) - 4 - (s->mb_x << 6)); - s->mv[1][0][1] = av_clip(s->mv[1][0][1], -60 - (s->mb_y << 6), (s->mb_height << 6) - 4 - (s->mb_y << 6)); - if(direct) { - s->current_picture.f.motion_val[0][xy][0] = s->mv[0][0][0]; - s->current_picture.f.motion_val[0][xy][1] = s->mv[0][0][1]; - s->current_picture.f.motion_val[1][xy][0] = s->mv[1][0][0]; - s->current_picture.f.motion_val[1][xy][1] = s->mv[1][0][1]; + if (!v->field_mode) { + s->mv[0][0][0] = scale_mv(s->next_picture.f.motion_val[1][xy][0], v->bfraction, 0, s->quarter_sample); + s->mv[0][0][1] = scale_mv(s->next_picture.f.motion_val[1][xy][1], v->bfraction, 0, s->quarter_sample); + s->mv[1][0][0] = scale_mv(s->next_picture.f.motion_val[1][xy][0], v->bfraction, 1, s->quarter_sample); + s->mv[1][0][1] = scale_mv(s->next_picture.f.motion_val[1][xy][1], v->bfraction, 1, s->quarter_sample); + + /* Pullback predicted motion vectors as specified in 8.4.5.4 */ + s->mv[0][0][0] = av_clip(s->mv[0][0][0], -60 - (s->mb_x << 6), (s->mb_width << 6) - 4 - (s->mb_x << 6)); + s->mv[0][0][1] = av_clip(s->mv[0][0][1], -60 - (s->mb_y << 6), (s->mb_height << 6) - 4 - (s->mb_y << 6)); + s->mv[1][0][0] = av_clip(s->mv[1][0][0], -60 - (s->mb_x << 6), (s->mb_width << 6) - 4 - (s->mb_x << 6)); + s->mv[1][0][1] = av_clip(s->mv[1][0][1], -60 - (s->mb_y << 6), (s->mb_height << 6) - 4 - (s->mb_y << 6)); + } + if (direct) { + s->current_picture.f.motion_val[0][xy + v->blocks_off][0] = s->mv[0][0][0]; + s->current_picture.f.motion_val[0][xy + v->blocks_off][1] = s->mv[0][0][1]; + s->current_picture.f.motion_val[1][xy + v->blocks_off][0] = s->mv[1][0][0]; + s->current_picture.f.motion_val[1][xy + v->blocks_off][1] = s->mv[1][0][1]; return; } - if((mvtype == BMV_TYPE_FORWARD) || (mvtype == BMV_TYPE_INTERPOLATED)) { - C = s->current_picture.f.motion_val[0][xy - 2]; - A = s->current_picture.f.motion_val[0][xy - wrap*2]; + if ((mvtype == BMV_TYPE_FORWARD) || (mvtype == BMV_TYPE_INTERPOLATED)) { + C = s->current_picture.f.motion_val[0][xy - 2]; + A = s->current_picture.f.motion_val[0][xy - wrap * 2]; off = (s->mb_x == (s->mb_width - 1)) ? -2 : 2; - B = s->current_picture.f.motion_val[0][xy - wrap*2 + off]; + B = s->current_picture.f.motion_val[0][xy - wrap * 2 + off]; - if(!s->mb_x) C[0] = C[1] = 0; - if(!s->first_slice_line) { // predictor A is not out of bounds - if(s->mb_width == 1) { + if (!s->mb_x) C[0] = C[1] = 0; + if (!s->first_slice_line) { // predictor A is not out of bounds + if (s->mb_width == 1) { px = A[0]; py = A[1]; } else { px = mid_pred(A[0], B[0], C[0]); py = mid_pred(A[1], B[1], C[1]); } - } else if(s->mb_x) { // predictor C is not out of bounds + } else if (s->mb_x) { // predictor C is not out of bounds px = C[0]; py = C[1]; } else { @@ -1233,34 +2245,34 @@ /* Pullback MV as specified in 8.3.5.3.4 */ { int qx, qy, X, Y; - if(v->profile < PROFILE_ADVANCED) { + if (v->profile < PROFILE_ADVANCED) { qx = (s->mb_x << 5); qy = (s->mb_y << 5); - X = (s->mb_width << 5) - 4; - Y = (s->mb_height << 5) - 4; - if(qx + px < -28) px = -28 - qx; - if(qy + py < -28) py = -28 - qy; - if(qx + px > X) px = X - qx; - if(qy + py > Y) py = Y - qy; + X = (s->mb_width << 5) - 4; + Y = (s->mb_height << 5) - 4; + if (qx + px < -28) px = -28 - qx; + if (qy + py < -28) py = -28 - qy; + if (qx + px > X) px = X - qx; + if (qy + py > Y) py = Y - qy; } else { qx = (s->mb_x << 6); qy = (s->mb_y << 6); - X = (s->mb_width << 6) - 4; - Y = (s->mb_height << 6) - 4; - if(qx + px < -60) px = -60 - qx; - if(qy + py < -60) py = -60 - qy; - if(qx + px > X) px = X - qx; - if(qy + py > Y) py = Y - qy; + X = (s->mb_width << 6) - 4; + Y = (s->mb_height << 6) - 4; + if (qx + px < -60) px = -60 - qx; + if (qy + py < -60) py = -60 - qy; + if (qx + px > X) px = X - qx; + if (qy + py > Y) py = Y - qy; } } /* Calculate hybrid prediction as specified in 8.3.5.3.5 */ - if(0 && !s->first_slice_line && s->mb_x) { - if(is_intra[xy - wrap]) + if (0 && !s->first_slice_line && s->mb_x) { + if (is_intra[xy - wrap]) sum = FFABS(px) + FFABS(py); else sum = FFABS(px - A[0]) + FFABS(py - A[1]); - if(sum > 32) { - if(get_bits1(&s->gb)) { + if (sum > 32) { + if (get_bits1(&s->gb)) { px = A[0]; py = A[1]; } else { @@ -1268,12 +2280,12 @@ py = C[1]; } } else { - if(is_intra[xy - 2]) + if (is_intra[xy - 2]) sum = FFABS(px) + FFABS(py); else sum = FFABS(px - C[0]) + FFABS(py - C[1]); - if(sum > 32) { - if(get_bits1(&s->gb)) { + if (sum > 32) { + if (get_bits1(&s->gb)) { px = A[0]; py = A[1]; } else { @@ -1287,22 +2299,23 @@ s->mv[0][0][0] = ((px + dmv_x[0] + r_x) & ((r_x << 1) - 1)) - r_x; s->mv[0][0][1] = ((py + dmv_y[0] + r_y) & ((r_y << 1) - 1)) - r_y; } - if((mvtype == BMV_TYPE_BACKWARD) || (mvtype == BMV_TYPE_INTERPOLATED)) { - C = s->current_picture.f.motion_val[1][xy - 2]; - A = s->current_picture.f.motion_val[1][xy - wrap*2]; + if ((mvtype == BMV_TYPE_BACKWARD) || (mvtype == BMV_TYPE_INTERPOLATED)) { + C = s->current_picture.f.motion_val[1][xy - 2]; + A = s->current_picture.f.motion_val[1][xy - wrap * 2]; off = (s->mb_x == (s->mb_width - 1)) ? -2 : 2; - B = s->current_picture.f.motion_val[1][xy - wrap*2 + off]; + B = s->current_picture.f.motion_val[1][xy - wrap * 2 + off]; - if(!s->mb_x) C[0] = C[1] = 0; - if(!s->first_slice_line) { // predictor A is not out of bounds - if(s->mb_width == 1) { + if (!s->mb_x) + C[0] = C[1] = 0; + if (!s->first_slice_line) { // predictor A is not out of bounds + if (s->mb_width == 1) { px = A[0]; py = A[1]; } else { px = mid_pred(A[0], B[0], C[0]); py = mid_pred(A[1], B[1], C[1]); } - } else if(s->mb_x) { // predictor C is not out of bounds + } else if (s->mb_x) { // predictor C is not out of bounds px = C[0]; py = C[1]; } else { @@ -1311,34 +2324,34 @@ /* Pullback MV as specified in 8.3.5.3.4 */ { int qx, qy, X, Y; - if(v->profile < PROFILE_ADVANCED) { + if (v->profile < PROFILE_ADVANCED) { qx = (s->mb_x << 5); qy = (s->mb_y << 5); - X = (s->mb_width << 5) - 4; - Y = (s->mb_height << 5) - 4; - if(qx + px < -28) px = -28 - qx; - if(qy + py < -28) py = -28 - qy; - if(qx + px > X) px = X - qx; - if(qy + py > Y) py = Y - qy; + X = (s->mb_width << 5) - 4; + Y = (s->mb_height << 5) - 4; + if (qx + px < -28) px = -28 - qx; + if (qy + py < -28) py = -28 - qy; + if (qx + px > X) px = X - qx; + if (qy + py > Y) py = Y - qy; } else { qx = (s->mb_x << 6); qy = (s->mb_y << 6); - X = (s->mb_width << 6) - 4; - Y = (s->mb_height << 6) - 4; - if(qx + px < -60) px = -60 - qx; - if(qy + py < -60) py = -60 - qy; - if(qx + px > X) px = X - qx; - if(qy + py > Y) py = Y - qy; + X = (s->mb_width << 6) - 4; + Y = (s->mb_height << 6) - 4; + if (qx + px < -60) px = -60 - qx; + if (qy + py < -60) py = -60 - qy; + if (qx + px > X) px = X - qx; + if (qy + py > Y) py = Y - qy; } } /* Calculate hybrid prediction as specified in 8.3.5.3.5 */ - if(0 && !s->first_slice_line && s->mb_x) { - if(is_intra[xy - wrap]) + if (0 && !s->first_slice_line && s->mb_x) { + if (is_intra[xy - wrap]) sum = FFABS(px) + FFABS(py); else sum = FFABS(px - A[0]) + FFABS(py - A[1]); - if(sum > 32) { - if(get_bits1(&s->gb)) { + if (sum > 32) { + if (get_bits1(&s->gb)) { px = A[0]; py = A[1]; } else { @@ -1346,12 +2359,12 @@ py = C[1]; } } else { - if(is_intra[xy - 2]) + if (is_intra[xy - 2]) sum = FFABS(px) + FFABS(py); else sum = FFABS(px - C[0]) + FFABS(py - C[1]); - if(sum > 32) { - if(get_bits1(&s->gb)) { + if (sum > 32) { + if (get_bits1(&s->gb)) { px = A[0]; py = A[1]; } else { @@ -1372,6 +2385,63 @@ s->current_picture.f.motion_val[1][xy][1] = s->mv[1][0][1]; } +static inline void vc1_pred_b_mv_intfi(VC1Context *v, int n, int *dmv_x, int *dmv_y, int mv1, int *pred_flag) +{ + int dir = (v->bmvtype == BMV_TYPE_BACKWARD) ? 1 : 0; + MpegEncContext *s = &v->s; + int mb_pos = s->mb_x + s->mb_y * s->mb_stride; + + if (v->bmvtype == BMV_TYPE_DIRECT) { + int total_opp, k, f; + if (s->next_picture.f.mb_type[mb_pos + v->mb_off] != MB_TYPE_INTRA) { + s->mv[0][0][0] = scale_mv_intfi(s->next_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][0], + v->bfraction, 0, s->quarter_sample, v->qs_last); + s->mv[0][0][1] = scale_mv_intfi(s->next_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][1], + v->bfraction, 0, s->quarter_sample, v->qs_last); + s->mv[1][0][0] = scale_mv_intfi(s->next_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][0], + v->bfraction, 1, s->quarter_sample, v->qs_last); + s->mv[1][0][1] = scale_mv_intfi(s->next_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][1], + v->bfraction, 1, s->quarter_sample, v->qs_last); + + total_opp = v->mv_f_next[0][s->block_index[0] + v->blocks_off] + + v->mv_f_next[0][s->block_index[1] + v->blocks_off] + + v->mv_f_next[0][s->block_index[2] + v->blocks_off] + + v->mv_f_next[0][s->block_index[3] + v->blocks_off]; + f = (total_opp > 2) ? 1 : 0; + } else { + s->mv[0][0][0] = s->mv[0][0][1] = 0; + s->mv[1][0][0] = s->mv[1][0][1] = 0; + f = 0; + } + v->ref_field_type[0] = v->ref_field_type[1] = v->cur_field_type ^ f; + for (k = 0; k < 4; k++) { + s->current_picture.f.motion_val[0][s->block_index[k] + v->blocks_off][0] = s->mv[0][0][0]; + s->current_picture.f.motion_val[0][s->block_index[k] + v->blocks_off][1] = s->mv[0][0][1]; + s->current_picture.f.motion_val[1][s->block_index[k] + v->blocks_off][0] = s->mv[1][0][0]; + s->current_picture.f.motion_val[1][s->block_index[k] + v->blocks_off][1] = s->mv[1][0][1]; + v->mv_f[0][s->block_index[k] + v->blocks_off] = f; + v->mv_f[1][s->block_index[k] + v->blocks_off] = f; + } + return; + } + if (v->bmvtype == BMV_TYPE_INTERPOLATED) { + vc1_pred_mv(v, 0, dmv_x[0], dmv_y[0], 1, v->range_x, v->range_y, v->mb_type[0], pred_flag[0], 0); + vc1_pred_mv(v, 0, dmv_x[1], dmv_y[1], 1, v->range_x, v->range_y, v->mb_type[0], pred_flag[1], 1); + return; + } + if (dir) { // backward + vc1_pred_mv(v, n, dmv_x[1], dmv_y[1], mv1, v->range_x, v->range_y, v->mb_type[0], pred_flag[1], 1); + if (n == 3 || mv1) { + vc1_pred_mv(v, 0, dmv_x[0], dmv_y[0], 1, v->range_x, v->range_y, v->mb_type[0], 0, 0); + } + } else { // forward + vc1_pred_mv(v, n, dmv_x[0], dmv_y[0], mv1, v->range_x, v->range_y, v->mb_type[0], pred_flag[0], 0); + if (n == 3 || mv1) { + vc1_pred_mv(v, 0, dmv_x[1], dmv_y[1], 1, v->range_x, v->range_y, v->mb_type[0], 0, 1); + } + } +} + /** Get predicted DC value for I-frames only * prediction dir: left=0, top=1 * @param s MpegEncContext @@ -1382,23 +2452,23 @@ * @param dir_ptr Prediction direction for use in AC prediction */ static inline int vc1_i_pred_dc(MpegEncContext *s, int overlap, int pq, int n, - int16_t **dc_val_ptr, int *dir_ptr) + int16_t **dc_val_ptr, int *dir_ptr) { int a, b, c, wrap, pred, scale; int16_t *dc_val; static const uint16_t dcpred[32] = { - -1, 1024, 512, 341, 256, 205, 171, 146, 128, - 114, 102, 93, 85, 79, 73, 68, 64, - 60, 57, 54, 51, 49, 47, 45, 43, - 41, 39, 38, 37, 35, 34, 33 + -1, 1024, 512, 341, 256, 205, 171, 146, 128, + 114, 102, 93, 85, 79, 73, 68, 64, + 60, 57, 54, 51, 49, 47, 45, 43, + 41, 39, 38, 37, 35, 34, 33 }; /* find prediction - wmv3_dc_scale always used here in fact */ - if (n < 4) scale = s->y_dc_scale; - else scale = s->c_dc_scale; + if (n < 4) scale = s->y_dc_scale; + else scale = s->c_dc_scale; - wrap = s->block_wrap[n]; - dc_val= s->dc_val[0] + s->block_index[n]; + wrap = s->block_wrap[n]; + dc_val = s->dc_val[0] + s->block_index[n]; /* B A * C X @@ -1407,25 +2477,26 @@ b = dc_val[ - 1 - wrap]; a = dc_val[ - wrap]; - if (pq < 9 || !overlap) - { + if (pq < 9 || !overlap) { /* Set outer values */ - if (s->first_slice_line && (n!=2 && n!=3)) b=a=dcpred[scale]; - if (s->mb_x == 0 && (n!=1 && n!=3)) b=c=dcpred[scale]; - } - else - { + if (s->first_slice_line && (n != 2 && n != 3)) + b = a = dcpred[scale]; + if (s->mb_x == 0 && (n != 1 && n != 3)) + b = c = dcpred[scale]; + } else { /* Set outer values */ - if (s->first_slice_line && (n!=2 && n!=3)) b=a=0; - if (s->mb_x == 0 && (n!=1 && n!=3)) b=c=0; + if (s->first_slice_line && (n != 2 && n != 3)) + b = a = 0; + if (s->mb_x == 0 && (n != 1 && n != 3)) + b = c = 0; } if (abs(a - b) <= abs(b - c)) { - pred = c; - *dir_ptr = 1;//left + pred = c; + *dir_ptr = 1; // left } else { - pred = a; - *dir_ptr = 0;//top + pred = a; + *dir_ptr = 0; // top } /* update predictor */ @@ -1455,7 +2526,7 @@ int q1, q2 = 0; wrap = s->block_wrap[n]; - dc_val= s->dc_val[0] + s->block_index[n]; + dc_val = s->dc_val[0] + s->block_index[n]; /* B A * C X @@ -1465,42 +2536,44 @@ a = dc_val[ - wrap]; /* scale predictors if needed */ q1 = s->current_picture.f.qscale_table[mb_pos]; - if(c_avail && (n!= 1 && n!=3)) { + if (c_avail && (n != 1 && n != 3)) { q2 = s->current_picture.f.qscale_table[mb_pos - 1]; - if(q2 && q2 != q1) + if (q2 && q2 != q1) c = (c * s->y_dc_scale_table[q2] * ff_vc1_dqscale[s->y_dc_scale_table[q1] - 1] + 0x20000) >> 18; } - if(a_avail && (n!= 2 && n!=3)) { + if (a_avail && (n != 2 && n != 3)) { q2 = s->current_picture.f.qscale_table[mb_pos - s->mb_stride]; - if(q2 && q2 != q1) + if (q2 && q2 != q1) a = (a * s->y_dc_scale_table[q2] * ff_vc1_dqscale[s->y_dc_scale_table[q1] - 1] + 0x20000) >> 18; } - if(a_avail && c_avail && (n!=3)) { + if (a_avail && c_avail && (n != 3)) { int off = mb_pos; - if(n != 1) off--; - if(n != 2) off -= s->mb_stride; + if (n != 1) + off--; + if (n != 2) + off -= s->mb_stride; q2 = s->current_picture.f.qscale_table[off]; - if(q2 && q2 != q1) + if (q2 && q2 != q1) b = (b * s->y_dc_scale_table[q2] * ff_vc1_dqscale[s->y_dc_scale_table[q1] - 1] + 0x20000) >> 18; } - if(a_avail && c_avail) { - if(abs(a - b) <= abs(b - c)) { - pred = c; - *dir_ptr = 1;//left + if (a_avail && c_avail) { + if (abs(a - b) <= abs(b - c)) { + pred = c; + *dir_ptr = 1; // left } else { - pred = a; - *dir_ptr = 0;//top + pred = a; + *dir_ptr = 0; // top } - } else if(a_avail) { - pred = a; - *dir_ptr = 0;//top - } else if(c_avail) { - pred = c; - *dir_ptr = 1;//left + } else if (a_avail) { + pred = a; + *dir_ptr = 0; // top + } else if (c_avail) { + pred = c; + *dir_ptr = 1; // left } else { - pred = 0; - *dir_ptr = 1;//left + pred = 0; + *dir_ptr = 1; // left } /* update predictor */ @@ -1516,11 +2589,12 @@ * @{ */ -static inline int vc1_coded_block_pred(MpegEncContext * s, int n, uint8_t **coded_block_ptr) +static inline int vc1_coded_block_pred(MpegEncContext * s, int n, + uint8_t **coded_block_ptr) { int xy, wrap, pred, a, b, c; - xy = s->block_index[n]; + xy = s->block_index[n]; wrap = s->b8_stride; /* B C @@ -1551,61 +2625,62 @@ * @param codingset set of VLC to decode data * @see 8.1.3.4 */ -static void vc1_decode_ac_coeff(VC1Context *v, int *last, int *skip, int *value, int codingset) +static void vc1_decode_ac_coeff(VC1Context *v, int *last, int *skip, + int *value, int codingset) { GetBitContext *gb = &v->s.gb; int index, escape, run = 0, level = 0, lst = 0; index = get_vlc2(gb, ff_vc1_ac_coeff_table[codingset].table, AC_VLC_BITS, 3); if (index != vc1_ac_sizes[codingset] - 1) { - run = vc1_index_decode_table[codingset][index][0]; + run = vc1_index_decode_table[codingset][index][0]; level = vc1_index_decode_table[codingset][index][1]; - lst = index >= vc1_last_decode_table[codingset] || get_bits_left(gb) < 0; - if(get_bits1(gb)) + lst = index >= vc1_last_decode_table[codingset] || get_bits_left(gb) < 0; + if (get_bits1(gb)) level = -level; } else { escape = decode210(gb); if (escape != 2) { index = get_vlc2(gb, ff_vc1_ac_coeff_table[codingset].table, AC_VLC_BITS, 3); - run = vc1_index_decode_table[codingset][index][0]; + run = vc1_index_decode_table[codingset][index][0]; level = vc1_index_decode_table[codingset][index][1]; - lst = index >= vc1_last_decode_table[codingset]; - if(escape == 0) { - if(lst) + lst = index >= vc1_last_decode_table[codingset]; + if (escape == 0) { + if (lst) level += vc1_last_delta_level_table[codingset][run]; else level += vc1_delta_level_table[codingset][run]; } else { - if(lst) + if (lst) run += vc1_last_delta_run_table[codingset][level] + 1; else run += vc1_delta_run_table[codingset][level] + 1; } - if(get_bits1(gb)) + if (get_bits1(gb)) level = -level; } else { int sign; lst = get_bits1(gb); - if(v->s.esc3_level_length == 0) { - if(v->pq < 8 || v->dquantfrm) { // table 59 + if (v->s.esc3_level_length == 0) { + if (v->pq < 8 || v->dquantfrm) { // table 59 v->s.esc3_level_length = get_bits(gb, 3); - if(!v->s.esc3_level_length) + if (!v->s.esc3_level_length) v->s.esc3_level_length = get_bits(gb, 2) + 8; - } else { //table 60 + } else { // table 60 v->s.esc3_level_length = get_unary(gb, 1, 6) + 2; } v->s.esc3_run_length = 3 + get_bits(gb, 2); } - run = get_bits(gb, v->s.esc3_run_length); - sign = get_bits1(gb); + run = get_bits(gb, v->s.esc3_run_length); + sign = get_bits1(gb); level = get_bits(gb, v->s.esc3_level_length); - if(sign) + if (sign) level = -level; } } - *last = lst; - *skip = run; + *last = lst; + *skip = run; *value = level; } @@ -1616,7 +2691,8 @@ * @param coded are AC coeffs present or not * @param codingset set of VLC to decode data */ -static int vc1_decode_i_block(VC1Context *v, DCTELEM block[64], int n, int coded, int codingset) +static int vc1_decode_i_block(VC1Context *v, DCTELEM block[64], int n, + int coded, int codingset) { GetBitContext *gb = &v->s.gb; MpegEncContext *s = &v->s; @@ -1632,25 +2708,21 @@ } else { dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3); } - if (dcdiff < 0){ + if (dcdiff < 0) { av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\n"); return -1; } - if (dcdiff) - { - if (dcdiff == 119 /* ESC index value */) - { + if (dcdiff) { + if (dcdiff == 119 /* ESC index value */) { /* TODO: Optimize */ - if (v->pq == 1) dcdiff = get_bits(gb, 10); + if (v->pq == 1) dcdiff = get_bits(gb, 10); else if (v->pq == 2) dcdiff = get_bits(gb, 9); - else dcdiff = get_bits(gb, 8); - } - else - { + else dcdiff = get_bits(gb, 8); + } else { if (v->pq == 1) - dcdiff = (dcdiff<<2) + get_bits(gb, 2) - 3; + dcdiff = (dcdiff << 2) + get_bits(gb, 2) - 3; else if (v->pq == 2) - dcdiff = (dcdiff<<1) + get_bits1(gb) - 1; + dcdiff = (dcdiff << 1) + get_bits1(gb) - 1; } if (get_bits1(gb)) dcdiff = -dcdiff; @@ -1671,7 +2743,7 @@ goto not_coded; } - //AC Decoding + // AC Decoding i = 1; { @@ -1682,87 +2754,87 @@ scale = v->pq * 2 + v->halfpq; - if(v->s.ac_pred) { - if(!dc_pred_dir) + if (v->s.ac_pred) { + if (!dc_pred_dir) zz_table = v->zz_8x8[2]; else zz_table = v->zz_8x8[3]; } else zz_table = v->zz_8x8[1]; - ac_val = s->ac_val[0][0] + s->block_index[n] * 16; + ac_val = s->ac_val[0][0] + s->block_index[n] * 16; ac_val2 = ac_val; - if(dc_pred_dir) //left + if (dc_pred_dir) // left ac_val -= 16; - else //top + else // top ac_val -= 16 * s->block_wrap[n]; while (!last) { vc1_decode_ac_coeff(v, &last, &skip, &value, codingset); i += skip; - if(i > 63) + if (i > 63) break; block[zz_table[i++]] = value; } /* apply AC prediction if needed */ - if(s->ac_pred) { - if(dc_pred_dir) { //left - for(k = 1; k < 8; k++) + if (s->ac_pred) { + if (dc_pred_dir) { // left + for (k = 1; k < 8; k++) block[k << v->left_blk_sh] += ac_val[k]; - } else { //top - for(k = 1; k < 8; k++) + } else { // top + for (k = 1; k < 8; k++) block[k << v->top_blk_sh] += ac_val[k + 8]; } } /* save AC coeffs for further prediction */ - for(k = 1; k < 8; k++) { + for (k = 1; k < 8; k++) { ac_val2[k] = block[k << v->left_blk_sh]; ac_val2[k + 8] = block[k << v->top_blk_sh]; } /* scale AC coeffs */ - for(k = 1; k < 64; k++) - if(block[k]) { + for (k = 1; k < 64; k++) + if (block[k]) { block[k] *= scale; - if(!v->pquantizer) + if (!v->pquantizer) block[k] += (block[k] < 0) ? -v->pq : v->pq; } - if(s->ac_pred) i = 63; + if (s->ac_pred) i = 63; } not_coded: - if(!coded) { + if (!coded) { int k, scale; - ac_val = s->ac_val[0][0] + s->block_index[n] * 16; + ac_val = s->ac_val[0][0] + s->block_index[n] * 16; ac_val2 = ac_val; i = 0; scale = v->pq * 2 + v->halfpq; memset(ac_val2, 0, 16 * 2); - if(dc_pred_dir) {//left + if (dc_pred_dir) { // left ac_val -= 16; - if(s->ac_pred) + if (s->ac_pred) memcpy(ac_val2, ac_val, 8 * 2); - } else {//top + } else { // top ac_val -= 16 * s->block_wrap[n]; - if(s->ac_pred) + if (s->ac_pred) memcpy(ac_val2 + 8, ac_val + 8, 8 * 2); } /* apply AC prediction if needed */ - if(s->ac_pred) { - if(dc_pred_dir) { //left - for(k = 1; k < 8; k++) { + if (s->ac_pred) { + if (dc_pred_dir) { //left + for (k = 1; k < 8; k++) { block[k << v->left_blk_sh] = ac_val[k] * scale; - if(!v->pquantizer && block[k << v->left_blk_sh]) + if (!v->pquantizer && block[k << v->left_blk_sh]) block[k << v->left_blk_sh] += (block[k << v->left_blk_sh] < 0) ? -v->pq : v->pq; } - } else { //top - for(k = 1; k < 8; k++) { + } else { // top + for (k = 1; k < 8; k++) { block[k << v->top_blk_sh] = ac_val[k + 8] * scale; - if(!v->pquantizer && block[k << v->top_blk_sh]) + if (!v->pquantizer && block[k << v->top_blk_sh]) block[k << v->top_blk_sh] += (block[k << v->top_blk_sh] < 0) ? -v->pq : v->pq; } } @@ -1782,7 +2854,8 @@ * @param codingset set of VLC to decode data * @param mquant quantizer value for this macroblock */ -static int vc1_decode_i_block_adv(VC1Context *v, DCTELEM block[64], int n, int coded, int codingset, int mquant) +static int vc1_decode_i_block_adv(VC1Context *v, DCTELEM block[64], int n, + int coded, int codingset, int mquant) { GetBitContext *gb = &v->s.gb; MpegEncContext *s = &v->s; @@ -1803,25 +2876,21 @@ } else { dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3); } - if (dcdiff < 0){ + if (dcdiff < 0) { av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\n"); return -1; } - if (dcdiff) - { - if (dcdiff == 119 /* ESC index value */) - { + if (dcdiff) { + if (dcdiff == 119 /* ESC index value */) { /* TODO: Optimize */ - if (mquant == 1) dcdiff = get_bits(gb, 10); + if (mquant == 1) dcdiff = get_bits(gb, 10); else if (mquant == 2) dcdiff = get_bits(gb, 9); - else dcdiff = get_bits(gb, 8); - } - else - { + else dcdiff = get_bits(gb, 8); + } else { if (mquant == 1) - dcdiff = (dcdiff<<2) + get_bits(gb, 2) - 3; + dcdiff = (dcdiff << 2) + get_bits(gb, 2) - 3; else if (mquant == 2) - dcdiff = (dcdiff<<1) + get_bits1(gb) - 1; + dcdiff = (dcdiff << 1) + get_bits1(gb) - 1; } if (get_bits1(gb)) dcdiff = -dcdiff; @@ -1842,122 +2911,136 @@ i = 1; /* check if AC is needed at all */ - if(!a_avail && !c_avail) use_pred = 0; - ac_val = s->ac_val[0][0] + s->block_index[n] * 16; + if (!a_avail && !c_avail) + use_pred = 0; + ac_val = s->ac_val[0][0] + s->block_index[n] * 16; ac_val2 = ac_val; scale = mquant * 2 + ((mquant == v->pq) ? v->halfpq : 0); - if(dc_pred_dir) //left + if (dc_pred_dir) // left ac_val -= 16; - else //top + else // top ac_val -= 16 * s->block_wrap[n]; q1 = s->current_picture.f.qscale_table[mb_pos]; - if(dc_pred_dir && c_avail && mb_pos) q2 = s->current_picture.f.qscale_table[mb_pos - 1]; - if(!dc_pred_dir && a_avail && mb_pos >= s->mb_stride) q2 = s->current_picture.f.qscale_table[mb_pos - s->mb_stride]; - if(dc_pred_dir && n==1) q2 = q1; - if(!dc_pred_dir && n==2) q2 = q1; - if(n==3) q2 = q1; + if ( dc_pred_dir && c_avail && mb_pos) + q2 = s->current_picture.f.qscale_table[mb_pos - 1]; + if (!dc_pred_dir && a_avail && mb_pos >= s->mb_stride) + q2 = s->current_picture.f.qscale_table[mb_pos - s->mb_stride]; + if ( dc_pred_dir && n == 1) + q2 = q1; + if (!dc_pred_dir && n == 2) + q2 = q1; + if (n == 3) + q2 = q1; - if(coded) { + if (coded) { int last = 0, skip, value; const uint8_t *zz_table; int k; - if(v->s.ac_pred) { - if(!dc_pred_dir) - zz_table = v->zz_8x8[2]; + if (v->s.ac_pred) { + if (!use_pred && v->fcm == 1) { + zz_table = v->zzi_8x8; + } else { + if (!dc_pred_dir) // top + zz_table = v->zz_8x8[2]; + else // left + zz_table = v->zz_8x8[3]; + } + } else { + if (v->fcm != 1) + zz_table = v->zz_8x8[1]; else - zz_table = v->zz_8x8[3]; - } else - zz_table = v->zz_8x8[1]; + zz_table = v->zzi_8x8; + } while (!last) { vc1_decode_ac_coeff(v, &last, &skip, &value, codingset); i += skip; - if(i > 63) + if (i > 63) break; block[zz_table[i++]] = value; } /* apply AC prediction if needed */ - if(use_pred) { + if (use_pred) { /* scale predictors if needed*/ - if(q2 && q1!=q2) { + if (q2 && q1 != q2) { q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1; q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1; - if(dc_pred_dir) { //left - for(k = 1; k < 8; k++) + if (dc_pred_dir) { // left + for (k = 1; k < 8; k++) block[k << v->left_blk_sh] += (ac_val[k] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18; - } else { //top - for(k = 1; k < 8; k++) + } else { // top + for (k = 1; k < 8; k++) block[k << v->top_blk_sh] += (ac_val[k + 8] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18; } } else { - if(dc_pred_dir) { //left - for(k = 1; k < 8; k++) + if (dc_pred_dir) { //left + for (k = 1; k < 8; k++) block[k << v->left_blk_sh] += ac_val[k]; } else { //top - for(k = 1; k < 8; k++) + for (k = 1; k < 8; k++) block[k << v->top_blk_sh] += ac_val[k + 8]; } } } /* save AC coeffs for further prediction */ - for(k = 1; k < 8; k++) { + for (k = 1; k < 8; k++) { ac_val2[k ] = block[k << v->left_blk_sh]; ac_val2[k + 8] = block[k << v->top_blk_sh]; } /* scale AC coeffs */ - for(k = 1; k < 64; k++) - if(block[k]) { + for (k = 1; k < 64; k++) + if (block[k]) { block[k] *= scale; - if(!v->pquantizer) + if (!v->pquantizer) block[k] += (block[k] < 0) ? -mquant : mquant; } - if(use_pred) i = 63; + if (use_pred) i = 63; } else { // no AC coeffs int k; memset(ac_val2, 0, 16 * 2); - if(dc_pred_dir) {//left - if(use_pred) { + if (dc_pred_dir) { // left + if (use_pred) { memcpy(ac_val2, ac_val, 8 * 2); - if(q2 && q1!=q2) { + if (q2 && q1 != q2) { q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1; q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1; - for(k = 1; k < 8; k++) + for (k = 1; k < 8; k++) ac_val2[k] = (ac_val2[k] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18; } } - } else {//top - if(use_pred) { + } else { // top + if (use_pred) { memcpy(ac_val2 + 8, ac_val + 8, 8 * 2); - if(q2 && q1!=q2) { + if (q2 && q1 != q2) { q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1; q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1; - for(k = 1; k < 8; k++) + for (k = 1; k < 8; k++) ac_val2[k + 8] = (ac_val2[k + 8] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18; } } } /* apply AC prediction if needed */ - if(use_pred) { - if(dc_pred_dir) { //left - for(k = 1; k < 8; k++) { + if (use_pred) { + if (dc_pred_dir) { // left + for (k = 1; k < 8; k++) { block[k << v->left_blk_sh] = ac_val2[k] * scale; - if(!v->pquantizer && block[k << v->left_blk_sh]) + if (!v->pquantizer && block[k << v->left_blk_sh]) block[k << v->left_blk_sh] += (block[k << v->left_blk_sh] < 0) ? -mquant : mquant; } - } else { //top - for(k = 1; k < 8; k++) { + } else { // top + for (k = 1; k < 8; k++) { block[k << v->top_blk_sh] = ac_val2[k + 8] * scale; - if(!v->pquantizer && block[k << v->top_blk_sh]) + if (!v->pquantizer && block[k << v->top_blk_sh]) block[k << v->top_blk_sh] += (block[k << v->top_blk_sh] < 0) ? -mquant : mquant; } } @@ -1977,7 +3060,8 @@ * @param mquant block quantizer * @param codingset set of VLC to decode data */ -static int vc1_decode_intra_block(VC1Context *v, DCTELEM block[64], int n, int coded, int mquant, int codingset) +static int vc1_decode_intra_block(VC1Context *v, DCTELEM block[64], int n, + int coded, int mquant, int codingset) { GetBitContext *gb = &v->s.gb; MpegEncContext *s = &v->s; @@ -1995,7 +3079,7 @@ s->dsp.clear_block(block); /* XXX: Guard against dumb values of mquant */ - mquant = (mquant < 1) ? 0 : ( (mquant>31) ? 31 : mquant ); + mquant = (mquant < 1) ? 0 : ((mquant > 31) ? 31 : mquant); /* Set DC scale - y and c use the same */ s->y_dc_scale = s->y_dc_scale_table[mquant]; @@ -2007,25 +3091,21 @@ } else { dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table, DC_VLC_BITS, 3); } - if (dcdiff < 0){ + if (dcdiff < 0) { av_log(s->avctx, AV_LOG_ERROR, "Illegal DC VLC\n"); return -1; } - if (dcdiff) - { - if (dcdiff == 119 /* ESC index value */) - { + if (dcdiff) { + if (dcdiff == 119 /* ESC index value */) { /* TODO: Optimize */ - if (mquant == 1) dcdiff = get_bits(gb, 10); + if (mquant == 1) dcdiff = get_bits(gb, 10); else if (mquant == 2) dcdiff = get_bits(gb, 9); - else dcdiff = get_bits(gb, 8); - } - else - { + else dcdiff = get_bits(gb, 8); + } else { if (mquant == 1) - dcdiff = (dcdiff<<2) + get_bits(gb, 2) - 3; + dcdiff = (dcdiff << 2) + get_bits(gb, 2) - 3; else if (mquant == 2) - dcdiff = (dcdiff<<1) + get_bits1(gb) - 1; + dcdiff = (dcdiff << 1) + get_bits1(gb) - 1; } if (get_bits1(gb)) dcdiff = -dcdiff; @@ -2047,115 +3127,130 @@ i = 1; /* check if AC is needed at all and adjust direction if needed */ - if(!a_avail) dc_pred_dir = 1; - if(!c_avail) dc_pred_dir = 0; - if(!a_avail && !c_avail) use_pred = 0; + if (!a_avail) dc_pred_dir = 1; + if (!c_avail) dc_pred_dir = 0; + if (!a_avail && !c_avail) use_pred = 0; ac_val = s->ac_val[0][0] + s->block_index[n] * 16; ac_val2 = ac_val; scale = mquant * 2 + v->halfpq; - if(dc_pred_dir) //left + if (dc_pred_dir) //left ac_val -= 16; else //top ac_val -= 16 * s->block_wrap[n]; q1 = s->current_picture.f.qscale_table[mb_pos]; - if(dc_pred_dir && c_avail && mb_pos) q2 = s->current_picture.f.qscale_table[mb_pos - 1]; - if(!dc_pred_dir && a_avail && mb_pos >= s->mb_stride) q2 = s->current_picture.f.qscale_table[mb_pos - s->mb_stride]; - if(dc_pred_dir && n==1) q2 = q1; - if(!dc_pred_dir && n==2) q2 = q1; - if(n==3) q2 = q1; + if (dc_pred_dir && c_avail && mb_pos) + q2 = s->current_picture.f.qscale_table[mb_pos - 1]; + if (!dc_pred_dir && a_avail && mb_pos >= s->mb_stride) + q2 = s->current_picture.f.qscale_table[mb_pos - s->mb_stride]; + if ( dc_pred_dir && n == 1) + q2 = q1; + if (!dc_pred_dir && n == 2) + q2 = q1; + if (n == 3) q2 = q1; - if(coded) { + if (coded) { int last = 0, skip, value; int k; while (!last) { vc1_decode_ac_coeff(v, &last, &skip, &value, codingset); i += skip; - if(i > 63) + if (i > 63) break; - block[v->zz_8x8[0][i++]] = value; + if (v->fcm == 0) + block[v->zz_8x8[0][i++]] = value; + else { + if (use_pred && (v->fcm == 1)) { + if (!dc_pred_dir) // top + block[v->zz_8x8[2][i++]] = value; + else // left + block[v->zz_8x8[3][i++]] = value; + } else { + block[v->zzi_8x8[i++]] = value; + } + } } /* apply AC prediction if needed */ - if(use_pred) { + if (use_pred) { /* scale predictors if needed*/ - if(q2 && q1!=q2) { + if (q2 && q1 != q2) { q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1; q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1; - if(dc_pred_dir) { //left - for(k = 1; k < 8; k++) + if (dc_pred_dir) { // left + for (k = 1; k < 8; k++) block[k << v->left_blk_sh] += (ac_val[k] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18; } else { //top - for(k = 1; k < 8; k++) + for (k = 1; k < 8; k++) block[k << v->top_blk_sh] += (ac_val[k + 8] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18; } } else { - if(dc_pred_dir) { //left - for(k = 1; k < 8; k++) + if (dc_pred_dir) { // left + for (k = 1; k < 8; k++) block[k << v->left_blk_sh] += ac_val[k]; - } else { //top - for(k = 1; k < 8; k++) + } else { // top + for (k = 1; k < 8; k++) block[k << v->top_blk_sh] += ac_val[k + 8]; } } } /* save AC coeffs for further prediction */ - for(k = 1; k < 8; k++) { + for (k = 1; k < 8; k++) { ac_val2[k ] = block[k << v->left_blk_sh]; ac_val2[k + 8] = block[k << v->top_blk_sh]; } /* scale AC coeffs */ - for(k = 1; k < 64; k++) - if(block[k]) { + for (k = 1; k < 64; k++) + if (block[k]) { block[k] *= scale; - if(!v->pquantizer) + if (!v->pquantizer) block[k] += (block[k] < 0) ? -mquant : mquant; } - if(use_pred) i = 63; + if (use_pred) i = 63; } else { // no AC coeffs int k; memset(ac_val2, 0, 16 * 2); - if(dc_pred_dir) {//left - if(use_pred) { + if (dc_pred_dir) { // left + if (use_pred) { memcpy(ac_val2, ac_val, 8 * 2); - if(q2 && q1!=q2) { + if (q2 && q1 != q2) { q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1; q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1; - for(k = 1; k < 8; k++) + for (k = 1; k < 8; k++) ac_val2[k] = (ac_val2[k] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18; } } - } else {//top - if(use_pred) { + } else { // top + if (use_pred) { memcpy(ac_val2 + 8, ac_val + 8, 8 * 2); - if(q2 && q1!=q2) { + if (q2 && q1 != q2) { q1 = q1 * 2 + ((q1 == v->pq) ? v->halfpq : 0) - 1; q2 = q2 * 2 + ((q2 == v->pq) ? v->halfpq : 0) - 1; - for(k = 1; k < 8; k++) + for (k = 1; k < 8; k++) ac_val2[k + 8] = (ac_val2[k + 8] * q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18; } } } /* apply AC prediction if needed */ - if(use_pred) { - if(dc_pred_dir) { //left - for(k = 1; k < 8; k++) { + if (use_pred) { + if (dc_pred_dir) { // left + for (k = 1; k < 8; k++) { block[k << v->left_blk_sh] = ac_val2[k] * scale; - if(!v->pquantizer && block[k << v->left_blk_sh]) + if (!v->pquantizer && block[k << v->left_blk_sh]) block[k << v->left_blk_sh] += (block[k << v->left_blk_sh] < 0) ? -mquant : mquant; } - } else { //top - for(k = 1; k < 8; k++) { + } else { // top + for (k = 1; k < 8; k++) { block[k << v->top_blk_sh] = ac_val2[k + 8] * scale; - if(!v->pquantizer && block[k << v->top_blk_sh]) + if (!v->pquantizer && block[k << v->top_blk_sh]) block[k << v->top_blk_sh] += (block[k << v->top_blk_sh] < 0) ? -mquant : mquant; } } @@ -2169,8 +3264,10 @@ /** Decode P block */ -static int vc1_decode_p_block(VC1Context *v, DCTELEM block[64], int n, int mquant, int ttmb, int first_block, - uint8_t *dst, int linesize, int skip_block, int *ttmb_out) +static int vc1_decode_p_block(VC1Context *v, DCTELEM block[64], int n, + int mquant, int ttmb, int first_block, + uint8_t *dst, int linesize, int skip_block, + int *ttmb_out) { MpegEncContext *s = &v->s; GetBitContext *gb = &s->gb; @@ -2182,50 +3279,56 @@ s->dsp.clear_block(block); - if(ttmb == -1) { + if (ttmb == -1) { ttblk = ff_vc1_ttblk_to_tt[v->tt_index][get_vlc2(gb, ff_vc1_ttblk_vlc[v->tt_index].table, VC1_TTBLK_VLC_BITS, 1)]; } - if(ttblk == TT_4X4) { + if (ttblk == TT_4X4) { subblkpat = ~(get_vlc2(gb, ff_vc1_subblkpat_vlc[v->tt_index].table, VC1_SUBBLKPAT_VLC_BITS, 1) + 1); } - if((ttblk != TT_8X8 && ttblk != TT_4X4) + if ((ttblk != TT_8X8 && ttblk != TT_4X4) && ((v->ttmbf || (ttmb != -1 && (ttmb & 8) && !first_block)) || (!v->res_rtm_flag && !first_block))) { subblkpat = decode012(gb); - if(subblkpat) subblkpat ^= 3; //swap decoded pattern bits - if(ttblk == TT_8X4_TOP || ttblk == TT_8X4_BOTTOM) ttblk = TT_8X4; - if(ttblk == TT_4X8_RIGHT || ttblk == TT_4X8_LEFT) ttblk = TT_4X8; + if (subblkpat) + subblkpat ^= 3; // swap decoded pattern bits + if (ttblk == TT_8X4_TOP || ttblk == TT_8X4_BOTTOM) + ttblk = TT_8X4; + if (ttblk == TT_4X8_RIGHT || ttblk == TT_4X8_LEFT) + ttblk = TT_4X8; } scale = 2 * mquant + ((v->pq == mquant) ? v->halfpq : 0); // convert transforms like 8X4_TOP to generic TT and SUBBLKPAT - if(ttblk == TT_8X4_TOP || ttblk == TT_8X4_BOTTOM) { + if (ttblk == TT_8X4_TOP || ttblk == TT_8X4_BOTTOM) { subblkpat = 2 - (ttblk == TT_8X4_TOP); - ttblk = TT_8X4; + ttblk = TT_8X4; } - if(ttblk == TT_4X8_RIGHT || ttblk == TT_4X8_LEFT) { + if (ttblk == TT_4X8_RIGHT || ttblk == TT_4X8_LEFT) { subblkpat = 2 - (ttblk == TT_4X8_LEFT); - ttblk = TT_4X8; + ttblk = TT_4X8; } - switch(ttblk) { + switch (ttblk) { case TT_8X8: - pat = 0xF; - i = 0; + pat = 0xF; + i = 0; last = 0; while (!last) { vc1_decode_ac_coeff(v, &last, &skip, &value, v->codingset2); i += skip; - if(i > 63) + if (i > 63) break; - idx = v->zz_8x8[0][i++]; + if (!v->interlace) + idx = v->zz_8x8[0][i++]; + else + idx = v->zzi_8x8[i++]; block[idx] = value * scale; - if(!v->pquantizer) + if (!v->pquantizer) block[idx] += (block[idx] < 0) ? -mquant : mquant; } - if(!skip_block){ - if(i==1) + if (!skip_block) { + if (i == 1) v->vc1dsp.vc1_inv_trans_8x8_dc(dst, linesize, block); - else{ + else { v->vc1dsp.vc1_inv_trans_8x8(block); s->dsp.add_pixels_clamped(block, dst, linesize); } @@ -2233,71 +3336,80 @@ break; case TT_4X4: pat = ~subblkpat & 0xF; - for(j = 0; j < 4; j++) { + for (j = 0; j < 4; j++) { last = subblkpat & (1 << (3 - j)); - i = 0; - off = (j & 1) * 4 + (j & 2) * 16; + i = 0; + off = (j & 1) * 4 + (j & 2) * 16; while (!last) { vc1_decode_ac_coeff(v, &last, &skip, &value, v->codingset2); i += skip; - if(i > 15) + if (i > 15) break; - idx = ff_vc1_simple_progressive_4x4_zz[i++]; + if (!v->interlace) + idx = ff_vc1_simple_progressive_4x4_zz[i++]; + else + idx = ff_vc1_adv_interlaced_4x4_zz[i++]; block[idx + off] = value * scale; - if(!v->pquantizer) + if (!v->pquantizer) block[idx + off] += (block[idx + off] < 0) ? -mquant : mquant; } - if(!(subblkpat & (1 << (3 - j))) && !skip_block){ - if(i==1) - v->vc1dsp.vc1_inv_trans_4x4_dc(dst + (j&1)*4 + (j&2)*2*linesize, linesize, block + off); + if (!(subblkpat & (1 << (3 - j))) && !skip_block) { + if (i == 1) + v->vc1dsp.vc1_inv_trans_4x4_dc(dst + (j & 1) * 4 + (j & 2) * 2 * linesize, linesize, block + off); else - v->vc1dsp.vc1_inv_trans_4x4(dst + (j&1)*4 + (j&2)*2*linesize, linesize, block + off); + v->vc1dsp.vc1_inv_trans_4x4(dst + (j & 1) * 4 + (j & 2) * 2 * linesize, linesize, block + off); } } break; case TT_8X4: - pat = ~((subblkpat & 2)*6 + (subblkpat & 1)*3) & 0xF; - for(j = 0; j < 2; j++) { + pat = ~((subblkpat & 2) * 6 + (subblkpat & 1) * 3) & 0xF; + for (j = 0; j < 2; j++) { last = subblkpat & (1 << (1 - j)); - i = 0; - off = j * 32; + i = 0; + off = j * 32; while (!last) { vc1_decode_ac_coeff(v, &last, &skip, &value, v->codingset2); i += skip; - if(i > 31) + if (i > 31) break; - idx = v->zz_8x4[i++]+off; + if (!v->interlace) + idx = v->zz_8x4[i++] + off; + else + idx = ff_vc1_adv_interlaced_8x4_zz[i++] + off; block[idx] = value * scale; - if(!v->pquantizer) + if (!v->pquantizer) block[idx] += (block[idx] < 0) ? -mquant : mquant; } - if(!(subblkpat & (1 << (1 - j))) && !skip_block){ - if(i==1) - v->vc1dsp.vc1_inv_trans_8x4_dc(dst + j*4*linesize, linesize, block + off); + if (!(subblkpat & (1 << (1 - j))) && !skip_block) { + if (i == 1) + v->vc1dsp.vc1_inv_trans_8x4_dc(dst + j * 4 * linesize, linesize, block + off); else - v->vc1dsp.vc1_inv_trans_8x4(dst + j*4*linesize, linesize, block + off); + v->vc1dsp.vc1_inv_trans_8x4(dst + j * 4 * linesize, linesize, block + off); } } break; case TT_4X8: - pat = ~(subblkpat*5) & 0xF; - for(j = 0; j < 2; j++) { + pat = ~(subblkpat * 5) & 0xF; + for (j = 0; j < 2; j++) { last = subblkpat & (1 << (1 - j)); - i = 0; - off = j * 4; + i = 0; + off = j * 4; while (!last) { vc1_decode_ac_coeff(v, &last, &skip, &value, v->codingset2); i += skip; - if(i > 31) + if (i > 31) break; - idx = v->zz_4x8[i++]+off; + if (!v->interlace) + idx = v->zz_4x8[i++] + off; + else + idx = ff_vc1_adv_interlaced_4x8_zz[i++] + off; block[idx] = value * scale; - if(!v->pquantizer) + if (!v->pquantizer) block[idx] += (block[idx] < 0) ? -mquant : mquant; } - if(!(subblkpat & (1 << (1 - j))) && !skip_block){ - if(i==1) - v->vc1dsp.vc1_inv_trans_4x8_dc(dst + j*4, linesize, block + off); + if (!(subblkpat & (1 << (1 - j))) && !skip_block) { + if (i == 1) + v->vc1dsp.vc1_inv_trans_4x8_dc(dst + j * 4, linesize, block + off); else v->vc1dsp.vc1_inv_trans_4x8(dst + j*4, linesize, block + off); } @@ -2316,15 +3428,15 @@ static av_always_inline void vc1_apply_p_v_loop_filter(VC1Context *v, int block_num) { - MpegEncContext *s = &v->s; + MpegEncContext *s = &v->s; int mb_cbp = v->cbp[s->mb_x - s->mb_stride], block_cbp = mb_cbp >> (block_num * 4), bottom_cbp, mb_is_intra = v->is_intra[s->mb_x - s->mb_stride], block_is_intra = mb_is_intra >> (block_num * 4), bottom_is_intra; - int idx, linesize = block_num > 3 ? s->uvlinesize : s->linesize, ttblk; + int idx, linesize = block_num > 3 ? s->uvlinesize : s->linesize, ttblk; uint8_t *dst; - if(block_num > 3) { + if (block_num > 3) { dst = s->dest[block_num - 3]; } else { dst = s->dest[0] + (block_num & 1) * 8 + ((block_num & 2) * 4 - 8) * linesize; @@ -2333,16 +3445,16 @@ int16_t (*mv)[2]; int mv_stride; - if(block_num > 3) { + if (block_num > 3) { bottom_cbp = v->cbp[s->mb_x] >> (block_num * 4); bottom_is_intra = v->is_intra[s->mb_x] >> (block_num * 4); mv = &v->luma_mv[s->mb_x - s->mb_stride]; mv_stride = s->mb_stride; } else { - bottom_cbp = (block_num < 2) ? (mb_cbp >> ((block_num + 2) * 4)) : - (v->cbp[s->mb_x] >> ((block_num - 2) * 4)); - bottom_is_intra = (block_num < 2) ? (mb_is_intra >> ((block_num + 2) * 4)) : - (v->is_intra[s->mb_x] >> ((block_num - 2) * 4)); + bottom_cbp = (block_num < 2) ? (mb_cbp >> ((block_num + 2) * 4)) + : (v->cbp[s->mb_x] >> ((block_num - 2) * 4)); + bottom_is_intra = (block_num < 2) ? (mb_is_intra >> ((block_num + 2) * 4)) + : (v->is_intra[s->mb_x] >> ((block_num - 2) * 4)); mv_stride = s->b8_stride; mv = &s->current_picture.f.motion_val[0][s->block_index[block_num] - 2 * mv_stride]; } @@ -2352,7 +3464,7 @@ v->vc1dsp.vc1_v_loop_filter8(dst, linesize, v->pq); } else { idx = ((bottom_cbp >> 2) | block_cbp) & 3; - if(idx == 3) { + if (idx == 3) { v->vc1dsp.vc1_v_loop_filter8(dst, linesize, v->pq); } else if (idx) { if (idx == 1) @@ -2364,7 +3476,7 @@ } dst -= 4 * linesize; - ttblk = (v->ttblk[s->mb_x - s->mb_stride] >> (block_num * 4)) & 0xf; + ttblk = (v->ttblk[s->mb_x - s->mb_stride] >> (block_num * 4)) & 0xF; if (ttblk == TT_4X4 || ttblk == TT_8X4) { idx = (block_cbp | (block_cbp >> 2)) & 3; if (idx == 3) { @@ -2380,12 +3492,12 @@ static av_always_inline void vc1_apply_p_h_loop_filter(VC1Context *v, int block_num) { - MpegEncContext *s = &v->s; + MpegEncContext *s = &v->s; int mb_cbp = v->cbp[s->mb_x - 1 - s->mb_stride], block_cbp = mb_cbp >> (block_num * 4), right_cbp, mb_is_intra = v->is_intra[s->mb_x - 1 - s->mb_stride], block_is_intra = mb_is_intra >> (block_num * 4), right_is_intra; - int idx, linesize = block_num > 3 ? s->uvlinesize : s->linesize, ttblk; + int idx, linesize = block_num > 3 ? s->uvlinesize : s->linesize, ttblk; uint8_t *dst; if (block_num > 3) { @@ -2397,15 +3509,15 @@ if (s->mb_x != s->mb_width || !(block_num & 5)) { int16_t (*mv)[2]; - if(block_num > 3) { + if (block_num > 3) { right_cbp = v->cbp[s->mb_x - s->mb_stride] >> (block_num * 4); right_is_intra = v->is_intra[s->mb_x - s->mb_stride] >> (block_num * 4); mv = &v->luma_mv[s->mb_x - s->mb_stride - 1]; - }else{ - right_cbp = (block_num & 1) ? (v->cbp[s->mb_x - s->mb_stride] >> ((block_num - 1) * 4)) : - (mb_cbp >> ((block_num + 1) * 4)); - right_is_intra = (block_num & 1) ? (v->is_intra[s->mb_x - s->mb_stride] >> ((block_num - 1) * 4)) : - (mb_is_intra >> ((block_num + 1) * 4)); + } else { + right_cbp = (block_num & 1) ? (v->cbp[s->mb_x - s->mb_stride] >> ((block_num - 1) * 4)) + : (mb_cbp >> ((block_num + 1) * 4)); + right_is_intra = (block_num & 1) ? (v->is_intra[s->mb_x - s->mb_stride] >> ((block_num - 1) * 4)) + : (mb_is_intra >> ((block_num + 1) * 4)); mv = &s->current_picture.f.motion_val[0][s->block_index[block_num] - s->b8_stride * 2 - 2]; } if (block_is_intra & 1 || right_is_intra & 1 || mv[0][0] != mv[1][0] || mv[0][1] != mv[1][1]) { @@ -2416,9 +3528,9 @@ v->vc1dsp.vc1_h_loop_filter8(dst, linesize, v->pq); } else if (idx) { if (idx == 1) - v->vc1dsp.vc1_h_loop_filter4(dst+4*linesize, linesize, v->pq); + v->vc1dsp.vc1_h_loop_filter4(dst + 4 * linesize, linesize, v->pq); else - v->vc1dsp.vc1_h_loop_filter4(dst, linesize, v->pq); + v->vc1dsp.vc1_h_loop_filter4(dst, linesize, v->pq); } } } @@ -2431,9 +3543,9 @@ v->vc1dsp.vc1_h_loop_filter8(dst, linesize, v->pq); } else if (idx) { if (idx == 1) - v->vc1dsp.vc1_h_loop_filter4(dst + linesize*4, linesize, v->pq); + v->vc1dsp.vc1_h_loop_filter4(dst + linesize * 4, linesize, v->pq); else - v->vc1dsp.vc1_h_loop_filter4(dst, linesize, v->pq); + v->vc1dsp.vc1_h_loop_filter4(dst, linesize, v->pq); } } } @@ -2463,7 +3575,7 @@ } } -/** Decode one P-frame MB (in Simple/Main profile) +/** Decode one P-frame MB */ static int vc1_decode_p_mb(VC1Context *v) { @@ -2495,10 +3607,8 @@ else skipped = v->s.mbskip_table[mb_pos]; - if (!fourmv) /* 1MV mode */ - { - if (!skipped) - { + if (!fourmv) { /* 1MV mode */ + if (!skipped) { GET_MVDATA(dmv_x, dmv_y); if (s->mb_intra) { @@ -2506,197 +3616,534 @@ s->current_picture.f.motion_val[1][s->block_index[0]][1] = 0; } s->current_picture.f.mb_type[mb_pos] = s->mb_intra ? MB_TYPE_INTRA : MB_TYPE_16x16; - vc1_pred_mv(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, v->mb_type[0]); + vc1_pred_mv(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, v->mb_type[0], 0, 0); /* FIXME Set DC val for inter block ? */ - if (s->mb_intra && !mb_has_coeffs) - { + if (s->mb_intra && !mb_has_coeffs) { GET_MQUANT(); s->ac_pred = get_bits1(gb); - cbp = 0; - } - else if (mb_has_coeffs) - { - if (s->mb_intra) s->ac_pred = get_bits1(gb); + cbp = 0; + } else if (mb_has_coeffs) { + if (s->mb_intra) + s->ac_pred = get_bits1(gb); cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); GET_MQUANT(); - } - else - { + } else { mquant = v->pq; - cbp = 0; + cbp = 0; } s->current_picture.f.qscale_table[mb_pos] = mquant; if (!v->ttmbf && !s->mb_intra && mb_has_coeffs) ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2); - if(!s->mb_intra) vc1_mc_1mv(v, 0); + if (!s->mb_intra) vc1_mc_1mv(v, 0); dst_idx = 0; - for (i=0; i<6; i++) - { + for (i = 0; i < 6; i++) { s->dc_val[0][s->block_index[i]] = 0; dst_idx += i >> 2; val = ((cbp >> (5 - i)) & 1); off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize); v->mb_type[0][s->block_index[i]] = s->mb_intra; - if(s->mb_intra) { + if (s->mb_intra) { /* check if prediction blocks A and C are available */ v->a_avail = v->c_avail = 0; - if(i == 2 || i == 3 || !s->first_slice_line) + if (i == 2 || i == 3 || !s->first_slice_line) v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]]; - if(i == 1 || i == 3 || s->mb_x) + if (i == 1 || i == 3 || s->mb_x) v->c_avail = v->mb_type[0][s->block_index[i] - 1]; - vc1_decode_intra_block(v, s->block[i], i, val, mquant, (i&4)?v->codingset2:v->codingset); - if((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue; + vc1_decode_intra_block(v, s->block[i], i, val, mquant, + (i & 4) ? v->codingset2 : v->codingset); + if ((i>3) && (s->flags & CODEC_FLAG_GRAY)) + continue; v->vc1dsp.vc1_inv_trans_8x8(s->block[i]); - if(v->rangeredfrm) for(j = 0; j < 64; j++) s->block[i][j] <<= 1; + if (v->rangeredfrm) + for (j = 0; j < 64; j++) + s->block[i][j] <<= 1; s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize); - if(v->pq >= 9 && v->overlap) { - if(v->c_avail) + if (v->pq >= 9 && v->overlap) { + if (v->c_avail) v->vc1dsp.vc1_h_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize); - if(v->a_avail) + if (v->a_avail) v->vc1dsp.vc1_v_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize); } - block_cbp |= 0xF << (i << 2); + block_cbp |= 0xF << (i << 2); block_intra |= 1 << i; - } else if(val) { - pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize, (i&4) && (s->flags & CODEC_FLAG_GRAY), &block_tt); + } else if (val) { + pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, + s->dest[dst_idx] + off, (i & 4) ? s->uvlinesize : s->linesize, + (i & 4) && (s->flags & CODEC_FLAG_GRAY), &block_tt); block_cbp |= pat << (i << 2); - if(!v->ttmbf && ttmb < 8) ttmb = -1; + if (!v->ttmbf && ttmb < 8) + ttmb = -1; first_block = 0; } } - } - else //Skipped - { + } else { // skipped s->mb_intra = 0; - for(i = 0; i < 6; i++) { + for (i = 0; i < 6; i++) { v->mb_type[0][s->block_index[i]] = 0; - s->dc_val[0][s->block_index[i]] = 0; + s->dc_val[0][s->block_index[i]] = 0; } - s->current_picture.f.mb_type[mb_pos] = MB_TYPE_SKIP; + s->current_picture.f.mb_type[mb_pos] = MB_TYPE_SKIP; s->current_picture.f.qscale_table[mb_pos] = 0; - vc1_pred_mv(v, 0, 0, 0, 1, v->range_x, v->range_y, v->mb_type[0]); + vc1_pred_mv(v, 0, 0, 0, 1, v->range_x, v->range_y, v->mb_type[0], 0, 0); vc1_mc_1mv(v, 0); } - } //1MV mode - else //4MV mode - { - if (!skipped /* unskipped MB */) - { + } else { // 4MV mode + if (!skipped /* unskipped MB */) { int intra_count = 0, coded_inter = 0; int is_intra[6], is_coded[6]; /* Get CBPCY */ cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); - for (i=0; i<6; i++) - { + for (i = 0; i < 6; i++) { val = ((cbp >> (5 - i)) & 1); s->dc_val[0][s->block_index[i]] = 0; - s->mb_intra = 0; - if(i < 4) { + s->mb_intra = 0; + if (i < 4) { dmv_x = dmv_y = 0; - s->mb_intra = 0; + s->mb_intra = 0; mb_has_coeffs = 0; - if(val) { + if (val) { GET_MVDATA(dmv_x, dmv_y); } - vc1_pred_mv(v, i, dmv_x, dmv_y, 0, v->range_x, v->range_y, v->mb_type[0]); - if(!s->mb_intra) vc1_mc_4mv_luma(v, i); + vc1_pred_mv(v, i, dmv_x, dmv_y, 0, v->range_x, v->range_y, v->mb_type[0], 0, 0); + if (!s->mb_intra) + vc1_mc_4mv_luma(v, i, 0); intra_count += s->mb_intra; - is_intra[i] = s->mb_intra; - is_coded[i] = mb_has_coeffs; + is_intra[i] = s->mb_intra; + is_coded[i] = mb_has_coeffs; } - if(i&4){ + if (i & 4) { is_intra[i] = (intra_count >= 3); is_coded[i] = val; } - if(i == 4) vc1_mc_4mv_chroma(v); + if (i == 4) + vc1_mc_4mv_chroma(v, 0); v->mb_type[0][s->block_index[i]] = is_intra[i]; - if(!coded_inter) coded_inter = !is_intra[i] & is_coded[i]; + if (!coded_inter) + coded_inter = !is_intra[i] & is_coded[i]; } // if there are no coded blocks then don't do anything more dst_idx = 0; - if(!intra_count && !coded_inter) + if (!intra_count && !coded_inter) goto end; GET_MQUANT(); s->current_picture.f.qscale_table[mb_pos] = mquant; /* test if block is intra and has pred */ { int intrapred = 0; - for(i=0; i<6; i++) - if(is_intra[i]) { - if(((!s->first_slice_line || (i==2 || i==3)) && v->mb_type[0][s->block_index[i] - s->block_wrap[i]]) - || ((s->mb_x || (i==1 || i==3)) && v->mb_type[0][s->block_index[i] - 1])) { + for (i = 0; i < 6; i++) + if (is_intra[i]) { + if (((!s->first_slice_line || (i == 2 || i == 3)) && v->mb_type[0][s->block_index[i] - s->block_wrap[i]]) + || ((s->mb_x || (i == 1 || i == 3)) && v->mb_type[0][s->block_index[i] - 1])) { intrapred = 1; break; } } - if(intrapred)s->ac_pred = get_bits1(gb); - else s->ac_pred = 0; + if (intrapred) + s->ac_pred = get_bits1(gb); + else + s->ac_pred = 0; } if (!v->ttmbf && coded_inter) ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2); - for (i=0; i<6; i++) - { - dst_idx += i >> 2; - off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize); + for (i = 0; i < 6; i++) { + dst_idx += i >> 2; + off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize); s->mb_intra = is_intra[i]; if (is_intra[i]) { /* check if prediction blocks A and C are available */ v->a_avail = v->c_avail = 0; - if(i == 2 || i == 3 || !s->first_slice_line) + if (i == 2 || i == 3 || !s->first_slice_line) v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]]; - if(i == 1 || i == 3 || s->mb_x) + if (i == 1 || i == 3 || s->mb_x) v->c_avail = v->mb_type[0][s->block_index[i] - 1]; - vc1_decode_intra_block(v, s->block[i], i, is_coded[i], mquant, (i&4)?v->codingset2:v->codingset); - if((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue; + vc1_decode_intra_block(v, s->block[i], i, is_coded[i], mquant, + (i & 4) ? v->codingset2 : v->codingset); + if ((i>3) && (s->flags & CODEC_FLAG_GRAY)) + continue; v->vc1dsp.vc1_inv_trans_8x8(s->block[i]); - if(v->rangeredfrm) for(j = 0; j < 64; j++) s->block[i][j] <<= 1; - s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize); - if(v->pq >= 9 && v->overlap) { - if(v->c_avail) + if (v->rangeredfrm) + for (j = 0; j < 64; j++) + s->block[i][j] <<= 1; + s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, + (i & 4) ? s->uvlinesize : s->linesize); + if (v->pq >= 9 && v->overlap) { + if (v->c_avail) v->vc1dsp.vc1_h_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize); - if(v->a_avail) + if (v->a_avail) v->vc1dsp.vc1_v_overlap(s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize); } - block_cbp |= 0xF << (i << 2); + block_cbp |= 0xF << (i << 2); block_intra |= 1 << i; - } else if(is_coded[i]) { - pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize, (i&4) && (s->flags & CODEC_FLAG_GRAY), &block_tt); + } else if (is_coded[i]) { + pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, + first_block, s->dest[dst_idx] + off, + (i & 4) ? s->uvlinesize : s->linesize, + (i & 4) && (s->flags & CODEC_FLAG_GRAY), + &block_tt); block_cbp |= pat << (i << 2); - if(!v->ttmbf && ttmb < 8) ttmb = -1; + if (!v->ttmbf && ttmb < 8) + ttmb = -1; first_block = 0; } } - } - else //Skipped MB - { - s->mb_intra = 0; + } else { // skipped MB + s->mb_intra = 0; s->current_picture.f.qscale_table[mb_pos] = 0; - for (i=0; i<6; i++) { + for (i = 0; i < 6; i++) { v->mb_type[0][s->block_index[i]] = 0; - s->dc_val[0][s->block_index[i]] = 0; + s->dc_val[0][s->block_index[i]] = 0; } - for (i=0; i<4; i++) - { - vc1_pred_mv(v, i, 0, 0, 0, v->range_x, v->range_y, v->mb_type[0]); - vc1_mc_4mv_luma(v, i); + for (i = 0; i < 4; i++) { + vc1_pred_mv(v, i, 0, 0, 0, v->range_x, v->range_y, v->mb_type[0], 0, 0); + vc1_mc_4mv_luma(v, i, 0); } - vc1_mc_4mv_chroma(v); + vc1_mc_4mv_chroma(v, 0); s->current_picture.f.qscale_table[mb_pos] = 0; } } end: - v->cbp[s->mb_x] = block_cbp; - v->ttblk[s->mb_x] = block_tt; + v->cbp[s->mb_x] = block_cbp; + v->ttblk[s->mb_x] = block_tt; v->is_intra[s->mb_x] = block_intra; return 0; } +/* Decode one macroblock in an interlaced frame p picture */ + +static int vc1_decode_p_mb_intfr(VC1Context *v) +{ + MpegEncContext *s = &v->s; + GetBitContext *gb = &s->gb; + int i; + int mb_pos = s->mb_x + s->mb_y * s->mb_stride; + int cbp = 0; /* cbp decoding stuff */ + int mqdiff, mquant; /* MB quantization */ + int ttmb = v->ttfrm; /* MB Transform type */ + + int mb_has_coeffs = 1; /* last_flag */ + int dmv_x, dmv_y; /* Differential MV components */ + int val; /* temp value */ + int first_block = 1; + int dst_idx, off; + int skipped, fourmv = 0, twomv = 0; + int block_cbp = 0, pat, block_tt = 0; + int idx_mbmode = 0, mvbp; + int stride_y, fieldtx; + + mquant = v->pq; /* Loosy initialization */ + + if (v->skip_is_raw) + skipped = get_bits1(gb); + else + skipped = v->s.mbskip_table[mb_pos]; + if (!skipped) { + if (v->fourmvswitch) + idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_INTFR_4MV_MBMODE_VLC_BITS, 2); // try getting this done + else + idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_INTFR_NON4MV_MBMODE_VLC_BITS, 2); // in a single line + switch (ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0]) { + /* store the motion vector type in a flag (useful later) */ + case MV_PMODE_INTFR_4MV: + fourmv = 1; + v->blk_mv_type[s->block_index[0]] = 0; + v->blk_mv_type[s->block_index[1]] = 0; + v->blk_mv_type[s->block_index[2]] = 0; + v->blk_mv_type[s->block_index[3]] = 0; + break; + case MV_PMODE_INTFR_4MV_FIELD: + fourmv = 1; + v->blk_mv_type[s->block_index[0]] = 1; + v->blk_mv_type[s->block_index[1]] = 1; + v->blk_mv_type[s->block_index[2]] = 1; + v->blk_mv_type[s->block_index[3]] = 1; + break; + case MV_PMODE_INTFR_2MV_FIELD: + twomv = 1; + v->blk_mv_type[s->block_index[0]] = 1; + v->blk_mv_type[s->block_index[1]] = 1; + v->blk_mv_type[s->block_index[2]] = 1; + v->blk_mv_type[s->block_index[3]] = 1; + break; + case MV_PMODE_INTFR_1MV: + v->blk_mv_type[s->block_index[0]] = 0; + v->blk_mv_type[s->block_index[1]] = 0; + v->blk_mv_type[s->block_index[2]] = 0; + v->blk_mv_type[s->block_index[3]] = 0; + break; + } + if (ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0] == MV_PMODE_INTFR_INTRA) { // intra MB + s->current_picture.f.motion_val[1][s->block_index[0]][0] = 0; + s->current_picture.f.motion_val[1][s->block_index[0]][1] = 0; + s->current_picture.f.mb_type[mb_pos] = MB_TYPE_INTRA; + s->mb_intra = v->is_intra[s->mb_x] = 1; + for (i = 0; i < 6; i++) + v->mb_type[0][s->block_index[i]] = 1; + fieldtx = v->fieldtx_plane[mb_pos] = get_bits1(gb); + mb_has_coeffs = get_bits1(gb); + if (mb_has_coeffs) + cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); + v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb); + GET_MQUANT(); + s->current_picture.f.qscale_table[mb_pos] = mquant; + /* Set DC scale - y and c use the same (not sure if necessary here) */ + s->y_dc_scale = s->y_dc_scale_table[mquant]; + s->c_dc_scale = s->c_dc_scale_table[mquant]; + dst_idx = 0; + for (i = 0; i < 6; i++) { + s->dc_val[0][s->block_index[i]] = 0; + dst_idx += i >> 2; + val = ((cbp >> (5 - i)) & 1); + v->mb_type[0][s->block_index[i]] = s->mb_intra; + v->a_avail = v->c_avail = 0; + if (i == 2 || i == 3 || !s->first_slice_line) + v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]]; + if (i == 1 || i == 3 || s->mb_x) + v->c_avail = v->mb_type[0][s->block_index[i] - 1]; + + vc1_decode_intra_block(v, s->block[i], i, val, mquant, + (i & 4) ? v->codingset2 : v->codingset); + if ((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue; + v->vc1dsp.vc1_inv_trans_8x8(s->block[i]); + if (i < 4) { + stride_y = s->linesize << fieldtx; + off = (fieldtx) ? ((i & 1) * 8) + ((i & 2) >> 1) * s->linesize : (i & 1) * 8 + 4 * (i & 2) * s->linesize; + } else { + stride_y = s->uvlinesize; + off = 0; + } + s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, stride_y); + //TODO: loop filter + } + + } else { // inter MB + mb_has_coeffs = ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][3]; + if (mb_has_coeffs) + cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); + if (ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0] == MV_PMODE_INTFR_2MV_FIELD) { + v->twomvbp = get_vlc2(gb, v->twomvbp_vlc->table, VC1_2MV_BLOCK_PATTERN_VLC_BITS, 1); + } else { + if ((ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0] == MV_PMODE_INTFR_4MV) + || (ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0] == MV_PMODE_INTFR_4MV_FIELD)) { + v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc->table, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1); + } + } + s->mb_intra = v->is_intra[s->mb_x] = 0; + for (i = 0; i < 6; i++) + v->mb_type[0][s->block_index[i]] = 0; + fieldtx = v->fieldtx_plane[mb_pos] = ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][1]; + /* for all motion vector read MVDATA and motion compensate each block */ + dst_idx = 0; + if (fourmv) { + mvbp = v->fourmvbp; + for (i = 0; i < 6; i++) { + if (i < 4) { + dmv_x = dmv_y = 0; + val = ((mvbp >> (3 - i)) & 1); + if (val) { + get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0); + } + vc1_pred_mv_intfr(v, i, dmv_x, dmv_y, 0, v->range_x, v->range_y, v->mb_type[0]); + vc1_mc_4mv_luma(v, i, 0); + } else if (i == 4) { + vc1_mc_4mv_chroma4(v); + } + } + } else if (twomv) { + mvbp = v->twomvbp; + dmv_x = dmv_y = 0; + if (mvbp & 2) { + get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0); + } + vc1_pred_mv_intfr(v, 0, dmv_x, dmv_y, 2, v->range_x, v->range_y, v->mb_type[0]); + vc1_mc_4mv_luma(v, 0, 0); + vc1_mc_4mv_luma(v, 1, 0); + dmv_x = dmv_y = 0; + if (mvbp & 1) { + get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0); + } + vc1_pred_mv_intfr(v, 2, dmv_x, dmv_y, 2, v->range_x, v->range_y, v->mb_type[0]); + vc1_mc_4mv_luma(v, 2, 0); + vc1_mc_4mv_luma(v, 3, 0); + vc1_mc_4mv_chroma4(v); + } else { + mvbp = ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][2]; + if (mvbp) { + get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0); + } + vc1_pred_mv_intfr(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, v->mb_type[0]); + vc1_mc_1mv(v, 0); + } + if (cbp) + GET_MQUANT(); // p. 227 + s->current_picture.f.qscale_table[mb_pos] = mquant; + if (!v->ttmbf && cbp) + ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2); + for (i = 0; i < 6; i++) { + s->dc_val[0][s->block_index[i]] = 0; + dst_idx += i >> 2; + val = ((cbp >> (5 - i)) & 1); + if (!fieldtx) + off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize); + else + off = (i & 4) ? 0 : ((i & 1) * 8 + ((i > 1) * s->linesize)); + if (val) { + pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, + first_block, s->dest[dst_idx] + off, + (i & 4) ? s->uvlinesize : (s->linesize << fieldtx), + (i & 4) && (s->flags & CODEC_FLAG_GRAY), &block_tt); + block_cbp |= pat << (i << 2); + if (!v->ttmbf && ttmb < 8) + ttmb = -1; + first_block = 0; + } + } + } + } else { // skipped + s->mb_intra = v->is_intra[s->mb_x] = 0; + for (i = 0; i < 6; i++) { + v->mb_type[0][s->block_index[i]] = 0; + s->dc_val[0][s->block_index[i]] = 0; + } + s->current_picture.f.mb_type[mb_pos] = MB_TYPE_SKIP; + s->current_picture.f.qscale_table[mb_pos] = 0; + v->blk_mv_type[s->block_index[0]] = 0; + v->blk_mv_type[s->block_index[1]] = 0; + v->blk_mv_type[s->block_index[2]] = 0; + v->blk_mv_type[s->block_index[3]] = 0; + vc1_pred_mv_intfr(v, 0, 0, 0, 1, v->range_x, v->range_y, v->mb_type[0]); + vc1_mc_1mv(v, 0); + } + if (s->mb_x == s->mb_width - 1) + memmove(v->is_intra_base, v->is_intra, sizeof(v->is_intra_base[0])*s->mb_stride); + return 0; +} + +static int vc1_decode_p_mb_intfi(VC1Context *v) +{ + MpegEncContext *s = &v->s; + GetBitContext *gb = &s->gb; + int i; + int mb_pos = s->mb_x + s->mb_y * s->mb_stride; + int cbp = 0; /* cbp decoding stuff */ + int mqdiff, mquant; /* MB quantization */ + int ttmb = v->ttfrm; /* MB Transform type */ + + int mb_has_coeffs = 1; /* last_flag */ + int dmv_x, dmv_y; /* Differential MV components */ + int val; /* temp values */ + int first_block = 1; + int dst_idx, off; + int pred_flag; + int block_cbp = 0, pat, block_tt = 0; + int idx_mbmode = 0; + + mquant = v->pq; /* Loosy initialization */ + + idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_IF_MBMODE_VLC_BITS, 2); + if (idx_mbmode <= 1) { // intra MB + s->mb_intra = v->is_intra[s->mb_x] = 1; + s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][0] = 0; + s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][1] = 0; + s->current_picture.f.mb_type[mb_pos + v->mb_off] = MB_TYPE_INTRA; + GET_MQUANT(); + s->current_picture.f.qscale_table[mb_pos] = mquant; + /* Set DC scale - y and c use the same (not sure if necessary here) */ + s->y_dc_scale = s->y_dc_scale_table[mquant]; + s->c_dc_scale = s->c_dc_scale_table[mquant]; + v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb); + mb_has_coeffs = idx_mbmode & 1; + if (mb_has_coeffs) + cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_ICBPCY_VLC_BITS, 2); + dst_idx = 0; + for (i = 0; i < 6; i++) { + s->dc_val[0][s->block_index[i]] = 0; + v->mb_type[0][s->block_index[i]] = 1; + dst_idx += i >> 2; + val = ((cbp >> (5 - i)) & 1); + v->a_avail = v->c_avail = 0; + if (i == 2 || i == 3 || !s->first_slice_line) + v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]]; + if (i == 1 || i == 3 || s->mb_x) + v->c_avail = v->mb_type[0][s->block_index[i] - 1]; + + vc1_decode_intra_block(v, s->block[i], i, val, mquant, + (i & 4) ? v->codingset2 : v->codingset); + if ((i>3) && (s->flags & CODEC_FLAG_GRAY)) + continue; + v->vc1dsp.vc1_inv_trans_8x8(s->block[i]); + off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize); + off += v->cur_field_type ? ((i & 4) ? s->current_picture_ptr->f.linesize[1] : s->current_picture_ptr->f.linesize[0]) : 0; + s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i & 4) ? s->uvlinesize : s->linesize); + // TODO: loop filter + } + } else { + s->mb_intra = v->is_intra[s->mb_x] = 0; + s->current_picture.f.mb_type[mb_pos + v->mb_off] = MB_TYPE_16x16; + for (i = 0; i < 6; i++) v->mb_type[0][s->block_index[i]] = 0; + if (idx_mbmode <= 5) { // 1-MV + dmv_x = dmv_y = 0; + if (idx_mbmode & 1) { + get_mvdata_interlaced(v, &dmv_x, &dmv_y, &pred_flag); + } + vc1_pred_mv(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, v->mb_type[0], pred_flag, 0); + vc1_mc_1mv(v, 0); + mb_has_coeffs = !(idx_mbmode & 2); + } else { // 4-MV + v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc->table, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1); + for (i = 0; i < 6; i++) { + if (i < 4) { + dmv_x = dmv_y = pred_flag = 0; + val = ((v->fourmvbp >> (3 - i)) & 1); + if (val) { + get_mvdata_interlaced(v, &dmv_x, &dmv_y, &pred_flag); + } + vc1_pred_mv(v, i, dmv_x, dmv_y, 0, v->range_x, v->range_y, v->mb_type[0], pred_flag, 0); + vc1_mc_4mv_luma(v, i, 0); + } else if (i == 4) + vc1_mc_4mv_chroma(v, 0); + } + mb_has_coeffs = idx_mbmode & 1; + } + if (mb_has_coeffs) + cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); + if (cbp) { + GET_MQUANT(); + } + s->current_picture.f.qscale_table[mb_pos] = mquant; + if (!v->ttmbf && cbp) { + ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2); + } + dst_idx = 0; + for (i = 0; i < 6; i++) { + s->dc_val[0][s->block_index[i]] = 0; + dst_idx += i >> 2; + val = ((cbp >> (5 - i)) & 1); + off = (i & 4) ? 0 : (i & 1) * 8 + (i & 2) * 4 * s->linesize; + if (v->cur_field_type) + off += (i & 4) ? s->current_picture_ptr->f.linesize[1] : s->current_picture_ptr->f.linesize[0]; + if (val) { + pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, + first_block, s->dest[dst_idx] + off, + (i & 4) ? s->uvlinesize : s->linesize, + (i & 4) && (s->flags & CODEC_FLAG_GRAY), + &block_tt); + block_cbp |= pat << (i << 2); + if (!v->ttmbf && ttmb < 8) ttmb = -1; + first_block = 0; + } + } + } + if (s->mb_x == s->mb_width - 1) + memmove(v->is_intra_base, v->is_intra, sizeof(v->is_intra_base[0]) * s->mb_stride); + return 0; +} + /** Decode one B-frame MB (in Main profile) */ static void vc1_decode_b_mb(VC1Context *v) @@ -2717,7 +4164,7 @@ int dmv_x[2], dmv_y[2]; int bmvtype = BMV_TYPE_BACKWARD; - mquant = v->pq; /* Loosy initialization */ + mquant = v->pq; /* Loosy initialization */ s->mb_intra = 0; if (v->dmb_is_raw) @@ -2730,9 +4177,9 @@ skipped = v->s.mbskip_table[mb_pos]; dmv_x[0] = dmv_x[1] = dmv_y[0] = dmv_y[1] = 0; - for(i = 0; i < 6; i++) { + for (i = 0; i < 6; i++) { v->mb_type[0][s->block_index[i]] = 0; - s->dc_val[0][s->block_index[i]] = 0; + s->dc_val[0][s->block_index[i]] = 0; } s->current_picture.f.qscale_table[mb_pos] = 0; @@ -2742,9 +4189,9 @@ dmv_x[1] = dmv_x[0]; dmv_y[1] = dmv_y[0]; } - if(skipped || !s->mb_intra) { + if (skipped || !s->mb_intra) { bmvtype = decode012(gb); - switch(bmvtype) { + switch (bmvtype) { case 0: bmvtype = (v->bfraction >= (B_FRACTION_DEN/2)) ? BMV_TYPE_BACKWARD : BMV_TYPE_FORWARD; break; @@ -2752,16 +4199,17 @@ bmvtype = (v->bfraction >= (B_FRACTION_DEN/2)) ? BMV_TYPE_FORWARD : BMV_TYPE_BACKWARD; break; case 2: - bmvtype = BMV_TYPE_INTERPOLATED; + bmvtype = BMV_TYPE_INTERPOLATED; dmv_x[0] = dmv_y[0] = 0; } } } - for(i = 0; i < 6; i++) + for (i = 0; i < 6; i++) v->mb_type[0][s->block_index[i]] = s->mb_intra; if (skipped) { - if(direct) bmvtype = BMV_TYPE_INTERPOLATED; + if (direct) + bmvtype = BMV_TYPE_INTERPOLATED; vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype); vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype); return; @@ -2771,28 +4219,28 @@ GET_MQUANT(); s->mb_intra = 0; s->current_picture.f.qscale_table[mb_pos] = mquant; - if(!v->ttmbf) + if (!v->ttmbf) ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2); dmv_x[0] = dmv_y[0] = dmv_x[1] = dmv_y[1] = 0; vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype); vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype); } else { - if(!mb_has_coeffs && !s->mb_intra) { + if (!mb_has_coeffs && !s->mb_intra) { /* no coded blocks - effectively skipped */ vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype); vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype); return; } - if(s->mb_intra && !mb_has_coeffs) { + if (s->mb_intra && !mb_has_coeffs) { GET_MQUANT(); s->current_picture.f.qscale_table[mb_pos] = mquant; s->ac_pred = get_bits1(gb); cbp = 0; vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype); } else { - if(bmvtype == BMV_TYPE_INTERPOLATED) { + if (bmvtype == BMV_TYPE_INTERPOLATED) { GET_MVDATA(dmv_x[0], dmv_y[0]); - if(!mb_has_coeffs) { + if (!mb_has_coeffs) { /* interpolated skipped block */ vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype); vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype); @@ -2800,47 +4248,210 @@ } } vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype); - if(!s->mb_intra) { + if (!s->mb_intra) { vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype); } - if(s->mb_intra) + if (s->mb_intra) s->ac_pred = get_bits1(gb); cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); GET_MQUANT(); s->current_picture.f.qscale_table[mb_pos] = mquant; - if(!v->ttmbf && !s->mb_intra && mb_has_coeffs) + if (!v->ttmbf && !s->mb_intra && mb_has_coeffs) ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2); } } dst_idx = 0; - for (i=0; i<6; i++) - { + for (i = 0; i < 6; i++) { s->dc_val[0][s->block_index[i]] = 0; dst_idx += i >> 2; val = ((cbp >> (5 - i)) & 1); off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize); v->mb_type[0][s->block_index[i]] = s->mb_intra; - if(s->mb_intra) { + if (s->mb_intra) { /* check if prediction blocks A and C are available */ v->a_avail = v->c_avail = 0; - if(i == 2 || i == 3 || !s->first_slice_line) + if (i == 2 || i == 3 || !s->first_slice_line) v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]]; - if(i == 1 || i == 3 || s->mb_x) + if (i == 1 || i == 3 || s->mb_x) v->c_avail = v->mb_type[0][s->block_index[i] - 1]; - vc1_decode_intra_block(v, s->block[i], i, val, mquant, (i&4)?v->codingset2:v->codingset); - if((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue; + vc1_decode_intra_block(v, s->block[i], i, val, mquant, + (i & 4) ? v->codingset2 : v->codingset); + if ((i>3) && (s->flags & CODEC_FLAG_GRAY)) + continue; v->vc1dsp.vc1_inv_trans_8x8(s->block[i]); - if(v->rangeredfrm) for(j = 0; j < 64; j++) s->block[i][j] <<= 1; + if (v->rangeredfrm) + for (j = 0; j < 64; j++) + s->block[i][j] <<= 1; s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, i & 4 ? s->uvlinesize : s->linesize); - } else if(val) { - vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize, (i&4) && (s->flags & CODEC_FLAG_GRAY), NULL); - if(!v->ttmbf && ttmb < 8) ttmb = -1; + } else if (val) { + vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, + first_block, s->dest[dst_idx] + off, + (i & 4) ? s->uvlinesize : s->linesize, + (i & 4) && (s->flags & CODEC_FLAG_GRAY), NULL); + if (!v->ttmbf && ttmb < 8) + ttmb = -1; first_block = 0; } } } +/** Decode one B-frame MB (in interlaced field B picture) + */ +static void vc1_decode_b_mb_intfi(VC1Context *v) +{ + MpegEncContext *s = &v->s; + GetBitContext *gb = &s->gb; + int i, j; + int mb_pos = s->mb_x + s->mb_y * s->mb_stride; + int cbp = 0; /* cbp decoding stuff */ + int mqdiff, mquant; /* MB quantization */ + int ttmb = v->ttfrm; /* MB Transform type */ + int mb_has_coeffs = 0; /* last_flag */ + int val; /* temp value */ + int first_block = 1; + int dst_idx, off; + int fwd; + int dmv_x[2], dmv_y[2], pred_flag[2]; + int bmvtype = BMV_TYPE_BACKWARD; + int idx_mbmode, interpmvp; + + mquant = v->pq; /* Loosy initialization */ + s->mb_intra = 0; + + idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_IF_MBMODE_VLC_BITS, 2); + if (idx_mbmode <= 1) { // intra MB + s->mb_intra = v->is_intra[s->mb_x] = 1; + s->current_picture.f.motion_val[1][s->block_index[0]][0] = 0; + s->current_picture.f.motion_val[1][s->block_index[0]][1] = 0; + s->current_picture.f.mb_type[mb_pos + v->mb_off] = MB_TYPE_INTRA; + GET_MQUANT(); + s->current_picture.f.qscale_table[mb_pos] = mquant; + /* Set DC scale - y and c use the same (not sure if necessary here) */ + s->y_dc_scale = s->y_dc_scale_table[mquant]; + s->c_dc_scale = s->c_dc_scale_table[mquant]; + v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb); + mb_has_coeffs = idx_mbmode & 1; + if (mb_has_coeffs) + cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_ICBPCY_VLC_BITS, 2); + dst_idx = 0; + for (i = 0; i < 6; i++) { + s->dc_val[0][s->block_index[i]] = 0; + dst_idx += i >> 2; + val = ((cbp >> (5 - i)) & 1); + v->mb_type[0][s->block_index[i]] = s->mb_intra; + v->a_avail = v->c_avail = 0; + if (i == 2 || i == 3 || !s->first_slice_line) + v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]]; + if (i == 1 || i == 3 || s->mb_x) + v->c_avail = v->mb_type[0][s->block_index[i] - 1]; + + vc1_decode_intra_block(v, s->block[i], i, val, mquant, + (i & 4) ? v->codingset2 : v->codingset); + if ((i>3) && (s->flags & CODEC_FLAG_GRAY)) + continue; + v->vc1dsp.vc1_inv_trans_8x8(s->block[i]); + if (v->rangeredfrm) + for (j = 0; j < 64; j++) + s->block[i][j] <<= 1; + off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize); + off += v->cur_field_type ? ((i & 4) ? s->current_picture_ptr->f.linesize[1] : s->current_picture_ptr->f.linesize[0]) : 0; + s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i & 4) ? s->uvlinesize : s->linesize); + // TODO: yet to perform loop filter + } + } else { + s->mb_intra = v->is_intra[s->mb_x] = 0; + s->current_picture.f.mb_type[mb_pos + v->mb_off] = MB_TYPE_16x16; + for (i = 0; i < 6; i++) v->mb_type[0][s->block_index[i]] = 0; + if (v->fmb_is_raw) + fwd = v->forward_mb_plane[mb_pos] = get_bits1(gb); + else + fwd = v->forward_mb_plane[mb_pos]; + if (idx_mbmode <= 5) { // 1-MV + dmv_x[0] = dmv_x[1] = dmv_y[0] = dmv_y[1] = 0; + pred_flag[0] = pred_flag[1] = 0; + if (fwd) + bmvtype = BMV_TYPE_FORWARD; + else { + bmvtype = decode012(gb); + switch (bmvtype) { + case 0: + bmvtype = BMV_TYPE_BACKWARD; + break; + case 1: + bmvtype = BMV_TYPE_DIRECT; + break; + case 2: + bmvtype = BMV_TYPE_INTERPOLATED; + interpmvp = get_bits1(gb); + } + } + v->bmvtype = bmvtype; + if (bmvtype != BMV_TYPE_DIRECT && idx_mbmode & 1) { + get_mvdata_interlaced(v, &dmv_x[bmvtype == BMV_TYPE_BACKWARD], &dmv_y[bmvtype == BMV_TYPE_BACKWARD], &pred_flag[bmvtype == BMV_TYPE_BACKWARD]); + } + if (bmvtype == BMV_TYPE_INTERPOLATED && interpmvp) { + get_mvdata_interlaced(v, &dmv_x[1], &dmv_y[1], &pred_flag[1]); + } + if (bmvtype == BMV_TYPE_DIRECT) { + dmv_x[0] = dmv_y[0] = pred_flag[0] = 0; + dmv_x[1] = dmv_y[1] = pred_flag[0] = 0; + } + vc1_pred_b_mv_intfi(v, 0, dmv_x, dmv_y, 1, pred_flag); + vc1_b_mc(v, dmv_x, dmv_y, (bmvtype == BMV_TYPE_DIRECT), bmvtype); + mb_has_coeffs = !(idx_mbmode & 2); + } else { // 4-MV + if (fwd) + bmvtype = BMV_TYPE_FORWARD; + v->bmvtype = bmvtype; + v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc->table, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1); + for (i = 0; i < 6; i++) { + if (i < 4) { + dmv_x[0] = dmv_y[0] = pred_flag[0] = 0; + dmv_x[1] = dmv_y[1] = pred_flag[1] = 0; + val = ((v->fourmvbp >> (3 - i)) & 1); + if (val) { + get_mvdata_interlaced(v, &dmv_x[bmvtype == BMV_TYPE_BACKWARD], + &dmv_y[bmvtype == BMV_TYPE_BACKWARD], + &pred_flag[bmvtype == BMV_TYPE_BACKWARD]); + } + vc1_pred_b_mv_intfi(v, i, dmv_x, dmv_y, 0, pred_flag); + vc1_mc_4mv_luma(v, i, bmvtype == BMV_TYPE_BACKWARD); + } else if (i == 4) + vc1_mc_4mv_chroma(v, bmvtype == BMV_TYPE_BACKWARD); + } + mb_has_coeffs = idx_mbmode & 1; + } + if (mb_has_coeffs) + cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); + if (cbp) { + GET_MQUANT(); + } + s->current_picture.f.qscale_table[mb_pos] = mquant; + if (!v->ttmbf && cbp) { + ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2); + } + dst_idx = 0; + for (i = 0; i < 6; i++) { + s->dc_val[0][s->block_index[i]] = 0; + dst_idx += i >> 2; + val = ((cbp >> (5 - i)) & 1); + off = (i & 4) ? 0 : (i & 1) * 8 + (i & 2) * 4 * s->linesize; + if (v->cur_field_type) + off += (i & 4) ? s->current_picture_ptr->f.linesize[1] : s->current_picture_ptr->f.linesize[0]; + if (val) { + vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, + first_block, s->dest[dst_idx] + off, + (i & 4) ? s->uvlinesize : s->linesize, + (i & 4) && (s->flags & CODEC_FLAG_GRAY), NULL); + if (!v->ttmbf && ttmb < 8) + ttmb = -1; + first_block = 0; + } + } + } +} + /** Decode blocks of I-frame */ static void vc1_decode_i_blocks(VC1Context *v) @@ -2852,7 +4463,7 @@ int mb_pos; /* select codingmode used for VLC tables selection */ - switch(v->y_ac_table_index){ + switch (v->y_ac_table_index) { case 0: v->codingset = (v->pqindex <= 8) ? CS_HIGH_RATE_INTRA : CS_LOW_MOT_INTRA; break; @@ -2864,7 +4475,7 @@ break; } - switch(v->c_ac_table_index){ + switch (v->c_ac_table_index) { case 0: v->codingset2 = (v->pqindex <= 8) ? CS_HIGH_RATE_INTER : CS_LOW_MOT_INTER; break; @@ -2882,12 +4493,12 @@ //do frame decode s->mb_x = s->mb_y = 0; - s->mb_intra = 1; + s->mb_intra = 1; s->first_slice_line = 1; - for(s->mb_y = 0; s->mb_y < s->mb_height; s->mb_y++) { + for (s->mb_y = 0; s->mb_y < s->mb_height; s->mb_y++) { s->mb_x = 0; ff_init_block_index(s); - for(; s->mb_x < s->mb_width; s->mb_x++) { + for (; s->mb_x < s->mb_width; s->mb_x++) { uint8_t *dst[6]; ff_update_block_index(s); dst[0] = s->dest[0]; @@ -2898,8 +4509,8 @@ dst[5] = s->dest[2]; s->dsp.clear_blocks(s->block[0]); mb_pos = s->mb_x + s->mb_y * s->mb_width; - s->current_picture.f.mb_type[mb_pos] = MB_TYPE_INTRA; - s->current_picture.f.qscale_table[mb_pos] = v->pq; + s->current_picture.f.mb_type[mb_pos] = MB_TYPE_INTRA; + s->current_picture.f.qscale_table[mb_pos] = v->pq; s->current_picture.f.motion_val[1][s->block_index[0]][0] = 0; s->current_picture.f.motion_val[1][s->block_index[0]][1] = 0; @@ -2907,44 +4518,49 @@ cbp = get_vlc2(&v->s.gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2); v->s.ac_pred = get_bits1(&v->s.gb); - for(k = 0; k < 6; k++) { + for (k = 0; k < 6; k++) { val = ((cbp >> (5 - k)) & 1); if (k < 4) { - int pred = vc1_coded_block_pred(&v->s, k, &coded_val); - val = val ^ pred; + int pred = vc1_coded_block_pred(&v->s, k, &coded_val); + val = val ^ pred; *coded_val = val; } cbp |= val << (5 - k); - vc1_decode_i_block(v, s->block[k], k, val, (k<4)? v->codingset : v->codingset2); + vc1_decode_i_block(v, s->block[k], k, val, (k < 4) ? v->codingset : v->codingset2); - if (k > 3 && (s->flags & CODEC_FLAG_GRAY)) continue; + if (k > 3 && (s->flags & CODEC_FLAG_GRAY)) + continue; v->vc1dsp.vc1_inv_trans_8x8(s->block[k]); - if(v->pq >= 9 && v->overlap) { - if (v->rangeredfrm) for(j = 0; j < 64; j++) s->block[k][j] <<= 1; + if (v->pq >= 9 && v->overlap) { + if (v->rangeredfrm) + for (j = 0; j < 64; j++) + s->block[k][j] <<= 1; s->dsp.put_signed_pixels_clamped(s->block[k], dst[k], k & 4 ? s->uvlinesize : s->linesize); } else { - if (v->rangeredfrm) for(j = 0; j < 64; j++) s->block[k][j] = (s->block[k][j] - 64) << 1; + if (v->rangeredfrm) + for (j = 0; j < 64; j++) + s->block[k][j] = (s->block[k][j] - 64) << 1; s->dsp.put_pixels_clamped(s->block[k], dst[k], k & 4 ? s->uvlinesize : s->linesize); } } - if(v->pq >= 9 && v->overlap) { - if(s->mb_x) { + if (v->pq >= 9 && v->overlap) { + if (s->mb_x) { v->vc1dsp.vc1_h_overlap(s->dest[0], s->linesize); v->vc1dsp.vc1_h_overlap(s->dest[0] + 8 * s->linesize, s->linesize); - if(!(s->flags & CODEC_FLAG_GRAY)) { + if (!(s->flags & CODEC_FLAG_GRAY)) { v->vc1dsp.vc1_h_overlap(s->dest[1], s->uvlinesize); v->vc1dsp.vc1_h_overlap(s->dest[2], s->uvlinesize); } } v->vc1dsp.vc1_h_overlap(s->dest[0] + 8, s->linesize); v->vc1dsp.vc1_h_overlap(s->dest[0] + 8 * s->linesize + 8, s->linesize); - if(!s->first_slice_line) { + if (!s->first_slice_line) { v->vc1dsp.vc1_v_overlap(s->dest[0], s->linesize); v->vc1dsp.vc1_v_overlap(s->dest[0] + 8, s->linesize); - if(!(s->flags & CODEC_FLAG_GRAY)) { + if (!(s->flags & CODEC_FLAG_GRAY)) { v->vc1dsp.vc1_v_overlap(s->dest[1], s->uvlinesize); v->vc1dsp.vc1_v_overlap(s->dest[2], s->uvlinesize); } @@ -2952,23 +4568,24 @@ v->vc1dsp.vc1_v_overlap(s->dest[0] + 8 * s->linesize, s->linesize); v->vc1dsp.vc1_v_overlap(s->dest[0] + 8 * s->linesize + 8, s->linesize); } - if(v->s.loop_filter) vc1_loop_filter_iblk(v, v->pq); + if (v->s.loop_filter) vc1_loop_filter_iblk(v, v->pq); - if(get_bits_count(&s->gb) > v->bits) { + if (get_bits_count(&s->gb) > v->bits) { 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\n", get_bits_count(&s->gb), v->bits); + av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i\n", + get_bits_count(&s->gb), v->bits); return; } } if (!v->s.loop_filter) ff_draw_horiz_band(s, s->mb_y * 16, 16); else if (s->mb_y) - ff_draw_horiz_band(s, (s->mb_y-1) * 16, 16); + ff_draw_horiz_band(s, (s->mb_y - 1) * 16, 16); s->first_slice_line = 0; } if (v->s.loop_filter) - ff_draw_horiz_band(s, (s->mb_height-1)*16, 16); + ff_draw_horiz_band(s, (s->mb_height - 1) * 16, 16); ff_er_add_slice(s, 0, 0, s->mb_width - 1, s->mb_height - 1, (AC_END|DC_END|MV_END)); } @@ -2986,7 +4603,7 @@ GetBitContext *gb = &s->gb; /* select codingmode used for VLC tables selection */ - switch(v->y_ac_table_index){ + switch (v->y_ac_table_index) { case 0: v->codingset = (v->pqindex <= 8) ? CS_HIGH_RATE_INTRA : CS_LOW_MOT_INTRA; break; @@ -2998,7 +4615,7 @@ break; } - switch(v->c_ac_table_index){ + switch (v->c_ac_table_index) { case 0: v->codingset2 = (v->pqindex <= 8) ? CS_HIGH_RATE_INTER : CS_LOW_MOT_INTER; break; @@ -3010,32 +4627,34 @@ break; } - //do frame decode - s->mb_x = s->mb_y = 0; - s->mb_intra = 1; + // do frame decode + s->mb_x = s->mb_y = 0; + s->mb_intra = 1; s->first_slice_line = 1; - s->mb_y = s->start_mb_y; + s->mb_y = s->start_mb_y; if (s->start_mb_y) { s->mb_x = 0; ff_init_block_index(s); - memset(&s->coded_block[s->block_index[0]-s->b8_stride], 0, + memset(&s->coded_block[s->block_index[0] - s->b8_stride], 0, (1 + s->b8_stride) * sizeof(*s->coded_block)); } - for(; s->mb_y < s->end_mb_y; s->mb_y++) { + for (; s->mb_y < s->end_mb_y; s->mb_y++) { s->mb_x = 0; ff_init_block_index(s); - for(;s->mb_x < s->mb_width; s->mb_x++) { + for (;s->mb_x < s->mb_width; s->mb_x++) { DCTELEM (*block)[64] = v->block[v->cur_blk_idx]; ff_update_block_index(s); s->dsp.clear_blocks(block[0]); mb_pos = s->mb_x + s->mb_y * s->mb_stride; - s->current_picture.f.mb_type[mb_pos] = MB_TYPE_INTRA; - s->current_picture.f.motion_val[1][s->block_index[0]][0] = 0; - s->current_picture.f.motion_val[1][s->block_index[0]][1] = 0; + s->current_picture.f.mb_type[mb_pos + v->mb_off] = MB_TYPE_INTRA; + s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][0] = 0; + s->current_picture.f.motion_val[1][s->block_index[0] + v->blocks_off][1] = 0; // do actual MB decoding and displaying + if (v->fieldtx_is_raw) + v->fieldtx_plane[mb_pos] = get_bits1(&v->s.gb); cbp = get_vlc2(&v->s.gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2); - if(v->acpred_is_raw) + if ( v->acpred_is_raw) v->s.ac_pred = get_bits1(&v->s.gb); else v->s.ac_pred = v->acpred_plane[mb_pos]; @@ -3050,32 +4669,36 @@ s->y_dc_scale = s->y_dc_scale_table[mquant]; s->c_dc_scale = s->c_dc_scale_table[mquant]; - for(k = 0; k < 6; k++) { + for (k = 0; k < 6; k++) { val = ((cbp >> (5 - k)) & 1); if (k < 4) { - int pred = vc1_coded_block_pred(&v->s, k, &coded_val); - val = val ^ pred; + int pred = vc1_coded_block_pred(&v->s, k, &coded_val); + val = val ^ pred; *coded_val = val; } cbp |= val << (5 - k); - v->a_avail = !s->first_slice_line || (k==2 || k==3); - v->c_avail = !!s->mb_x || (k==1 || k==3); + v->a_avail = !s->first_slice_line || (k == 2 || k == 3); + v->c_avail = !!s->mb_x || (k == 1 || k == 3); - vc1_decode_i_block_adv(v, block[k], k, val, (k<4)? v->codingset : v->codingset2, mquant); + vc1_decode_i_block_adv(v, block[k], k, val, + (k < 4) ? v->codingset : v->codingset2, mquant); - if (k > 3 && (s->flags & CODEC_FLAG_GRAY)) continue; + if (k > 3 && (s->flags & CODEC_FLAG_GRAY)) + continue; v->vc1dsp.vc1_inv_trans_8x8(block[k]); } vc1_smooth_overlap_filter_iblk(v); vc1_put_signed_blocks_clamped(v); - if(v->s.loop_filter) vc1_loop_filter_iblk_delayed(v, v->pq); + if (v->s.loop_filter) vc1_loop_filter_iblk_delayed(v, v->pq); - if(get_bits_count(&s->gb) > v->bits) { + if (get_bits_count(&s->gb) > v->bits) { + // TODO: may need modification to handle slice coding ff_er_add_slice(s, 0, s->start_mb_y, s->mb_x, s->mb_y, (AC_END|DC_END|MV_END)); - av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i\n", get_bits_count(&s->gb), v->bits); + av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i\n", + get_bits_count(&s->gb), v->bits); return; } } @@ -3089,14 +4712,16 @@ /* raw bottom MB row */ s->mb_x = 0; ff_init_block_index(s); - for(;s->mb_x < s->mb_width; s->mb_x++) { + for (;s->mb_x < s->mb_width; s->mb_x++) { ff_update_block_index(s); vc1_put_signed_blocks_clamped(v); - if(v->s.loop_filter) vc1_loop_filter_iblk_delayed(v, v->pq); + if (v->s.loop_filter) + vc1_loop_filter_iblk_delayed(v, v->pq); } if (v->s.loop_filter) ff_draw_horiz_band(s, (s->end_mb_y-1)*16, 16); - ff_er_add_slice(s, 0, s->start_mb_y, s->mb_width - 1, s->end_mb_y - 1, (AC_END|DC_END|MV_END)); + ff_er_add_slice(s, 0, s->start_mb_y << v->field_mode, s->mb_width - 1, + (s->end_mb_y << v->field_mode) - 1, (AC_END|DC_END|MV_END)); } static void vc1_decode_p_blocks(VC1Context *v) @@ -3105,7 +4730,7 @@ int apply_loop_filter; /* select codingmode used for VLC tables selection */ - switch(v->c_ac_table_index){ + switch (v->c_ac_table_index) { case 0: v->codingset = (v->pqindex <= 8) ? CS_HIGH_RATE_INTRA : CS_LOW_MOT_INTRA; break; @@ -3117,7 +4742,7 @@ break; } - switch(v->c_ac_table_index){ + switch (v->c_ac_table_index) { case 0: v->codingset2 = (v->pqindex <= 8) ? CS_HIGH_RATE_INTER : CS_LOW_MOT_INTER; break; @@ -3129,29 +4754,35 @@ break; } - apply_loop_filter = s->loop_filter && !(s->avctx->skip_loop_filter >= AVDISCARD_NONKEY); + apply_loop_filter = s->loop_filter && !(s->avctx->skip_loop_filter >= AVDISCARD_NONKEY); s->first_slice_line = 1; memset(v->cbp_base, 0, sizeof(v->cbp_base[0])*2*s->mb_stride); - for(s->mb_y = s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) { + for (s->mb_y = s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) { s->mb_x = 0; ff_init_block_index(s); - for(; s->mb_x < s->mb_width; s->mb_x++) { + for (; s->mb_x < s->mb_width; s->mb_x++) { ff_update_block_index(s); - vc1_decode_p_mb(v); - if (s->mb_y != s->start_mb_y && apply_loop_filter) + if (v->fcm == 2) + vc1_decode_p_mb_intfi(v); + else if (v->fcm == 1) + vc1_decode_p_mb_intfr(v); + else vc1_decode_p_mb(v); + if (s->mb_y != s->start_mb_y && apply_loop_filter && v->fcm == 0) vc1_apply_p_loop_filter(v); - if(get_bits_count(&s->gb) > v->bits || get_bits_count(&s->gb) < 0) { + if (get_bits_count(&s->gb) > v->bits || get_bits_count(&s->gb) < 0) { + // TODO: may need modification to handle slice coding ff_er_add_slice(s, 0, s->start_mb_y, 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); + 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; } } - memmove(v->cbp_base, v->cbp, sizeof(v->cbp_base[0])*s->mb_stride); - memmove(v->ttblk_base, v->ttblk, sizeof(v->ttblk_base[0])*s->mb_stride); - memmove(v->is_intra_base, v->is_intra, sizeof(v->is_intra_base[0])*s->mb_stride); - memmove(v->luma_mv_base, v->luma_mv, sizeof(v->luma_mv_base[0])*s->mb_stride); - if (s->mb_y != s->start_mb_y) ff_draw_horiz_band(s, (s->mb_y-1) * 16, 16); + memmove(v->cbp_base, v->cbp, sizeof(v->cbp_base[0]) * s->mb_stride); + memmove(v->ttblk_base, v->ttblk, sizeof(v->ttblk_base[0]) * s->mb_stride); + memmove(v->is_intra_base, v->is_intra, sizeof(v->is_intra_base[0]) * s->mb_stride); + memmove(v->luma_mv_base, v->luma_mv, sizeof(v->luma_mv_base[0]) * s->mb_stride); + if (s->mb_y != s->start_mb_y) ff_draw_horiz_band(s, (s->mb_y - 1) * 16, 16); s->first_slice_line = 0; } if (apply_loop_filter) { @@ -3163,8 +4794,9 @@ } } if (s->end_mb_y >= s->start_mb_y) - ff_draw_horiz_band(s, (s->end_mb_y-1) * 16, 16); - ff_er_add_slice(s, 0, s->start_mb_y, s->mb_width - 1, s->end_mb_y - 1, (AC_END|DC_END|MV_END)); + ff_draw_horiz_band(s, (s->end_mb_y - 1) * 16, 16); + ff_er_add_slice(s, 0, s->start_mb_y << v->field_mode, s->mb_width - 1, + (s->end_mb_y << v->field_mode) - 1, (AC_END|DC_END|MV_END)); } static void vc1_decode_b_blocks(VC1Context *v) @@ -3172,7 +4804,7 @@ MpegEncContext *s = &v->s; /* select codingmode used for VLC tables selection */ - switch(v->c_ac_table_index){ + switch (v->c_ac_table_index) { case 0: v->codingset = (v->pqindex <= 8) ? CS_HIGH_RATE_INTRA : CS_LOW_MOT_INTRA; break; @@ -3184,7 +4816,7 @@ break; } - switch(v->c_ac_table_index){ + switch (v->c_ac_table_index) { case 0: v->codingset2 = (v->pqindex <= 8) ? CS_HIGH_RATE_INTER : CS_LOW_MOT_INTER; break; @@ -3197,29 +4829,35 @@ } s->first_slice_line = 1; - for(s->mb_y = s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) { + for (s->mb_y = s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) { s->mb_x = 0; ff_init_block_index(s); - for(; s->mb_x < s->mb_width; s->mb_x++) { + for (; s->mb_x < s->mb_width; s->mb_x++) { ff_update_block_index(s); - vc1_decode_b_mb(v); - if(get_bits_count(&s->gb) > v->bits || get_bits_count(&s->gb) < 0) { + if (v->fcm == 2) + vc1_decode_b_mb_intfi(v); + else + vc1_decode_b_mb(v); + if (get_bits_count(&s->gb) > v->bits || get_bits_count(&s->gb) < 0) { + // TODO: may need modification to handle slice coding ff_er_add_slice(s, 0, s->start_mb_y, 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); + 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(v, v->pq); + if (v->s.loop_filter) vc1_loop_filter_iblk(v, v->pq); } if (!v->s.loop_filter) ff_draw_horiz_band(s, s->mb_y * 16, 16); else if (s->mb_y) - ff_draw_horiz_band(s, (s->mb_y-1) * 16, 16); + ff_draw_horiz_band(s, (s->mb_y - 1) * 16, 16); s->first_slice_line = 0; } if (v->s.loop_filter) - ff_draw_horiz_band(s, (s->end_mb_y-1)*16, 16); - ff_er_add_slice(s, 0, s->start_mb_y, s->mb_width - 1, s->end_mb_y - 1, (AC_END|DC_END|MV_END)); + ff_draw_horiz_band(s, (s->end_mb_y - 1) * 16, 16); + ff_er_add_slice(s, 0, s->start_mb_y << v->field_mode, s->mb_width - 1, + (s->end_mb_y << v->field_mode) - 1, (AC_END|DC_END|MV_END)); } static void vc1_decode_skip_blocks(VC1Context *v) @@ -3228,7 +4866,7 @@ ff_er_add_slice(s, 0, s->start_mb_y, s->mb_width - 1, s->end_mb_y - 1, (AC_END|DC_END|MV_END)); s->first_slice_line = 1; - for(s->mb_y = s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) { + for (s->mb_y = s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) { s->mb_x = 0; ff_init_block_index(s); ff_update_block_index(s); @@ -3245,33 +4883,33 @@ { v->s.esc3_level_length = 0; - if(v->x8_type){ - ff_intrax8_decode_picture(&v->x8, 2*v->pq+v->halfpq, v->pq*(!v->pquantizer) ); - }else{ - v->cur_blk_idx = 0; - v->left_blk_idx = -1; - v->topleft_blk_idx = 1; - v->top_blk_idx = 2; - switch(v->s.pict_type) { + if (v->x8_type) { + ff_intrax8_decode_picture(&v->x8, 2*v->pq + v->halfpq, v->pq * !v->pquantizer); + } else { + v->cur_blk_idx = 0; + v->left_blk_idx = -1; + v->topleft_blk_idx = 1; + v->top_blk_idx = 2; + switch (v->s.pict_type) { case AV_PICTURE_TYPE_I: - if(v->profile == PROFILE_ADVANCED) + if (v->profile == PROFILE_ADVANCED) vc1_decode_i_blocks_adv(v); else vc1_decode_i_blocks(v); break; case AV_PICTURE_TYPE_P: - if(v->p_frame_skipped) + if (v->p_frame_skipped) vc1_decode_skip_blocks(v); else vc1_decode_p_blocks(v); break; case AV_PICTURE_TYPE_B: - if(v->bi_type){ - if(v->profile == PROFILE_ADVANCED) + if (v->bi_type) { + if (v->profile == PROFILE_ADVANCED) vc1_decode_i_blocks_adv(v); else vc1_decode_i_blocks(v); - }else + } else vc1_decode_b_blocks(v); break; } @@ -3301,7 +4939,7 @@ static inline int get_fp_val(GetBitContext* gb) { - return (get_bits_long(gb, 30) - (1<<29)) << 1; + return (get_bits_long(gb, 30) - (1 << 29)) << 1; } static void vc1_sprite_parse_transform(GetBitContext* gb, int c[7]) @@ -3310,9 +4948,9 @@ switch (get_bits(gb, 2)) { case 0: - c[0] = 1<<16; + c[0] = 1 << 16; c[2] = get_fp_val(gb); - c[4] = 1<<16; + c[4] = 1 << 16; break; case 1: c[0] = c[4] = get_fp_val(gb); @@ -3335,7 +4973,7 @@ if (get_bits1(gb)) c[6] = get_fp_val(gb); else - c[6] = 1<<16; + c[6] = 1 << 16; } static void vc1_parse_sprites(VC1Context *v, GetBitContext* gb, SpriteData* sd) @@ -3351,7 +4989,7 @@ for (i = 0; i < 7; i++) av_log(avctx, AV_LOG_DEBUG, " %d.%.3d", sd->coefs[sprite][i] / (1<<16), - (abs(sd->coefs[sprite][i]) & 0xFFFF) * 1000 / (1<<16)); + (abs(sd->coefs[sprite][i]) & 0xFFFF) * 1000 / (1 << 16)); av_log(avctx, AV_LOG_DEBUG, "\n"); } @@ -3374,8 +5012,8 @@ av_log(avctx, AV_LOG_DEBUG, "Effect: %d; params: ", sd->effect_type); for (i = 0; i < sd->effect_pcount1; i++) av_log(avctx, AV_LOG_DEBUG, " %d.%.2d", - sd->effect_params1[i] / (1<<16), - (abs(sd->effect_params1[i]) & 0xFFFF) * 1000 / (1<<16)); + sd->effect_params1[i] / (1 << 16), + (abs(sd->effect_params1[i]) & 0xFFFF) * 1000 / (1 << 16)); av_log(avctx, AV_LOG_DEBUG, "\n"); } @@ -3386,11 +5024,11 @@ } else if (sd->effect_pcount2) { i = -1; av_log(avctx, AV_LOG_DEBUG, "Effect params 2: "); - while (++i < sd->effect_pcount2){ + while (++i < sd->effect_pcount2) { sd->effect_params2[i] = get_fp_val(gb); av_log(avctx, AV_LOG_DEBUG, " %d.%.2d", - sd->effect_params2[i] / (1<<16), - (abs(sd->effect_params2[i]) & 0xFFFF) * 1000 / (1<<16)); + sd->effect_params2[i] / (1 << 16), + (abs(sd->effect_params2[i]) & 0xFFFF) * 1000 / (1 << 16)); } av_log(avctx, AV_LOG_DEBUG, "\n"); } @@ -3417,11 +5055,11 @@ for (i = 0; i < 2; i++) { xoff[i] = av_clip(sd->coefs[i][2], 0, v->sprite_width-1 << 16); xadv[i] = sd->coefs[i][0]; - if (xadv[i] != 1<<16 || (v->sprite_width<<16) - (v->output_width<<16) - xoff[i]) + if (xadv[i] != 1<<16 || (v->sprite_width << 16) - (v->output_width << 16) - xoff[i]) xadv[i] = av_clip(xadv[i], 0, ((v->sprite_width<<16) - xoff[i] - 1) / v->output_width); yoff[i] = av_clip(sd->coefs[i][5], 0, v->sprite_height-1 << 16); - yadv[i] = av_clip(sd->coefs[i][4], 0, ((v->sprite_height<<16) - yoff[i]) / v->output_height); + yadv[i] = av_clip(sd->coefs[i][4], 0, ((v->sprite_height << 16) - yoff[i]) / v->output_height); } alpha = av_clip(sd->coefs[1][6], 0, (1<<16) - 1); @@ -3435,29 +5073,29 @@ for (sprite = 0; sprite <= v->two_sprites; sprite++) { uint8_t *iplane = s->current_picture.f.data[plane]; int iline = s->current_picture.f.linesize[plane]; - int ycoord = yoff[sprite] + yadv[sprite]*row; - int yline = ycoord>>16; - ysub[sprite] = ycoord&0xFFFF; + int ycoord = yoff[sprite] + yadv[sprite] * row; + int yline = ycoord >> 16; + ysub[sprite] = ycoord & 0xFFFF; if (sprite) { iplane = s->last_picture.f.data[plane]; iline = s->last_picture.f.linesize[plane]; } - if (!(xoff[sprite]&0xFFFF) && xadv[sprite] == 1<<16) { - src_h[sprite][0] = iplane+(xoff[sprite]>>16)+ yline *iline; + if (!(xoff[sprite] & 0xFFFF) && xadv[sprite] == 1 << 16) { + src_h[sprite][0] = iplane + (xoff[sprite] >> 16) + yline * iline; if (ysub[sprite]) - src_h[sprite][1] = iplane+(xoff[sprite]>>16)+(yline+1)*iline; + src_h[sprite][1] = iplane + (xoff[sprite] >> 16) + (yline + 1) * iline; } else { if (sr_cache[sprite][0] != yline) { if (sr_cache[sprite][1] == yline) { FFSWAP(uint8_t*, v->sr_rows[sprite][0], v->sr_rows[sprite][1]); FFSWAP(int, sr_cache[sprite][0], sr_cache[sprite][1]); } else { - v->vc1dsp.sprite_h(v->sr_rows[sprite][0], iplane+yline*iline, xoff[sprite], xadv[sprite], width); + v->vc1dsp.sprite_h(v->sr_rows[sprite][0], iplane + yline * iline, xoff[sprite], xadv[sprite], width); sr_cache[sprite][0] = yline; } } if (ysub[sprite] && sr_cache[sprite][1] != yline + 1) { - v->vc1dsp.sprite_h(v->sr_rows[sprite][1], iplane+(yline+1)*iline, xoff[sprite], xadv[sprite], width); + v->vc1dsp.sprite_h(v->sr_rows[sprite][1], iplane + (yline + 1) * iline, xoff[sprite], xadv[sprite], width); sr_cache[sprite][1] = yline + 1; } src_h[sprite][0] = v->sr_rows[sprite][0]; @@ -3500,7 +5138,7 @@ static int vc1_decode_sprites(VC1Context *v, GetBitContext* gb) { - MpegEncContext *s = &v->s; + MpegEncContext *s = &v->s; AVCodecContext *avctx = s->avctx; SpriteData sd; @@ -3533,7 +5171,7 @@ static void vc1_sprite_flush(AVCodecContext *avctx) { - VC1Context *v = avctx->priv_data; + VC1Context *v = avctx->priv_data; MpegEncContext *s = &v->s; AVFrame *f = &s->current_picture.f; int plane, i; @@ -3545,7 +5183,7 @@ if (f->data[0]) for (plane = 0; plane < (s->flags&CODEC_FLAG_GRAY ? 1 : 3); plane++) for (i = 0; i < v->sprite_height>>!!plane; i++) - memset(f->data[plane]+i*f->linesize[plane], + memset(f->data[plane] + i * f->linesize[plane], plane ? 128 : 0, f->linesize[plane]); } @@ -3557,31 +5195,45 @@ int i; /* Allocate mb bitplanes */ - v->mv_type_mb_plane = av_malloc(s->mb_stride * s->mb_height); - v->direct_mb_plane = av_malloc(s->mb_stride * s->mb_height); - v->acpred_plane = av_malloc(s->mb_stride * s->mb_height); - v->over_flags_plane = av_malloc(s->mb_stride * s->mb_height); + v->mv_type_mb_plane = av_malloc (s->mb_stride * s->mb_height); + v->direct_mb_plane = av_malloc (s->mb_stride * s->mb_height); + v->forward_mb_plane = av_malloc (s->mb_stride * s->mb_height); + v->fieldtx_plane = av_mallocz(s->mb_stride * s->mb_height); + v->acpred_plane = av_malloc (s->mb_stride * s->mb_height); + v->over_flags_plane = av_malloc (s->mb_stride * s->mb_height); v->n_allocated_blks = s->mb_width + 2; - v->block = av_malloc(sizeof(*v->block) * v->n_allocated_blks); - v->cbp_base = av_malloc(sizeof(v->cbp_base[0]) * 2 * s->mb_stride); - v->cbp = v->cbp_base + s->mb_stride; - v->ttblk_base = av_malloc(sizeof(v->ttblk_base[0]) * 2 * s->mb_stride); - v->ttblk = v->ttblk_base + s->mb_stride; - v->is_intra_base = av_malloc(sizeof(v->is_intra_base[0]) * 2 * s->mb_stride); - v->is_intra = v->is_intra_base + s->mb_stride; - v->luma_mv_base = av_malloc(sizeof(v->luma_mv_base[0]) * 2 * s->mb_stride); - v->luma_mv = v->luma_mv_base + s->mb_stride; + v->block = av_malloc(sizeof(*v->block) * v->n_allocated_blks); + v->cbp_base = av_malloc(sizeof(v->cbp_base[0]) * 2 * s->mb_stride); + v->cbp = v->cbp_base + s->mb_stride; + v->ttblk_base = av_malloc(sizeof(v->ttblk_base[0]) * 2 * s->mb_stride); + v->ttblk = v->ttblk_base + s->mb_stride; + v->is_intra_base = av_mallocz(sizeof(v->is_intra_base[0]) * 2 * s->mb_stride); + v->is_intra = v->is_intra_base + s->mb_stride; + v->luma_mv_base = av_malloc(sizeof(v->luma_mv_base[0]) * 2 * s->mb_stride); + v->luma_mv = v->luma_mv_base + s->mb_stride; /* allocate block type info in that way so it could be used with s->block_index[] */ v->mb_type_base = av_malloc(s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2); - v->mb_type[0] = v->mb_type_base + s->b8_stride + 1; - v->mb_type[1] = v->mb_type_base + s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride + 1; - v->mb_type[2] = v->mb_type[1] + s->mb_stride * (s->mb_height + 1); + v->mb_type[0] = v->mb_type_base + s->b8_stride + 1; + v->mb_type[1] = v->mb_type_base + s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride + 1; + v->mb_type[2] = v->mb_type[1] + s->mb_stride * (s->mb_height + 1); + + /* allocate memory to store block level MV info */ + v->blk_mv_type_base = av_mallocz( s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2); + v->blk_mv_type = v->blk_mv_type_base + s->b8_stride + 1; + v->mv_f_base = av_mallocz(2 * (s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2)); + v->mv_f[0] = v->mv_f_base + s->b8_stride + 1; + v->mv_f[1] = v->mv_f[0] + (s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2); + v->mv_f_last_base = av_mallocz(2 * (s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2)); + v->mv_f_last[0] = v->mv_f_last_base + s->b8_stride + 1; + v->mv_f_last[1] = v->mv_f_last[0] + (s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2); + v->mv_f_next_base = av_mallocz(2 * (s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2)); + v->mv_f_next[0] = v->mv_f_next_base + s->b8_stride + 1; + v->mv_f_next[1] = v->mv_f_next[0] + (s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2); /* Init coded blocks info */ - if (v->profile == PROFILE_ADVANCED) - { + if (v->profile == PROFILE_ADVANCED) { // if (alloc_bitplane(&v->over_flags_plane, s->mb_width, s->mb_height) < 0) // return -1; // if (alloc_bitplane(&v->ac_pred_plane, s->mb_width, s->mb_height) < 0) @@ -3592,7 +5244,7 @@ if (s->avctx->codec_id == CODEC_ID_WMV3IMAGE || s->avctx->codec_id == CODEC_ID_VC1IMAGE) { for (i = 0; i < 4; i++) - if (!(v->sr_rows[i>>1][i%2] = av_malloc(v->output_width))) return -1; + if (!(v->sr_rows[i >> 1][i & 1] = av_malloc(v->output_width))) return -1; } if (!v->mv_type_mb_plane || !v->direct_mb_plane || !v->acpred_plane || !v->over_flags_plane || @@ -3618,7 +5270,8 @@ v->output_width = avctx->width; v->output_height = avctx->height; - if (!avctx->extradata_size || !avctx->extradata) return -1; + if (!avctx->extradata_size || !avctx->extradata) + return -1; if (!(avctx->flags & CODEC_FLAG_GRAY)) avctx->pix_fmt = avctx->get_format(avctx, avctx->codec->pix_fmts); else @@ -3626,17 +5279,17 @@ avctx->hwaccel = ff_find_hwaccel(avctx->codec->id, avctx->pix_fmt); v->s.avctx = avctx; avctx->flags |= CODEC_FLAG_EMU_EDGE; - v->s.flags |= CODEC_FLAG_EMU_EDGE; + v->s.flags |= CODEC_FLAG_EMU_EDGE; - if(avctx->idct_algo==FF_IDCT_AUTO){ - avctx->idct_algo=FF_IDCT_WMV2; + if (avctx->idct_algo == FF_IDCT_AUTO) { + avctx->idct_algo = FF_IDCT_WMV2; } - if (vc1_init_common(v) < 0) return -1; + if (vc1_init_common(v) < 0) + return -1; ff_vc1dsp_init(&v->vc1dsp); - if (avctx->codec_id == CODEC_ID_WMV3 || avctx->codec_id == CODEC_ID_WMV3IMAGE) - { + if (avctx->codec_id == CODEC_ID_WMV3 || avctx->codec_id == CODEC_ID_WMV3IMAGE) { int count = 0; // looks like WMV3 has a sequence header stored in the extradata @@ -3650,13 +5303,10 @@ return -1; count = avctx->extradata_size*8 - get_bits_count(&gb); - if (count>0) - { + if (count > 0) { av_log(avctx, AV_LOG_INFO, "Extra data: %i bits left, value: %X\n", count, get_bits(&gb, count)); - } - else if (count < 0) - { + } else if (count < 0) { av_log(avctx, AV_LOG_INFO, "Read %i bits in overflow\n", -count); } } else { // VC1/WVC1/WVP2 @@ -3667,30 +5317,31 @@ uint8_t *buf2 = NULL; int seq_initialized = 0, ep_initialized = 0; - if(avctx->extradata_size < 16) { + if (avctx->extradata_size < 16) { av_log(avctx, AV_LOG_ERROR, "Extradata size too small: %i\n", avctx->extradata_size); return -1; } - buf2 = av_mallocz(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); + buf2 = av_mallocz(avctx->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); start = find_next_marker(start, end); // in WVC1 extradata first byte is its size, but can be 0 in mkv - next = start; - for(; next < end; start = next){ + next = start; + for (; next < end; start = next) { next = find_next_marker(start + 4, end); size = next - start - 4; - if(size <= 0) continue; + if (size <= 0) + continue; buf2_size = vc1_unescape_buffer(start + 4, size, buf2); init_get_bits(&gb, buf2, buf2_size * 8); - switch(AV_RB32(start)){ + switch (AV_RB32(start)) { case VC1_CODE_SEQHDR: - if(vc1_decode_sequence_header(avctx, v, &gb) < 0){ + if (vc1_decode_sequence_header(avctx, v, &gb) < 0) { av_free(buf2); return -1; } seq_initialized = 1; break; case VC1_CODE_ENTRYPOINT: - if(vc1_decode_entry_point(avctx, v, &gb) < 0){ + if (vc1_decode_entry_point(avctx, v, &gb) < 0) { av_free(buf2); return -1; } @@ -3699,7 +5350,7 @@ } } av_free(buf2); - if(!seq_initialized || !ep_initialized){ + if (!seq_initialized || !ep_initialized) { av_log(avctx, AV_LOG_ERROR, "Incomplete extradata\n"); return -1; } @@ -3710,18 +5361,19 @@ if (v->profile == PROFILE_ADVANCED) avctx->level = v->level; - avctx->has_b_frames= !!(avctx->max_b_frames); + avctx->has_b_frames = !!(avctx->max_b_frames); - s->mb_width = (avctx->coded_width+15)>>4; - s->mb_height = (avctx->coded_height+15)>>4; + s->mb_width = (avctx->coded_width + 15) >> 4; + s->mb_height = (avctx->coded_height + 15) >> 4; if (v->profile == PROFILE_ADVANCED || v->res_fasttx) { - for (i = 0; i < 64; i++) { -#define transpose(x) ((x>>3) | ((x&7)<<3)) + for (i = 0; i < 64; i++) { +#define transpose(x) ((x >> 3) | ((x & 7) << 3)) v->zz_8x8[0][i] = transpose(wmv1_scantable[0][i]); v->zz_8x8[1][i] = transpose(wmv1_scantable[1][i]); v->zz_8x8[2][i] = transpose(wmv1_scantable[2][i]); v->zz_8x8[3][i] = transpose(wmv1_scantable[3][i]); + v->zzi_8x8[i] = transpose(ff_vc1_adv_interlaced_8x8_zz[i]); } v->left_blk_sh = 0; v->top_blk_sh = 3; @@ -3739,10 +5391,10 @@ avctx->coded_height = avctx->height = v->output_height; // prevent 16.16 overflows - if (v->sprite_width > 1<<14 || - v->sprite_height > 1<<14 || - v->output_width > 1<<14 || - v->output_height > 1<<14) return -1; + if (v->sprite_width > 1 << 14 || + v->sprite_height > 1 << 14 || + v->output_width > 1 << 14 || + v->output_height > 1 << 14) return -1; } return 0; } @@ -3759,15 +5411,21 @@ && v->sprite_output_frame.data[0]) avctx->release_buffer(avctx, &v->sprite_output_frame); for (i = 0; i < 4; i++) - av_freep(&v->sr_rows[i>>1][i%2]); + av_freep(&v->sr_rows[i >> 1][i & 1]); av_freep(&v->hrd_rate); av_freep(&v->hrd_buffer); MPV_common_end(&v->s); av_freep(&v->mv_type_mb_plane); av_freep(&v->direct_mb_plane); + av_freep(&v->forward_mb_plane); + av_freep(&v->fieldtx_plane); av_freep(&v->acpred_plane); av_freep(&v->over_flags_plane); av_freep(&v->mb_type_base); + av_freep(&v->blk_mv_type_base); + av_freep(&v->mv_f_base); + av_freep(&v->mv_f_last_base); + av_freep(&v->mv_f_next_base); av_freep(&v->block); av_freep(&v->cbp_base); av_freep(&v->ttblk_base); @@ -3781,9 +5439,8 @@ /** Decode a VC1/WMV3 frame * @todo TODO: Handle VC-1 IDUs (Transport level?) */ -static int vc1_decode_frame(AVCodecContext *avctx, - void *data, int *data_size, - AVPacket *avpkt) +static int vc1_decode_frame(AVCodecContext *avctx, void *data, + int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size, n_slices = 0, i; @@ -3791,19 +5448,24 @@ MpegEncContext *s = &v->s; AVFrame *pict = data; uint8_t *buf2 = NULL; + uint8_t *buf_field2 = NULL; const uint8_t *buf_start = buf; + int mb_height, n_slices1=-1; struct { uint8_t *buf; GetBitContext gb; int mby_start; } *slices = NULL; + if(s->flags & CODEC_FLAG_LOW_DELAY) + s->low_delay = 1; + /* no supplementary picture */ if (buf_size == 0 || (buf_size == 4 && AV_RB32(buf) == VC1_CODE_ENDOFSEQ)) { /* special case for last picture */ - if (s->low_delay==0 && s->next_picture_ptr) { - *pict= *(AVFrame*)s->next_picture_ptr; - s->next_picture_ptr= NULL; + if (s->low_delay == 0 && s->next_picture_ptr) { + *pict = *(AVFrame*)s->next_picture_ptr; + s->next_picture_ptr = NULL; *data_size = sizeof(AVFrame); } @@ -3811,7 +5473,7 @@ return 0; } - if (s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU){ + if (s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) { if (v->profile < PROFILE_ADVANCED) avctx->pix_fmt = PIX_FMT_VDPAU_WMV3; else @@ -3823,33 +5485,57 @@ int buf_size2 = 0; buf2 = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE); - if(IS_MARKER(AV_RB32(buf))){ /* frame starts with marker and needs to be parsed */ + if (IS_MARKER(AV_RB32(buf))) { /* frame starts with marker and needs to be parsed */ const uint8_t *start, *end, *next; int size; next = buf; - for(start = buf, end = buf + buf_size; next < end; start = next){ + for (start = buf, end = buf + buf_size; next < end; start = next) { next = find_next_marker(start + 4, end); size = next - start - 4; - if(size <= 0) continue; - switch(AV_RB32(start)){ + if (size <= 0) continue; + switch (AV_RB32(start)) { case VC1_CODE_FRAME: if (avctx->hwaccel || s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) buf_start = start; buf_size2 = vc1_unescape_buffer(start + 4, size, buf2); break; + case VC1_CODE_FIELD: { + int buf_size3; + slices = av_realloc(slices, sizeof(*slices) * (n_slices+1)); + if (!slices) + goto err; + slices[n_slices].buf = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE); + if (!slices[n_slices].buf) + goto err; + buf_size3 = vc1_unescape_buffer(start + 4, size, + slices[n_slices].buf); + init_get_bits(&slices[n_slices].gb, slices[n_slices].buf, + buf_size3 << 3); + /* assuming that the field marker is at the exact middle, + hope it's correct */ + slices[n_slices].mby_start = s->mb_height >> 1; + n_slices1 = n_slices - 1; // index of the last slice of the first field + n_slices++; + // not necessary, ad hoc until I find a way to handle WVC1i + buf_field2 = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE); + vc1_unescape_buffer(start + 4, size, buf_field2); + break; + } case VC1_CODE_ENTRYPOINT: /* it should be before frame data */ buf_size2 = vc1_unescape_buffer(start + 4, size, buf2); - init_get_bits(&s->gb, buf2, buf_size2*8); + init_get_bits(&s->gb, buf2, buf_size2 * 8); vc1_decode_entry_point(avctx, v, &s->gb); break; case VC1_CODE_SLICE: { int buf_size3; slices = av_realloc(slices, sizeof(*slices) * (n_slices+1)); - if (!slices) goto err; + if (!slices) + goto err; slices[n_slices].buf = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE); - if (!slices[n_slices].buf) goto err; + if (!slices[n_slices].buf) + goto err; buf_size3 = vc1_unescape_buffer(start + 4, size, slices[n_slices].buf); init_get_bits(&slices[n_slices].gb, slices[n_slices].buf, @@ -3860,21 +5546,19 @@ } } } - }else if(v->interlace && ((buf[0] & 0xC0) == 0xC0)){ /* WVC1 interlaced stores both fields divided by marker */ + } else if (v->interlace && ((buf[0] & 0xC0) == 0xC0)) { /* WVC1 interlaced stores both fields divided by marker */ const uint8_t *divider; divider = find_next_marker(buf, buf + buf_size); - if((divider == (buf + buf_size)) || AV_RB32(divider) != VC1_CODE_FIELD){ + if ((divider == (buf + buf_size)) || AV_RB32(divider) != VC1_CODE_FIELD) { av_log(avctx, AV_LOG_ERROR, "Error in WVC1 interlaced frame\n"); goto err; + } else { // found field marker, unescape second field + buf_field2 = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE); + vc1_unescape_buffer(divider + 4, buf + buf_size - divider - 4, buf_field2); } - buf_size2 = vc1_unescape_buffer(buf, divider - buf, buf2); - // TODO - if(!v->warn_interlaced++) - av_log(v->s.avctx, AV_LOG_ERROR, "Interlaced WVC1 support is not implemented\n"); - goto err; - }else{ + } else { buf_size2 = vc1_unescape_buffer(buf, buf_size, buf2); } init_get_bits(&s->gb, buf2, buf_size2*8); @@ -3882,8 +5566,8 @@ init_get_bits(&s->gb, buf, buf_size*8); if (v->res_sprite) { - v->new_sprite = !get_bits1(&s->gb); - v->two_sprites = get_bits1(&s->gb); + v->new_sprite = !get_bits1(&s->gb); + v->two_sprites = get_bits1(&s->gb); /* res_sprite means a Windows Media Image stream, CODEC_ID_*IMAGE means we're using the sprite compositor. These are intentionally kept separate so you can get the raw sprites by using the wmv3 decoder for WMVP or @@ -3920,23 +5604,24 @@ /* We need to set current_picture_ptr before reading the header, * otherwise we cannot store anything in there. */ if (s->current_picture_ptr == NULL || s->current_picture_ptr->f.data[0]) { - int i= ff_find_unused_picture(s, 0); - s->current_picture_ptr= &s->picture[i]; + int i = ff_find_unused_picture(s, 0); + s->current_picture_ptr = &s->picture[i]; } // do parse frame header - if(v->profile < PROFILE_ADVANCED) { - if(vc1_parse_frame_header(v, &s->gb) == -1) { + v->pic_header_flag = 0; + if (v->profile < PROFILE_ADVANCED) { + if (vc1_parse_frame_header(v, &s->gb) == -1) { goto err; } } else { - if(vc1_parse_frame_header_adv(v, &s->gb) == -1) { + if (vc1_parse_frame_header_adv(v, &s->gb) == -1) { goto err; } } if ((avctx->codec_id == CODEC_ID_WMV3IMAGE || avctx->codec_id == CODEC_ID_VC1IMAGE) - && s->pict_type!=AV_PICTURE_TYPE_I) { + && s->pict_type != AV_PICTURE_TYPE_I) { av_log(v->s.avctx, AV_LOG_ERROR, "Sprite decoder: expected I-frame\n"); goto err; } @@ -3945,10 +5630,10 @@ s->current_picture_ptr->f.repeat_pict = 0; // Pulldown flags are only valid when 'broadcast' has been set. // So ticks_per_frame will be 2 - if (v->rff){ + if (v->rff) { // repeat field s->current_picture_ptr->f.repeat_pict = 1; - }else if (v->rptfrm){ + } else if (v->rptfrm) { // repeat frames s->current_picture_ptr->f.repeat_pict = v->rptfrm * 2; } @@ -3958,28 +5643,28 @@ s->current_picture.f.key_frame = s->pict_type == AV_PICTURE_TYPE_I; /* skip B-frames if we don't have reference frames */ - if(s->last_picture_ptr==NULL && (s->pict_type==AV_PICTURE_TYPE_B || s->dropable)){ + if (s->last_picture_ptr == NULL && (s->pict_type == AV_PICTURE_TYPE_B || s->dropable)) { goto err; } - if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==AV_PICTURE_TYPE_B) - || (avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=AV_PICTURE_TYPE_I) - || avctx->skip_frame >= AVDISCARD_ALL) { + if ((avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type == AV_PICTURE_TYPE_B) || + (avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type != AV_PICTURE_TYPE_I) || + avctx->skip_frame >= AVDISCARD_ALL) { goto end; } - if(s->next_p_frame_damaged){ - if(s->pict_type==AV_PICTURE_TYPE_B) + if (s->next_p_frame_damaged) { + if (s->pict_type == AV_PICTURE_TYPE_B) goto end; else - s->next_p_frame_damaged=0; + s->next_p_frame_damaged = 0; } - if(MPV_frame_start(s, avctx) < 0) { + if (MPV_frame_start(s, avctx) < 0) { goto err; } - s->me.qpel_put= s->dsp.put_qpel_pixels_tab; - s->me.qpel_avg= s->dsp.avg_qpel_pixels_tab; + s->me.qpel_put = s->dsp.put_qpel_pixels_tab; + s->me.qpel_avg = s->dsp.avg_qpel_pixels_tab; if ((CONFIG_VC1_VDPAU_DECODER) &&s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU) @@ -3995,48 +5680,96 @@ ff_er_frame_start(s); v->bits = buf_size * 8; + if (v->field_mode) { + uint8_t *tmp[2]; + s->current_picture.f.linesize[0] <<= 1; + s->current_picture.f.linesize[1] <<= 1; + s->current_picture.f.linesize[2] <<= 1; + s->linesize <<= 1; + s->uvlinesize <<= 1; + tmp[0] = v->mv_f_last[0]; + tmp[1] = v->mv_f_last[1]; + v->mv_f_last[0] = v->mv_f_next[0]; + v->mv_f_last[1] = v->mv_f_next[1]; + v->mv_f_next[0] = v->mv_f[0]; + v->mv_f_next[1] = v->mv_f[1]; + v->mv_f[0] = tmp[0]; + v->mv_f[1] = tmp[1]; + } + mb_height = s->mb_height >> v->field_mode; for (i = 0; i <= n_slices; i++) { - if (i && get_bits1(&s->gb)) - vc1_parse_frame_header_adv(v, &s->gb); - s->start_mb_y = (i == 0) ? 0 : FFMAX(0, slices[i-1].mby_start); - s->end_mb_y = (i == n_slices) ? s->mb_height : FFMIN(s->mb_height, slices[i].mby_start); + if (i > 0 && slices[i - 1].mby_start >= mb_height) { + v->second_field = 1; + v->blocks_off = s->mb_width * s->mb_height << 1; + v->mb_off = s->mb_stride * s->mb_height >> 1; + } else { + v->second_field = 0; + v->blocks_off = 0; + v->mb_off = 0; + } + if (i) { + v->pic_header_flag = 0; + if (v->field_mode && i == n_slices1 + 2) + vc1_parse_frame_header_adv(v, &s->gb); + else if (get_bits1(&s->gb)) { + v->pic_header_flag = 1; + vc1_parse_frame_header_adv(v, &s->gb); + } + } + s->start_mb_y = (i == 0) ? 0 : FFMAX(0, slices[i-1].mby_start % mb_height); + if (!v->field_mode || v->second_field) + s->end_mb_y = (i == n_slices ) ? mb_height : FFMIN(mb_height, slices[i].mby_start % mb_height); + else + s->end_mb_y = (i == n_slices1 + 1) ? mb_height : FFMIN(mb_height, slices[i].mby_start % mb_height); vc1_decode_blocks(v); - if (i != n_slices) s->gb = slices[i].gb; + if (i != n_slices) + s->gb = slices[i].gb; + } + if (v->field_mode) { + av_free(buf_field2); + v->second_field = 0; + } + if (v->field_mode) { + if (s->pict_type == AV_PICTURE_TYPE_B) { + memcpy(v->mv_f_base, v->mv_f_next_base, + 2 * (s->b8_stride * (s->mb_height * 2 + 1) + s->mb_stride * (s->mb_height + 1) * 2)); + } + s->current_picture.f.linesize[0] >>= 1; + s->current_picture.f.linesize[1] >>= 1; + s->current_picture.f.linesize[2] >>= 1; + s->linesize >>= 1; + s->uvlinesize >>= 1; } //av_log(s->avctx, AV_LOG_INFO, "Consumed %i/%i bits\n", get_bits_count(&s->gb), s->gb.size_in_bits); -// if(get_bits_count(&s->gb) > buf_size * 8) +// if (get_bits_count(&s->gb) > buf_size * 8) // return -1; ff_er_frame_end(s); } MPV_frame_end(s); -assert(s->current_picture.f.pict_type == s->current_picture_ptr->f.pict_type); -assert(s->current_picture.f.pict_type == s->pict_type); - if (avctx->codec_id == CODEC_ID_WMV3IMAGE || avctx->codec_id == CODEC_ID_VC1IMAGE) { image: avctx->width = avctx->coded_width = v->output_width; avctx->height = avctx->coded_height = v->output_height; - if (avctx->skip_frame >= AVDISCARD_NONREF) goto end; + if (avctx->skip_frame >= AVDISCARD_NONREF) + goto end; #if CONFIG_WMV3IMAGE_DECODER || CONFIG_VC1IMAGE_DECODER - if (vc1_decode_sprites(v, &s->gb)) goto err; + if (vc1_decode_sprites(v, &s->gb)) + goto err; #endif - *pict = v->sprite_output_frame; + *pict = v->sprite_output_frame; *data_size = sizeof(AVFrame); } else { - - if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { - *pict= *(AVFrame*)s->current_picture_ptr; - } else if (s->last_picture_ptr != NULL) { - *pict= *(AVFrame*)s->last_picture_ptr; - } - - if(s->last_picture_ptr || s->low_delay){ - *data_size = sizeof(AVFrame); - ff_print_debug_info(s, pict); - } - + if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) { + *pict = *(AVFrame*)s->current_picture_ptr; + } else if (s->last_picture_ptr != NULL) { + *pict = *(AVFrame*)s->last_picture_ptr; + } + if (s->last_picture_ptr || s->low_delay) { + *data_size = sizeof(AVFrame); + ff_print_debug_info(s, pict); + } } end: @@ -4051,6 +5784,7 @@ for (i = 0; i < n_slices; i++) av_free(slices[i].buf); av_free(slices); + av_free(buf_field2); return -1; } @@ -4072,9 +5806,9 @@ .close = vc1_decode_end, .decode = vc1_decode_frame, .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY, - .long_name = NULL_IF_CONFIG_SMALL("SMPTE VC-1"), - .pix_fmts = ff_hwaccel_pixfmt_list_420, - .profiles = NULL_IF_CONFIG_SMALL(profiles) + .long_name = NULL_IF_CONFIG_SMALL("SMPTE VC-1"), + .pix_fmts = ff_hwaccel_pixfmt_list_420, + .profiles = NULL_IF_CONFIG_SMALL(profiles) }; #if CONFIG_WMV3_DECODER @@ -4087,9 +5821,9 @@ .close = vc1_decode_end, .decode = vc1_decode_frame, .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY, - .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9"), - .pix_fmts = ff_hwaccel_pixfmt_list_420, - .profiles = NULL_IF_CONFIG_SMALL(profiles) + .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9"), + .pix_fmts = ff_hwaccel_pixfmt_list_420, + .profiles = NULL_IF_CONFIG_SMALL(profiles) }; #endif @@ -4103,9 +5837,9 @@ .close = vc1_decode_end, .decode = vc1_decode_frame, .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU, - .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9 VDPAU"), - .pix_fmts = (const enum PixelFormat[]){PIX_FMT_VDPAU_WMV3, PIX_FMT_NONE}, - .profiles = NULL_IF_CONFIG_SMALL(profiles) + .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9 VDPAU"), + .pix_fmts = (const enum PixelFormat[]){PIX_FMT_VDPAU_WMV3, PIX_FMT_NONE}, + .profiles = NULL_IF_CONFIG_SMALL(profiles) }; #endif @@ -4119,9 +5853,9 @@ .close = vc1_decode_end, .decode = vc1_decode_frame, .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU, - .long_name = NULL_IF_CONFIG_SMALL("SMPTE VC-1 VDPAU"), - .pix_fmts = (const enum PixelFormat[]){PIX_FMT_VDPAU_VC1, PIX_FMT_NONE}, - .profiles = NULL_IF_CONFIG_SMALL(profiles) + .long_name = NULL_IF_CONFIG_SMALL("SMPTE VC-1 VDPAU"), + .pix_fmts = (const enum PixelFormat[]){PIX_FMT_VDPAU_VC1, PIX_FMT_NONE}, + .profiles = NULL_IF_CONFIG_SMALL(profiles) }; #endif diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vc1dsp.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vc1dsp.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vc1dsp.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vc1dsp.c 2011-11-04 12:38:27.000000000 +0000 @@ -688,6 +688,26 @@ } } +static void put_no_rnd_vc1_chroma_mc4_c(uint8_t *dst, uint8_t *src, int stride, int h, int x, int y){ + const int A=(8-x)*(8-y); + const int B=( x)*(8-y); + const int C=(8-x)*( y); + const int D=( x)*( y); + int i; + + assert(x<8 && y<8 && x>=0 && y>=0); + + for(i=0; i> 6; + dst[1] = (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + 32 - 4) >> 6; + dst[2] = (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + 32 - 4) >> 6; + dst[3] = (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + 32 - 4) >> 6; + dst+= stride; + src+= stride; + } +} + #define avg2(a,b) ((a+b+1)>>1) static void avg_no_rnd_vc1_chroma_mc8_c(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int x, int y){ const int A=(8-x)*(8-y); @@ -829,6 +849,7 @@ dsp->put_no_rnd_vc1_chroma_pixels_tab[0]= put_no_rnd_vc1_chroma_mc8_c; dsp->avg_no_rnd_vc1_chroma_pixels_tab[0]= avg_no_rnd_vc1_chroma_mc8_c; + dsp->put_no_rnd_vc1_chroma_pixels_tab[1] = put_no_rnd_vc1_chroma_mc4_c; #if CONFIG_WMV3IMAGE_DECODER || CONFIG_VC1IMAGE_DECODER dsp->sprite_h = sprite_h_c; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vc1.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vc1.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vc1.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vc1.h 2011-11-04 12:38:27.000000000 +0000 @@ -30,7 +30,7 @@ /** Markers used in VC-1 AP frame data */ //@{ -enum VC1Code{ +enum VC1Code { VC1_CODE_RES0 = 0x00000100, VC1_CODE_ENDOFSEQ = 0x0000010A, VC1_CODE_SLICE, @@ -105,12 +105,25 @@ }; //@} +/** MBMODE for interlaced frame P-picture */ +//@{ +enum MBModesIntfr { + MV_PMODE_INTFR_1MV, + MV_PMODE_INTFR_2MV_FIELD, + MV_PMODE_INTFR_2MV, + MV_PMODE_INTFR_4MV_FIELD, + MV_PMODE_INTFR_4MV, + MV_PMODE_INTFR_INTRA, +}; +//@} + /** @name MV types for B frames */ //@{ enum BMVTypes { BMV_TYPE_BACKWARD, BMV_TYPE_FORWARD, - BMV_TYPE_INTERPOLATED + BMV_TYPE_INTERPOLATED, + BMV_TYPE_DIRECT }; //@} @@ -120,10 +133,10 @@ TT_8X8, TT_8X4_BOTTOM, TT_8X4_TOP, - TT_8X4, //Both halves + TT_8X4, // both halves TT_4X8_RIGHT, TT_4X8_LEFT, - TT_4X8, //Both halves + TT_4X8, // both halves TT_4X4 }; //@} @@ -211,16 +224,16 @@ /** Frame decoding info for all profiles */ //@{ - uint8_t mv_mode; ///< MV coding monde - uint8_t mv_mode2; ///< Secondary MV coding mode (B frames) - int k_x; ///< Number of bits for MVs (depends on MV range) - int k_y; ///< Number of bits for MVs (depends on MV range) - int range_x, range_y; ///< MV range - uint8_t pq, altpq; ///< Current/alternate frame quantizer scale - uint8_t zz_8x8[4][64];///< Zigzag table for TT_8x8, permuted for IDCT + uint8_t mv_mode; ///< MV coding monde + uint8_t mv_mode2; ///< Secondary MV coding mode (B frames) + int k_x; ///< Number of bits for MVs (depends on MV range) + int k_y; ///< Number of bits for MVs (depends on MV range) + int range_x, range_y; ///< MV range + uint8_t pq, altpq; ///< Current/alternate frame quantizer scale + uint8_t zz_8x8[4][64]; ///< Zigzag table for TT_8x8, permuted for IDCT int left_blk_sh, top_blk_sh; ///< Either 3 or 0, positions of l/t in blk[] - const uint8_t* zz_8x4;///< Zigzag scan table for TT_8x4 coding mode - const uint8_t* zz_4x8;///< Zigzag scan table for TT_4x8 coding mode + const uint8_t* zz_8x4; ///< Zigzag scan table for TT_8x4 coding mode + const uint8_t* zz_4x8; ///< Zigzag scan table for TT_4x8 coding mode /** pquant parameters */ //@{ uint8_t dquantfrm; @@ -232,15 +245,15 @@ * @see 8.1.1.10, p(1)10 */ //@{ - int c_ac_table_index; ///< Chroma index from ACFRM element - int y_ac_table_index; ///< Luma index from AC2FRM element + int c_ac_table_index; ///< Chroma index from ACFRM element + int y_ac_table_index; ///< Luma index from AC2FRM element //@} - int ttfrm; ///< Transform type info present at frame level - uint8_t ttmbf; ///< Transform type flag + int ttfrm; ///< Transform type info present at frame level + uint8_t ttmbf; ///< Transform type flag int *ttblk_base, *ttblk; ///< Transform type at the block level - int codingset; ///< index of current table set from 11.8 to use for luma block decoding - int codingset2; ///< index of current table set from 11.8 to use for chroma block decoding - int pqindex; ///< raw pqindex used in coding set selection + int codingset; ///< index of current table set from 11.8 to use for luma block decoding + int codingset2; ///< index of current table set from 11.8 to use for chroma block decoding + int pqindex; ///< raw pqindex used in coding set selection int a_avail, c_avail; uint8_t *mb_type_base, *mb_type[3]; @@ -260,22 +273,24 @@ * -# 2 -> [-512, 511.f] x [-128, 127.f] * -# 3 -> [-1024, 1023.f] x [-256, 255.f] */ - uint8_t mvrange; - uint8_t pquantizer; ///< Uniform (over sequence) quantizer in use - VLC *cbpcy_vlc; ///< CBPCY VLC table - int tt_index; ///< Index for Transform Type tables - uint8_t* mv_type_mb_plane; ///< bitplane for mv_type == (4MV) - uint8_t* direct_mb_plane; ///< bitplane for "direct" MBs - int mv_type_is_raw; ///< mv type mb plane is not coded - int dmb_is_raw; ///< direct mb plane is raw - int skip_is_raw; ///< skip mb plane is not coded - uint8_t luty[256], lutuv[256]; // lookup tables used for intensity compensation - int use_ic; ///< use intensity compensation in B-frames - int rnd; ///< rounding control + uint8_t mvrange; ///< Extended MV range flag + uint8_t pquantizer; ///< Uniform (over sequence) quantizer in use + VLC *cbpcy_vlc; ///< CBPCY VLC table + int tt_index; ///< Index for Transform Type tables (to decode TTMB) + uint8_t* mv_type_mb_plane; ///< bitplane for mv_type == (4MV) + uint8_t* direct_mb_plane; ///< bitplane for "direct" MBs + uint8_t* forward_mb_plane; ///< bitplane for "forward" MBs + int mv_type_is_raw; ///< mv type mb plane is not coded + int dmb_is_raw; ///< direct mb plane is raw + int fmb_is_raw; ///< forward mb plane is raw + int skip_is_raw; ///< skip mb plane is not coded + uint8_t luty[256], lutuv[256]; ///< lookup tables used for intensity compensation + int use_ic; ///< use intensity compensation in B-frames + int rnd; ///< rounding control /** Frame decoding info for S/M profiles only */ //@{ - uint8_t rangeredfrm; ///< out_sample = CLIP((in_sample-128)*2+128) + uint8_t rangeredfrm; ///< out_sample = CLIP((in_sample-128)*2+128) uint8_t interpfrm; //@} @@ -307,6 +322,44 @@ uint8_t range_mapuv; //@} + /** Frame decoding info for interlaced picture */ + uint8_t dmvrange; ///< Extended differential MV range flag + int fourmvswitch; + int intcomp; + uint8_t lumscale2; ///< for interlaced field P picture + uint8_t lumshift2; + uint8_t luty2[256], lutuv2[256]; // lookup tables used for intensity compensation + VLC* mbmode_vlc; + VLC* imv_vlc; + VLC* twomvbp_vlc; + VLC* fourmvbp_vlc; + uint8_t twomvbp; + uint8_t fourmvbp; + uint8_t* fieldtx_plane; + int fieldtx_is_raw; + int8_t zzi_8x8[64]; + uint8_t *blk_mv_type_base, *blk_mv_type; ///< 0: frame MV, 1: field MV (interlaced frame) + uint8_t *mv_f_base, *mv_f[2]; ///< 0: MV obtained from same field, 1: opposite field + uint8_t *mv_f_last_base, *mv_f_last[2]; + uint8_t *mv_f_next_base, *mv_f_next[2]; + int field_mode; ///< 1 for interlaced field pictures + int fptype; + int second_field; + int refdist; ///< distance of the current picture from reference + int numref; ///< number of past field pictures used as reference + // 0 corresponds to 1 and 1 corresponds to 2 references + int reffield; ///< if numref = 0 (1 reference) then reffield decides which + // field to use among the two fields from previous frame + int intcompfield; ///< which of the two fields to be intensity compensated + // 0: both fields, 1: bottom field, 2: top field + int cur_field_type; ///< 0: top, 1: bottom + int ref_field_type[2]; ///< forward and backward reference field type (top or bottom) + int blocks_off, mb_off; + int qs_last; ///< if qpel has been used in the previous (tr.) picture + int bmvtype; + int frfd, brfd; ///< reference frame distance (forward or backward) + int pic_header_flag; + /** Frame decoding info for sprite modes */ //@{ int new_sprite; @@ -325,11 +378,11 @@ uint32_t *cbp_base, *cbp; uint8_t *is_intra_base, *is_intra; int16_t (*luma_mv_base)[2], (*luma_mv)[2]; - uint8_t bfraction_lut_index;///< Index for BFRACTION value (see Table 40, reproduced into ff_vc1_bfraction_lut[]) - uint8_t broken_link; ///< Broken link flag (BROKEN_LINK syntax element) - uint8_t closed_entry; ///< Closed entry point flag (CLOSED_ENTRY syntax element) + uint8_t bfraction_lut_index; ///< Index for BFRACTION value (see Table 40, reproduced into ff_vc1_bfraction_lut[]) + uint8_t broken_link; ///< Broken link flag (BROKEN_LINK syntax element) + uint8_t closed_entry; ///< Closed entry point flag (CLOSED_ENTRY syntax element) - int parse_only; ///< Context is used within parser + int parse_only; ///< Context is used within parser int warn_interlaced; } VC1Context; @@ -341,11 +394,12 @@ { uint32_t mrk = 0xFFFFFFFF; - if(end-src < 4) return end; - while(src < end){ + if (end-src < 4) + return end; + while (src < end) { mrk = (mrk << 8) | *src++; - if(IS_MARKER(mrk)) - return src-4; + if (IS_MARKER(mrk)) + return src - 4; } return end; } @@ -354,12 +408,13 @@ { int dsize = 0, i; - if(size < 4){ - for(dsize = 0; dsize < size; dsize++) *dst++ = *src++; + if (size < 4) { + for (dsize = 0; dsize < size; dsize++) + *dst++ = *src++; return size; } - for(i = 0; i < size; i++, src++) { - if(src[0] == 3 && i >= 2 && !src[-1] && !src[-2] && i < size-1 && src[1] < 4) { + for (i = 0; i < size; i++, src++) { + if (src[0] == 3 && i >= 2 && !src[-1] && !src[-2] && i < size-1 && src[1] < 4) { dst[dsize++] = src[1]; src++; i++; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vc1_parser.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vc1_parser.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vc1_parser.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vc1_parser.c 2011-11-04 12:38:27.000000000 +0000 @@ -185,10 +185,9 @@ } AVCodecParser ff_vc1_parser = { - { CODEC_ID_VC1 }, - sizeof(VC1ParseContext), - NULL, - vc1_parse, - ff_parse1_close, - vc1_split, + .codec_ids = { CODEC_ID_VC1 }, + .priv_data_size = sizeof(VC1ParseContext), + .parser_parse = vc1_parse, + .parser_close = ff_parse1_close, + .split = vc1_split, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vcr1.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vcr1.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vcr1.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vcr1.c 2011-11-04 12:38:27.000000000 +0000 @@ -132,7 +132,7 @@ emms_c(); - align_put_bits(&a->pb); + avpriv_align_put_bits(&a->pb); while(get_bit_count(&a->pb)&31) put_bits(&a->pb, 8, 0); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vda.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vda.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vda.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vda.c 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,271 @@ +/* + * VDA HW acceleration. + * + * copyright (c) 2011 Sebastien Zwickert + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "vda_internal.h" + +/** + * \addtogroup VDA_Decoding + * + * @{ + */ + +/* Mutex manager callback. */ +static int vda_lock_operation(void **mtx, enum AVLockOp op) +{ + switch(op) + { + case AV_LOCK_CREATE: + *mtx = av_malloc(sizeof(pthread_mutex_t)); + if(!*mtx) + return 1; + return !!pthread_mutex_init(*mtx, NULL); + case AV_LOCK_OBTAIN: + return !!pthread_mutex_lock(*mtx); + case AV_LOCK_RELEASE: + return !!pthread_mutex_unlock(*mtx); + case AV_LOCK_DESTROY: + pthread_mutex_destroy(*mtx); + av_freep(mtx); + return 0; + } + return 1; +} + +/* Helper to create a dictionary according to the given pts. */ +static CFDictionaryRef vda_dictionary_with_pts(int64_t i_pts) +{ + CFStringRef key = CFSTR("FF_VDA_DECODER_PTS_KEY"); + CFNumberRef value = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &i_pts); + CFDictionaryRef user_info = CFDictionaryCreate( kCFAllocatorDefault, + (const void **)&key, + (const void **)&value, + 1, + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks); + CFRelease(value); + return user_info; +} + +/* Helper to retrieve the pts from the given dictionary. */ +static int64_t vda_pts_from_dictionary(CFDictionaryRef user_info) +{ + CFNumberRef pts; + int64_t outValue = 0; + + if (NULL == user_info) + return 0; + + pts = CFDictionaryGetValue(user_info, CFSTR("FF_VDA_DECODER_PTS_KEY")); + + if (pts) + CFNumberGetValue(pts, kCFNumberSInt64Type, &outValue); + + return outValue; +} + +/* Removes and releases all frames from the queue. */ +static void vda_clear_queue(struct vda_context *vda_ctx) +{ + vda_frame *top_frame; + + vda_lock_operation(&vda_ctx->queue_mutex, AV_LOCK_OBTAIN); + + while (vda_ctx->queue != NULL) + { + top_frame = vda_ctx->queue; + vda_ctx->queue = top_frame->next_frame; + ff_vda_release_vda_frame(top_frame); + } + + vda_lock_operation(&vda_ctx->queue_mutex, AV_LOCK_RELEASE); +} + + +/* Decoder callback that adds the vda frame to the queue in display order. */ +static void vda_decoder_callback (void *vda_hw_ctx, + CFDictionaryRef user_info, + OSStatus status, + uint32_t infoFlags, + CVImageBufferRef image_buffer) +{ + struct vda_context *vda_ctx = (struct vda_context*)vda_hw_ctx; + vda_frame *new_frame; + vda_frame *queue_walker; + + if (NULL == image_buffer) + return; + + if (kCVPixelFormatType_422YpCbCr8 != CVPixelBufferGetPixelFormatType(image_buffer)) + return; + + new_frame = (vda_frame *)av_mallocz(sizeof(vda_frame)); + new_frame->next_frame = NULL; + new_frame->cv_buffer = CVPixelBufferRetain(image_buffer); + new_frame->pts = vda_pts_from_dictionary(user_info); + + vda_lock_operation(&vda_ctx->queue_mutex, AV_LOCK_OBTAIN); + + queue_walker = vda_ctx->queue; + + if (!queue_walker || (new_frame->pts < queue_walker->pts)) + { + /* we have an empty queue, or this frame earlier than the current queue head */ + new_frame->next_frame = queue_walker; + vda_ctx->queue = new_frame; + } + else + { + /* walk the queue and insert this frame where it belongs in display order */ + vda_frame *next_frame; + + while (1) + { + next_frame = queue_walker->next_frame; + + if (!next_frame || (new_frame->pts < next_frame->pts)) + { + new_frame->next_frame = next_frame; + queue_walker->next_frame = new_frame; + break; + } + queue_walker = next_frame; + } + } + + vda_lock_operation(&vda_ctx->queue_mutex, AV_LOCK_RELEASE); +} + +int ff_vda_create_decoder(struct vda_context *vda_ctx, + uint8_t *extradata, + int extradata_size) +{ + OSStatus status = kVDADecoderNoErr; + CFNumberRef height; + CFNumberRef width; + CFNumberRef format; + CFDataRef avc_data; + CFMutableDictionaryRef config_info; + + if (av_lockmgr_register(vda_lock_operation)) + return -1; + + vda_lock_operation(&vda_ctx->queue_mutex, AV_LOCK_CREATE); + + config_info = (CFDictionaryCreateMutable(kCFAllocatorDefault, + 4, + &kCFTypeDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks)); + + height = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vda_ctx->height); + width = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vda_ctx->width); + format = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &vda_ctx->format); + avc_data = CFDataCreate(kCFAllocatorDefault, extradata, extradata_size); + + CFDictionarySetValue(config_info, kVDADecoderConfiguration_Height, height); + CFDictionarySetValue(config_info, kVDADecoderConfiguration_Width, width); + CFDictionarySetValue(config_info, kVDADecoderConfiguration_SourceFormat, format); + CFDictionarySetValue(config_info, kVDADecoderConfiguration_avcCData, avc_data); + + status = VDADecoderCreate( config_info, + NULL, + (VDADecoderOutputCallback *)vda_decoder_callback, + (void *)vda_ctx, + &vda_ctx->decoder ); + + CFRelease(height); + CFRelease(width); + CFRelease(format); + CFRelease(avc_data); + CFRelease(config_info); + + if (kVDADecoderNoErr != status) + return status; + + return 0; +} + +int ff_vda_destroy_decoder(struct vda_context *vda_ctx) +{ + OSStatus status = kVDADecoderNoErr; + + if (vda_ctx->decoder) + status = VDADecoderDestroy(vda_ctx->decoder); + + vda_clear_queue(vda_ctx); + + if (vda_ctx->queue_mutex != NULL) + vda_lock_operation(&vda_ctx->queue_mutex, AV_LOCK_DESTROY); + + if (kVDADecoderNoErr != status) + return status; + + return 0; +} + +vda_frame *ff_vda_queue_pop(struct vda_context *vda_ctx) +{ + vda_frame *top_frame; + + if (!vda_ctx->queue) + return NULL; + + vda_lock_operation(&vda_ctx->queue_mutex, AV_LOCK_OBTAIN); + top_frame = vda_ctx->queue; + vda_ctx->queue = top_frame->next_frame; + vda_lock_operation(&vda_ctx->queue_mutex, AV_LOCK_RELEASE); + + return top_frame; +} + +void ff_vda_release_vda_frame(vda_frame *frame) +{ + if (frame != NULL) + { + CVPixelBufferRelease(frame->cv_buffer); + av_freep(&frame); + } +} + +int ff_vda_decoder_decode(struct vda_context *vda_ctx, + uint8_t *bitstream, + int bitstream_size, + int64_t frame_pts) +{ + OSStatus status = kVDADecoderNoErr; + CFDictionaryRef user_info; + CFDataRef coded_frame; + + coded_frame = CFDataCreate(kCFAllocatorDefault, bitstream, bitstream_size); + user_info = vda_dictionary_with_pts(frame_pts); + + status = VDADecoderDecode(vda_ctx->decoder, 0, coded_frame, user_info); + + CFRelease(user_info); + CFRelease(coded_frame); + + if (kVDADecoderNoErr != status) + return status; + + return 0; +} + +/* @} */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vda.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vda.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vda.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vda.h 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,140 @@ +/* + * VDA HW acceleration + * + * copyright (c) 2011 Sebastien Zwickert + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_VDA_H +#define AVCODEC_VDA_H + +#include + +// emmintrin.h is unable to compile with -std=c99 -Werror=missing-prototypes +// http://openradar.appspot.com/8026390 +#undef __GNUC_STDC_INLINE__ + +#define Picture QuickdrawPicture + +#include +#include "avcodec.h" +#include + +/** + * This structure is used to store a decoded frame information and data. + */ +typedef struct +{ + /** + * The PTS of the frame. + * + * - encoding: unused + * - decoding: Set/Unset by libavcodec. + */ + int64_t pts; + + /** + * The CoreVideo buffer that contains the decoded data. + * + * - encoding: unused + * - decoding: Set/Unset by libavcodec. + */ + CVPixelBufferRef cv_buffer; + + /** + * A pointer to the next frame. + * + * - encoding: unused + * - decoding: Set/Unset by libavcodec. + */ + struct vda_frame *next_frame; + +} vda_frame; + +/** + * This structure is used to provide the necessary configurations and data + * to the VDA FFmpeg HWAccel implementation. + * + * The application must make it available as AVCodecContext.hwaccel_context. + */ +struct vda_context { + + /** + * VDA decoder object. + * + * - encoding: unused + * - decoding: Set/Unset by libavcodec. + */ + VDADecoder decoder; + + /** + * VDA frames queue ordered by presentation timestamp. + * + * - encoding: unused + * - decoding: Set/Unset by libavcodec. + */ + vda_frame *queue; + + /** + * Mutex for locking queue operations. + * + * - encoding: unused + * - decoding: Set/Unset by libavcodec. + */ + void *queue_mutex; + + /** + * The frame width. + * + * - encoding: unused + * - decoding: Set/Unset by user. + */ + int width; + + /** + * The frame height. + * + * - encoding: unused + * - decoding: Set/Unset by user. + */ + int height; + + /** + * The frame format. + * + * - encoding: unused + * - decoding: Set/Unset by user. + */ + int format; +}; + +/** Creates the video decoder. */ +int ff_vda_create_decoder(struct vda_context *vda_ctx, + uint8_t *extradata, + int extradata_size); + +/** Destroys the video decoder. */ +int ff_vda_destroy_decoder(struct vda_context *vda_ctx); + +/** Returns the top frame of the queue. */ +vda_frame *ff_vda_queue_pop(struct vda_context *vda_ctx); + +/** Releases the given frame. */ +void ff_vda_release_vda_frame(vda_frame *frame); + +#endif /* AVCODEC_VDA_H */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vda_h264.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vda_h264.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vda_h264.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vda_h264.c 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,107 @@ +/* + * VDA H264 HW acceleration. + * + * copyright (c) 2011 Sebastien Zwickert + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "vda_internal.h" + +/* This structure is used to store the bitstream of the current frame. */ +struct vda_picture_context { + uint8_t *bitstream; + int bitstream_size; +}; + +static int start_frame(AVCodecContext *avctx, + av_unused const uint8_t *buffer, + av_unused uint32_t size) +{ + const H264Context *h = avctx->priv_data; + struct vda_context *vda_ctx = avctx->hwaccel_context; + struct vda_picture_context *pic_ctx = h->s.current_picture_ptr->f.hwaccel_picture_private; + + if (!vda_ctx->decoder) + return -1; + + pic_ctx->bitstream = NULL; + pic_ctx->bitstream_size = 0; + + return 0; +} + +static int decode_slice(AVCodecContext *avctx, + const uint8_t *buffer, + uint32_t size) +{ + H264Context *h = avctx->priv_data; + struct vda_context *vda_ctx = avctx->hwaccel_context; + struct vda_picture_context *pic_ctx = h->s.current_picture_ptr->f.hwaccel_picture_private; + void *tmp; + + if (!vda_ctx->decoder) + return -1; + + tmp = av_realloc(pic_ctx->bitstream, pic_ctx->bitstream_size+size+4); + if (!tmp) + return AVERROR(ENOMEM); + + pic_ctx->bitstream = tmp; + + AV_WB32(pic_ctx->bitstream+pic_ctx->bitstream_size, size); + memcpy(pic_ctx->bitstream+pic_ctx->bitstream_size+4, buffer, size); + + pic_ctx->bitstream_size += size + 4; + + return 0; +} + +static int end_frame(AVCodecContext *avctx) +{ + H264Context *h = avctx->priv_data; + struct vda_context *vda_ctx = avctx->hwaccel_context; + struct vda_picture_context *pic_ctx = h->s.current_picture_ptr->f.hwaccel_picture_private; + AVFrame *frame = (AVFrame*)h->s.current_picture_ptr; + int status; + + if (!vda_ctx->decoder || !pic_ctx->bitstream) + return -1; + + status = ff_vda_decoder_decode(vda_ctx, pic_ctx->bitstream, + pic_ctx->bitstream_size, + frame->reordered_opaque); + + if (status) + av_log(avctx, AV_LOG_ERROR, "Failed to decode frame (%d)\n", status); + + av_freep(&pic_ctx->bitstream); + + return status; +} + +AVHWAccel ff_h264_vda_hwaccel = { + .name = "h264_vda", + .type = AVMEDIA_TYPE_VIDEO, + .id = CODEC_ID_H264, + .pix_fmt = PIX_FMT_VDA_VLD, + .capabilities = 0, + .start_frame = start_frame, + .decode_slice = decode_slice, + .end_frame = end_frame, + .priv_data_size = sizeof(struct vda_picture_context), +}; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vda_internal.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vda_internal.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vda_internal.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vda_internal.h 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,50 @@ +/* + * VDA HW acceleration + * + * copyright (c) 2011 Sebastien Zwickert + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_VDA_INTERNAL_H +#define AVCODEC_VDA_INTERNAL_H + +#include "h264.h" +#include "h264data.h" + +#include "vda.h" + +#include +#include +#include +#include + +/** + * \addtogroup VDA_Decoding + * + * @{ + */ + +/** Send a frame data to the hardware decoder. */ +int ff_vda_decoder_decode(struct vda_context *vda_ctx, + uint8_t *bitstream, + int bitstream_size, + int64_t frame_pts); + +/* @} */ + +#endif /* AVCODEC_VDA_INTERNAL_H */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/version.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/version.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/version.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/version.h 2011-11-04 12:38:27.000000000 +0000 @@ -21,8 +21,8 @@ #define AVCODEC_VERSION_H #define LIBAVCODEC_VERSION_MAJOR 53 -#define LIBAVCODEC_VERSION_MINOR 19 -#define LIBAVCODEC_VERSION_MICRO 1 +#define LIBAVCODEC_VERSION_MINOR 27 +#define LIBAVCODEC_VERSION_MICRO 0 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \ @@ -77,8 +77,8 @@ #ifndef FF_API_DRC_SCALE #define FF_API_DRC_SCALE (LIBAVCODEC_VERSION_MAJOR < 54) #endif -#ifndef FF_API_VERY_AGGRESSIVE -#define FF_API_VERY_AGGRESSIVE (LIBAVCODEC_VERSION_MAJOR < 54) +#ifndef FF_API_ER +#define FF_API_ER (LIBAVCODEC_VERSION_MAJOR < 54) #endif #ifndef FF_API_AVCODEC_INIT #define FF_API_AVCODEC_INIT (LIBAVCODEC_VERSION_MAJOR < 54) @@ -98,5 +98,11 @@ #ifndef FF_API_MJPEG_GLOBAL_OPTS #define FF_API_MJPEG_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54) #endif +#ifndef FF_API_GET_ALPHA_INFO +#define FF_API_GET_ALPHA_INFO (LIBAVCODEC_VERSION_MAJOR < 54) +#endif +#ifndef FF_API_PARSE_FRAME +#define FF_API_PARSE_FRAME (LIBAVCODEC_VERSION_MAJOR < 54) +#endif #endif /* AVCODEC_VERSION_H */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vorbisdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vorbisdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vorbisdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vorbisdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -966,7 +966,7 @@ static av_cold int vorbis_decode_init(AVCodecContext *avccontext) { - vorbis_context *vc = avccontext->priv_data ; + vorbis_context *vc = avccontext->priv_data; uint8_t *headers = avccontext->extradata; int headers_len = avccontext->extradata_size; uint8_t *header_start[3]; @@ -991,7 +991,7 @@ return -1; } - if (ff_split_xiph_headers(headers, headers_len, 30, header_start, header_len) < 0) { + if (avpriv_split_xiph_headers(headers, headers_len, 30, header_start, header_len) < 0) { av_log(avccontext, AV_LOG_ERROR, "Extradata corrupt.\n"); return -1; } @@ -1030,7 +1030,7 @@ avccontext->sample_rate = vc->audio_samplerate; avccontext->frame_size = FFMIN(vc->blocksize[0], vc->blocksize[1]) >> 2; - return 0 ; + return 0; } // Decode audiopackets ------------------------------------------------- @@ -1608,10 +1608,10 @@ { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; - vorbis_context *vc = avccontext->priv_data ; + vorbis_context *vc = avccontext->priv_data; GetBitContext *gb = &(vc->gb); const float *channel_ptrs[255]; - int i, len; + int i, len, out_size; if (!buf_size) return 0; @@ -1630,12 +1630,19 @@ if (!vc->first_frame) { vc->first_frame = 1; *data_size = 0; - return buf_size ; + return buf_size; } av_dlog(NULL, "parsed %d bytes %d bits, returned %d samples (*ch*bits) \n", get_bits_count(gb) / 8, get_bits_count(gb) % 8, len); + out_size = len * vc->audio_channels * + av_get_bytes_per_sample(avccontext->sample_fmt); + if (*data_size < out_size) { + av_log(avccontext, AV_LOG_ERROR, "output buffer is too small\n"); + return AVERROR(EINVAL); + } + if (vc->audio_channels > 8) { for (i = 0; i < vc->audio_channels; i++) channel_ptrs[i] = vc->channel_floors + i * len; @@ -1651,10 +1658,9 @@ vc->fmt_conv.float_to_int16_interleave(data, channel_ptrs, len, vc->audio_channels); - *data_size = len * vc->audio_channels * - av_get_bytes_per_sample(avccontext->sample_fmt); + *data_size = out_size; - return buf_size ; + return buf_size; } // Close decoder @@ -1665,7 +1671,7 @@ vorbis_free(vc); - return 0 ; + return 0; } AVCodec ff_vorbis_decoder = { diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vorbis_enc_data.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vorbis_enc_data.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vorbis_enc_data.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vorbis_enc_data.h 2011-11-04 12:38:27.000000000 +0000 @@ -492,13 +492,13 @@ int dim; int subclass; int masterbook; - const int *nbooks; + const int nbooks[4]; } floor_classes[] = { - { 3, 0, 0, (const int[]){ 4 } }, - { 4, 1, 0, (const int[]){ 5, 6 } }, - { 3, 1, 1, (const int[]){ 7, 8 } }, - { 4, 2, 2, (const int[]){ -1, 9, 10, 11 } }, - { 3, 2, 3, (const int[]){ -1, 12, 13, 14 } }, + { 3, 0, 0, { 4 } }, + { 4, 1, 0, { 5, 6 } }, + { 3, 1, 1, { 7, 8 } }, + { 4, 2, 2, { -1, 9, 10, 11 } }, + { 3, 2, 3, { -1, 12, 13, 14 } }, }; #endif /* AVCODEC_VORBIS_ENC_DATA_H */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vp3.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vp3.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vp3.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vp3.c 2011-11-04 12:38:27.000000000 +0000 @@ -45,6 +45,7 @@ #define FRAGMENT_PIXELS 8 static av_cold int vp3_decode_end(AVCodecContext *avctx); +static void vp3_decode_flush(AVCodecContext *avctx); //FIXME split things out into their own arrays typedef struct Vp3Fragment { @@ -890,7 +891,7 @@ /* decode a VLC into a token */ token = get_vlc2(gb, vlc_table, 11, 3); /* use the token to get a zero run, a coefficient, and an eob run */ - if (token <= 6) { + if ((unsigned) token <= 6U) { eob_run = eob_run_base[token]; if (eob_run_get_bits[token]) eob_run += get_bits(gb, eob_run_get_bits[token]); @@ -908,7 +909,7 @@ coeff_i += eob_run; eob_run = 0; } - } else { + } else if (token >= 0) { bits_to_get = coeff_get_bits[token]; if (bits_to_get) bits_to_get = get_bits(gb, bits_to_get); @@ -942,6 +943,10 @@ for (i = coeff_index+1; i <= coeff_index+zero_run; i++) s->num_coded_frags[plane][i]--; coeff_i++; + } else { + av_log(s->avctx, AV_LOG_ERROR, + "Invalid token %d\n", token); + return -1; } } @@ -991,6 +996,8 @@ /* unpack the Y plane DC coefficients */ residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_y_table], 0, 0, residual_eob_run); + if (residual_eob_run < 0) + return residual_eob_run; /* reverse prediction of the Y-plane DC coefficients */ reverse_dc_prediction(s, 0, s->fragment_width[0], s->fragment_height[0]); @@ -998,8 +1005,12 @@ /* unpack the C plane DC coefficients */ residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0, 1, residual_eob_run); + if (residual_eob_run < 0) + return residual_eob_run; residual_eob_run = unpack_vlcs(s, gb, &s->dc_vlc[dc_c_table], 0, 2, residual_eob_run); + if (residual_eob_run < 0) + return residual_eob_run; /* reverse prediction of the C-plane DC coefficients */ if (!(s->avctx->flags & CODEC_FLAG_GRAY)) @@ -1036,11 +1047,17 @@ for (i = 1; i <= 63; i++) { residual_eob_run = unpack_vlcs(s, gb, y_tables[i], i, 0, residual_eob_run); + if (residual_eob_run < 0) + return residual_eob_run; residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i, 1, residual_eob_run); + if (residual_eob_run < 0) + return residual_eob_run; residual_eob_run = unpack_vlcs(s, gb, c_tables[i], i, 2, residual_eob_run); + if (residual_eob_run < 0) + return residual_eob_run; } return 0; @@ -1316,7 +1333,7 @@ int h, cy; int offset[4]; - if (HAVE_PTHREADS && s->avctx->active_thread_type&FF_THREAD_FRAME) { + if (HAVE_THREADS && s->avctx->active_thread_type&FF_THREAD_FRAME) { int y_flipped = s->flipped_image ? s->avctx->height-y : y; // At the end of the frame, report INT_MAX instead of the height of the frame. @@ -1400,7 +1417,7 @@ int fragment_width = s->fragment_width[!!plane]; int fragment_height = s->fragment_height[!!plane]; int fragment_start = s->fragment_start[plane]; - int do_await = !plane && HAVE_PTHREADS && (s->avctx->active_thread_type&FF_THREAD_FRAME); + int do_await = !plane && HAVE_THREADS && (s->avctx->active_thread_type&FF_THREAD_FRAME); if (!s->flipped_image) stride = -stride; if (CONFIG_GRAY && plane && (s->avctx->flags & CODEC_FLAG_GRAY)) @@ -1571,9 +1588,6 @@ return 0; } -/* - * This is the ffmpeg/libavcodec API init function. - */ static av_cold int vp3_decode_init(AVCodecContext *avctx) { Vp3DecodeContext *s = avctx->priv_data; @@ -1777,10 +1791,15 @@ Vp3DecodeContext *s = dst->priv_data, *s1 = src->priv_data; int qps_changed = 0, i, err; +#define copy_fields(to, from, start_field, end_field) memcpy(&to->start_field, &from->start_field, (char*)&to->end_field - (char*)&to->start_field) + if (!s1->current_frame.data[0] ||s->width != s1->width - ||s->height!= s1->height) + ||s->height!= s1->height) { + if (s != s1) + copy_fields(s, s1, golden_frame, current_frame); return -1; + } if (s != s1) { // init tables if the first frame hasn't been decoded @@ -1796,8 +1815,6 @@ memcpy(s->motion_val[1], s1->motion_val[1], c_fragment_count * sizeof(*s->motion_val[1])); } -#define copy_fields(to, from, start_field, end_field) memcpy(&to->start_field, &from->start_field, (char*)&to->end_field - (char*)&to->start_field) - // copy previous frame data copy_fields(s, s1, golden_frame, dsp); @@ -1822,9 +1839,6 @@ return 0; } -/* - * This is the ffmpeg/libavcodec API frame decode function. - */ static int vp3_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) @@ -1966,7 +1980,7 @@ *data_size=sizeof(AVFrame); *(AVFrame*)data= s->current_frame; - if (!HAVE_PTHREADS || !(s->avctx->active_thread_type&FF_THREAD_FRAME)) + if (!HAVE_THREADS || !(s->avctx->active_thread_type&FF_THREAD_FRAME)) update_frames(avctx); return buf_size; @@ -1974,23 +1988,19 @@ error: ff_thread_report_progress(&s->current_frame, INT_MAX, 0); - if (!HAVE_PTHREADS || !(s->avctx->active_thread_type&FF_THREAD_FRAME)) + if (!HAVE_THREADS || !(s->avctx->active_thread_type&FF_THREAD_FRAME)) avctx->release_buffer(avctx, &s->current_frame); return -1; } -/* - * This is the ffmpeg/libavcodec API module cleanup function. - */ +static void vp3_decode_flush(AVCodecContext *avctx); + static av_cold int vp3_decode_end(AVCodecContext *avctx) { Vp3DecodeContext *s = avctx->priv_data; int i; - if (avctx->is_copy && !s->current_frame.data[0]) - return 0; - av_free(s->superblock_coding); av_free(s->all_fragments); av_free(s->coded_fragment_list[0]); @@ -2017,12 +2027,7 @@ free_vlc(&s->motion_vector_vlc); /* release all frames */ - if (s->golden_frame.data[0]) - ff_thread_release_buffer(avctx, &s->golden_frame); - if (s->last_frame.data[0] && s->last_frame.type != FF_BUFFER_TYPE_COPY) - ff_thread_release_buffer(avctx, &s->last_frame); - /* no need to release the current_frame since it will always be pointing - * to the same frame as either the golden or last frame */ + vp3_decode_flush(avctx); return 0; } @@ -2276,7 +2281,7 @@ return -1; } - if (ff_split_xiph_headers(avctx->extradata, avctx->extradata_size, + if (avpriv_split_xiph_headers(avctx->extradata, avctx->extradata_size, 42, header_start, header_len) < 0) { av_log(avctx, AV_LOG_ERROR, "Corrupt extradata\n"); return -1; @@ -2342,6 +2347,23 @@ ff_thread_release_buffer(avctx, &s->current_frame); } +static int vp3_init_thread_copy(AVCodecContext *avctx) +{ + Vp3DecodeContext *s = avctx->priv_data; + + s->superblock_coding = NULL; + s->all_fragments = NULL; + s->coded_fragment_list[0] = NULL; + s->dct_tokens_base = NULL; + s->superblock_fragments = NULL; + s->macroblock_coding = NULL; + s->motion_val[0] = NULL; + s->motion_val[1] = NULL; + s->edge_emu_buffer = NULL; + + return 0; +} + AVCodec ff_theora_decoder = { .name = "theora", .type = AVMEDIA_TYPE_VIDEO, @@ -2353,6 +2375,7 @@ .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS, .flush = vp3_decode_flush, .long_name = NULL_IF_CONFIG_SMALL("Theora"), + .init_thread_copy = ONLY_IF_THREADS_ENABLED(vp3_init_thread_copy), .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context) }; #endif @@ -2368,5 +2391,6 @@ .capabilities = CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_FRAME_THREADS, .flush = vp3_decode_flush, .long_name = NULL_IF_CONFIG_SMALL("On2 VP3"), + .init_thread_copy = ONLY_IF_THREADS_ENABLED(vp3_init_thread_copy), .update_thread_context = ONLY_IF_THREADS_ENABLED(vp3_update_thread_context) }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vp3_parser.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vp3_parser.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vp3_parser.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vp3_parser.c 2011-11-04 12:38:27.000000000 +0000 @@ -36,9 +36,7 @@ } AVCodecParser ff_vp3_parser = { - { CODEC_ID_THEORA, CODEC_ID_VP3, - CODEC_ID_VP6, CODEC_ID_VP6F, CODEC_ID_VP6A }, - 0, - NULL, - parse, + .codec_ids = { CODEC_ID_THEORA, CODEC_ID_VP3, CODEC_ID_VP6, + CODEC_ID_VP6F, CODEC_ID_VP6A }, + .parser_parse = parse, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vp56.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vp56.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vp56.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vp56.h 2011-11-04 12:38:27.000000000 +0000 @@ -334,15 +334,13 @@ return -tree->val; } -/** - * This is identical to vp8_rac_get_tree except for the possibility of starting - * on a node other than the root node, needed for coeff decode where this is - * used to save a bit after a 0 token (by disallowing EOB to immediately follow.) - */ -static av_always_inline -int vp8_rac_get_tree_with_offset(VP56RangeCoder *c, const int8_t (*tree)[2], - const uint8_t *probs, int i) +// how probabilities are associated with decisions is different I think +// well, the new scheme fits in the old but this way has one fewer branches per decision +static av_always_inline int vp8_rac_get_tree(VP56RangeCoder *c, const int8_t (*tree)[2], + const uint8_t *probs) { + int i = 0; + do { i = tree[i][vp56_rac_get_prob(c, probs[i])]; } while (i > 0); @@ -350,15 +348,6 @@ return -i; } -// how probabilities are associated with decisions is different I think -// well, the new scheme fits in the old but this way has one fewer branches per decision -static av_always_inline -int vp8_rac_get_tree(VP56RangeCoder *c, const int8_t (*tree)[2], - const uint8_t *probs) -{ - return vp8_rac_get_tree_with_offset(c, tree, probs, 0); -} - // DCTextra static av_always_inline int vp8_rac_get_coeff(VP56RangeCoder *c, const uint8_t *prob) { diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vp6.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vp6.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vp6.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vp6.c 2011-11-04 12:38:27.000000000 +0000 @@ -376,7 +376,7 @@ if (b > 3) pt = 1; vlc_coeff = &s->dccv_vlc[pt]; - for (coeff_idx=0; coeff_idx<64; ) { + for (coeff_idx = 0;;) { int run = 1; if (coeff_idx<2 && s->nb_null[coeff_idx][pt]) { s->nb_null[coeff_idx][pt]--; @@ -413,6 +413,8 @@ } } coeff_idx+=run; + if (coeff_idx >= 64) + break; cg = FFMIN(vp6_coeff_groups[coeff_idx], 3); vlc_coeff = &s->ract_vlc[pt][ct][cg]; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vp8.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vp8.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vp8.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vp8.c 2011-11-04 12:38:27.000000000 +0000 @@ -33,7 +33,57 @@ # include "arm/vp8.h" #endif -static void vp8_decode_flush(AVCodecContext *avctx) +static void free_buffers(VP8Context *s) +{ + av_freep(&s->macroblocks_base); + av_freep(&s->filter_strength); + av_freep(&s->intra4x4_pred_mode_top); + av_freep(&s->top_nnz); + av_freep(&s->edge_emu_buffer); + av_freep(&s->top_border); + + s->macroblocks = NULL; +} + +static int vp8_alloc_frame(VP8Context *s, AVFrame *f) +{ + int ret; + if ((ret = ff_thread_get_buffer(s->avctx, f)) < 0) + return ret; + if (s->num_maps_to_be_freed) { + assert(!s->maps_are_invalid); + f->ref_index[0] = s->segmentation_maps[--s->num_maps_to_be_freed]; + } else if (!(f->ref_index[0] = av_mallocz(s->mb_width * s->mb_height))) { + ff_thread_release_buffer(s->avctx, f); + return AVERROR(ENOMEM); + } + return 0; +} + +static void vp8_release_frame(VP8Context *s, AVFrame *f, int prefer_delayed_free, int can_direct_free) +{ + if (f->ref_index[0]) { + if (prefer_delayed_free) { + /* Upon a size change, we want to free the maps but other threads may still + * be using them, so queue them. Upon a seek, all threads are inactive so + * we want to cache one to prevent re-allocation in the next decoding + * iteration, but the rest we can free directly. */ + int max_queued_maps = can_direct_free ? 1 : FF_ARRAY_ELEMS(s->segmentation_maps); + if (s->num_maps_to_be_freed < max_queued_maps) { + s->segmentation_maps[s->num_maps_to_be_freed++] = f->ref_index[0]; + } else if (can_direct_free) /* vp8_decode_flush(), but our queue is full */ { + av_free(f->ref_index[0]); + } /* else: MEMLEAK (should never happen, but better that than crash) */ + f->ref_index[0] = NULL; + } else /* vp8_decode_free() */ { + av_free(f->ref_index[0]); + } + } + ff_thread_release_buffer(s->avctx, f); +} + +static void vp8_decode_flush_impl(AVCodecContext *avctx, + int prefer_delayed_free, int can_direct_free, int free_mem) { VP8Context *s = avctx->priv_data; int i; @@ -41,19 +91,19 @@ if (!avctx->is_copy) { for (i = 0; i < 5; i++) if (s->frames[i].data[0]) - ff_thread_release_buffer(avctx, &s->frames[i]); + vp8_release_frame(s, &s->frames[i], prefer_delayed_free, can_direct_free); } memset(s->framep, 0, sizeof(s->framep)); - av_freep(&s->macroblocks_base); - av_freep(&s->filter_strength); - av_freep(&s->intra4x4_pred_mode_top); - av_freep(&s->top_nnz); - av_freep(&s->edge_emu_buffer); - av_freep(&s->top_border); - av_freep(&s->segmentation_map); + if (free_mem) { + free_buffers(s); + s->maps_are_invalid = 1; + } +} - s->macroblocks = NULL; +static void vp8_decode_flush(AVCodecContext *avctx) +{ + vp8_decode_flush_impl(avctx, 1, 1, 0); } static int update_dimensions(VP8Context *s, int width, int height) @@ -63,7 +113,7 @@ if (av_image_check_size(width, height, 0, s->avctx)) return AVERROR_INVALIDDATA; - vp8_decode_flush(s->avctx); + vp8_decode_flush_impl(s->avctx, 1, 0, 1); avcodec_set_dimensions(s->avctx, width, height); } @@ -76,10 +126,9 @@ s->intra4x4_pred_mode_top = av_mallocz(s->mb_width*4); s->top_nnz = av_mallocz(s->mb_width*sizeof(*s->top_nnz)); s->top_border = av_mallocz((s->mb_width+1)*sizeof(*s->top_border)); - s->segmentation_map = av_mallocz(s->mb_width*s->mb_height); if (!s->macroblocks_base || !s->filter_strength || !s->intra4x4_pred_mode_top || - !s->top_nnz || !s->top_border || !s->segmentation_map) + !s->top_nnz || !s->top_border) return AVERROR(ENOMEM); s->macroblocks = s->macroblocks_base + 1; @@ -273,7 +322,7 @@ if (!s->macroblocks_base || /* first frame */ width != s->avctx->width || height != s->avctx->height) { - if ((ret = update_dimensions(s, width, height) < 0)) + if ((ret = update_dimensions(s, width, height)) < 0) return ret; } @@ -487,6 +536,7 @@ AV_ZERO32(&near_mv[0]); AV_ZERO32(&near_mv[1]); + AV_ZERO32(&near_mv[2]); /* Process MB on top, left and top-left */ #define MV_EDGE_CHECK(n)\ @@ -589,9 +639,10 @@ { VP56RangeCoder *c = &s->c; - if (s->segmentation.update_map) - *segment = vp8_rac_get_tree(c, vp8_segmentid_tree, s->prob->segmentid); - else + if (s->segmentation.update_map) { + int bit = vp56_rac_get_prob(c, s->prob->segmentid[0]); + *segment = vp56_rac_get_prob(c, s->prob->segmentid[1+bit]) + 2*bit; + } else *segment = ref ? *ref : *segment; s->segment = *segment; @@ -919,7 +970,8 @@ int mb_x, int mb_y) { AVCodecContext *avctx = s->avctx; - int x, y, mode, nnz, tr; + int x, y, mode, nnz; + uint32_t tr; // for the first row, we need to run xchg_mb_border to init the top edge to 127 // otherwise, skip it if we aren't going to deblock @@ -948,7 +1000,7 @@ // from the top macroblock if (!(!mb_y && avctx->flags & CODEC_FLAG_EMU_EDGE) && mb_x == s->mb_width-1) { - tr = tr_right[-1]*0x01010101; + tr = tr_right[-1]*0x01010101u; tr_right = (uint8_t *)&tr; } @@ -1501,6 +1553,14 @@ } } +static void release_queued_segmaps(VP8Context *s, int is_close) +{ + int leave_behind = is_close ? 0 : !s->maps_are_invalid; + while (s->num_maps_to_be_freed > leave_behind) + av_freep(&s->segmentation_maps[--s->num_maps_to_be_freed]); + s->maps_are_invalid = 0; +} + static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { @@ -1509,6 +1569,8 @@ enum AVDiscard skip_thresh; AVFrame *av_uninit(curframe), *prev_frame = s->framep[VP56_FRAME_CURRENT]; + release_queued_segmaps(s, 0); + if ((ret = decode_frame_header(s, avpkt->data, avpkt->size)) < 0) return ret; @@ -1531,7 +1593,7 @@ &s->frames[i] != s->framep[VP56_FRAME_PREVIOUS] && &s->frames[i] != s->framep[VP56_FRAME_GOLDEN] && &s->frames[i] != s->framep[VP56_FRAME_GOLDEN2]) - ff_thread_release_buffer(avctx, &s->frames[i]); + vp8_release_frame(s, &s->frames[i], 1, 0); // find a free buffer for (i = 0; i < 5; i++) @@ -1547,13 +1609,12 @@ abort(); } if (curframe->data[0]) - ff_thread_release_buffer(avctx, curframe); + vp8_release_frame(s, curframe, 1, 0); curframe->key_frame = s->keyframe; curframe->pict_type = s->keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P; curframe->reference = referenced ? 3 : 0; - curframe->ref_index[0] = s->segmentation_map; - if ((ret = ff_thread_get_buffer(avctx, curframe))) { + if ((ret = vp8_alloc_frame(s, curframe))) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed!\n"); return ret; } @@ -1645,8 +1706,8 @@ s->dsp.prefetch(dst[0] + (mb_x&3)*4*s->linesize + 64, s->linesize, 4); s->dsp.prefetch(dst[1] + (mb_x&7)*s->uvlinesize + 64, dst[2] - dst[1], 2); - decode_mb_mode(s, mb, mb_x, mb_y, s->segmentation_map + mb_xy, - prev_frame ? prev_frame->ref_index[0] + mb_xy : NULL); + decode_mb_mode(s, mb, mb_x, mb_y, curframe->ref_index[0] + mb_xy, + prev_frame && prev_frame->ref_index[0] ? prev_frame->ref_index[0] + mb_xy : NULL); prefetch_motion(s, mb, mb_x, mb_y, mb_xy, VP56_FRAME_PREVIOUS); @@ -1729,7 +1790,8 @@ static av_cold int vp8_decode_free(AVCodecContext *avctx) { - vp8_decode_flush(avctx); + vp8_decode_flush_impl(avctx, 0, 1, 1); + release_queued_segmaps(avctx->priv_data, 1); return 0; } @@ -1749,6 +1811,11 @@ { VP8Context *s = dst->priv_data, *s_src = src->priv_data; + if (s->macroblocks_base && + (s_src->mb_width != s->mb_width || s_src->mb_height != s->mb_height)) { + free_buffers(s); + } + s->prob[0] = s_src->prob[!s_src->update_probabilities]; s->segmentation = s_src->segmentation; s->lf_delta = s_src->lf_delta; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vp8.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vp8.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vp8.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vp8.h 2011-11-04 12:38:27.000000000 +0000 @@ -130,7 +130,6 @@ uint8_t *intra4x4_pred_mode_top; uint8_t intra4x4_pred_mode_left[4]; - uint8_t *segmentation_map; /** * Macroblocks can have one of 4 different quants in a frame when @@ -237,6 +236,16 @@ H264PredContext hpc; vp8_mc_func put_pixels_tab[3][3][3]; AVFrame frames[5]; + + /** + * A list of segmentation_map buffers that are to be free()'ed in + * the next decoding iteration. We can't free() them right away + * because the map may still be used by subsequent decoding threads. + * Unused if frame threading is off. + */ + uint8_t *segmentation_maps[5]; + int num_maps_to_be_freed; + int maps_are_invalid; } VP8Context; #endif /* AVCODEC_VP8_H */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vp8_parser.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vp8_parser.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vp8_parser.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vp8_parser.c 2011-11-04 12:38:27.000000000 +0000 @@ -33,8 +33,6 @@ } AVCodecParser ff_vp8_parser = { - { CODEC_ID_VP8 }, - 0, - NULL, - parse, + .codec_ids = { CODEC_ID_VP8 }, + .parser_parse = parse, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vqavideo.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vqavideo.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/vqavideo.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/vqavideo.c 2011-11-04 12:38:27.000000000 +0000 @@ -138,6 +138,10 @@ /* load up the VQA parameters from the header */ vqa_header = (unsigned char *)s->avctx->extradata; s->vqa_version = vqa_header[0]; + if (s->vqa_version < 1 || s->vqa_version > 3) { + av_log(s->avctx, AV_LOG_ERROR, " VQA video: unsupported version %d\n", s->vqa_version); + return -1; + } s->width = AV_RL16(&vqa_header[6]); s->height = AV_RL16(&vqa_header[8]); if(av_image_check_size(s->width, s->height, 0, avctx)){ @@ -226,6 +230,8 @@ src_index += 2; av_dlog(NULL, "(1) copy %X bytes from absolute pos %X\n", count, src_pos); CHECK_COUNT(); + if (src_pos + count > dest_size) + return; for (i = 0; i < count; i++) dest[dest_index + i] = dest[src_pos + i]; dest_index += count; @@ -248,6 +254,8 @@ src_index += 2; av_dlog(NULL, "(3) copy %X bytes from absolute pos %X\n", count, src_pos); CHECK_COUNT(); + if (src_pos + count > dest_size) + return; for (i = 0; i < count; i++) dest[dest_index + i] = dest[src_pos + i]; dest_index += count; @@ -268,6 +276,8 @@ src_index += 2; av_dlog(NULL, "(5) copy %X bytes from relpos %X\n", count, src_pos); CHECK_COUNT(); + if (dest_index < src_pos) + return; for (i = 0; i < count; i++) dest[dest_index + i] = dest[dest_index - src_pos + i]; dest_index += count; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/w32pthreads.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/w32pthreads.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/w32pthreads.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/w32pthreads.h 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,207 @@ +/* + * Copyright (C) 2010-2011 x264 project + * + * Authors: Steven Walters + * Pegasys Inc. + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * w32threads to pthreads wrapper + */ + +#ifndef AVCODEC_W32PTHREADS_H +#define AVCODEC_W32PTHREADS_H + +/* Build up a pthread-like API using underlying Windows API. Have only static + * methods so as to not conflict with a potentially linked in pthread-win32 + * library. + * As most functions here are used without checking return values, + * only implement return values as necessary. */ + +#define WIN32_LEAN_AND_MEAN +#include +#include + +typedef struct { + void *handle; + void *(*func)(void* arg); + void *arg; + void *ret; +} pthread_t; + +/* the conditional variable api for windows 6.0+ uses critical sections and + * not mutexes */ +typedef CRITICAL_SECTION pthread_mutex_t; + +/* This is the CONDITIONAL_VARIABLE typedef for using Window's native + * conditional variables on kernels 6.0+. + * MinGW does not currently have this typedef. */ +typedef struct { + void *ptr; +} pthread_cond_t; + +/* function pointers to conditional variable API on windows 6.0+ kernels */ +static void (WINAPI *cond_broadcast)(pthread_cond_t *cond); +static void (WINAPI *cond_init)(pthread_cond_t *cond); +static void (WINAPI *cond_signal)(pthread_cond_t *cond); +static BOOL (WINAPI *cond_wait)(pthread_cond_t *cond, pthread_mutex_t *mutex, + DWORD milliseconds); + +static unsigned __stdcall attribute_align_arg win32thread_worker(void *arg) +{ + pthread_t *h = arg; + h->ret = h->func(h->arg); + return 0; +} + +static int pthread_create(pthread_t *thread, const void *unused_attr, + void *(*start_routine)(void*), void *arg) +{ + thread->func = start_routine; + thread->arg = arg; + thread->handle = (void*)_beginthreadex(NULL, 0, win32thread_worker, thread, + 0, NULL); + return !thread->handle; +} + +static void pthread_join(pthread_t thread, void **value_ptr) +{ + DWORD ret = WaitForSingleObject(thread.handle, INFINITE); + if (ret != WAIT_OBJECT_0) + return; + if (value_ptr) + *value_ptr = thread.ret; + CloseHandle(thread.handle); +} + +#define pthread_mutex_init(m, a) InitializeCriticalSection(m) +#define pthread_mutex_destroy(m) DeleteCriticalSection(m) +#define pthread_mutex_lock(m) EnterCriticalSection(m) +#define pthread_mutex_unlock(m) LeaveCriticalSection(m) + +/* for pre-Windows 6.0 platforms we need to define and use our own condition + * variable and api */ +typedef struct { + pthread_mutex_t mtx_waiter_count; + volatile int waiter_count; + HANDLE semaphore; +} win32_cond_t; + +static void pthread_cond_init(pthread_cond_t *cond, const void *unused_attr) +{ + win32_cond_t *win32_cond = NULL; + if (cond_init) { + cond_init(cond); + return; + } + + /* non native condition variables */ + win32_cond = av_mallocz(sizeof(win32_cond_t)); + if (!win32_cond) + return; + cond->ptr = win32_cond; + win32_cond->semaphore = CreateSemaphore(NULL, 0, 0x7fffffff, NULL); + if (!win32_cond->semaphore) + return; + + pthread_mutex_init(&win32_cond->mtx_waiter_count, NULL); +} + +static void pthread_cond_destroy(pthread_cond_t *cond) +{ + win32_cond_t *win32_cond = cond->ptr; + /* native condition variables do not destroy */ + if (cond_init) + return; + + /* non native condition variables */ + CloseHandle(win32_cond->semaphore); + pthread_mutex_destroy(&win32_cond->mtx_waiter_count); + av_freep(&win32_cond); + cond->ptr = NULL; +} + +static void pthread_cond_broadcast(pthread_cond_t *cond) +{ + win32_cond_t *win32_cond = cond->ptr; + if (cond_broadcast) { + cond_broadcast(cond); + return; + } + + /* non native condition variables */ + pthread_mutex_lock(&win32_cond->mtx_waiter_count); + if (win32_cond->waiter_count) { + ReleaseSemaphore(win32_cond->semaphore, win32_cond->waiter_count, NULL); + win32_cond->waiter_count = 0; + } + pthread_mutex_unlock(&win32_cond->mtx_waiter_count); +} + +static void pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) +{ + win32_cond_t *win32_cond = cond->ptr; + if (cond_wait) { + cond_wait(cond, mutex, INFINITE); + return; + } + + /* non native condition variables */ + pthread_mutex_lock(&win32_cond->mtx_waiter_count); + win32_cond->waiter_count++; + pthread_mutex_unlock(&win32_cond->mtx_waiter_count); + + pthread_mutex_unlock(mutex); + WaitForSingleObject(win32_cond->semaphore, INFINITE); + pthread_mutex_lock(mutex); +} + +static void pthread_cond_signal(pthread_cond_t *cond) +{ + win32_cond_t *win32_cond = cond->ptr; + if (cond_signal) { + cond_signal(cond); + return; + } + + /* non-native condition variables */ + pthread_mutex_lock(&win32_cond->mtx_waiter_count); + if (win32_cond->waiter_count) { + ReleaseSemaphore(win32_cond->semaphore, 1, NULL); + win32_cond->waiter_count--; + } + pthread_mutex_unlock(&win32_cond->mtx_waiter_count); +} + +static void w32thread_init(void) +{ + HANDLE kernel_dll = GetModuleHandle(TEXT("kernel32.dll")); + /* if one is available, then they should all be available */ + cond_init = + (void*)GetProcAddress(kernel_dll, "InitializeConditionVariable"); + cond_broadcast = + (void*)GetProcAddress(kernel_dll, "WakeAllConditionVariable"); + cond_signal = + (void*)GetProcAddress(kernel_dll, "WakeConditionVariable"); + cond_wait = + (void*)GetProcAddress(kernel_dll, "SleepConditionVariableCS"); +} + +#endif /* AVCODEC_W32PTHREADS_H */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/w32thread.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/w32thread.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/w32thread.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/w32thread.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,176 +0,0 @@ -/* - * Copyright (c) 2004 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -//#define DEBUG - -#include "avcodec.h" -#include "thread.h" - -#define WIN32_LEAN_AND_MEAN -#include -#include - -typedef struct ThreadContext{ - AVCodecContext *avctx; - HANDLE thread; - HANDLE work_sem; - HANDLE job_sem; - HANDLE done_sem; - int (*func)(AVCodecContext *c, void *arg); - int (*func2)(AVCodecContext *c, void *arg, int, int); - void *arg; - int argsize; - int *jobnr; - int *ret; - int threadnr; -}ThreadContext; - - -static unsigned WINAPI attribute_align_arg thread_func(void *v){ - ThreadContext *c= v; - - for(;;){ - int ret, jobnr; -//printf("thread_func %X enter wait\n", (int)v); fflush(stdout); - WaitForSingleObject(c->work_sem, INFINITE); - // avoid trying to access jobnr if we should quit - if (!c->func && !c->func2) - break; - WaitForSingleObject(c->job_sem, INFINITE); - jobnr = (*c->jobnr)++; - ReleaseSemaphore(c->job_sem, 1, 0); -//printf("thread_func %X after wait (func=%X)\n", (int)v, (int)c->func); fflush(stdout); - if(c->func) - ret= c->func(c->avctx, (uint8_t *)c->arg + jobnr*c->argsize); - else - ret= c->func2(c->avctx, c->arg, jobnr, c->threadnr); - if (c->ret) - c->ret[jobnr] = ret; -//printf("thread_func %X signal complete\n", (int)v); fflush(stdout); - ReleaseSemaphore(c->done_sem, 1, 0); - } - - return 0; -} - -/** - * Free what has been allocated by ff_thread_init(). - * Must be called after decoding has finished, especially do not call while avcodec_thread_execute() is running. - */ -void ff_thread_free(AVCodecContext *s){ - ThreadContext *c= s->thread_opaque; - int i; - - for(i=0; ithread_count; i++){ - - c[i].func= NULL; - c[i].func2= NULL; - } - ReleaseSemaphore(c[0].work_sem, s->thread_count, 0); - for(i=0; ithread_count; i++){ - WaitForSingleObject(c[i].thread, INFINITE); - if(c[i].thread) CloseHandle(c[i].thread); - } - if(c[0].work_sem) CloseHandle(c[0].work_sem); - if(c[0].job_sem) CloseHandle(c[0].job_sem); - if(c[0].done_sem) CloseHandle(c[0].done_sem); - - av_freep(&s->thread_opaque); -} - -static int avcodec_thread_execute(AVCodecContext *s, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size){ - ThreadContext *c= s->thread_opaque; - int i; - int jobnr = 0; - - assert(s == c->avctx); - - /* note, we can be certain that this is not called with the same AVCodecContext by different threads at the same time */ - - for(i=0; ithread_count; i++){ - c[i].arg= arg; - c[i].argsize= size; - c[i].func= func; - c[i].ret= ret; - c[i].jobnr = &jobnr; - } - ReleaseSemaphore(c[0].work_sem, count, 0); - for(i=0; ithread_opaque; - int i; - for(i=0; ithread_count; i++) - c[i].func2 = func; - avcodec_thread_execute(s, NULL, arg, ret, count, 0); -} - -int ff_thread_init(AVCodecContext *s){ - int i; - ThreadContext *c; - uint32_t threadid; - - if (s->thread_type && !(s->thread_type & FF_THREAD_SLICE)) { - av_log(s, AV_LOG_WARNING, - "This thread library only supports FF_THREAD_SLICE" - " threading algorithm.\n"); - return 0; - } - - if (s->thread_count <= 1) - return 0; - - s->active_thread_type= FF_THREAD_SLICE; - - assert(!s->thread_opaque); - c= av_mallocz(sizeof(ThreadContext)*s->thread_count); - s->thread_opaque= c; - if(!(c[0].work_sem = CreateSemaphore(NULL, 0, INT_MAX, NULL))) - goto fail; - if(!(c[0].job_sem = CreateSemaphore(NULL, 1, 1, NULL))) - goto fail; - if(!(c[0].done_sem = CreateSemaphore(NULL, 0, INT_MAX, NULL))) - goto fail; - - for(i=0; ithread_count; i++){ -//printf("init semaphors %d\n", i); fflush(stdout); - c[i].avctx= s; - c[i].work_sem = c[0].work_sem; - c[i].job_sem = c[0].job_sem; - c[i].done_sem = c[0].done_sem; - c[i].threadnr = i; - -//printf("create thread %d\n", i); fflush(stdout); - c[i].thread = (HANDLE)_beginthreadex(NULL, 0, thread_func, &c[i], 0, &threadid ); - if( !c[i].thread ) goto fail; - } -//printf("init done\n"); fflush(stdout); - - s->execute= avcodec_thread_execute; - s->execute2= avcodec_thread_execute2; - - return 0; -fail: - ff_thread_free(s); - return -1; -} diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/wavpack.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/wavpack.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/wavpack.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/wavpack.c 2011-11-04 12:38:27.000000000 +0000 @@ -808,15 +808,13 @@ } s->frame_flags = AV_RL32(buf); buf += 4; if(s->frame_flags&0x80){ - bpp = sizeof(float); avctx->sample_fmt = AV_SAMPLE_FMT_FLT; } else if((s->frame_flags&0x03) <= 1){ - bpp = 2; avctx->sample_fmt = AV_SAMPLE_FMT_S16; } else { - bpp = 4; avctx->sample_fmt = AV_SAMPLE_FMT_S32; } + bpp = av_get_bytes_per_sample(avctx->sample_fmt); samples = (uint8_t*)samples + bpp * wc->ch_offset; s->stereo = !(s->frame_flags & WV_MONO); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/wmadec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/wmadec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/wmadec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/wmadec.c 2011-11-04 12:38:27.000000000 +0000 @@ -816,7 +816,7 @@ const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; WMACodecContext *s = avctx->priv_data; - int nb_frames, bit_offset, i, pos, len; + int nb_frames, bit_offset, i, pos, len, out_size; uint8_t *q; int16_t *samples; @@ -838,13 +838,19 @@ if (s->use_bit_reservoir) { /* read super frame header */ skip_bits(&s->gb, 4); /* super frame index */ - nb_frames = get_bits(&s->gb, 4) - 1; + nb_frames = get_bits(&s->gb, 4) - (s->last_superframe_len <= 0); + } else { + nb_frames = 1; + } - if((nb_frames+1) * s->nb_channels * s->frame_len * sizeof(int16_t) > *data_size){ - av_log(s->avctx, AV_LOG_ERROR, "Insufficient output space\n"); - goto fail; - } + out_size = nb_frames * s->frame_len * s->nb_channels * + av_get_bytes_per_sample(avctx->sample_fmt); + if (*data_size < out_size) { + av_log(s->avctx, AV_LOG_ERROR, "Insufficient output space\n"); + goto fail; + } + if (s->use_bit_reservoir) { bit_offset = get_bits(&s->gb, s->byte_offset_bits + 3); if (s->last_superframe_len > 0) { @@ -873,6 +879,7 @@ if (wma_decode_frame(s, samples) < 0) goto fail; samples += s->nb_channels * s->frame_len; + nb_frames--; } /* read each frame starting from bit_offset */ @@ -901,10 +908,6 @@ s->last_superframe_len = len; memcpy(s->last_superframe, buf + pos, len); } else { - if(s->nb_channels * s->frame_len * sizeof(int16_t) > *data_size){ - av_log(s->avctx, AV_LOG_ERROR, "Insufficient output space\n"); - goto fail; - } /* single frame decode */ if (wma_decode_frame(s, samples) < 0) goto fail; @@ -912,7 +915,7 @@ } //av_log(NULL, AV_LOG_ERROR, "%d %d %d %d outbytes:%d eaten:%d\n", s->frame_len_bits, s->block_len_bits, s->frame_len, s->block_len, (int8_t *)samples - (int8_t *)data, s->block_align); - *data_size = (int8_t *)samples - (int8_t *)data; + *data_size = out_size; return buf_size; fail: /* when error, we reset the bit reservoir */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/wmaenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/wmaenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/wmaenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/wmaenc.c 2011-11-04 12:38:27.000000000 +0000 @@ -311,7 +311,7 @@ put_bits(&s->pb, s->coef_vlcs[tindex]->huffbits[1], s->coef_vlcs[tindex]->huffcodes[1]); } if (s->version == 1 && s->nb_channels >= 2) { - align_put_bits(&s->pb); + avpriv_align_put_bits(&s->pb); } } return 0; @@ -327,7 +327,7 @@ return INT_MAX; } - align_put_bits(&s->pb); + avpriv_align_put_bits(&s->pb); return put_bits_count(&s->pb)/8 - s->block_align; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/wmalosslessdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/wmalosslessdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/wmalosslessdec.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/wmalosslessdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,1170 @@ +/* + * Wmall compatible decoder + * Copyright (c) 2007 Baptiste Coudurier, Benjamin Larsson, Ulion + * Copyright (c) 2008 - 2011 Sascha Sommer, Benjamin Larsson + * Copyright (c) 2011 Andreas Öman + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * @brief wmall decoder implementation + * Wmall is an MDCT based codec comparable to wma standard or AAC. + * The decoding therefore consists of the following steps: + * - bitstream decoding + * - reconstruction of per-channel data + * - rescaling and inverse quantization + * - IMDCT + * - windowing and overlapp-add + * + * The compressed wmall bitstream is split into individual packets. + * Every such packet contains one or more wma frames. + * The compressed frames may have a variable length and frames may + * cross packet boundaries. + * Common to all wmall frames is the number of samples that are stored in + * a frame. + * The number of samples and a few other decode flags are stored + * as extradata that has to be passed to the decoder. + * + * The wmall frames themselves are again split into a variable number of + * subframes. Every subframe contains the data for 2^N time domain samples + * where N varies between 7 and 12. + * + * Example wmall bitstream (in samples): + * + * || packet 0 || packet 1 || packet 2 packets + * --------------------------------------------------- + * || frame 0 || frame 1 || frame 2 || frames + * --------------------------------------------------- + * || | | || | | | || || subframes of channel 0 + * --------------------------------------------------- + * || | | || | | | || || subframes of channel 1 + * --------------------------------------------------- + * + * The frame layouts for the individual channels of a wma frame does not need + * to be the same. + * + * However, if the offsets and lengths of several subframes of a frame are the + * same, the subframes of the channels can be grouped. + * Every group may then use special coding techniques like M/S stereo coding + * to improve the compression ratio. These channel transformations do not + * need to be applied to a whole subframe. Instead, they can also work on + * individual scale factor bands (see below). + * The coefficients that carry the audio signal in the frequency domain + * are transmitted as huffman-coded vectors with 4, 2 and 1 elements. + * In addition to that, the encoder can switch to a runlevel coding scheme + * by transmitting subframe_length / 128 zero coefficients. + * + * Before the audio signal can be converted to the time domain, the + * coefficients have to be rescaled and inverse quantized. + * A subframe is therefore split into several scale factor bands that get + * scaled individually. + * Scale factors are submitted for every frame but they might be shared + * between the subframes of a channel. Scale factors are initially DPCM-coded. + * Once scale factors are shared, the differences are transmitted as runlevel + * codes. + * Every subframe length and offset combination in the frame layout shares a + * common quantization factor that can be adjusted for every channel by a + * modifier. + * After the inverse quantization, the coefficients get processed by an IMDCT. + * The resulting values are then windowed with a sine window and the first half + * of the values are added to the second half of the output from the previous + * subframe in order to reconstruct the output samples. + */ + +#include "avcodec.h" +#include "internal.h" +#include "get_bits.h" +#include "put_bits.h" +#include "dsputil.h" +#include "wma.h" + +/** current decoder limitations */ +#define WMALL_MAX_CHANNELS 8 ///< max number of handled channels +#define MAX_SUBFRAMES 32 ///< max number of subframes per channel +#define MAX_BANDS 29 ///< max number of scale factor bands +#define MAX_FRAMESIZE 32768 ///< maximum compressed frame size + +#define WMALL_BLOCK_MIN_BITS 6 ///< log2 of min block size +#define WMALL_BLOCK_MAX_BITS 12 ///< log2 of max block size +#define WMALL_BLOCK_MAX_SIZE (1 << WMALL_BLOCK_MAX_BITS) ///< maximum block size +#define WMALL_BLOCK_SIZES (WMALL_BLOCK_MAX_BITS - WMALL_BLOCK_MIN_BITS + 1) ///< possible block sizes + + +#define VLCBITS 9 +#define SCALEVLCBITS 8 +#define VEC4MAXDEPTH ((HUFF_VEC4_MAXBITS+VLCBITS-1)/VLCBITS) +#define VEC2MAXDEPTH ((HUFF_VEC2_MAXBITS+VLCBITS-1)/VLCBITS) +#define VEC1MAXDEPTH ((HUFF_VEC1_MAXBITS+VLCBITS-1)/VLCBITS) +#define SCALEMAXDEPTH ((HUFF_SCALE_MAXBITS+SCALEVLCBITS-1)/SCALEVLCBITS) +#define SCALERLMAXDEPTH ((HUFF_SCALE_RL_MAXBITS+VLCBITS-1)/VLCBITS) + +static float sin64[33]; ///< sinus table for decorrelation + +/** + * @brief frame specific decoder context for a single channel + */ +typedef struct { + int16_t prev_block_len; ///< length of the previous block + uint8_t transmit_coefs; + uint8_t num_subframes; + uint16_t subframe_len[MAX_SUBFRAMES]; ///< subframe length in samples + uint16_t subframe_offset[MAX_SUBFRAMES]; ///< subframe positions in the current frame + uint8_t cur_subframe; ///< current subframe number + uint16_t decoded_samples; ///< number of already processed samples + uint8_t grouped; ///< channel is part of a group + int quant_step; ///< quantization step for the current subframe + int8_t reuse_sf; ///< share scale factors between subframes + int8_t scale_factor_step; ///< scaling step for the current subframe + int max_scale_factor; ///< maximum scale factor for the current subframe + int saved_scale_factors[2][MAX_BANDS]; ///< resampled and (previously) transmitted scale factor values + int8_t scale_factor_idx; ///< index for the transmitted scale factor values (used for resampling) + int* scale_factors; ///< pointer to the scale factor values used for decoding + uint8_t table_idx; ///< index in sf_offsets for the scale factor reference block + float* coeffs; ///< pointer to the subframe decode buffer + uint16_t num_vec_coeffs; ///< number of vector coded coefficients + DECLARE_ALIGNED(16, float, out)[WMALL_BLOCK_MAX_SIZE + WMALL_BLOCK_MAX_SIZE / 2]; ///< output buffer +} WmallChannelCtx; + +/** + * @brief channel group for channel transformations + */ +typedef struct { + uint8_t num_channels; ///< number of channels in the group + int8_t transform; ///< transform on / off + int8_t transform_band[MAX_BANDS]; ///< controls if the transform is enabled for a certain band + float decorrelation_matrix[WMALL_MAX_CHANNELS*WMALL_MAX_CHANNELS]; + float* channel_data[WMALL_MAX_CHANNELS]; ///< transformation coefficients +} WmallChannelGrp; + +/** + * @brief main decoder context + */ +typedef struct WmallDecodeCtx { + /* generic decoder variables */ + AVCodecContext* avctx; ///< codec context for av_log + DSPContext dsp; ///< accelerated DSP functions + uint8_t frame_data[MAX_FRAMESIZE + + FF_INPUT_BUFFER_PADDING_SIZE];///< compressed frame data + PutBitContext pb; ///< context for filling the frame_data buffer + FFTContext mdct_ctx[WMALL_BLOCK_SIZES]; ///< MDCT context per block size + DECLARE_ALIGNED(16, float, tmp)[WMALL_BLOCK_MAX_SIZE]; ///< IMDCT output buffer + float* windows[WMALL_BLOCK_SIZES]; ///< windows for the different block sizes + + /* frame size dependent frame information (set during initialization) */ + uint32_t decode_flags; ///< used compression features + uint8_t len_prefix; ///< frame is prefixed with its length + uint8_t dynamic_range_compression; ///< frame contains DRC data + uint8_t bits_per_sample; ///< integer audio sample size for the unscaled IMDCT output (used to scale to [-1.0, 1.0]) + uint16_t samples_per_frame; ///< number of samples to output + uint16_t log2_frame_size; + int8_t num_channels; ///< number of channels in the stream (same as AVCodecContext.num_channels) + int8_t lfe_channel; ///< lfe channel index + uint8_t max_num_subframes; + uint8_t subframe_len_bits; ///< number of bits used for the subframe length + uint8_t max_subframe_len_bit; ///< flag indicating that the subframe is of maximum size when the first subframe length bit is 1 + uint16_t min_samples_per_subframe; + int8_t num_sfb[WMALL_BLOCK_SIZES]; ///< scale factor bands per block size + int16_t sfb_offsets[WMALL_BLOCK_SIZES][MAX_BANDS]; ///< scale factor band offsets (multiples of 4) + int8_t sf_offsets[WMALL_BLOCK_SIZES][WMALL_BLOCK_SIZES][MAX_BANDS]; ///< scale factor resample matrix + int16_t subwoofer_cutoffs[WMALL_BLOCK_SIZES]; ///< subwoofer cutoff values + + /* packet decode state */ + GetBitContext pgb; ///< bitstream reader context for the packet + int next_packet_start; ///< start offset of the next wma packet in the demuxer packet + uint8_t packet_offset; ///< frame offset in the packet + uint8_t packet_sequence_number; ///< current packet number + int num_saved_bits; ///< saved number of bits + int frame_offset; ///< frame offset in the bit reservoir + int subframe_offset; ///< subframe offset in the bit reservoir + uint8_t packet_loss; ///< set in case of bitstream error + uint8_t packet_done; ///< set when a packet is fully decoded + + /* frame decode state */ + uint32_t frame_num; ///< current frame number (not used for decoding) + GetBitContext gb; ///< bitstream reader context + int buf_bit_size; ///< buffer size in bits + float* samples; ///< current samplebuffer pointer + float* samples_end; ///< maximum samplebuffer pointer + uint8_t drc_gain; ///< gain for the DRC tool + int8_t skip_frame; ///< skip output step + int8_t parsed_all_subframes; ///< all subframes decoded? + + /* subframe/block decode state */ + int16_t subframe_len; ///< current subframe length + int8_t channels_for_cur_subframe; ///< number of channels that contain the subframe + int8_t channel_indexes_for_cur_subframe[WMALL_MAX_CHANNELS]; + int8_t num_bands; ///< number of scale factor bands + int8_t transmit_num_vec_coeffs; ///< number of vector coded coefficients is part of the bitstream + int16_t* cur_sfb_offsets; ///< sfb offsets for the current block + uint8_t table_idx; ///< index for the num_sfb, sfb_offsets, sf_offsets and subwoofer_cutoffs tables + int8_t esc_len; ///< length of escaped coefficients + + uint8_t num_chgroups; ///< number of channel groups + WmallChannelGrp chgroup[WMALL_MAX_CHANNELS]; ///< channel group information + + WmallChannelCtx channel[WMALL_MAX_CHANNELS]; ///< per channel data + + // WMA lossless + + uint8_t do_arith_coding; + uint8_t do_ac_filter; + uint8_t do_inter_ch_decorr; + uint8_t do_mclms; + uint8_t do_lpc; + + int8_t acfilter_order; + int8_t acfilter_scaling; + int acfilter_coeffs[16]; + + int8_t mclms_order; + int8_t mclms_scaling; + int16_t mclms_coeffs[128]; + int16_t mclms_coeffs_cur[4]; + + int movave_scaling; + int quant_stepsize; + + struct { + int order; + int scaling; + int coefsend; + int bitsend; + int16_t coefs[256]; + } cdlms[2][9]; + + + int cdlms_ttl[2]; + + int bV3RTM; + + int is_channel_coded[2]; + + int transient[2]; + int transient_pos[2]; + int seekable_tile; + + int ave_sum[2]; + + int channel_residues[2][2048]; + + + int lpc_coefs[2][40]; + int lpc_order; + int lpc_scaling; + int lpc_intbits; + + int channel_coeffs[2][2048]; + +} WmallDecodeCtx; + + +#undef dprintf +#define dprintf(pctx, ...) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__) + + +/** + *@brief helper function to print the most important members of the context + *@param s context + */ +static void av_cold dump_context(WmallDecodeCtx *s) +{ +#define PRINT(a, b) av_log(s->avctx, AV_LOG_DEBUG, " %s = %d\n", a, b); +#define PRINT_HEX(a, b) av_log(s->avctx, AV_LOG_DEBUG, " %s = %x\n", a, b); + + PRINT("ed sample bit depth", s->bits_per_sample); + PRINT_HEX("ed decode flags", s->decode_flags); + PRINT("samples per frame", s->samples_per_frame); + PRINT("log2 frame size", s->log2_frame_size); + PRINT("max num subframes", s->max_num_subframes); + PRINT("len prefix", s->len_prefix); + PRINT("num channels", s->num_channels); +} + +/** + *@brief Uninitialize the decoder and free all resources. + *@param avctx codec context + *@return 0 on success, < 0 otherwise + */ +static av_cold int decode_end(AVCodecContext *avctx) +{ + WmallDecodeCtx *s = avctx->priv_data; + int i; + + for (i = 0; i < WMALL_BLOCK_SIZES; i++) + ff_mdct_end(&s->mdct_ctx[i]); + + return 0; +} + +/** + *@brief Initialize the decoder. + *@param avctx codec context + *@return 0 on success, -1 otherwise + */ +static av_cold int decode_init(AVCodecContext *avctx) +{ + WmallDecodeCtx *s = avctx->priv_data; + uint8_t *edata_ptr = avctx->extradata; + unsigned int channel_mask; + int i; + int log2_max_num_subframes; + int num_possible_block_sizes; + + s->avctx = avctx; + dsputil_init(&s->dsp, avctx); + init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE); + + avctx->sample_fmt = AV_SAMPLE_FMT_FLT; + + if (avctx->extradata_size >= 18) { + s->decode_flags = AV_RL16(edata_ptr+14); + channel_mask = AV_RL32(edata_ptr+2); + s->bits_per_sample = AV_RL16(edata_ptr); + /** dump the extradata */ + for (i = 0; i < avctx->extradata_size; i++) + dprintf(avctx, "[%x] ", avctx->extradata[i]); + dprintf(avctx, "\n"); + + } else { + av_log_ask_for_sample(avctx, "Unknown extradata size\n"); + return AVERROR_INVALIDDATA; + } + + /** generic init */ + s->log2_frame_size = av_log2(avctx->block_align) + 4; + + /** frame info */ + s->skip_frame = 1; /* skip first frame */ + s->packet_loss = 1; + s->len_prefix = (s->decode_flags & 0x40); + + /** get frame len */ + s->samples_per_frame = 1 << ff_wma_get_frame_len_bits(avctx->sample_rate, + 3, s->decode_flags); + + /** init previous block len */ + for (i = 0; i < avctx->channels; i++) + s->channel[i].prev_block_len = s->samples_per_frame; + + /** subframe info */ + log2_max_num_subframes = ((s->decode_flags & 0x38) >> 3); + s->max_num_subframes = 1 << log2_max_num_subframes; + s->max_subframe_len_bit = 0; + s->subframe_len_bits = av_log2(log2_max_num_subframes) + 1; + + num_possible_block_sizes = log2_max_num_subframes + 1; + s->min_samples_per_subframe = s->samples_per_frame / s->max_num_subframes; + s->dynamic_range_compression = (s->decode_flags & 0x80); + + s->bV3RTM = s->decode_flags & 0x100; + + if (s->max_num_subframes > MAX_SUBFRAMES) { + av_log(avctx, AV_LOG_ERROR, "invalid number of subframes %i\n", + s->max_num_subframes); + return AVERROR_INVALIDDATA; + } + + s->num_channels = avctx->channels; + + /** extract lfe channel position */ + s->lfe_channel = -1; + + if (channel_mask & 8) { + unsigned int mask; + for (mask = 1; mask < 16; mask <<= 1) { + if (channel_mask & mask) + ++s->lfe_channel; + } + } + + if (s->num_channels < 0) { + av_log(avctx, AV_LOG_ERROR, "invalid number of channels %d\n", s->num_channels); + return AVERROR_INVALIDDATA; + } else if (s->num_channels > WMALL_MAX_CHANNELS) { + av_log_ask_for_sample(avctx, "unsupported number of channels\n"); + return AVERROR_PATCHWELCOME; + } + + avctx->channel_layout = channel_mask; + return 0; +} + +/** + *@brief Decode the subframe length. + *@param s context + *@param offset sample offset in the frame + *@return decoded subframe length on success, < 0 in case of an error + */ +static int decode_subframe_length(WmallDecodeCtx *s, int offset) +{ + int frame_len_ratio; + int subframe_len, len; + + /** no need to read from the bitstream when only one length is possible */ + if (offset == s->samples_per_frame - s->min_samples_per_subframe) + return s->min_samples_per_subframe; + + len = av_log2(s->max_num_subframes - 1) + 1; + frame_len_ratio = get_bits(&s->gb, len); + + subframe_len = s->min_samples_per_subframe * (frame_len_ratio + 1); + + /** sanity check the length */ + if (subframe_len < s->min_samples_per_subframe || + subframe_len > s->samples_per_frame) { + av_log(s->avctx, AV_LOG_ERROR, "broken frame: subframe_len %i\n", + subframe_len); + return AVERROR_INVALIDDATA; + } + return subframe_len; +} + +/** + *@brief Decode how the data in the frame is split into subframes. + * Every WMA frame contains the encoded data for a fixed number of + * samples per channel. The data for every channel might be split + * into several subframes. This function will reconstruct the list of + * subframes for every channel. + * + * If the subframes are not evenly split, the algorithm estimates the + * channels with the lowest number of total samples. + * Afterwards, for each of these channels a bit is read from the + * bitstream that indicates if the channel contains a subframe with the + * next subframe size that is going to be read from the bitstream or not. + * If a channel contains such a subframe, the subframe size gets added to + * the channel's subframe list. + * The algorithm repeats these steps until the frame is properly divided + * between the individual channels. + * + *@param s context + *@return 0 on success, < 0 in case of an error + */ +static int decode_tilehdr(WmallDecodeCtx *s) +{ + uint16_t num_samples[WMALL_MAX_CHANNELS]; /**< sum of samples for all currently known subframes of a channel */ + uint8_t contains_subframe[WMALL_MAX_CHANNELS]; /**< flag indicating if a channel contains the current subframe */ + int channels_for_cur_subframe = s->num_channels; /**< number of channels that contain the current subframe */ + int fixed_channel_layout = 0; /**< flag indicating that all channels use the same subfra2me offsets and sizes */ + int min_channel_len = 0; /**< smallest sum of samples (channels with this length will be processed first) */ + int c; + + /* Should never consume more than 3073 bits (256 iterations for the + * while loop when always the minimum amount of 128 samples is substracted + * from missing samples in the 8 channel case). + * 1 + BLOCK_MAX_SIZE * MAX_CHANNELS / BLOCK_MIN_SIZE * (MAX_CHANNELS + 4) + */ + + /** reset tiling information */ + for (c = 0; c < s->num_channels; c++) + s->channel[c].num_subframes = 0; + + memset(num_samples, 0, sizeof(num_samples)); + + if (s->max_num_subframes == 1 || get_bits1(&s->gb)) + fixed_channel_layout = 1; + + /** loop until the frame data is split between the subframes */ + do { + int subframe_len; + + /** check which channels contain the subframe */ + for (c = 0; c < s->num_channels; c++) { + if (num_samples[c] == min_channel_len) { + if (fixed_channel_layout || channels_for_cur_subframe == 1 || + (min_channel_len == s->samples_per_frame - s->min_samples_per_subframe)) { + contains_subframe[c] = 1; + } + else { + contains_subframe[c] = get_bits1(&s->gb); + } + } else + contains_subframe[c] = 0; + } + + /** get subframe length, subframe_len == 0 is not allowed */ + if ((subframe_len = decode_subframe_length(s, min_channel_len)) <= 0) + return AVERROR_INVALIDDATA; + /** add subframes to the individual channels and find new min_channel_len */ + min_channel_len += subframe_len; + for (c = 0; c < s->num_channels; c++) { + WmallChannelCtx* chan = &s->channel[c]; + + if (contains_subframe[c]) { + if (chan->num_subframes >= MAX_SUBFRAMES) { + av_log(s->avctx, AV_LOG_ERROR, + "broken frame: num subframes > 31\n"); + return AVERROR_INVALIDDATA; + } + chan->subframe_len[chan->num_subframes] = subframe_len; + num_samples[c] += subframe_len; + ++chan->num_subframes; + if (num_samples[c] > s->samples_per_frame) { + av_log(s->avctx, AV_LOG_ERROR, "broken frame: " + "channel len(%d) > samples_per_frame(%d)\n", + num_samples[c], s->samples_per_frame); + return AVERROR_INVALIDDATA; + } + } else if (num_samples[c] <= min_channel_len) { + if (num_samples[c] < min_channel_len) { + channels_for_cur_subframe = 0; + min_channel_len = num_samples[c]; + } + ++channels_for_cur_subframe; + } + } + } while (min_channel_len < s->samples_per_frame); + + for (c = 0; c < s->num_channels; c++) { + int i; + int offset = 0; + for (i = 0; i < s->channel[c].num_subframes; i++) { + s->channel[c].subframe_offset[i] = offset; + offset += s->channel[c].subframe_len[i]; + } + } + + return 0; +} + + +static int my_log2(unsigned int i) +{ + unsigned int iLog2 = 0; + while ((i >> iLog2) > 1) + iLog2++; + return iLog2; +} + + +/** + * + */ +static void decode_ac_filter(WmallDecodeCtx *s) +{ + int i; + s->acfilter_order = get_bits(&s->gb, 4) + 1; + s->acfilter_scaling = get_bits(&s->gb, 4); + + for(i = 0; i < s->acfilter_order; i++) { + s->acfilter_coeffs[i] = get_bits(&s->gb, s->acfilter_scaling) + 1; + } +} + + +/** + * + */ +static void decode_mclms(WmallDecodeCtx *s) +{ + s->mclms_order = (get_bits(&s->gb, 4) + 1) * 2; + s->mclms_scaling = get_bits(&s->gb, 4); + if(get_bits1(&s->gb)) { + // mclms_send_coef + int i; + int send_coef_bits; + int cbits = av_log2(s->mclms_scaling + 1); + assert(cbits == my_log2(s->mclms_scaling + 1)); + if(1 << cbits < s->mclms_scaling + 1) + cbits++; + + send_coef_bits = (cbits ? get_bits(&s->gb, cbits) : 0) + 2; + + for(i = 0; i < s->mclms_order * s->num_channels * s->num_channels; i++) { + s->mclms_coeffs[i] = get_bits(&s->gb, send_coef_bits); + } + + for(i = 0; i < s->num_channels; i++) { + int c; + for(c = 0; c < i; c++) { + s->mclms_coeffs_cur[i * s->num_channels + c] = get_bits(&s->gb, send_coef_bits); + } + } + } +} + + +/** + * + */ +static void decode_cdlms(WmallDecodeCtx *s) +{ + int c, i; + int cdlms_send_coef = get_bits1(&s->gb); + + for(c = 0; c < s->num_channels; c++) { + s->cdlms_ttl[c] = get_bits(&s->gb, 3) + 1; + for(i = 0; i < s->cdlms_ttl[c]; i++) { + s->cdlms[c][i].order = (get_bits(&s->gb, 7) + 1) * 8; + } + + for(i = 0; i < s->cdlms_ttl[c]; i++) { + s->cdlms[c][i].scaling = get_bits(&s->gb, 4); + } + + if(cdlms_send_coef) { + for(i = 0; i < s->cdlms_ttl[c]; i++) { + int cbits, shift_l, shift_r, j; + cbits = av_log2(s->cdlms[c][i].order); + if(1 << cbits < s->cdlms[c][i].order) + cbits++; + s->cdlms[c][i].coefsend = get_bits(&s->gb, cbits) + 1; + + cbits = av_log2(s->cdlms[c][i].scaling + 1); + if(1 << cbits < s->cdlms[c][i].scaling + 1) + cbits++; + + s->cdlms[c][i].bitsend = get_bits(&s->gb, cbits) + 2; + shift_l = 32 - s->cdlms[c][i].bitsend; + shift_r = 32 - 2 - s->cdlms[c][i].scaling; + for(j = 0; j < s->cdlms[c][i].coefsend; j++) { + s->cdlms[c][i].coefs[j] = + (get_bits(&s->gb, s->cdlms[c][i].bitsend) << shift_l) >> shift_r; + } + } + } + } +} + +/** + * + */ +static int decode_channel_residues(WmallDecodeCtx *s, int ch, int tile_size) +{ + int i = 0; + unsigned int ave_mean; + s->transient[ch] = get_bits1(&s->gb); + if(s->transient[ch]) + s->transient_pos[ch] = get_bits(&s->gb, av_log2(tile_size)); + + if(s->seekable_tile) { + ave_mean = get_bits(&s->gb, s->bits_per_sample); + s->ave_sum[ch] = ave_mean << (s->movave_scaling + 1); +// s->ave_sum[ch] *= 2; + } + + if(s->seekable_tile) { + if(s->do_inter_ch_decorr) + s->channel_residues[ch][0] = get_sbits(&s->gb, s->bits_per_sample + 1); + else + s->channel_residues[ch][0] = get_sbits(&s->gb, s->bits_per_sample); + i++; + } + for(; i < tile_size; i++) { + int quo = 0, rem, rem_bits, residue; + while(get_bits1(&s->gb)) + quo++; + if(quo >= 32) + quo += get_bits_long(&s->gb, get_bits(&s->gb, 5) + 1); + + ave_mean = (s->ave_sum[ch] + (1 << s->movave_scaling)) >> (s->movave_scaling + 1); + rem_bits = av_ceil_log2(ave_mean); + rem = rem_bits ? get_bits(&s->gb, rem_bits) : 0; + residue = (quo << rem_bits) + rem; + + s->ave_sum[ch] = residue + s->ave_sum[ch] - (s->ave_sum[ch] >> s->movave_scaling); + + if(residue & 1) + residue = -(residue >> 1) - 1; + else + residue = residue >> 1; + s->channel_residues[ch][i] = residue; + +// dprintf(s->avctx, "%5d: %5d %10d %12d %12d %5d %-16d %04x\n",i, quo, ave_mean, s->ave_sum[ch], rem, rem_bits, s->channel_residues[ch][i], show_bits(&s->gb, 16)); + } + + return 0; + +} + + +/** + * + */ +static void +decode_lpc(WmallDecodeCtx *s) +{ + int ch, i, cbits; + s->lpc_order = get_bits(&s->gb, 5) + 1; + s->lpc_scaling = get_bits(&s->gb, 4); + s->lpc_intbits = get_bits(&s->gb, 3) + 1; + cbits = s->lpc_scaling + s->lpc_intbits; + for(ch = 0; ch < s->num_channels; ch++) { + for(i = 0; i < s->lpc_order; i++) { + s->lpc_coefs[ch][i] = get_sbits(&s->gb, cbits); + } + } +} + + + +/** + *@brief Decode a single subframe (block). + *@param s codec context + *@return 0 on success, < 0 when decoding failed + */ +static int decode_subframe(WmallDecodeCtx *s) +{ + int offset = s->samples_per_frame; + int subframe_len = s->samples_per_frame; + int i; + int total_samples = s->samples_per_frame * s->num_channels; + int rawpcm_tile; + int padding_zeroes; + + s->subframe_offset = get_bits_count(&s->gb); + + /** reset channel context and find the next block offset and size + == the next block of the channel with the smallest number of + decoded samples + */ + for (i = 0; i < s->num_channels; i++) { + s->channel[i].grouped = 0; + if (offset > s->channel[i].decoded_samples) { + offset = s->channel[i].decoded_samples; + subframe_len = + s->channel[i].subframe_len[s->channel[i].cur_subframe]; + } + } + + /** get a list of all channels that contain the estimated block */ + s->channels_for_cur_subframe = 0; + for (i = 0; i < s->num_channels; i++) { + const int cur_subframe = s->channel[i].cur_subframe; + /** substract already processed samples */ + total_samples -= s->channel[i].decoded_samples; + + /** and count if there are multiple subframes that match our profile */ + if (offset == s->channel[i].decoded_samples && + subframe_len == s->channel[i].subframe_len[cur_subframe]) { + total_samples -= s->channel[i].subframe_len[cur_subframe]; + s->channel[i].decoded_samples += + s->channel[i].subframe_len[cur_subframe]; + s->channel_indexes_for_cur_subframe[s->channels_for_cur_subframe] = i; + ++s->channels_for_cur_subframe; + } + } + + /** check if the frame will be complete after processing the + estimated block */ + if (!total_samples) + s->parsed_all_subframes = 1; + + + s->seekable_tile = get_bits1(&s->gb); + if(s->seekable_tile) { + s->do_arith_coding = get_bits1(&s->gb); + if(s->do_arith_coding) { + dprintf(s->avctx, "do_arith_coding == 1"); + abort(); + } + s->do_ac_filter = get_bits1(&s->gb); + s->do_inter_ch_decorr = get_bits1(&s->gb); + s->do_mclms = get_bits1(&s->gb); + + if(s->do_ac_filter) + decode_ac_filter(s); + + if(s->do_mclms) + decode_mclms(s); + + decode_cdlms(s); + s->movave_scaling = get_bits(&s->gb, 3); + s->quant_stepsize = get_bits(&s->gb, 8) + 1; + } + + rawpcm_tile = get_bits1(&s->gb); + + for(i = 0; i < s->num_channels; i++) { + s->is_channel_coded[i] = 1; + } + + if(!rawpcm_tile) { + + for(i = 0; i < s->num_channels; i++) { + s->is_channel_coded[i] = get_bits1(&s->gb); + } + + if(s->bV3RTM) { + // LPC + s->do_lpc = get_bits1(&s->gb); + if(s->do_lpc) { + decode_lpc(s); + } + } else { + s->do_lpc = 0; + } + } + + + if(get_bits1(&s->gb)) { + padding_zeroes = get_bits(&s->gb, 5); + } else { + padding_zeroes = 0; + } + + if(rawpcm_tile) { + + int bits = s->bits_per_sample - padding_zeroes; + int j; + dprintf(s->avctx, "RAWPCM %d bits per sample. total %d bits, remain=%d\n", bits, + bits * s->num_channels * subframe_len, get_bits_count(&s->gb)); + for(i = 0; i < s->num_channels; i++) { + for(j = 0; j < subframe_len; j++) { + s->channel_coeffs[i][j] = get_sbits(&s->gb, bits); +// dprintf(s->avctx, "PCM[%d][%d] = 0x%04x\n", i, j, s->channel_coeffs[i][j]); + } + } + } else { + for(i = 0; i < s->num_channels; i++) + if(s->is_channel_coded[i]) + decode_channel_residues(s, i, subframe_len); + } + + /** handled one subframe */ + + for (i = 0; i < s->channels_for_cur_subframe; i++) { + int c = s->channel_indexes_for_cur_subframe[i]; + if (s->channel[c].cur_subframe >= s->channel[c].num_subframes) { + av_log(s->avctx, AV_LOG_ERROR, "broken subframe\n"); + return AVERROR_INVALIDDATA; + } + ++s->channel[c].cur_subframe; + } + return 0; +} + +/** + *@brief Decode one WMA frame. + *@param s codec context + *@return 0 if the trailer bit indicates that this is the last frame, + * 1 if there are additional frames + */ +static int decode_frame(WmallDecodeCtx *s) +{ + GetBitContext* gb = &s->gb; + int more_frames = 0; + int len = 0; + int i; + + /** check for potential output buffer overflow */ + if (s->num_channels * s->samples_per_frame > s->samples_end - s->samples) { + /** return an error if no frame could be decoded at all */ + av_log(s->avctx, AV_LOG_ERROR, + "not enough space for the output samples\n"); + s->packet_loss = 1; + return 0; + } + + /** get frame length */ + if (s->len_prefix) + len = get_bits(gb, s->log2_frame_size); + + /** decode tile information */ + if (decode_tilehdr(s)) { + s->packet_loss = 1; + return 0; + } + + /** read drc info */ + if (s->dynamic_range_compression) { + s->drc_gain = get_bits(gb, 8); + } + + /** no idea what these are for, might be the number of samples + that need to be skipped at the beginning or end of a stream */ + if (get_bits1(gb)) { + int skip; + + /** usually true for the first frame */ + if (get_bits1(gb)) { + skip = get_bits(gb, av_log2(s->samples_per_frame * 2)); + dprintf(s->avctx, "start skip: %i\n", skip); + } + + /** sometimes true for the last frame */ + if (get_bits1(gb)) { + skip = get_bits(gb, av_log2(s->samples_per_frame * 2)); + dprintf(s->avctx, "end skip: %i\n", skip); + } + + } + + /** reset subframe states */ + s->parsed_all_subframes = 0; + for (i = 0; i < s->num_channels; i++) { + s->channel[i].decoded_samples = 0; + s->channel[i].cur_subframe = 0; + s->channel[i].reuse_sf = 0; + } + + /** decode all subframes */ + while (!s->parsed_all_subframes) { + if (decode_subframe(s) < 0) { + s->packet_loss = 1; + return 0; + } + } + + dprintf(s->avctx, "Frame done\n"); + + if (s->skip_frame) { + s->skip_frame = 0; + } else + s->samples += s->num_channels * s->samples_per_frame; + + if (s->len_prefix) { + if (len != (get_bits_count(gb) - s->frame_offset) + 2) { + /** FIXME: not sure if this is always an error */ + av_log(s->avctx, AV_LOG_ERROR, + "frame[%i] would have to skip %i bits\n", s->frame_num, + len - (get_bits_count(gb) - s->frame_offset) - 1); + s->packet_loss = 1; + return 0; + } + + /** skip the rest of the frame data */ + skip_bits_long(gb, len - (get_bits_count(gb) - s->frame_offset) - 1); + } else { +/* + while (get_bits_count(gb) < s->num_saved_bits && get_bits1(gb) == 0) { + dprintf(s->avctx, "skip1\n"); + } +*/ + } + + /** decode trailer bit */ + more_frames = get_bits1(gb); + ++s->frame_num; + return more_frames; +} + +/** + *@brief Calculate remaining input buffer length. + *@param s codec context + *@param gb bitstream reader context + *@return remaining size in bits + */ +static int remaining_bits(WmallDecodeCtx *s, GetBitContext *gb) +{ + return s->buf_bit_size - get_bits_count(gb); +} + +/** + *@brief Fill the bit reservoir with a (partial) frame. + *@param s codec context + *@param gb bitstream reader context + *@param len length of the partial frame + *@param append decides wether to reset the buffer or not + */ +static void save_bits(WmallDecodeCtx *s, GetBitContext* gb, int len, + int append) +{ + int buflen; + + /** when the frame data does not need to be concatenated, the input buffer + is resetted and additional bits from the previous frame are copyed + and skipped later so that a fast byte copy is possible */ + + if (!append) { + s->frame_offset = get_bits_count(gb) & 7; + s->num_saved_bits = s->frame_offset; + init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE); + } + + buflen = (s->num_saved_bits + len + 8) >> 3; + + if (len <= 0 || buflen > MAX_FRAMESIZE) { + av_log_ask_for_sample(s->avctx, "input buffer too small\n"); + s->packet_loss = 1; + return; + } + + s->num_saved_bits += len; + if (!append) { + avpriv_copy_bits(&s->pb, gb->buffer + (get_bits_count(gb) >> 3), + s->num_saved_bits); + } else { + int align = 8 - (get_bits_count(gb) & 7); + align = FFMIN(align, len); + put_bits(&s->pb, align, get_bits(gb, align)); + len -= align; + avpriv_copy_bits(&s->pb, gb->buffer + (get_bits_count(gb) >> 3), len); + } + skip_bits_long(gb, len); + + { + PutBitContext tmp = s->pb; + flush_put_bits(&tmp); + } + + init_get_bits(&s->gb, s->frame_data, s->num_saved_bits); + skip_bits(&s->gb, s->frame_offset); +} + +/** + *@brief Decode a single WMA packet. + *@param avctx codec context + *@param data the output buffer + *@param data_size number of bytes that were written to the output buffer + *@param avpkt input packet + *@return number of bytes that were read from the input buffer + */ +static int decode_packet(AVCodecContext *avctx, + void *data, int *data_size, AVPacket* avpkt) +{ + WmallDecodeCtx *s = avctx->priv_data; + GetBitContext* gb = &s->pgb; + const uint8_t* buf = avpkt->data; + int buf_size = avpkt->size; + int num_bits_prev_frame; + int packet_sequence_number; + + s->samples = data; + s->samples_end = (float*)((int8_t*)data + *data_size); + *data_size = 0; + + if (s->packet_done || s->packet_loss) { + s->packet_done = 0; + + /** sanity check for the buffer length */ + if (buf_size < avctx->block_align) + return 0; + + s->next_packet_start = buf_size - avctx->block_align; + buf_size = avctx->block_align; + s->buf_bit_size = buf_size << 3; + + /** parse packet header */ + init_get_bits(gb, buf, s->buf_bit_size); + packet_sequence_number = get_bits(gb, 4); + int seekable_frame_in_packet = get_bits1(gb); + int spliced_packet = get_bits1(gb); + + /** get number of bits that need to be added to the previous frame */ + num_bits_prev_frame = get_bits(gb, s->log2_frame_size); + + /** check for packet loss */ + if (!s->packet_loss && + ((s->packet_sequence_number + 1) & 0xF) != packet_sequence_number) { + s->packet_loss = 1; + av_log(avctx, AV_LOG_ERROR, "Packet loss detected! seq %x vs %x\n", + s->packet_sequence_number, packet_sequence_number); + } + s->packet_sequence_number = packet_sequence_number; + + if (num_bits_prev_frame > 0) { + int remaining_packet_bits = s->buf_bit_size - get_bits_count(gb); + if (num_bits_prev_frame >= remaining_packet_bits) { + num_bits_prev_frame = remaining_packet_bits; + s->packet_done = 1; + } + + /** append the previous frame data to the remaining data from the + previous packet to create a full frame */ + save_bits(s, gb, num_bits_prev_frame, 1); + + /** decode the cross packet frame if it is valid */ + if (!s->packet_loss) + decode_frame(s); + } else if (s->num_saved_bits - s->frame_offset) { + dprintf(avctx, "ignoring %x previously saved bits\n", + s->num_saved_bits - s->frame_offset); + } + + if (s->packet_loss) { + /** reset number of saved bits so that the decoder + does not start to decode incomplete frames in the + s->len_prefix == 0 case */ + s->num_saved_bits = 0; + s->packet_loss = 0; + } + + } else { + int frame_size; + + s->buf_bit_size = (avpkt->size - s->next_packet_start) << 3; + init_get_bits(gb, avpkt->data, s->buf_bit_size); + skip_bits(gb, s->packet_offset); + + if (s->len_prefix && remaining_bits(s, gb) > s->log2_frame_size && + (frame_size = show_bits(gb, s->log2_frame_size)) && + frame_size <= remaining_bits(s, gb)) { + save_bits(s, gb, frame_size, 0); + s->packet_done = !decode_frame(s); + } else if (!s->len_prefix + && s->num_saved_bits > get_bits_count(&s->gb)) { + /** when the frames do not have a length prefix, we don't know + the compressed length of the individual frames + however, we know what part of a new packet belongs to the + previous frame + therefore we save the incoming packet first, then we append + the "previous frame" data from the next packet so that + we get a buffer that only contains full frames */ + s->packet_done = !decode_frame(s); + } else { + s->packet_done = 1; + } + } + + if (s->packet_done && !s->packet_loss && + remaining_bits(s, gb) > 0) { + /** save the rest of the data so that it can be decoded + with the next packet */ + save_bits(s, gb, remaining_bits(s, gb), 0); + } + + *data_size = 0; // (int8_t *)s->samples - (int8_t *)data; + s->packet_offset = get_bits_count(gb) & 7; + + return (s->packet_loss) ? AVERROR_INVALIDDATA : get_bits_count(gb) >> 3; +} + +/** + *@brief Clear decoder buffers (for seeking). + *@param avctx codec context + */ +static void flush(AVCodecContext *avctx) +{ + WmallDecodeCtx *s = avctx->priv_data; + int i; + /** reset output buffer as a part of it is used during the windowing of a + new frame */ + for (i = 0; i < s->num_channels; i++) + memset(s->channel[i].out, 0, s->samples_per_frame * + sizeof(*s->channel[i].out)); + s->packet_loss = 1; +} + + +/** + *@brief wmall decoder + */ +AVCodec ff_wmalossless_decoder = { + "wmalossless", + AVMEDIA_TYPE_AUDIO, + CODEC_ID_WMALOSSLESS, + sizeof(WmallDecodeCtx), + decode_init, + NULL, + decode_end, + decode_packet, + .capabilities = CODEC_CAP_SUBFRAMES | CODEC_CAP_EXPERIMENTAL, + .flush= flush, + .long_name = NULL_IF_CONFIG_SMALL("Windows Media Audio 9 Lossless"), +}; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/wmaprodec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/wmaprodec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/wmaprodec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/wmaprodec.c 2011-11-04 12:38:27.000000000 +0000 @@ -86,12 +86,14 @@ * subframe in order to reconstruct the output samples. */ +#include "libavutil/intreadwrite.h" #include "avcodec.h" #include "internal.h" #include "get_bits.h" #include "put_bits.h" #include "wmaprodata.h" #include "dsputil.h" +#include "fmtconvert.h" #include "sinewin.h" #include "wma.h" @@ -166,6 +168,7 @@ /* generic decoder variables */ AVCodecContext* avctx; ///< codec context for av_log DSPContext dsp; ///< accelerated DSP functions + FmtConvertContext fmt_conv; uint8_t frame_data[MAX_FRAMESIZE + FF_INPUT_BUFFER_PADDING_SIZE];///< compressed frame data PutBitContext pb; ///< context for filling the frame_data buffer @@ -279,6 +282,7 @@ s->avctx = avctx; dsputil_init(&s->dsp, avctx); + ff_fmt_convert_init(&s->fmt_conv, avctx); init_put_bits(&s->pb, s->frame_data, MAX_FRAMESIZE); avctx->sample_fmt = AV_SAMPLE_FMT_FLT; @@ -767,7 +771,7 @@ /* Integers 0..15 as single-precision floats. The table saves a costly int to float conversion, and storing the values as integers allows fast sign-flipping. */ - static const int fval_tab[16] = { + static const uint32_t fval_tab[16] = { 0x00000000, 0x3f800000, 0x40000000, 0x40400000, 0x40800000, 0x40a00000, 0x40c00000, 0x40e00000, 0x41000000, 0x41100000, 0x41200000, 0x41300000, @@ -799,7 +803,7 @@ 4 vector coded large values) */ while ((s->transmit_num_vec_coeffs || !rl_mode) && (cur_coeff + 3 < ci->num_vec_coeffs)) { - int vals[4]; + uint32_t vals[4]; int i; unsigned int idx; @@ -809,15 +813,15 @@ for (i = 0; i < 4; i += 2) { idx = get_vlc2(&s->gb, vec2_vlc.table, VLCBITS, VEC2MAXDEPTH); if (idx == HUFF_VEC2_SIZE - 1) { - int v0, v1; + uint32_t v0, v1; v0 = get_vlc2(&s->gb, vec1_vlc.table, VLCBITS, VEC1MAXDEPTH); if (v0 == HUFF_VEC1_SIZE - 1) v0 += ff_wma_get_large_val(&s->gb); v1 = get_vlc2(&s->gb, vec1_vlc.table, VLCBITS, VEC1MAXDEPTH); if (v1 == HUFF_VEC1_SIZE - 1) v1 += ff_wma_get_large_val(&s->gb); - ((float*)vals)[i ] = v0; - ((float*)vals)[i+1] = v1; + vals[i ] = ((av_alias32){ .f32 = v0 }).u32; + vals[i+1] = ((av_alias32){ .f32 = v1 }).u32; } else { vals[i] = fval_tab[symbol_to_vec2[idx] >> 4 ]; vals[i+1] = fval_tab[symbol_to_vec2[idx] & 0xF]; @@ -833,8 +837,8 @@ /** decode sign */ for (i = 0; i < 4; i++) { if (vals[i]) { - int sign = get_bits1(&s->gb) - 1; - *(uint32_t*)&ci->coeffs[cur_coeff] = vals[i] ^ sign<<31; + uint32_t sign = get_bits1(&s->gb) - 1; + AV_WN32A(&ci->coeffs[cur_coeff], vals[i] ^ sign << 31); num_zeros = 0; } else { ci->coeffs[cur_coeff] = 0; @@ -1281,6 +1285,7 @@ int more_frames = 0; int len = 0; int i; + const float *out_ptr[WMAPRO_MAX_CHANNELS]; /** check for potential output buffer overflow */ if (s->num_channels * s->samples_per_frame > s->samples_end - s->samples) { @@ -1356,18 +1361,12 @@ } /** interleave samples and write them to the output buffer */ - for (i = 0; i < s->num_channels; i++) { - float* ptr = s->samples + i; - int incr = s->num_channels; - float* iptr = s->channel[i].out; - float* iend = iptr + s->samples_per_frame; - - // FIXME should create/use a DSP function here - while (iptr < iend) { - *ptr = *iptr++; - ptr += incr; - } + for (i = 0; i < s->num_channels; i++) + out_ptr[i] = s->channel[i].out; + s->fmt_conv.float_interleave(s->samples, out_ptr, s->samples_per_frame, + s->num_channels); + for (i = 0; i < s->num_channels; i++) { /** reuse second half of the IMDCT output for the next frame */ memcpy(&s->channel[i].out[0], &s->channel[i].out[s->samples_per_frame], @@ -1446,14 +1445,14 @@ s->num_saved_bits += len; if (!append) { - ff_copy_bits(&s->pb, gb->buffer + (get_bits_count(gb) >> 3), + avpriv_copy_bits(&s->pb, gb->buffer + (get_bits_count(gb) >> 3), s->num_saved_bits); } else { int align = 8 - (get_bits_count(gb) & 7); align = FFMIN(align, len); put_bits(&s->pb, align, get_bits(gb, align)); len -= align; - ff_copy_bits(&s->pb, gb->buffer + (get_bits_count(gb) >> 3), len); + avpriv_copy_bits(&s->pb, gb->buffer + (get_bits_count(gb) >> 3), len); } skip_bits_long(gb, len); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/wmavoice.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/wmavoice.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/wmavoice.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/wmavoice.c 2011-11-04 12:38:27.000000000 +0000 @@ -1085,7 +1085,7 @@ int excl_range = s->aw_pulse_range; // always 16 or 24 uint16_t *use_mask_ptr = &use_mask[idx >> 4]; int first_sh = 16 - (idx & 15); - *use_mask_ptr++ &= 0xFFFF << first_sh; + *use_mask_ptr++ &= 0xFFFFu << first_sh; excl_range -= first_sh; if (excl_range >= 16) { *use_mask_ptr++ = 0; @@ -1730,7 +1730,7 @@ { WMAVoiceContext *s = ctx->priv_data; GetBitContext *gb = &s->gb, s_gb; - int n, res, n_samples = 480; + int n, res, out_size, n_samples = 480; double lsps[MAX_FRAMES][MAX_LSPS]; const double *mean_lsf = s->lsps == 16 ? wmavoice_mean_lsf16[s->lsp_def_mode] : wmavoice_mean_lsf10[s->lsp_def_mode]; @@ -1748,7 +1748,10 @@ s->sframe_cache_size = 0; } - if ((res = check_bits_for_superframe(gb, s)) == 1) return 1; + if ((res = check_bits_for_superframe(gb, s)) == 1) { + *data_size = 0; + return 1; + } /* First bit is speech/music bit, it differentiates between WMAVoice * speech samples (the actual codec) and WMAVoice music samples, which @@ -1789,6 +1792,14 @@ stabilize_lsps(lsps[n], s->lsps); } + out_size = n_samples * av_get_bytes_per_sample(ctx->sample_fmt); + if (*data_size < out_size) { + av_log(ctx, AV_LOG_ERROR, + "Output buffer too small (%d given - %zu needed)\n", + *data_size, out_size); + return -1; + } + /* Parse frames, optionally preceeded by per-frame (independent) LSPs. */ for (n = 0; n < 3; n++) { if (!s->has_residual_lsps) { @@ -1808,8 +1819,10 @@ &samples[n * MAX_FRAMESIZE], lsps[n], n == 0 ? s->prev_lsps : lsps[n - 1], &excitation[s->history_nsamples + n * MAX_FRAMESIZE], - &synth[s->lsps + n * MAX_FRAMESIZE]))) + &synth[s->lsps + n * MAX_FRAMESIZE]))) { + *data_size = 0; return res; + } } /* Statistics? FIXME - we don't check for length, a slight overrun @@ -1821,7 +1834,7 @@ } /* Specify nr. of output samples */ - *data_size = n_samples * sizeof(float); + *data_size = out_size; /* Update history */ memcpy(s->prev_lsps, lsps[2], @@ -1872,7 +1885,7 @@ * @param size size of the source data, in bytes * @param gb bit I/O context specifying the current position in the source. * data. This function might use this to align the bit position to - * a whole-byte boundary before calling #ff_copy_bits() on aligned + * a whole-byte boundary before calling #avpriv_copy_bits() on aligned * source data * @param nbits the amount of bits to copy from source to target * @@ -1893,7 +1906,7 @@ rmn_bits &= 7; rmn_bytes >>= 3; if ((rmn_bits = FFMIN(rmn_bits, nbits)) > 0) put_bits(pb, rmn_bits, get_bits(gb, rmn_bits)); - ff_copy_bits(pb, data + size - rmn_bytes, + avpriv_copy_bits(pb, data + size - rmn_bytes, FFMIN(nbits - rmn_bits, rmn_bytes << 3)); } @@ -1915,22 +1928,16 @@ GetBitContext *gb = &s->gb; int size, res, pos; - if (*data_size < 480 * sizeof(float)) { - av_log(ctx, AV_LOG_ERROR, - "Output buffer too small (%d given - %zu needed)\n", - *data_size, 480 * sizeof(float)); - return -1; - } - *data_size = 0; - /* Packets are sometimes a multiple of ctx->block_align, with a packet * header at each ctx->block_align bytes. However, FFmpeg's ASF demuxer * feeds us ASF packets, which may concatenate multiple "codec" packets * in a single "muxer" packet, so we artificially emulate that by * capping the packet size at ctx->block_align. */ for (size = avpkt->size; size > ctx->block_align; size -= ctx->block_align); - if (!size) + if (!size) { + *data_size = 0; return 0; + } init_get_bits(&s->gb, avpkt->data, size << 3); /* size == ctx->block_align is used to indicate whether we are dealing with diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/ac3dsp.asm ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/ac3dsp.asm --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/ac3dsp.asm 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/ac3dsp.asm 2011-11-04 12:38:27.000000000 +0000 @@ -19,8 +19,8 @@ ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** -%include "x86inc.asm" -%include "x86util.asm" +%include "libavutil/x86/x86inc.asm" +%include "libavutil/x86/x86util.asm" SECTION_RODATA diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/ac3dsp_mmx.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/ac3dsp_mmx.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/ac3dsp_mmx.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/ac3dsp_mmx.c 2011-11-04 12:38:27.000000000 +0000 @@ -50,9 +50,9 @@ av_cold void ff_ac3dsp_init_x86(AC3DSPContext *c, int bit_exact) { +#if HAVE_YASM int mm_flags = av_get_cpu_flags(); -#if HAVE_YASM if (mm_flags & AV_CPU_FLAG_MMX) { c->ac3_exponent_min = ff_ac3_exponent_min_mmx; c->ac3_max_msb_abs_int16 = ff_ac3_max_msb_abs_int16_mmx; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/dct32_sse.asm ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/dct32_sse.asm --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/dct32_sse.asm 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/dct32_sse.asm 2011-11-04 12:38:27.000000000 +0000 @@ -19,8 +19,8 @@ ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** -%include "x86inc.asm" -%include "x86util.asm" +%include "libavutil/x86/x86inc.asm" +%include "libavutil/x86/x86util.asm" SECTION_RODATA 32 diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/deinterlace.asm ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/deinterlace.asm --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/deinterlace.asm 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/deinterlace.asm 2011-11-04 12:38:27.000000000 +0000 @@ -20,8 +20,8 @@ ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** -%include "x86inc.asm" -%include "x86util.asm" +%include "libavutil/x86/x86inc.asm" +%include "libavutil/x86/x86util.asm" SECTION_RODATA diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/diracdsp_mmx.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/diracdsp_mmx.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/diracdsp_mmx.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/diracdsp_mmx.c 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2010 David Conrad + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "dsputil_mmx.h" +#include "diracdsp_mmx.h" + +void ff_put_rect_clamped_mmx(uint8_t *dst, int dst_stride, const int16_t *src, int src_stride, int width, int height); +void ff_put_rect_clamped_sse2(uint8_t *dst, int dst_stride, const int16_t *src, int src_stride, int width, int height); +void ff_put_signed_rect_clamped_mmx(uint8_t *dst, int dst_stride, const int16_t *src, int src_stride, int width, int height); +void ff_put_signed_rect_clamped_sse2(uint8_t *dst, int dst_stride, const int16_t *src, int src_stride, int width, int height); + +#define HPEL_FILTER(MMSIZE, EXT) \ + void ff_dirac_hpel_filter_v_ ## EXT(uint8_t *, uint8_t *, int, int); \ + void ff_dirac_hpel_filter_h_ ## EXT(uint8_t *, uint8_t *, int); \ + \ + static void dirac_hpel_filter_ ## EXT(uint8_t *dsth, uint8_t *dstv, uint8_t *dstc, \ + uint8_t *src, int stride, int width, int height) \ + { \ + while( height-- ) \ + { \ + ff_dirac_hpel_filter_v_ ## EXT(dstv-MMSIZE, src-MMSIZE, stride, width+MMSIZE+5); \ + ff_dirac_hpel_filter_h_ ## EXT(dsth, src, width); \ + ff_dirac_hpel_filter_h_ ## EXT(dstc, dstv, width); \ + \ + dsth += stride; \ + dstv += stride; \ + dstc += stride; \ + src += stride; \ + } \ + } + +#if !ARCH_X86_64 +HPEL_FILTER(8, mmx) +#endif +HPEL_FILTER(16, sse2) + +#define PIXFUNC(PFX, IDX, EXT) \ + /*MMXDISABLEDc->PFX ## _dirac_pixels_tab[0][IDX] = ff_ ## PFX ## _dirac_pixels8_ ## EXT;*/ \ + c->PFX ## _dirac_pixels_tab[1][IDX] = ff_ ## PFX ## _dirac_pixels16_ ## EXT; \ + c->PFX ## _dirac_pixels_tab[2][IDX] = ff_ ## PFX ## _dirac_pixels32_ ## EXT + +void ff_diracdsp_init_mmx(DiracDSPContext* c) +{ + int mm_flags = av_get_cpu_flags();; + +#if HAVE_YASM + c->add_dirac_obmc[0] = ff_add_dirac_obmc8_mmx; +#if !ARCH_X86_64 + c->add_dirac_obmc[1] = ff_add_dirac_obmc16_mmx; + c->add_dirac_obmc[2] = ff_add_dirac_obmc32_mmx; + c->dirac_hpel_filter = dirac_hpel_filter_mmx; + c->add_rect_clamped = ff_add_rect_clamped_mmx; + c->put_signed_rect_clamped = ff_put_signed_rect_clamped_mmx; +#endif +#endif + + PIXFUNC(put, 0, mmx); + PIXFUNC(avg, 0, mmx); + + if (mm_flags & AV_CPU_FLAG_MMX2) { + PIXFUNC(avg, 0, mmx2); + } + + if (mm_flags & AV_CPU_FLAG_SSE2) { +#if HAVE_YASM + c->dirac_hpel_filter = dirac_hpel_filter_sse2; + c->add_rect_clamped = ff_add_rect_clamped_sse2; + c->put_signed_rect_clamped = ff_put_signed_rect_clamped_sse2; + + c->add_dirac_obmc[1] = ff_add_dirac_obmc16_sse2; + c->add_dirac_obmc[2] = ff_add_dirac_obmc32_sse2; +#endif + c->put_dirac_pixels_tab[1][0] = ff_put_dirac_pixels16_sse2; + c->avg_dirac_pixels_tab[1][0] = ff_avg_dirac_pixels16_sse2; + c->put_dirac_pixels_tab[2][0] = ff_put_dirac_pixels32_sse2; + c->avg_dirac_pixels_tab[2][0] = ff_avg_dirac_pixels32_sse2; + } +} diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/diracdsp_mmx.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/diracdsp_mmx.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/diracdsp_mmx.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/diracdsp_mmx.h 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2010 David Conrad + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_X86_DIRACDSP_H +#define AVCODEC_X86_DIRACDSP_H + +#include "libavcodec/diracdsp.h" + +void ff_diracdsp_init_mmx(DiracDSPContext* c); + +DECL_DIRAC_PIXOP(put, mmx); +DECL_DIRAC_PIXOP(avg, mmx); +DECL_DIRAC_PIXOP(avg, mmx2); + +void ff_put_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h); +void ff_avg_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h); +void ff_put_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h); +void ff_avg_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h); + +void ff_add_rect_clamped_mmx(uint8_t *, const uint16_t *, int, const int16_t *, int, int, int); +void ff_add_rect_clamped_sse2(uint8_t *, const uint16_t *, int, const int16_t *, int, int, int); + +void ff_add_dirac_obmc8_mmx(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen); +void ff_add_dirac_obmc16_mmx(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen); +void ff_add_dirac_obmc32_mmx(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen); + +void ff_add_dirac_obmc16_sse2(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen); +void ff_add_dirac_obmc32_sse2(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen); + +#endif diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/diracdsp_yasm.asm ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/diracdsp_yasm.asm --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/diracdsp_yasm.asm 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/diracdsp_yasm.asm 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,260 @@ +;****************************************************************************** +;* Copyright (c) 2010 David Conrad +;* +;* This file is part of FFmpeg. +;* +;* FFmpeg is free software; you can redistribute it and/or +;* modify it under the terms of the GNU Lesser General Public +;* License as published by the Free Software Foundation; either +;* version 2.1 of the License, or (at your option) any later version. +;* +;* FFmpeg is distributed in the hope that it will be useful, +;* but WITHOUT ANY WARRANTY; without even the implied warranty of +;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;* Lesser General Public License for more details. +;* +;* You should have received a copy of the GNU Lesser General Public +;* License along with FFmpeg; if not, write to the Free Software +;* 51, Inc., Foundation Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;****************************************************************************** + +%include "x86inc.asm" + +SECTION_RODATA +pw_3: times 8 dw 3 +pw_7: times 8 dw 7 +pw_16: times 8 dw 16 +pw_32: times 8 dw 32 +pb_128: times 16 db 128 + +section .text + +%macro UNPACK_ADD 6 + mov%5 %1, %3 + mov%6 m5, %4 + mova m4, %1 + mova %2, m5 + punpcklbw %1, m7 + punpcklbw m5, m7 + punpckhbw m4, m7 + punpckhbw %2, m7 + paddw %1, m5 + paddw %2, m4 +%endmacro + +%macro HPEL_FILTER 1 +; dirac_hpel_filter_v_sse2(uint8_t *dst, uint8_t *src, int stride, int width); +cglobal dirac_hpel_filter_v_%1, 4,6,8, dst, src, stride, width, src0, stridex3 + mov src0q, srcq + lea stridex3q, [3*strideq] + sub src0q, stridex3q + pxor m7, m7 +.loop: + ; 7*(src[0] + src[1]) + UNPACK_ADD m0, m1, [srcq], [srcq + strideq], a,a + pmullw m0, [pw_7] + pmullw m1, [pw_7] + + ; 3*( ... + src[-2] + src[3]) + UNPACK_ADD m2, m3, [src0q + strideq], [srcq + stridex3q], a,a + paddw m0, m2 + paddw m1, m3 + pmullw m0, [pw_3] + pmullw m1, [pw_3] + + ; ... - 7*(src[-1] + src[2]) + UNPACK_ADD m2, m3, [src0q + strideq*2], [srcq + strideq*2], a,a + pmullw m2, [pw_7] + pmullw m3, [pw_7] + psubw m0, m2 + psubw m1, m3 + + ; ... - (src[-3] + src[4]) + UNPACK_ADD m2, m3, [src0q], [srcq + strideq*4], a,a + psubw m0, m2 + psubw m1, m3 + + paddw m0, [pw_16] + paddw m1, [pw_16] + psraw m0, 5 + psraw m1, 5 + packuswb m0, m1 + mova [dstq], m0 + add dstq, mmsize + add srcq, mmsize + add src0q, mmsize + sub widthd, mmsize + jg .loop + RET + +; dirac_hpel_filter_h_sse2(uint8_t *dst, uint8_t *src, int width); +cglobal dirac_hpel_filter_h_%1, 3,3,8, dst, src, width + dec widthd + pxor m7, m7 + and widthd, ~(mmsize-1) +.loop: + ; 7*(src[0] + src[1]) + UNPACK_ADD m0, m1, [srcq + widthq], [srcq + widthq + 1], u,u + pmullw m0, [pw_7] + pmullw m1, [pw_7] + + ; 3*( ... + src[-2] + src[3]) + UNPACK_ADD m2, m3, [srcq + widthq - 2], [srcq + widthq + 3], u,u + paddw m0, m2 + paddw m1, m3 + pmullw m0, [pw_3] + pmullw m1, [pw_3] + + ; ... - 7*(src[-1] + src[2]) + UNPACK_ADD m2, m3, [srcq + widthq - 1], [srcq + widthq + 2], u,u + pmullw m2, [pw_7] + pmullw m3, [pw_7] + psubw m0, m2 + psubw m1, m3 + + ; ... - (src[-3] + src[4]) + UNPACK_ADD m2, m3, [srcq + widthq - 3], [srcq + widthq + 4], u,u + psubw m0, m2 + psubw m1, m3 + + paddw m0, [pw_16] + paddw m1, [pw_16] + psraw m0, 5 + psraw m1, 5 + packuswb m0, m1 + mova [dstq + widthq], m0 + sub widthd, mmsize + jge .loop + RET +%endmacro + +%macro PUT_RECT 1 +; void put_rect_clamped(uint8_t *dst, int dst_stride, int16_t *src, int src_stride, int width, int height) +cglobal put_signed_rect_clamped_%1, 5,7,3, dst, dst_stride, src, src_stride, w, dst2, src2 + mova m0, [pb_128] + add wd, (mmsize-1) + and wd, ~(mmsize-1) + +%ifdef ARCH_X86_64 + mov r10d, r5m + mov r11d, wd + %define wspill r11d + %define hd r10d +%else + mov r4m, wd + %define wspill r4m + %define hd r5mp +%endif + +.loopy + lea src2q, [srcq+src_strideq*2] + lea dst2q, [dstq+dst_strideq] +.loopx: + sub wd, mmsize + mova m1, [srcq +2*wq] + mova m2, [src2q+2*wq] + packsswb m1, [srcq +2*wq+mmsize] + packsswb m2, [src2q+2*wq+mmsize] + paddb m1, m0 + paddb m2, m0 + mova [dstq +wq], m1 + mova [dst2q+wq], m2 + jg .loopx + + lea srcq, [srcq+src_strideq*4] + lea dstq, [dstq+dst_strideq*2] + sub hd, 2 + mov wd, wspill + jg .loopy + RET +%endm + +%macro ADD_RECT 1 +; void add_rect_clamped(uint8_t *dst, uint16_t *src, int stride, int16_t *idwt, int idwt_stride, int width, int height) +cglobal add_rect_clamped_%1, 7,7,3, dst, src, stride, idwt, idwt_stride, w, h + mova m0, [pw_32] + add wd, (mmsize-1) + and wd, ~(mmsize-1) + +%ifdef ARCH_X86_64 + mov r11d, wd + %define wspill r11d +%else + mov r5m, wd + %define wspill r5m +%endif + +.loop: + sub wd, mmsize + movu m1, [srcq +2*wq] ; FIXME: ensure alignment + paddw m1, m0 + psraw m1, 6 + movu m2, [srcq +2*wq+mmsize] ; FIXME: ensure alignment + paddw m2, m0 + psraw m2, 6 + paddw m1, [idwtq+2*wq] + paddw m2, [idwtq+2*wq+mmsize] + packuswb m1, m2 + mova [dstq +wq], m1 + jg .loop + + lea srcq, [srcq + 2*strideq] + add dstq, strideq + lea idwtq, [idwtq+ 2*idwt_strideq] + sub hd, 1 + mov wd, wspill + jg .loop + RET +%endm + +%macro ADD_OBMC 2 +; void add_obmc(uint16_t *dst, uint8_t *src, int stride, uint8_t *obmc_weight, int yblen) +cglobal add_dirac_obmc%1_%2, 6,6,5, dst, src, stride, obmc, yblen + pxor m4, m4 +.loop: +%assign i 0 +%rep %1 / mmsize + mova m0, [srcq+i] + mova m1, m0 + punpcklbw m0, m4 + punpckhbw m1, m4 + mova m2, [obmcq+i] + mova m3, m2 + punpcklbw m2, m4 + punpckhbw m3, m4 + pmullw m0, m2 + pmullw m1, m3 + mova m2, [dstq+2*i] + mova m3, [dstq+2*i+mmsize] + paddw m0, m2 + paddw m1, m3 + mova [dstq+2*i], m0 + mova [dstq+2*i+mmsize], m1 +%assign i i+mmsize +%endrep + lea srcq, [srcq+strideq] + lea dstq, [dstq+2*strideq] + add obmcq, 32 + sub yblend, 1 + jg .loop + RET +%endm + +INIT_MMX +%ifndef ARCH_X86_64 +PUT_RECT mmx +ADD_RECT mmx + +HPEL_FILTER mmx +ADD_OBMC 32, mmx +ADD_OBMC 16, mmx +%endif +ADD_OBMC 8, mmx + +INIT_XMM +PUT_RECT sse2 +ADD_RECT sse2 + +HPEL_FILTER sse2 +ADD_OBMC 32, sse2 +ADD_OBMC 16, sse2 diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/dsputilenc_yasm.asm ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/dsputilenc_yasm.asm --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/dsputilenc_yasm.asm 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/dsputilenc_yasm.asm 2011-11-04 12:38:27.000000000 +0000 @@ -21,8 +21,8 @@ ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;***************************************************************************** -%include "x86inc.asm" -%include "x86util.asm" +%include "libavutil/x86/x86inc.asm" +%include "libavutil/x86/x86util.asm" SECTION .text diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/dsputil_mmx.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/dsputil_mmx.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/dsputil_mmx.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/dsputil_mmx.c 2011-11-04 12:38:27.000000000 +0000 @@ -31,6 +31,7 @@ #include "libavcodec/ac3dec.h" #include "dsputil_mmx.h" #include "idct_xvid.h" +#include "diracdsp_mmx.h" //#undef NDEBUG //#include @@ -64,6 +65,8 @@ DECLARE_ALIGNED(8, const uint64_t, ff_pw_96 ) = 0x0060006000600060ULL; DECLARE_ALIGNED(8, const uint64_t, ff_pw_128) = 0x0080008000800080ULL; DECLARE_ALIGNED(8, const uint64_t, ff_pw_255) = 0x00ff00ff00ff00ffULL; +DECLARE_ALIGNED(16, const xmm_reg, ff_pw_512) = {0x0200020002000200ULL, 0x0200020002000200ULL}; +DECLARE_ALIGNED(16, const xmm_reg, ff_pw_1019)= {0x03FB03FB03FB03FBULL, 0x03FB03FB03FB03FBULL}; DECLARE_ALIGNED(16, const xmm_reg, ff_pb_0 ) = {0x0000000000000000ULL, 0x0000000000000000ULL}; DECLARE_ALIGNED(16, const xmm_reg, ff_pb_1 ) = {0x0101010101010101ULL, 0x0101010101010101ULL}; @@ -1862,6 +1865,84 @@ avg_pixels8_mmx2(dst, src, stride, 8); } +/* only used in VP3/5/6 */ +static void put_vp_no_rnd_pixels8_l2_mmx(uint8_t *dst, const uint8_t *a, const uint8_t *b, int stride, int h) +{ +// START_TIMER + MOVQ_BFE(mm6); + __asm__ volatile( + "1: \n\t" + "movq (%1), %%mm0 \n\t" + "movq (%2), %%mm1 \n\t" + "movq (%1,%4), %%mm2 \n\t" + "movq (%2,%4), %%mm3 \n\t" + PAVGBP_MMX_NO_RND(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5) + "movq %%mm4, (%3) \n\t" + "movq %%mm5, (%3,%4) \n\t" + + "movq (%1,%4,2), %%mm0 \n\t" + "movq (%2,%4,2), %%mm1 \n\t" + "movq (%1,%5), %%mm2 \n\t" + "movq (%2,%5), %%mm3 \n\t" + "lea (%1,%4,4), %1 \n\t" + "lea (%2,%4,4), %2 \n\t" + PAVGBP_MMX_NO_RND(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5) + "movq %%mm4, (%3,%4,2) \n\t" + "movq %%mm5, (%3,%5) \n\t" + "lea (%3,%4,4), %3 \n\t" + "subl $4, %0 \n\t" + "jnz 1b \n\t" + :"+r"(h), "+r"(a), "+r"(b), "+r"(dst) + :"r"((x86_reg)stride), "r"((x86_reg)3L*stride) + :"memory"); +// STOP_TIMER("put_vp_no_rnd_pixels8_l2_mmx") +} +static void put_vp_no_rnd_pixels16_l2_mmx(uint8_t *dst, const uint8_t *a, const uint8_t *b, int stride, int h) +{ + put_vp_no_rnd_pixels8_l2_mmx(dst, a, b, stride, h); + put_vp_no_rnd_pixels8_l2_mmx(dst+8, a+8, b+8, stride, h); +} + +#if CONFIG_DIRAC_DECODER +#define DIRAC_PIXOP(OPNAME, EXT)\ +void ff_ ## OPNAME ## _dirac_pixels8_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h)\ +{\ + OPNAME ## _pixels8_ ## EXT(dst, src[0], stride, h);\ +}\ +void ff_ ## OPNAME ## _dirac_pixels16_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h)\ +{\ + OPNAME ## _pixels16_ ## EXT(dst, src[0], stride, h);\ +}\ +void ff_ ## OPNAME ## _dirac_pixels32_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h)\ +{\ + OPNAME ## _pixels16_ ## EXT(dst , src[0] , stride, h);\ + OPNAME ## _pixels16_ ## EXT(dst+16, src[0]+16, stride, h);\ +} + +DIRAC_PIXOP(put, mmx) +DIRAC_PIXOP(avg, mmx) +DIRAC_PIXOP(avg, mmx2) + +void ff_put_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h) +{ + put_pixels16_sse2(dst, src[0], stride, h); +} +void ff_avg_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h) +{ + avg_pixels16_sse2(dst, src[0], stride, h); +} +void ff_put_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h) +{ + put_pixels16_sse2(dst , src[0] , stride, h); + put_pixels16_sse2(dst+16, src[0]+16, stride, h); +} +void ff_avg_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h) +{ + avg_pixels16_sse2(dst , src[0] , stride, h); + avg_pixels16_sse2(dst+16, src[0]+16, stride, h); +} +#endif + /* XXX: those functions should be suppressed ASAP when all IDCTs are converted */ #if CONFIG_GPL @@ -2453,6 +2534,9 @@ if (!high_bit_depth) c->draw_edges = draw_edges_mmx; + c->put_no_rnd_pixels_l2[0]= put_vp_no_rnd_pixels16_l2_mmx; + c->put_no_rnd_pixels_l2[1]= put_vp_no_rnd_pixels8_l2_mmx; + if (CONFIG_H263_DECODER || CONFIG_H263_ENCODER) { c->h263_v_loop_filter= h263_v_loop_filter_mmx; c->h263_h_loop_filter= h263_h_loop_filter_mmx; @@ -2664,18 +2748,18 @@ } if(mm_flags & AV_CPU_FLAG_SSE2){ if (!high_bit_depth) { - H264_QPEL_FUNCS(0, 1, sse2); - H264_QPEL_FUNCS(0, 2, sse2); - H264_QPEL_FUNCS(0, 3, sse2); - H264_QPEL_FUNCS(1, 1, sse2); - H264_QPEL_FUNCS(1, 2, sse2); - H264_QPEL_FUNCS(1, 3, sse2); - H264_QPEL_FUNCS(2, 1, sse2); - H264_QPEL_FUNCS(2, 2, sse2); - H264_QPEL_FUNCS(2, 3, sse2); - H264_QPEL_FUNCS(3, 1, sse2); - H264_QPEL_FUNCS(3, 2, sse2); - H264_QPEL_FUNCS(3, 3, sse2); + H264_QPEL_FUNCS(0, 1, sse2); + H264_QPEL_FUNCS(0, 2, sse2); + H264_QPEL_FUNCS(0, 3, sse2); + H264_QPEL_FUNCS(1, 1, sse2); + H264_QPEL_FUNCS(1, 2, sse2); + H264_QPEL_FUNCS(1, 3, sse2); + H264_QPEL_FUNCS(2, 1, sse2); + H264_QPEL_FUNCS(2, 2, sse2); + H264_QPEL_FUNCS(2, 3, sse2); + H264_QPEL_FUNCS(3, 1, sse2); + H264_QPEL_FUNCS(3, 2, sse2); + H264_QPEL_FUNCS(3, 3, sse2); } #if HAVE_YASM #define H264_QPEL_FUNCS_10(x, y, CPU)\ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/dsputil_yasm.asm ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/dsputil_yasm.asm --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/dsputil_yasm.asm 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/dsputil_yasm.asm 2011-11-04 12:38:27.000000000 +0000 @@ -19,7 +19,7 @@ ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** -%include "x86inc.asm" +%include "libavutil/x86/x86inc.asm" %include "x86util.asm" SECTION_RODATA @@ -1055,14 +1055,6 @@ ; int32_t max, unsigned int len) ;----------------------------------------------------------------------------- -%macro SPLATD_MMX 1 - punpckldq %1, %1 -%endmacro - -%macro SPLATD_SSE2 1 - pshufd %1, %1, 0 -%endmacro - %macro VECTOR_CLIP_INT32 4 cglobal vector_clip_int32_%1, 5,5,%2, dst, src, min, max, len %ifidn %1, sse2 diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/dwt.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/dwt.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/dwt.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/dwt.c 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,202 @@ +/* + * MMX optimized discrete wavelet transform + * Copyright (c) 2002-2004 Michael Niedermayer + * Copyright (c) 2010 David Conrad + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/x86_cpu.h" +#include "dsputil_mmx.h" +#include "dwt.h" + +#define COMPOSE_VERTICAL(ext, align) \ +void ff_vertical_compose53iL0##ext(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width); \ +void ff_vertical_compose_dirac53iH0##ext(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width); \ +void ff_vertical_compose_dd137iL0##ext(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, IDWTELEM *b3, IDWTELEM *b4, int width); \ +void ff_vertical_compose_dd97iH0##ext(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, IDWTELEM *b3, IDWTELEM *b4, int width); \ +void ff_vertical_compose_haar##ext(IDWTELEM *b0, IDWTELEM *b1, int width); \ +void ff_horizontal_compose_haar0i##ext(IDWTELEM *b, IDWTELEM *tmp, int w);\ +void ff_horizontal_compose_haar1i##ext(IDWTELEM *b, IDWTELEM *tmp, int w);\ +\ +static void vertical_compose53iL0##ext(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width) \ +{ \ + int i, width_align = width&~(align-1); \ +\ + for(i=width_align; i>1;\ + int x= w2 - (w2&(align-1));\ + ff_horizontal_compose_haar0i##ext(b, tmp, w);\ +\ + for (; x < w2; x++) {\ + b[2*x ] = tmp[x];\ + b[2*x+1] = COMPOSE_HAARiH0(b[x+w2], tmp[x]);\ + }\ +}\ +static void horizontal_compose_haar1i##ext(IDWTELEM *b, IDWTELEM *tmp, int w)\ +{\ + int w2= w>>1;\ + int x= w2 - (w2&(align-1));\ + ff_horizontal_compose_haar1i##ext(b, tmp, w);\ +\ + for (; x < w2; x++) {\ + b[2*x ] = (tmp[x] + 1)>>1;\ + b[2*x+1] = (COMPOSE_HAARiH0(b[x+w2], tmp[x]) + 1)>>1;\ + }\ +}\ +\ + +#if HAVE_YASM +#if !ARCH_X86_64 +COMPOSE_VERTICAL(_mmx, 4) +#endif +COMPOSE_VERTICAL(_sse2, 8) +#endif + + +void ff_horizontal_compose_dd97i_ssse3(IDWTELEM *b, IDWTELEM *tmp, int w); + +static void horizontal_compose_dd97i_ssse3(IDWTELEM *b, IDWTELEM *tmp, int w) +{ + int w2= w>>1; + int x= w2 - (w2&7); + ff_horizontal_compose_dd97i_ssse3(b, tmp, w); + + for (; x < w2; x++) { + b[2*x ] = (tmp[x] + 1)>>1; + b[2*x+1] = (COMPOSE_DD97iH0(tmp[x-1], tmp[x], b[x+w2], tmp[x+1], tmp[x+2]) + 1)>>1; + } +} + +void ff_spatial_idwt_init_mmx(DWTContext *d, enum dwt_type type) +{ +#if HAVE_YASM + int mm_flags = av_get_cpu_flags();; + +#if !ARCH_X86_64 + if (!(mm_flags & AV_CPU_FLAG_MMX)) + return; + + switch (type) { + case DWT_DIRAC_DD9_7: + d->vertical_compose_l0 = vertical_compose53iL0_mmx; + d->vertical_compose_h0 = vertical_compose_dd97iH0_mmx; + break; + case DWT_DIRAC_LEGALL5_3: + d->vertical_compose_l0 = vertical_compose53iL0_mmx; + d->vertical_compose_h0 = vertical_compose_dirac53iH0_mmx; + break; + case DWT_DIRAC_DD13_7: + d->vertical_compose_l0 = vertical_compose_dd137iL0_mmx; + d->vertical_compose_h0 = vertical_compose_dd97iH0_mmx; + break; + case DWT_DIRAC_HAAR0: + d->vertical_compose = vertical_compose_haar_mmx; + d->horizontal_compose = horizontal_compose_haar0i_mmx; + break; + case DWT_DIRAC_HAAR1: + d->vertical_compose = vertical_compose_haar_mmx; + d->horizontal_compose = horizontal_compose_haar1i_mmx; + break; + } +#endif + + if (!(mm_flags & AV_CPU_FLAG_SSE2)) + return; + + switch (type) { + case DWT_DIRAC_DD9_7: + d->vertical_compose_l0 = vertical_compose53iL0_sse2; + d->vertical_compose_h0 = vertical_compose_dd97iH0_sse2; + break; + case DWT_DIRAC_LEGALL5_3: + d->vertical_compose_l0 = vertical_compose53iL0_sse2; + d->vertical_compose_h0 = vertical_compose_dirac53iH0_sse2; + break; + case DWT_DIRAC_DD13_7: + d->vertical_compose_l0 = vertical_compose_dd137iL0_sse2; + d->vertical_compose_h0 = vertical_compose_dd97iH0_sse2; + break; + case DWT_DIRAC_HAAR0: + d->vertical_compose = vertical_compose_haar_sse2; + d->horizontal_compose = horizontal_compose_haar0i_sse2; + break; + case DWT_DIRAC_HAAR1: + d->vertical_compose = vertical_compose_haar_sse2; + d->horizontal_compose = horizontal_compose_haar1i_sse2; + break; + } + + if (!(mm_flags & AV_CPU_FLAG_SSSE3)) + return; + + switch (type) { + case DWT_DIRAC_DD9_7: + d->horizontal_compose = horizontal_compose_dd97i_ssse3; + break; + } +#endif // HAVE_YASM +} diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/dwt.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/dwt.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/dwt.h 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/dwt.h 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,30 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_X86_DWT_H +#define AVCODEC_X86_DWT_H + +#include "libavcodec/dwt.h" + +void ff_horizontal_compose_dd97i_end_c(IDWTELEM *b, IDWTELEM *tmp, int w2, int x); +void ff_horizontal_compose_haar1i_end_c(IDWTELEM *b, IDWTELEM *tmp, int w2, int x); +void ff_horizontal_compose_haar0i_end_c(IDWTELEM *b, IDWTELEM *tmp, int w2, int x); + +void ff_spatial_idwt_init_mmx(DWTContext *d, enum dwt_type type); + +#endif diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/dwt_yasm.asm ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/dwt_yasm.asm --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/dwt_yasm.asm 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/dwt_yasm.asm 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,291 @@ +;****************************************************************************** +;* MMX optimized discrete wavelet trasnform +;* Copyright (c) 2010 David Conrad +;* +;* This file is part of FFmpeg. +;* +;* FFmpeg is free software; you can redistribute it and/or +;* modify it under the terms of the GNU Lesser General Public +;* License as published by the Free Software Foundation; either +;* version 2.1 of the License, or (at your option) any later version. +;* +;* FFmpeg is distributed in the hope that it will be useful, +;* but WITHOUT ANY WARRANTY; without even the implied warranty of +;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;* Lesser General Public License for more details. +;* +;* You should have received a copy of the GNU Lesser General Public +;* License along with FFmpeg; if not, write to the Free Software +;* 51, Inc., Foundation Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;****************************************************************************** + +%include "x86inc.asm" + +SECTION_RODATA +pw_1: times 8 dw 1 +pw_2: times 8 dw 2 +pw_8: times 8 dw 8 +pw_16: times 8 dw 16 +pw_1991: times 4 dw 9,-1 + +section .text + +; %1 -= (%2 + %3 + 2)>>2 %4 is pw_2 +%macro COMPOSE_53iL0 4 + paddw %2, %3 + paddw %2, %4 + psraw %2, 2 + psubw %1, %2 +%endm + +; m1 = %1 + (-m0 + 9*m1 + 9*%2 -%3 + 8)>>4 +; if %4 is supplied, %1 is loaded unaligned from there +; m2: clobbered m3: pw_8 m4: pw_1991 +%macro COMPOSE_DD97iH0 3-4 + paddw m0, %3 + paddw m1, %2 + psubw m0, m3 + mova m2, m1 + punpcklwd m1, m0 + punpckhwd m2, m0 + pmaddwd m1, m4 + pmaddwd m2, m4 +%if %0 > 3 + movu %1, %4 +%endif + psrad m1, 4 + psrad m2, 4 + packssdw m1, m2 + paddw m1, %1 +%endm + +%macro COMPOSE_VERTICAL 1 +; void vertical_compose53iL0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, +; int width) +cglobal vertical_compose53iL0_%1, 4,4,1, b0, b1, b2, width + mova m2, [pw_2] +.loop: + sub widthd, mmsize/2 + mova m1, [b0q+2*widthq] + mova m0, [b1q+2*widthq] + COMPOSE_53iL0 m0, m1, [b2q+2*widthq], m2 + mova [b1q+2*widthq], m0 + jg .loop + REP_RET + +; void vertical_compose_dirac53iH0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, +; int width) +cglobal vertical_compose_dirac53iH0_%1, 4,4,1, b0, b1, b2, width + mova m1, [pw_1] +.loop: + sub widthd, mmsize/2 + mova m0, [b0q+2*widthq] + paddw m0, [b2q+2*widthq] + paddw m0, m1 + psraw m0, 1 + paddw m0, [b1q+2*widthq] + mova [b1q+2*widthq], m0 + jg .loop + REP_RET + +; void vertical_compose_dd97iH0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, +; IDWTELEM *b3, IDWTELEM *b4, int width) +cglobal vertical_compose_dd97iH0_%1, 6,6,5, b0, b1, b2, b3, b4, width + mova m3, [pw_8] + mova m4, [pw_1991] +.loop: + sub widthd, mmsize/2 + mova m0, [b0q+2*widthq] + mova m1, [b1q+2*widthq] + COMPOSE_DD97iH0 [b2q+2*widthq], [b3q+2*widthq], [b4q+2*widthq] + mova [b2q+2*widthq], m1 + jg .loop + REP_RET + +; void vertical_compose_dd137iL0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, +; IDWTELEM *b3, IDWTELEM *b4, int width) +cglobal vertical_compose_dd137iL0_%1, 6,6,6, b0, b1, b2, b3, b4, width + mova m3, [pw_16] + mova m4, [pw_1991] +.loop: + sub widthd, mmsize/2 + mova m0, [b0q+2*widthq] + mova m1, [b1q+2*widthq] + mova m5, [b2q+2*widthq] + paddw m0, [b4q+2*widthq] + paddw m1, [b3q+2*widthq] + psubw m0, m3 + mova m2, m1 + punpcklwd m1, m0 + punpckhwd m2, m0 + pmaddwd m1, m4 + pmaddwd m2, m4 + psrad m1, 5 + psrad m2, 5 + packssdw m1, m2 + psubw m5, m1 + mova [b2q+2*widthq], m5 + jg .loop + REP_RET + +; void vertical_compose_haar(IDWTELEM *b0, IDWTELEM *b1, int width) +cglobal vertical_compose_haar_%1, 3,4,3, b0, b1, width + mova m3, [pw_1] +.loop: + sub widthd, mmsize/2 + mova m1, [b1q+2*widthq] + mova m0, [b0q+2*widthq] + mova m2, m1 + paddw m1, m3 + psraw m1, 1 + psubw m0, m1 + mova [b0q+2*widthq], m0 + paddw m2, m0 + mova [b1q+2*widthq], m2 + jg .loop + REP_RET +%endmacro + +; extend the left and right edges of the tmp array by %1 and %2 respectively +%macro EDGE_EXTENSION 3 + mov %3, [tmpq] +%assign %%i 1 +%rep %1 + mov [tmpq-2*%%i], %3 + %assign %%i %%i+1 +%endrep + mov %3, [tmpq+2*w2q-2] +%assign %%i 0 +%rep %2 + mov [tmpq+2*w2q+2*%%i], %3 + %assign %%i %%i+1 +%endrep +%endmacro + + +%macro HAAR_HORIZONTAL 2 +; void horizontal_compose_haari(IDWTELEM *b, IDWTELEM *tmp, int width) +cglobal horizontal_compose_haar%2i_%1, 3,6,4, b, tmp, w, x, w2, b_w2 + mov w2d, wd + xor xq, xq + shr w2d, 1 + lea b_w2q, [bq+wq] + mova m3, [pw_1] +.lowpass_loop: + movu m1, [b_w2q + 2*xq] + mova m0, [bq + 2*xq] + paddw m1, m3 + psraw m1, 1 + psubw m0, m1 + mova [tmpq + 2*xq], m0 + add xq, mmsize/2 + cmp xq, w2q + jl .lowpass_loop + + xor xq, xq + and w2q, ~(mmsize/2 - 1) + cmp w2q, mmsize/2 + jl .end + +.highpass_loop: + movu m1, [b_w2q + 2*xq] + mova m0, [tmpq + 2*xq] + paddw m1, m0 + + ; shift and interleave +%if %2 == 1 + paddw m0, m3 + paddw m1, m3 + psraw m0, 1 + psraw m1, 1 +%endif + mova m2, m0 + punpcklwd m0, m1 + punpckhwd m2, m1 + mova [bq+4*xq], m0 + mova [bq+4*xq+mmsize], m2 + + add xq, mmsize/2 + cmp xq, w2q + jl .highpass_loop +.end: + REP_RET +%endmacro + + +INIT_XMM +; void horizontal_compose_dd97i(IDWTELEM *b, IDWTELEM *tmp, int width) +cglobal horizontal_compose_dd97i_ssse3, 3,6,8, b, tmp, w, x, w2, b_w2 + mov w2d, wd + xor xd, xd + shr w2d, 1 + lea b_w2q, [bq+wq] + movu m4, [bq+wq] + mova m7, [pw_2] + pslldq m4, 14 +.lowpass_loop: + movu m1, [b_w2q + 2*xq] + mova m0, [bq + 2*xq] + mova m2, m1 + palignr m1, m4, 14 + mova m4, m2 + COMPOSE_53iL0 m0, m1, m2, m7 + mova [tmpq + 2*xq], m0 + add xd, mmsize/2 + cmp xd, w2d + jl .lowpass_loop + + EDGE_EXTENSION 1, 2, xw + ; leave the last up to 7 (sse) or 3 (mmx) values for C + xor xd, xd + and w2d, ~(mmsize/2 - 1) + cmp w2d, mmsize/2 + jl .end + + mova m7, [tmpq-mmsize] + mova m0, [tmpq] + mova m5, [pw_1] + mova m3, [pw_8] + mova m4, [pw_1991] +.highpass_loop: + mova m6, m0 + palignr m0, m7, 14 + mova m7, [tmpq + 2*xq + 16] + mova m1, m7 + mova m2, m7 + palignr m1, m6, 2 + palignr m2, m6, 4 + COMPOSE_DD97iH0 m0, m6, m2, [b_w2q + 2*xq] + mova m0, m7 + mova m7, m6 + + ; shift and interleave + paddw m6, m5 + paddw m1, m5 + psraw m6, 1 + psraw m1, 1 + mova m2, m6 + punpcklwd m6, m1 + punpckhwd m2, m1 + mova [bq+4*xq], m6 + mova [bq+4*xq+mmsize], m2 + + add xd, mmsize/2 + cmp xd, w2d + jl .highpass_loop +.end: + REP_RET + + +%ifndef ARCH_X86_64 +INIT_MMX +COMPOSE_VERTICAL mmx +HAAR_HORIZONTAL mmx, 0 +HAAR_HORIZONTAL mmx, 1 +%endif + +;;INIT_XMM +INIT_XMM +COMPOSE_VERTICAL sse2 +HAAR_HORIZONTAL sse2, 0 +HAAR_HORIZONTAL sse2, 1 diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/fft_mmx.asm ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/fft_mmx.asm --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/fft_mmx.asm 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/fft_mmx.asm 2011-11-04 12:38:27.000000000 +0000 @@ -28,7 +28,7 @@ ; in blocks as conventient to the vector size. ; i.e. {4x real, 4x imaginary, 4x real, ...} (or 2x respectively) -%include "x86inc.asm" +%include "libavutil/x86/x86inc.asm" %ifdef ARCH_X86_64 %define pointer resq diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/fmtconvert.asm ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/fmtconvert.asm --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/fmtconvert.asm 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/fmtconvert.asm 2011-11-04 12:38:27.000000000 +0000 @@ -19,11 +19,155 @@ ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** -%include "x86inc.asm" -%include "x86util.asm" +%include "libavutil/x86/x86inc.asm" +%include "libavutil/x86/x86util.asm" SECTION_TEXT +;--------------------------------------------------------------------------------- +; void int32_to_float_fmul_scalar(float *dst, const int *src, float mul, int len); +;--------------------------------------------------------------------------------- +%macro INT32_TO_FLOAT_FMUL_SCALAR 2 +%ifdef UNIX64 +cglobal int32_to_float_fmul_scalar_%1, 3,3,%2, dst, src, len +%else +cglobal int32_to_float_fmul_scalar_%1, 4,4,%2, dst, src, mul, len +%endif +%ifdef WIN64 + SWAP 0, 2 +%elifdef ARCH_X86_32 + movss m0, mulm +%endif + SPLATD m0 + shl lenq, 2 + add srcq, lenq + add dstq, lenq + neg lenq +.loop: +%ifidn %1, sse2 + cvtdq2ps m1, [srcq+lenq ] + cvtdq2ps m2, [srcq+lenq+16] +%else + cvtpi2ps m1, [srcq+lenq ] + cvtpi2ps m3, [srcq+lenq+ 8] + cvtpi2ps m2, [srcq+lenq+16] + cvtpi2ps m4, [srcq+lenq+24] + movlhps m1, m3 + movlhps m2, m4 +%endif + mulps m1, m0 + mulps m2, m0 + mova [dstq+lenq ], m1 + mova [dstq+lenq+16], m2 + add lenq, 32 + jl .loop + REP_RET +%endmacro + +INIT_XMM +%define SPLATD SPLATD_SSE +%define movdqa movaps +INT32_TO_FLOAT_FMUL_SCALAR sse, 5 +%undef movdqa +%define SPLATD SPLATD_SSE2 +INT32_TO_FLOAT_FMUL_SCALAR sse2, 3 +%undef SPLATD + + +;------------------------------------------------------------------------------ +; void ff_float_to_int16(int16_t *dst, const float *src, long len); +;------------------------------------------------------------------------------ +%macro FLOAT_TO_INT16 2 +cglobal float_to_int16_%1, 3,3,%2, dst, src, len + add lenq, lenq + lea srcq, [srcq+2*lenq] + add dstq, lenq + neg lenq +.loop: +%ifidn %1, sse2 + cvtps2dq m0, [srcq+2*lenq ] + cvtps2dq m1, [srcq+2*lenq+16] + packssdw m0, m1 + mova [dstq+lenq], m0 +%else + cvtps2pi m0, [srcq+2*lenq ] + cvtps2pi m1, [srcq+2*lenq+ 8] + cvtps2pi m2, [srcq+2*lenq+16] + cvtps2pi m3, [srcq+2*lenq+24] + packssdw m0, m1 + packssdw m2, m3 + mova [dstq+lenq ], m0 + mova [dstq+lenq+8], m2 +%endif + add lenq, 16 + js .loop +%ifnidn %1, sse2 + emms +%endif + REP_RET +%endmacro + +INIT_XMM +FLOAT_TO_INT16 sse2, 2 +INIT_MMX +FLOAT_TO_INT16 sse, 0 +%define cvtps2pi pf2id +FLOAT_TO_INT16 3dnow, 0 +%undef cvtps2pi + + +;------------------------------------------------------------------------------- +; void ff_float_to_int16_interleave2(int16_t *dst, const float **src, long len); +;------------------------------------------------------------------------------- +%macro FLOAT_TO_INT16_INTERLEAVE2 1 +cglobal float_to_int16_interleave2_%1, 3,4,2, dst, src0, src1, len + lea lenq, [4*r2q] + mov src1q, [src0q+gprsize] + mov src0q, [src0q] + add dstq, lenq + add src0q, lenq + add src1q, lenq + neg lenq +.loop: +%ifidn %1, sse2 + cvtps2dq m0, [src0q+lenq] + cvtps2dq m1, [src1q+lenq] + packssdw m0, m1 + movhlps m1, m0 + punpcklwd m0, m1 + mova [dstq+lenq], m0 +%else + cvtps2pi m0, [src0q+lenq ] + cvtps2pi m1, [src0q+lenq+8] + cvtps2pi m2, [src1q+lenq ] + cvtps2pi m3, [src1q+lenq+8] + packssdw m0, m1 + packssdw m2, m3 + mova m1, m0 + punpcklwd m0, m2 + punpckhwd m1, m2 + mova [dstq+lenq ], m0 + mova [dstq+lenq+8], m1 +%endif + add lenq, 16 + js .loop +%ifnidn %1, sse2 + emms +%endif + REP_RET +%endmacro + +INIT_MMX +%define cvtps2pi pf2id +FLOAT_TO_INT16_INTERLEAVE2 3dnow +%undef cvtps2pi +%define movdqa movaps +FLOAT_TO_INT16_INTERLEAVE2 sse +%undef movdqa +INIT_XMM +FLOAT_TO_INT16_INTERLEAVE2 sse2 + + %macro PSWAPD_SSE 2 pshufw %1, %2, 0x4e %endmacro diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/fmtconvert_mmx.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/fmtconvert_mmx.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/fmtconvert_mmx.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/fmtconvert_mmx.c 2011-11-04 12:38:27.000000000 +0000 @@ -26,133 +26,32 @@ #include "libavutil/x86_cpu.h" #include "libavcodec/fmtconvert.h" -static void int32_to_float_fmul_scalar_sse(float *dst, const int *src, float mul, int len) -{ - x86_reg i = -4*len; - __asm__ volatile( - "movss %3, %%xmm4 \n" - "shufps $0, %%xmm4, %%xmm4 \n" - "1: \n" - "cvtpi2ps (%2,%0), %%xmm0 \n" - "cvtpi2ps 8(%2,%0), %%xmm1 \n" - "cvtpi2ps 16(%2,%0), %%xmm2 \n" - "cvtpi2ps 24(%2,%0), %%xmm3 \n" - "movlhps %%xmm1, %%xmm0 \n" - "movlhps %%xmm3, %%xmm2 \n" - "mulps %%xmm4, %%xmm0 \n" - "mulps %%xmm4, %%xmm2 \n" - "movaps %%xmm0, (%1,%0) \n" - "movaps %%xmm2, 16(%1,%0) \n" - "add $32, %0 \n" - "jl 1b \n" - :"+r"(i) - :"r"(dst+len), "r"(src+len), "m"(mul) - ); -} - -static void int32_to_float_fmul_scalar_sse2(float *dst, const int *src, float mul, int len) -{ - x86_reg i = -4*len; - __asm__ volatile( - "movss %3, %%xmm4 \n" - "shufps $0, %%xmm4, %%xmm4 \n" - "1: \n" - "cvtdq2ps (%2,%0), %%xmm0 \n" - "cvtdq2ps 16(%2,%0), %%xmm1 \n" - "mulps %%xmm4, %%xmm0 \n" - "mulps %%xmm4, %%xmm1 \n" - "movaps %%xmm0, (%1,%0) \n" - "movaps %%xmm1, 16(%1,%0) \n" - "add $32, %0 \n" - "jl 1b \n" - :"+r"(i) - :"r"(dst+len), "r"(src+len), "m"(mul) - ); -} - -static void float_to_int16_3dnow(int16_t *dst, const float *src, long len){ - x86_reg reglen = len; - // not bit-exact: pf2id uses different rounding than C and SSE - __asm__ volatile( - "add %0 , %0 \n\t" - "lea (%2,%0,2) , %2 \n\t" - "add %0 , %1 \n\t" - "neg %0 \n\t" - "1: \n\t" - "pf2id (%2,%0,2) , %%mm0 \n\t" - "pf2id 8(%2,%0,2) , %%mm1 \n\t" - "pf2id 16(%2,%0,2) , %%mm2 \n\t" - "pf2id 24(%2,%0,2) , %%mm3 \n\t" - "packssdw %%mm1 , %%mm0 \n\t" - "packssdw %%mm3 , %%mm2 \n\t" - "movq %%mm0 , (%1,%0) \n\t" - "movq %%mm2 , 8(%1,%0) \n\t" - "add $16 , %0 \n\t" - " js 1b \n\t" - "femms \n\t" - :"+r"(reglen), "+r"(dst), "+r"(src) - ); -} +#if HAVE_YASM -static void float_to_int16_sse(int16_t *dst, const float *src, long len){ - x86_reg reglen = len; - __asm__ volatile( - "add %0 , %0 \n\t" - "lea (%2,%0,2) , %2 \n\t" - "add %0 , %1 \n\t" - "neg %0 \n\t" - "1: \n\t" - "cvtps2pi (%2,%0,2) , %%mm0 \n\t" - "cvtps2pi 8(%2,%0,2) , %%mm1 \n\t" - "cvtps2pi 16(%2,%0,2) , %%mm2 \n\t" - "cvtps2pi 24(%2,%0,2) , %%mm3 \n\t" - "packssdw %%mm1 , %%mm0 \n\t" - "packssdw %%mm3 , %%mm2 \n\t" - "movq %%mm0 , (%1,%0) \n\t" - "movq %%mm2 , 8(%1,%0) \n\t" - "add $16 , %0 \n\t" - " js 1b \n\t" - "emms \n\t" - :"+r"(reglen), "+r"(dst), "+r"(src) - ); -} +void ff_int32_to_float_fmul_scalar_sse (float *dst, const int *src, float mul, int len); +void ff_int32_to_float_fmul_scalar_sse2(float *dst, const int *src, float mul, int len); -static void float_to_int16_sse2(int16_t *dst, const float *src, long len){ - x86_reg reglen = len; - __asm__ volatile( - "add %0 , %0 \n\t" - "lea (%2,%0,2) , %2 \n\t" - "add %0 , %1 \n\t" - "neg %0 \n\t" - "1: \n\t" - "cvtps2dq (%2,%0,2) , %%xmm0 \n\t" - "cvtps2dq 16(%2,%0,2) , %%xmm1 \n\t" - "packssdw %%xmm1 , %%xmm0 \n\t" - "movdqa %%xmm0 , (%1,%0) \n\t" - "add $16 , %0 \n\t" - " js 1b \n\t" - :"+r"(reglen), "+r"(dst), "+r"(src) - ); -} +void ff_float_to_int16_3dnow(int16_t *dst, const float *src, long len); +void ff_float_to_int16_sse (int16_t *dst, const float *src, long len); +void ff_float_to_int16_sse2 (int16_t *dst, const float *src, long len); + +void ff_float_to_int16_interleave2_3dnow(int16_t *dst, const float **src, long len); +void ff_float_to_int16_interleave2_sse (int16_t *dst, const float **src, long len); +void ff_float_to_int16_interleave2_sse2 (int16_t *dst, const float **src, long len); void ff_float_to_int16_interleave6_sse(int16_t *dst, const float **src, int len); void ff_float_to_int16_interleave6_3dnow(int16_t *dst, const float **src, int len); void ff_float_to_int16_interleave6_3dn2(int16_t *dst, const float **src, int len); -#if !HAVE_YASM -#define ff_float_to_int16_interleave6_sse(a,b,c) float_to_int16_interleave_misc_sse(a,b,c,6) -#define ff_float_to_int16_interleave6_3dnow(a,b,c) float_to_int16_interleave_misc_3dnow(a,b,c,6) -#define ff_float_to_int16_interleave6_3dn2(a,b,c) float_to_int16_interleave_misc_3dnow(a,b,c,6) -#endif #define ff_float_to_int16_interleave6_sse2 ff_float_to_int16_interleave6_sse -#define FLOAT_TO_INT16_INTERLEAVE(cpu, body) \ +#define FLOAT_TO_INT16_INTERLEAVE(cpu) \ /* gcc pessimizes register allocation if this is in the same function as float_to_int16_interleave_sse2*/\ static av_noinline void float_to_int16_interleave_misc_##cpu(int16_t *dst, const float **src, long len, int channels){\ DECLARE_ALIGNED(16, int16_t, tmp)[len];\ int i,j,c;\ for(c=0; cfloat_interleave = float_interleave_mmx; -#endif - if(mm_flags & AV_CPU_FLAG_3DNOW){ + if (HAVE_AMD3DNOW && mm_flags & AV_CPU_FLAG_3DNOW) { if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ - c->float_to_int16 = float_to_int16_3dnow; + c->float_to_int16 = ff_float_to_int16_3dnow; c->float_to_int16_interleave = float_to_int16_interleave_3dnow; } } - if(mm_flags & AV_CPU_FLAG_3DNOWEXT){ + if (HAVE_AMD3DNOWEXT && mm_flags & AV_CPU_FLAG_3DNOWEXT) { if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ c->float_to_int16_interleave = float_to_int16_interleave_3dn2; } } - if(mm_flags & AV_CPU_FLAG_SSE){ - c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_sse; - c->float_to_int16 = float_to_int16_sse; + if (HAVE_SSE && mm_flags & AV_CPU_FLAG_SSE) { + c->int32_to_float_fmul_scalar = ff_int32_to_float_fmul_scalar_sse; + c->float_to_int16 = ff_float_to_int16_sse; c->float_to_int16_interleave = float_to_int16_interleave_sse; -#if HAVE_YASM c->float_interleave = float_interleave_sse; -#endif } - if(mm_flags & AV_CPU_FLAG_SSE2){ - c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_sse2; - c->float_to_int16 = float_to_int16_sse2; + if (HAVE_SSE && mm_flags & AV_CPU_FLAG_SSE2) { + c->int32_to_float_fmul_scalar = ff_int32_to_float_fmul_scalar_sse2; + c->float_to_int16 = ff_float_to_int16_sse2; c->float_to_int16_interleave = float_to_int16_interleave_sse2; } } +#endif } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/h264_chromamc.asm ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/h264_chromamc.asm --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/h264_chromamc.asm 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/h264_chromamc.asm 2011-11-04 12:38:27.000000000 +0000 @@ -20,8 +20,8 @@ ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** -%include "x86inc.asm" -%include "x86util.asm" +%include "libavutil/x86/x86inc.asm" +%include "libavutil/x86/x86util.asm" SECTION_RODATA diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/h264_deblock_10bit.asm ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/h264_deblock_10bit.asm --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/h264_deblock_10bit.asm 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/h264_deblock_10bit.asm 2011-11-04 12:38:27.000000000 +0000 @@ -24,8 +24,8 @@ ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** -%include "x86inc.asm" -%include "x86util.asm" +%include "libavutil/x86/x86inc.asm" +%include "libavutil/x86/x86util.asm" SECTION_RODATA diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/h264_deblock.asm ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/h264_deblock.asm --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/h264_deblock.asm 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/h264_deblock.asm 2011-11-04 12:38:27.000000000 +0000 @@ -24,8 +24,8 @@ ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** -%include "x86inc.asm" -%include "x86util.asm" +%include "libavutil/x86/x86inc.asm" +%include "libavutil/x86/x86util.asm" SECTION .text diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/h264dsp_mmx.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/h264dsp_mmx.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/h264dsp_mmx.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/h264dsp_mmx.c 2011-11-04 12:38:27.000000000 +0000 @@ -298,63 +298,53 @@ /***********************************/ /* weighted prediction */ -#define H264_WEIGHT(W, H, OPT) \ -void ff_h264_weight_ ## W ## x ## H ## _ ## OPT(uint8_t *dst, \ - int stride, int log2_denom, int weight, int offset); - -#define H264_BIWEIGHT(W, H, OPT) \ -void ff_h264_biweight_ ## W ## x ## H ## _ ## OPT(uint8_t *dst, \ - uint8_t *src, int stride, int log2_denom, int weightd, \ +#define H264_WEIGHT(W, OPT) \ +void ff_h264_weight_ ## W ## _ ## OPT(uint8_t *dst, \ + int stride, int height, int log2_denom, int weight, int offset); + +#define H264_BIWEIGHT(W, OPT) \ +void ff_h264_biweight_ ## W ## _ ## OPT(uint8_t *dst, \ + uint8_t *src, int stride, int height, int log2_denom, int weightd, \ int weights, int offset); -#define H264_BIWEIGHT_MMX(W,H) \ -H264_WEIGHT (W, H, mmx2) \ -H264_BIWEIGHT(W, H, mmx2) - -#define H264_BIWEIGHT_MMX_SSE(W,H) \ -H264_BIWEIGHT_MMX(W, H) \ -H264_WEIGHT (W, H, sse2) \ -H264_BIWEIGHT (W, H, sse2) \ -H264_BIWEIGHT (W, H, ssse3) - -H264_BIWEIGHT_MMX_SSE(16, 16) -H264_BIWEIGHT_MMX_SSE(16, 8) -H264_BIWEIGHT_MMX_SSE( 8, 16) -H264_BIWEIGHT_MMX_SSE( 8, 8) -H264_BIWEIGHT_MMX_SSE( 8, 4) -H264_BIWEIGHT_MMX ( 4, 8) -H264_BIWEIGHT_MMX ( 4, 4) -H264_BIWEIGHT_MMX ( 4, 2) - -#define H264_WEIGHT_10(W, H, DEPTH, OPT) \ -void ff_h264_weight_ ## W ## x ## H ## _ ## DEPTH ## _ ## OPT(uint8_t *dst, \ - int stride, int log2_denom, int weight, int offset); - -#define H264_BIWEIGHT_10(W, H, DEPTH, OPT) \ -void ff_h264_biweight_ ## W ## x ## H ## _ ## DEPTH ## _ ## OPT \ - (uint8_t *dst, uint8_t *src, int stride, int log2_denom, \ +#define H264_BIWEIGHT_MMX(W) \ +H264_WEIGHT (W, mmx2) \ +H264_BIWEIGHT(W, mmx2) + +#define H264_BIWEIGHT_MMX_SSE(W) \ +H264_BIWEIGHT_MMX(W) \ +H264_WEIGHT (W, sse2) \ +H264_BIWEIGHT (W, sse2) \ +H264_BIWEIGHT (W, ssse3) + +H264_BIWEIGHT_MMX_SSE(16) +H264_BIWEIGHT_MMX_SSE( 8) +H264_BIWEIGHT_MMX ( 4) + +#define H264_WEIGHT_10(W, DEPTH, OPT) \ +void ff_h264_weight_ ## W ## _ ## DEPTH ## _ ## OPT(uint8_t *dst, \ + int stride, int height, int log2_denom, int weight, int offset); + +#define H264_BIWEIGHT_10(W, DEPTH, OPT) \ +void ff_h264_biweight_ ## W ## _ ## DEPTH ## _ ## OPT \ + (uint8_t *dst, uint8_t *src, int stride, int height, int log2_denom, \ int weightd, int weights, int offset); -#define H264_BIWEIGHT_10_SSE(W, H, DEPTH) \ -H264_WEIGHT_10 (W, H, DEPTH, sse2) \ -H264_WEIGHT_10 (W, H, DEPTH, sse4) \ -H264_BIWEIGHT_10(W, H, DEPTH, sse2) \ -H264_BIWEIGHT_10(W, H, DEPTH, sse4) - -H264_BIWEIGHT_10_SSE(16, 16, 10) -H264_BIWEIGHT_10_SSE(16, 8, 10) -H264_BIWEIGHT_10_SSE( 8, 16, 10) -H264_BIWEIGHT_10_SSE( 8, 8, 10) -H264_BIWEIGHT_10_SSE( 8, 4, 10) -H264_BIWEIGHT_10_SSE( 4, 8, 10) -H264_BIWEIGHT_10_SSE( 4, 4, 10) -H264_BIWEIGHT_10_SSE( 4, 2, 10) +#define H264_BIWEIGHT_10_SSE(W, DEPTH) \ +H264_WEIGHT_10 (W, DEPTH, sse2) \ +H264_WEIGHT_10 (W, DEPTH, sse4) \ +H264_BIWEIGHT_10(W, DEPTH, sse2) \ +H264_BIWEIGHT_10(W, DEPTH, sse4) + +H264_BIWEIGHT_10_SSE(16, 10) +H264_BIWEIGHT_10_SSE( 8, 10) +H264_BIWEIGHT_10_SSE( 4, 10) void ff_h264dsp_init_x86(H264DSPContext *c, const int bit_depth, const int chroma_format_idc) { int mm_flags = av_get_cpu_flags(); - if (mm_flags & AV_CPU_FLAG_MMX2) { + if (chroma_format_idc == 1 && mm_flags & AV_CPU_FLAG_MMX2) { c->h264_loop_filter_strength= h264_loop_filter_strength_mmx2; } @@ -394,23 +384,13 @@ c->h264_v_loop_filter_luma_intra = ff_deblock_v_luma_intra_8_mmxext; c->h264_h_loop_filter_luma_intra = ff_deblock_h_luma_intra_8_mmxext; #endif - c->weight_h264_pixels_tab[0]= ff_h264_weight_16x16_mmx2; - c->weight_h264_pixels_tab[1]= ff_h264_weight_16x8_mmx2; - c->weight_h264_pixels_tab[2]= ff_h264_weight_8x16_mmx2; - c->weight_h264_pixels_tab[3]= ff_h264_weight_8x8_mmx2; - c->weight_h264_pixels_tab[4]= ff_h264_weight_8x4_mmx2; - c->weight_h264_pixels_tab[5]= ff_h264_weight_4x8_mmx2; - c->weight_h264_pixels_tab[6]= ff_h264_weight_4x4_mmx2; - c->weight_h264_pixels_tab[7]= ff_h264_weight_4x2_mmx2; - - c->biweight_h264_pixels_tab[0]= ff_h264_biweight_16x16_mmx2; - c->biweight_h264_pixels_tab[1]= ff_h264_biweight_16x8_mmx2; - c->biweight_h264_pixels_tab[2]= ff_h264_biweight_8x16_mmx2; - c->biweight_h264_pixels_tab[3]= ff_h264_biweight_8x8_mmx2; - c->biweight_h264_pixels_tab[4]= ff_h264_biweight_8x4_mmx2; - c->biweight_h264_pixels_tab[5]= ff_h264_biweight_4x8_mmx2; - c->biweight_h264_pixels_tab[6]= ff_h264_biweight_4x4_mmx2; - c->biweight_h264_pixels_tab[7]= ff_h264_biweight_4x2_mmx2; + c->weight_h264_pixels_tab[0]= ff_h264_weight_16_mmx2; + c->weight_h264_pixels_tab[1]= ff_h264_weight_8_mmx2; + c->weight_h264_pixels_tab[2]= ff_h264_weight_4_mmx2; + + c->biweight_h264_pixels_tab[0]= ff_h264_biweight_16_mmx2; + c->biweight_h264_pixels_tab[1]= ff_h264_biweight_8_mmx2; + c->biweight_h264_pixels_tab[2]= ff_h264_biweight_4_mmx2; if (mm_flags&AV_CPU_FLAG_SSE2) { c->h264_idct8_add = ff_h264_idct8_add_8_sse2; @@ -422,17 +402,11 @@ c->h264_idct_add16intra = ff_h264_idct_add16intra_8_sse2; c->h264_luma_dc_dequant_idct= ff_h264_luma_dc_dequant_idct_sse2; - c->weight_h264_pixels_tab[0]= ff_h264_weight_16x16_sse2; - c->weight_h264_pixels_tab[1]= ff_h264_weight_16x8_sse2; - c->weight_h264_pixels_tab[2]= ff_h264_weight_8x16_sse2; - c->weight_h264_pixels_tab[3]= ff_h264_weight_8x8_sse2; - c->weight_h264_pixels_tab[4]= ff_h264_weight_8x4_sse2; - - c->biweight_h264_pixels_tab[0]= ff_h264_biweight_16x16_sse2; - c->biweight_h264_pixels_tab[1]= ff_h264_biweight_16x8_sse2; - c->biweight_h264_pixels_tab[2]= ff_h264_biweight_8x16_sse2; - c->biweight_h264_pixels_tab[3]= ff_h264_biweight_8x8_sse2; - c->biweight_h264_pixels_tab[4]= ff_h264_biweight_8x4_sse2; + c->weight_h264_pixels_tab[0]= ff_h264_weight_16_sse2; + c->weight_h264_pixels_tab[1]= ff_h264_weight_8_sse2; + + c->biweight_h264_pixels_tab[0]= ff_h264_biweight_16_sse2; + c->biweight_h264_pixels_tab[1]= ff_h264_biweight_8_sse2; #if HAVE_ALIGNED_STACK c->h264_v_loop_filter_luma = ff_deblock_v_luma_8_sse2; @@ -442,11 +416,8 @@ #endif } if (mm_flags&AV_CPU_FLAG_SSSE3) { - c->biweight_h264_pixels_tab[0]= ff_h264_biweight_16x16_ssse3; - c->biweight_h264_pixels_tab[1]= ff_h264_biweight_16x8_ssse3; - c->biweight_h264_pixels_tab[2]= ff_h264_biweight_8x16_ssse3; - c->biweight_h264_pixels_tab[3]= ff_h264_biweight_8x8_ssse3; - c->biweight_h264_pixels_tab[4]= ff_h264_biweight_8x4_ssse3; + c->biweight_h264_pixels_tab[0]= ff_h264_biweight_16_ssse3; + c->biweight_h264_pixels_tab[1]= ff_h264_biweight_8_ssse3; } if (HAVE_AVX && mm_flags&AV_CPU_FLAG_AVX) { #if HAVE_ALIGNED_STACK @@ -485,23 +456,13 @@ c->h264_idct8_add4 = ff_h264_idct8_add4_10_sse2; #endif - c->weight_h264_pixels_tab[0] = ff_h264_weight_16x16_10_sse2; - c->weight_h264_pixels_tab[1] = ff_h264_weight_16x8_10_sse2; - c->weight_h264_pixels_tab[2] = ff_h264_weight_8x16_10_sse2; - c->weight_h264_pixels_tab[3] = ff_h264_weight_8x8_10_sse2; - c->weight_h264_pixels_tab[4] = ff_h264_weight_8x4_10_sse2; - c->weight_h264_pixels_tab[5] = ff_h264_weight_4x8_10_sse2; - c->weight_h264_pixels_tab[6] = ff_h264_weight_4x4_10_sse2; - c->weight_h264_pixels_tab[7] = ff_h264_weight_4x2_10_sse2; - - c->biweight_h264_pixels_tab[0] = ff_h264_biweight_16x16_10_sse2; - c->biweight_h264_pixels_tab[1] = ff_h264_biweight_16x8_10_sse2; - c->biweight_h264_pixels_tab[2] = ff_h264_biweight_8x16_10_sse2; - c->biweight_h264_pixels_tab[3] = ff_h264_biweight_8x8_10_sse2; - c->biweight_h264_pixels_tab[4] = ff_h264_biweight_8x4_10_sse2; - c->biweight_h264_pixels_tab[5] = ff_h264_biweight_4x8_10_sse2; - c->biweight_h264_pixels_tab[6] = ff_h264_biweight_4x4_10_sse2; - c->biweight_h264_pixels_tab[7] = ff_h264_biweight_4x2_10_sse2; + c->weight_h264_pixels_tab[0] = ff_h264_weight_16_10_sse2; + c->weight_h264_pixels_tab[1] = ff_h264_weight_8_10_sse2; + c->weight_h264_pixels_tab[2] = ff_h264_weight_4_10_sse2; + + c->biweight_h264_pixels_tab[0] = ff_h264_biweight_16_10_sse2; + c->biweight_h264_pixels_tab[1] = ff_h264_biweight_8_10_sse2; + c->biweight_h264_pixels_tab[2] = ff_h264_biweight_4_10_sse2; c->h264_v_loop_filter_chroma= ff_deblock_v_chroma_10_sse2; c->h264_v_loop_filter_chroma_intra= ff_deblock_v_chroma_intra_10_sse2; @@ -513,23 +474,13 @@ #endif } if (mm_flags&AV_CPU_FLAG_SSE4) { - c->weight_h264_pixels_tab[0] = ff_h264_weight_16x16_10_sse4; - c->weight_h264_pixels_tab[1] = ff_h264_weight_16x8_10_sse4; - c->weight_h264_pixels_tab[2] = ff_h264_weight_8x16_10_sse4; - c->weight_h264_pixels_tab[3] = ff_h264_weight_8x8_10_sse4; - c->weight_h264_pixels_tab[4] = ff_h264_weight_8x4_10_sse4; - c->weight_h264_pixels_tab[5] = ff_h264_weight_4x8_10_sse4; - c->weight_h264_pixels_tab[6] = ff_h264_weight_4x4_10_sse4; - c->weight_h264_pixels_tab[7] = ff_h264_weight_4x2_10_sse4; - - c->biweight_h264_pixels_tab[0] = ff_h264_biweight_16x16_10_sse4; - c->biweight_h264_pixels_tab[1] = ff_h264_biweight_16x8_10_sse4; - c->biweight_h264_pixels_tab[2] = ff_h264_biweight_8x16_10_sse4; - c->biweight_h264_pixels_tab[3] = ff_h264_biweight_8x8_10_sse4; - c->biweight_h264_pixels_tab[4] = ff_h264_biweight_8x4_10_sse4; - c->biweight_h264_pixels_tab[5] = ff_h264_biweight_4x8_10_sse4; - c->biweight_h264_pixels_tab[6] = ff_h264_biweight_4x4_10_sse4; - c->biweight_h264_pixels_tab[7] = ff_h264_biweight_4x2_10_sse4; + c->weight_h264_pixels_tab[0] = ff_h264_weight_16_10_sse4; + c->weight_h264_pixels_tab[1] = ff_h264_weight_8_10_sse4; + c->weight_h264_pixels_tab[2] = ff_h264_weight_4_10_sse4; + + c->biweight_h264_pixels_tab[0] = ff_h264_biweight_16_10_sse4; + c->biweight_h264_pixels_tab[1] = ff_h264_biweight_8_10_sse4; + c->biweight_h264_pixels_tab[2] = ff_h264_biweight_4_10_sse4; } #if HAVE_AVX if (mm_flags&AV_CPU_FLAG_AVX) { diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/h264_idct_10bit.asm ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/h264_idct_10bit.asm --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/h264_idct_10bit.asm 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/h264_idct_10bit.asm 2011-11-04 12:38:27.000000000 +0000 @@ -22,8 +22,8 @@ ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** -%include "x86inc.asm" -%include "x86util.asm" +%include "libavutil/x86/x86inc.asm" +%include "libavutil/x86/x86util.asm" SECTION_RODATA diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/h264_idct.asm ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/h264_idct.asm --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/h264_idct.asm 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/h264_idct.asm 2011-11-04 12:38:27.000000000 +0000 @@ -26,8 +26,8 @@ ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;***************************************************************************** -%include "x86inc.asm" -%include "x86util.asm" +%include "libavutil/x86/x86inc.asm" +%include "libavutil/x86/x86util.asm" SECTION_RODATA diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/h264_intrapred_10bit.asm ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/h264_intrapred_10bit.asm --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/h264_intrapred_10bit.asm 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/h264_intrapred_10bit.asm 2011-11-04 12:38:27.000000000 +0000 @@ -22,8 +22,8 @@ ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** -%include "x86inc.asm" -%include "x86util.asm" +%include "libavutil/x86/x86inc.asm" +%include "libavutil/x86/x86util.asm" SECTION_RODATA diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/h264_intrapred.asm ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/h264_intrapred.asm --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/h264_intrapred.asm 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/h264_intrapred.asm 2011-11-04 12:38:27.000000000 +0000 @@ -22,8 +22,8 @@ ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** -%include "x86inc.asm" -%include "x86util.asm" +%include "libavutil/x86/x86inc.asm" +%include "libavutil/x86/x86util.asm" SECTION_RODATA diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/h264_intrapred_init.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/h264_intrapred_init.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/h264_intrapred_init.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/h264_intrapred_init.c 2011-11-04 12:38:27.000000000 +0000 @@ -169,9 +169,9 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth, const int chroma_format_idc) { +#if HAVE_YASM int mm_flags = av_get_cpu_flags(); -#if HAVE_YASM if (bit_depth == 8) { if (mm_flags & AV_CPU_FLAG_MMX) { h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vertical_mmx; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/h264_weight_10bit.asm ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/h264_weight_10bit.asm --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/h264_weight_10bit.asm 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/h264_weight_10bit.asm 2011-11-04 12:38:27.000000000 +0000 @@ -36,33 +36,27 @@ SECTION .text ;----------------------------------------------------------------------------- -; void h264_weight(uint8_t *dst, int stride, int log2_denom, +; void h264_weight(uint8_t *dst, int stride, int height, int log2_denom, ; int weight, int offset); ;----------------------------------------------------------------------------- -%ifdef ARCH_X86_32 -DECLARE_REG_TMP 2 -%else -DECLARE_REG_TMP 10 -%endif - -%macro WEIGHT_PROLOGUE 1 - mov t0, %1 +%macro WEIGHT_PROLOGUE 0 .prologue - PROLOGUE 0,5,8 + PROLOGUE 0,6,8 movifnidn r0, r0mp movifnidn r1d, r1m - movifnidn r3d, r3m + movifnidn r2d, r2m movifnidn r4d, r4m + movifnidn r5d, r5m %endmacro %macro WEIGHT_SETUP 1 mova m0, [pw_1] - movd m2, r2m + movd m2, r3m pslld m0, m2 ; 1< +;* +;* This file is part of FFmpeg. +;* +;* FFmpeg is free software; you can redistribute it and/or +;* modify it under the terms of the GNU Lesser General Public +;* License as published by the Free Software Foundation; either +;* version 2.1 of the License, or (at your option) any later version. +;* +;* FFmpeg is distributed in the hope that it will be useful, +;* but WITHOUT ANY WARRANTY; without even the implied warranty of +;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;* Lesser General Public License for more details. +;* +;* You should have received a copy of the GNU Lesser General Public +;* License along with FFmpeg; if not, write to the Free Software +;* 51, Inc., Foundation Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;****************************************************************************** + +%include "x86inc.asm" +%include "x86util.asm" + +%define W1sh2 22725 ; W1 = 90901 = 22725<<2 + 1 +%define W2sh2 21407 ; W2 = 85627 = 21407<<2 - 1 +%define W3sh2 19265 ; W3 = 77062 = 19265<<2 + 2 +%define W4sh2 16384 ; W4 = 65535 = 16384<<2 - 1 +%define W5sh2 12873 ; W5 = 51491 = 12873<<2 - 1 +%define W6sh2 8867 ; W6 = 35468 = 8867<<2 +%define W7sh2 4520 ; W7 = 18081 = 4520<<2 + 1 + +%ifdef ARCH_X86_64 + +SECTION_RODATA + +w4_plus_w2: times 4 dw W4sh2, +W2sh2 +w4_min_w2: times 4 dw W4sh2, -W2sh2 +w4_plus_w6: times 4 dw W4sh2, +W6sh2 +w4_min_w6: times 4 dw W4sh2, -W6sh2 +w1_plus_w3: times 4 dw W1sh2, +W3sh2 +w3_min_w1: times 4 dw W3sh2, -W1sh2 +w7_plus_w3: times 4 dw W7sh2, +W3sh2 +w3_min_w7: times 4 dw W3sh2, -W7sh2 +w1_plus_w5: times 4 dw W1sh2, +W5sh2 +w5_min_w1: times 4 dw W5sh2, -W1sh2 +w5_plus_w7: times 4 dw W5sh2, +W7sh2 +w7_min_w5: times 4 dw W7sh2, -W5sh2 +pw_88: times 8 dw 0x2008 + +cextern pw_1 +cextern pw_4 +cextern pw_512 +cextern pw_1019 + +section .text align=16 + +; interleave data while maintaining source +; %1=type, %2=dstlo, %3=dsthi, %4=src, %5=interleave +%macro SBUTTERFLY3 5 + punpckl%1 m%2, m%4, m%5 + punpckh%1 m%3, m%4, m%5 +%endmacro + +; %1/%2=src1/dst1, %3/%4=dst2, %5/%6=src2, %7=shift +; action: %3/%4 = %1/%2 - %5/%6; %1/%2 += %5/%6 +; %1/%2/%3/%4 >>= %7; dword -> word (in %1/%3) +%macro SUMSUB_SHPK 7 + psubd %3, %1, %5 ; { a0 - b0 }[0-3] + psubd %4, %2, %6 ; { a0 - b0 }[4-7] + paddd %1, %5 ; { a0 + b0 }[0-3] + paddd %2, %6 ; { a0 + b0 }[4-7] + psrad %1, %7 + psrad %2, %7 + psrad %3, %7 + psrad %4, %7 + packssdw %1, %2 ; row[0] + packssdw %3, %4 ; row[7] +%endmacro + +; %1 = row or col (for rounding variable) +; %2 = number of bits to shift at the end +; %3 = optimization +%macro IDCT_1D 3 + ; a0 = (W4 * row[0]) + (1 << (15 - 1)); + ; a1 = a0; + ; a2 = a0; + ; a3 = a0; + ; a0 += W2 * row[2]; + ; a1 += W6 * row[2]; + ; a2 -= W6 * row[2]; + ; a3 -= W2 * row[2]; +%ifidn %1, col + paddw m10,[pw_88] +%endif +%ifidn %1, row + paddw m10,[pw_1] +%endif + SBUTTERFLY3 wd, 0, 1, 10, 8 ; { row[0], row[2] }[0-3]/[4-7] + pmaddwd m2, m0, [w4_plus_w6] + pmaddwd m3, m1, [w4_plus_w6] + pmaddwd m4, m0, [w4_min_w6] + pmaddwd m5, m1, [w4_min_w6] + pmaddwd m6, m0, [w4_min_w2] + pmaddwd m7, m1, [w4_min_w2] + pmaddwd m0, [w4_plus_w2] + pmaddwd m1, [w4_plus_w2] + + ; a0: -1*row[0]-1*row[2] + ; a1: -1*row[0] + ; a2: -1*row[0] + ; a3: -1*row[0]+1*row[2] + + ; a0 += W4*row[4] + W6*row[6]; i.e. -1*row[4] + ; a1 -= W4*row[4] + W2*row[6]; i.e. -1*row[4]-1*row[6] + ; a2 -= W4*row[4] - W2*row[6]; i.e. -1*row[4]+1*row[6] + ; a3 += W4*row[4] - W6*row[6]; i.e. -1*row[4] + SBUTTERFLY3 wd, 8, 9, 13, 12 ; { row[4], row[6] }[0-3]/[4-7] + pmaddwd m10, m8, [w4_plus_w6] + pmaddwd m11, m9, [w4_plus_w6] + paddd m0, m10 ; a0[0-3] + paddd m1, m11 ; a0[4-7] + pmaddwd m10, m8, [w4_min_w6] + pmaddwd m11, m9, [w4_min_w6] + paddd m6, m10 ; a3[0-3] + paddd m7, m11 ; a3[4-7] + pmaddwd m10, m8, [w4_min_w2] + pmaddwd m11, m9, [w4_min_w2] + pmaddwd m8, [w4_plus_w2] + pmaddwd m9, [w4_plus_w2] + psubd m4, m10 ; a2[0-3] intermediate + psubd m5, m11 ; a2[4-7] intermediate + psubd m2, m8 ; a1[0-3] intermediate + psubd m3, m9 ; a1[4-7] intermediate + + ; load/store + mova [r2+ 0], m0 + mova [r2+ 32], m2 + mova [r2+ 64], m4 + mova [r2+ 96], m6 + mova m10,[r2+ 16] ; { row[1] }[0-7] + mova m8, [r2+ 48] ; { row[3] }[0-7] + mova m13,[r2+ 80] ; { row[5] }[0-7] + mova m14,[r2+112] ; { row[7] }[0-7] + mova [r2+ 16], m1 + mova [r2+ 48], m3 + mova [r2+ 80], m5 + mova [r2+112], m7 +%ifidn %1, row + pmullw m10,[r3+ 16] + pmullw m8, [r3+ 48] + pmullw m13,[r3+ 80] + pmullw m14,[r3+112] +%endif + + ; b0 = MUL(W1, row[1]); + ; MAC(b0, W3, row[3]); + ; b1 = MUL(W3, row[1]); + ; MAC(b1, -W7, row[3]); + ; b2 = MUL(W5, row[1]); + ; MAC(b2, -W1, row[3]); + ; b3 = MUL(W7, row[1]); + ; MAC(b3, -W5, row[3]); + SBUTTERFLY3 wd, 0, 1, 10, 8 ; { row[1], row[3] }[0-3]/[4-7] + pmaddwd m2, m0, [w3_min_w7] + pmaddwd m3, m1, [w3_min_w7] + pmaddwd m4, m0, [w5_min_w1] + pmaddwd m5, m1, [w5_min_w1] + pmaddwd m6, m0, [w7_min_w5] + pmaddwd m7, m1, [w7_min_w5] + pmaddwd m0, [w1_plus_w3] + pmaddwd m1, [w1_plus_w3] + + ; b0: +1*row[1]+2*row[3] + ; b1: +2*row[1]-1*row[3] + ; b2: -1*row[1]-1*row[3] + ; b3: +1*row[1]+1*row[3] + + ; MAC(b0, W5, row[5]); + ; MAC(b0, W7, row[7]); + ; MAC(b1, -W1, row[5]); + ; MAC(b1, -W5, row[7]); + ; MAC(b2, W7, row[5]); + ; MAC(b2, W3, row[7]); + ; MAC(b3, W3, row[5]); + ; MAC(b3, -W1, row[7]); + SBUTTERFLY3 wd, 8, 9, 13, 14 ; { row[5], row[7] }[0-3]/[4-7] + + ; b0: -1*row[5]+1*row[7] + ; b1: -1*row[5]+1*row[7] + ; b2: +1*row[5]+2*row[7] + ; b3: +2*row[5]-1*row[7] + + pmaddwd m10, m8, [w1_plus_w5] + pmaddwd m11, m9, [w1_plus_w5] + pmaddwd m12, m8, [w5_plus_w7] + pmaddwd m13, m9, [w5_plus_w7] + psubd m2, m10 ; b1[0-3] + psubd m3, m11 ; b1[4-7] + paddd m0, m12 ; b0[0-3] + paddd m1, m13 ; b0[4-7] + pmaddwd m12, m8, [w7_plus_w3] + pmaddwd m13, m9, [w7_plus_w3] + pmaddwd m8, [w3_min_w1] + pmaddwd m9, [w3_min_w1] + paddd m4, m12 ; b2[0-3] + paddd m5, m13 ; b2[4-7] + paddd m6, m8 ; b3[0-3] + paddd m7, m9 ; b3[4-7] + + ; row[0] = (a0 + b0) >> 15; + ; row[7] = (a0 - b0) >> 15; + ; row[1] = (a1 + b1) >> 15; + ; row[6] = (a1 - b1) >> 15; + ; row[2] = (a2 + b2) >> 15; + ; row[5] = (a2 - b2) >> 15; + ; row[3] = (a3 + b3) >> 15; + ; row[4] = (a3 - b3) >> 15; + mova m8, [r2+ 0] ; a0[0-3] + mova m9, [r2+16] ; a0[4-7] + SUMSUB_SHPK m8, m9, m10, m11, m0, m1, %2 + mova m0, [r2+32] ; a1[0-3] + mova m1, [r2+48] ; a1[4-7] + SUMSUB_SHPK m0, m1, m9, m11, m2, m3, %2 + mova m1, [r2+64] ; a2[0-3] + mova m2, [r2+80] ; a2[4-7] + SUMSUB_SHPK m1, m2, m11, m3, m4, m5, %2 + mova m2, [r2+96] ; a3[0-3] + mova m3, [r2+112] ; a3[4-7] + SUMSUB_SHPK m2, m3, m4, m5, m6, m7, %2 +%endmacro + +; void prores_idct_put_10_(uint8_t *pixels, int stride, +; DCTELEM *block, const int16_t *qmat); +%macro idct_put_fn 2 +cglobal prores_idct_put_10_%1, 4, 4, %2 + movsxd r1, r1d + pxor m15, m15 ; zero + + ; for (i = 0; i < 8; i++) + ; idctRowCondDC(block + i*8); + mova m10,[r2+ 0] ; { row[0] }[0-7] + mova m8, [r2+32] ; { row[2] }[0-7] + mova m13,[r2+64] ; { row[4] }[0-7] + mova m12,[r2+96] ; { row[6] }[0-7] + + pmullw m10,[r3+ 0] + pmullw m8, [r3+32] + pmullw m13,[r3+64] + pmullw m12,[r3+96] + + IDCT_1D row, 15, %1 + + ; transpose for second part of IDCT + TRANSPOSE8x8W 8, 0, 1, 2, 4, 11, 9, 10, 3 + mova [r2+ 16], m0 + mova [r2+ 48], m2 + mova [r2+ 80], m11 + mova [r2+112], m10 + SWAP 8, 10 + SWAP 1, 8 + SWAP 4, 13 + SWAP 9, 12 + + ; for (i = 0; i < 8; i++) + ; idctSparseColAdd(dest + i, line_size, block + i); + IDCT_1D col, 18, %1 + + ; clip/store + mova m3, [pw_4] + mova m5, [pw_1019] + pmaxsw m8, m3 + pmaxsw m0, m3 + pmaxsw m1, m3 + pmaxsw m2, m3 + pmaxsw m4, m3 + pmaxsw m11, m3 + pmaxsw m9, m3 + pmaxsw m10, m3 + pminsw m8, m5 + pminsw m0, m5 + pminsw m1, m5 + pminsw m2, m5 + pminsw m4, m5 + pminsw m11, m5 + pminsw m9, m5 + pminsw m10, m5 + + lea r2, [r1*3] + mova [r0 ], m8 + mova [r0+r1 ], m0 + mova [r0+r1*2], m1 + mova [r0+r2 ], m2 + lea r0, [r0+r1*4] + mova [r0 ], m4 + mova [r0+r1 ], m11 + mova [r0+r1*2], m9 + mova [r0+r2 ], m10 + RET +%endmacro + +INIT_XMM +idct_put_fn sse2, 16 +INIT_XMM +idct_put_fn sse4, 16 +INIT_AVX +idct_put_fn avx, 16 + +%endif diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/proresdsp-init.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/proresdsp-init.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/proresdsp-init.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/proresdsp-init.c 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,57 @@ +/* + * Apple ProRes compatible decoder + * + * Copyright (c) 2010-2011 Maxim Poliakovski + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavcodec/proresdsp.h" + +void ff_prores_idct_put_10_sse2(uint16_t *dst, int linesize, + DCTELEM *block, const int16_t *qmat); +void ff_prores_idct_put_10_sse4(uint16_t *dst, int linesize, + DCTELEM *block, const int16_t *qmat); +void ff_prores_idct_put_10_avx (uint16_t *dst, int linesize, + DCTELEM *block, const int16_t *qmat); + +void ff_proresdsp_x86_init(ProresDSPContext *dsp, AVCodecContext *avctx) +{ +#if ARCH_X86_64 && HAVE_YASM + int flags = av_get_cpu_flags(); + + if(avctx->flags & CODEC_FLAG_BITEXACT) + return; + + if (flags & AV_CPU_FLAG_SSE2) { + dsp->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM; + dsp->idct_put = ff_prores_idct_put_10_sse2; + } + + if (flags & AV_CPU_FLAG_SSE4) { + dsp->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM; + dsp->idct_put = ff_prores_idct_put_10_sse4; + } + +#if HAVE_AVX + if (flags & AV_CPU_FLAG_AVX) { + dsp->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM; + dsp->idct_put = ff_prores_idct_put_10_avx; + } +#endif /* HAVE_AVX */ +#endif /* ARCH_X86_64 && HAVE_YASM */ +} diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/v210.asm ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/v210.asm --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/v210.asm 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/v210.asm 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,85 @@ +;****************************************************************************** +;* V210 SIMD unpack +;* Copyright (c) 2011 Loren Merritt +;* Copyright (c) 2011 Kieran Kunhya +;* +;* This file is part of Libav. +;* +;* Libav is free software; you can redistribute it and/or +;* modify it under the terms of the GNU Lesser General Public +;* License as published by the Free Software Foundation; either +;* version 2.1 of the License, or (at your option) any later version. +;* +;* Libav is distributed in the hope that it will be useful, +;* but WITHOUT ANY WARRANTY; without even the implied warranty of +;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;* Lesser General Public License for more details. +;* +;* You should have received a copy of the GNU Lesser General Public +;* License along with Libav; if not, write to the Free Software +;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;****************************************************************************** + +%include "libavutil/x86/x86inc.asm" +%include "libavutil/x86/x86util.asm" + +SECTION_RODATA + +v210_mask: times 4 dd 0x3ff +v210_mult: dw 64,4,64,4,64,4,64,4 +v210_luma_shuf: db 8,9,0,1,2,3,12,13,4,5,6,7,-1,-1,-1,-1 +v210_chroma_shuf: db 0,1,8,9,6,7,-1,-1,2,3,4,5,12,13,-1,-1 + +SECTION .text + +%macro v210_planar_unpack 2 + +; v210_planar_unpack(const uint32_t *src, uint16_t *y, uint16_t *u, uint16_t *v, int width) +cglobal v210_planar_unpack_%1_%2, 5, 5 + movsxdifnidn r4, r4d + lea r1, [r1+2*r4] + add r2, r4 + add r3, r4 + neg r4 + + mova m3, [v210_mult] + mova m4, [v210_mask] + mova m5, [v210_luma_shuf] + mova m6, [v210_chroma_shuf] +.loop +%ifidn %1, unaligned + movu m0, [r0] +%else + mova m0, [r0] +%endif + + pmullw m1, m0, m3 + psrld m0, 10 + psrlw m1, 6 ; u0 v0 y1 y2 v1 u2 y4 y5 + pand m0, m4 ; y0 __ u1 __ y3 __ v2 __ + + shufps m2, m1, m0, 0x8d ; y1 y2 y4 y5 y0 __ y3 __ + pshufb m2, m5 ; y0 y1 y2 y3 y4 y5 __ __ + movu [r1+2*r4], m2 + + shufps m1, m0, 0xd8 ; u0 v0 v1 u2 u1 __ v2 __ + pshufb m1, m6 ; u0 u1 u2 __ v0 v1 v2 __ + movq [r2+r4], m1 + movhps [r3+r4], m1 + + add r0, mmsize + add r4, 6 + jl .loop + + REP_RET +%endmacro + +INIT_XMM +v210_planar_unpack unaligned, ssse3 +INIT_AVX +v210_planar_unpack unaligned, avx + +INIT_XMM +v210_planar_unpack aligned, ssse3 +INIT_AVX +v210_planar_unpack aligned, avx diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/v210-init.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/v210-init.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/v210-init.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/v210-init.c 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,48 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/cpu.h" +#include "libavcodec/v210dec.h" + +extern void ff_v210_planar_unpack_unaligned_ssse3(const uint32_t *src, uint16_t *y, uint16_t *u, uint16_t *v, int width); +extern void ff_v210_planar_unpack_unaligned_avx(const uint32_t *src, uint16_t *y, uint16_t *u, uint16_t *v, int width); + +extern void ff_v210_planar_unpack_aligned_ssse3(const uint32_t *src, uint16_t *y, uint16_t *u, uint16_t *v, int width); +extern void ff_v210_planar_unpack_aligned_avx(const uint32_t *src, uint16_t *y, uint16_t *u, uint16_t *v, int width); + +av_cold void v210_x86_init(V210DecContext *s) +{ + int cpu_flags = av_get_cpu_flags(); + +#if HAVE_YASM + if (s->aligned_input) { + if (cpu_flags & AV_CPU_FLAG_SSSE3) + s->unpack_frame = ff_v210_planar_unpack_aligned_ssse3; + + if (cpu_flags & AV_CPU_FLAG_AVX) + s->unpack_frame = ff_v210_planar_unpack_aligned_avx; + } + else { + if (cpu_flags & AV_CPU_FLAG_SSSE3) + s->unpack_frame = ff_v210_planar_unpack_unaligned_ssse3; + + if (cpu_flags & AV_CPU_FLAG_AVX) + s->unpack_frame = ff_v210_planar_unpack_unaligned_avx; + } +#endif +} diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/vc1dsp_yasm.asm ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/vc1dsp_yasm.asm --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/vc1dsp_yasm.asm 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/vc1dsp_yasm.asm 2011-11-04 12:38:27.000000000 +0000 @@ -19,8 +19,8 @@ ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** -%include "x86inc.asm" -%include "x86util.asm" +%include "libavutil/x86/x86inc.asm" +%include "libavutil/x86/x86util.asm" cextern pw_4 cextern pw_5 diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/vp3dsp.asm ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/vp3dsp.asm --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/vp3dsp.asm 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/vp3dsp.asm 2011-11-04 12:38:27.000000000 +0000 @@ -19,8 +19,8 @@ ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** -%include "x86inc.asm" -%include "x86util.asm" +%include "libavutil/x86/x86inc.asm" +%include "libavutil/x86/x86util.asm" ; MMX-optimized functions cribbed from the original VP3 source code. diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/vp56dsp.asm ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/vp56dsp.asm --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/vp56dsp.asm 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/vp56dsp.asm 2011-11-04 12:38:27.000000000 +0000 @@ -20,8 +20,8 @@ ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** -%include "x86inc.asm" -%include "x86util.asm" +%include "libavutil/x86/x86inc.asm" +%include "libavutil/x86/x86util.asm" cextern pw_64 diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/vp8dsp.asm ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/vp8dsp.asm --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/vp8dsp.asm 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/vp8dsp.asm 2011-11-04 12:38:27.000000000 +0000 @@ -20,8 +20,8 @@ ;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ;****************************************************************************** -%include "x86inc.asm" -%include "x86util.asm" +%include "libavutil/x86/x86inc.asm" +%include "libavutil/x86/x86util.asm" SECTION_RODATA diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/vp8dsp-init.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/vp8dsp-init.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/x86/vp8dsp-init.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/x86/vp8dsp-init.c 2011-11-04 12:38:27.000000000 +0000 @@ -283,9 +283,9 @@ av_cold void ff_vp8dsp_init_x86(VP8DSPContext* c) { +#if HAVE_YASM int mm_flags = av_get_cpu_flags(); -#if HAVE_YASM if (mm_flags & AV_CPU_FLAG_MMX) { c->vp8_idct_dc_add = ff_vp8_idct_dc_add_mmx; c->vp8_idct_dc_add4y = ff_vp8_idct_dc_add4y_mmx; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/xan.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/xan.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/xan.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/xan.c 2011-11-04 12:38:27.000000000 +0000 @@ -555,8 +555,10 @@ } buf_size = buf_end - buf; } - if (s->palettes_count <= 0) + if (s->palettes_count <= 0) { + av_log(s->avctx, AV_LOG_ERROR, "No palette found\n"); return AVERROR_INVALIDDATA; + } if ((ret = avctx->get_buffer(avctx, &s->current_frame))) { av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n"); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/xiph.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/xiph.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/xiph.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/xiph.c 2011-11-04 12:38:27.000000000 +0000 @@ -21,7 +21,7 @@ #include "libavutil/intreadwrite.h" #include "xiph.h" -int ff_split_xiph_headers(uint8_t *extradata, int extradata_size, +int avpriv_split_xiph_headers(uint8_t *extradata, int extradata_size, int first_header_size, uint8_t *header_start[3], int header_len[3]) { diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/xiph.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/xiph.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/xiph.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/xiph.h 2011-11-04 12:38:27.000000000 +0000 @@ -36,8 +36,8 @@ * @param[out] header_len The sizes of each of the three headers. * @return On error a negative value is returned, on success zero. */ -int ff_split_xiph_headers(uint8_t *extradata, int extradata_size, - int first_header_size, uint8_t *header_start[3], - int header_len[3]); +int avpriv_split_xiph_headers(uint8_t *extradata, int extradata_size, + int first_header_size, uint8_t *header_start[3], + int header_len[3]); #endif /* AVCODEC_XIPH_H */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/xsubenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/xsubenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/xsubenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/xsubenc.c 2011-11-04 12:38:27.000000000 +0000 @@ -90,7 +90,7 @@ if (color != PADDING_COLOR && (PADDING + (w&1))) put_xsub_rle(pb, PADDING + (w&1), PADDING_COLOR); - align_put_bits(pb); + avpriv_align_put_bits(pb); bitmap += linesize; } @@ -194,7 +194,7 @@ // Enforce total height to be be multiple of 2 if (h->rects[0]->h & 1) { put_xsub_rle(&pb, h->rects[0]->w, PADDING_COLOR); - align_put_bits(&pb); + avpriv_align_put_bits(&pb); } flush_put_bits(&pb); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/xxan.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/xxan.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/xxan.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/xxan.c 2011-11-04 12:38:27.000000000 +0000 @@ -129,7 +129,9 @@ if (size + size2 > dest_end - dest) break; } - if (src + size > src_end || dest + size + size2 > dest_end) + if (src + size > src_end || + dest + size + size2 > dest_end || + dest + size - orig_dest < back ) return -1; bytestream_get_buffer(&src, dest, size); dest += size; @@ -194,6 +196,8 @@ if (mode) { for (j = 0; j < avctx->height >> 1; j++) { for (i = 0; i < avctx->width >> 1; i++) { + if (src_end - src < 1) + return 0; val = *src++; if (val) { val = AV_RL16(table + (val << 1)); @@ -202,8 +206,6 @@ U[i] = uval | (uval >> 5); V[i] = vval | (vval >> 5); } - if (src == src_end) - return 0; } U += s->pic.linesize[1]; V += s->pic.linesize[2]; @@ -214,6 +216,8 @@ for (j = 0; j < avctx->height >> 2; j++) { for (i = 0; i < avctx->width >> 1; i += 2) { + if (src_end - src < 1) + return 0; val = *src++; if (val) { val = AV_RL16(table + (val << 1)); @@ -302,6 +306,9 @@ corr_end - corr_off); if (dec_size < 0) dec_size = 0; + else + dec_size = FFMIN(dec_size, s->buffer_size/2 - 1); + for (i = 0; i < dec_size; i++) s->y_buffer[i*2+1] = (s->y_buffer[i*2+1] + (s->scratch_buffer[i] << 1)) & 0x3F; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/zmbv.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/zmbv.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavcodec/zmbv.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavcodec/zmbv.c 2011-11-04 12:38:27.000000000 +0000 @@ -574,7 +574,7 @@ default: av_log(avctx, AV_LOG_ERROR, "Cannot handle format %i\n", c->fmt); } - memcpy(c->prev, c->cur, c->width * c->height * (c->bpp / 8)); + FFSWAP(uint8_t *, c->cur, c->prev); } *data_size = sizeof(AVFrame); *(AVFrame*)data = c->pic; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/alldevices.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/alldevices.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/alldevices.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/alldevices.c 2011-11-04 12:38:27.000000000 +0000 @@ -47,6 +47,7 @@ REGISTER_INDEV (LAVFI, lavfi); REGISTER_INDEV (OPENAL, openal); REGISTER_INOUTDEV (OSS, oss); + REGISTER_INDEV (PULSE, pulse); REGISTER_OUTDEV (SDL, sdl); REGISTER_INOUTDEV (SNDIO, sndio); REGISTER_INDEV (V4L2, v4l2); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/alsa-audio-dec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/alsa-audio-dec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/alsa-audio-dec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/alsa-audio-dec.c 2011-11-04 12:38:27.000000000 +0000 @@ -61,7 +61,7 @@ enum CodecID codec_id; double o; - st = av_new_stream(s1, 0); + st = avformat_new_stream(s1, NULL); if (!st) { av_log(s1, AV_LOG_ERROR, "Cannot add stream\n"); @@ -132,8 +132,8 @@ } static const AVOption options[] = { - { "sample_rate", "", offsetof(AlsaData, sample_rate), FF_OPT_TYPE_INT, {.dbl = 48000}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, - { "channels", "", offsetof(AlsaData, channels), FF_OPT_TYPE_INT, {.dbl = 2}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, + { "sample_rate", "", offsetof(AlsaData, sample_rate), AV_OPT_TYPE_INT, {.dbl = 48000}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, + { "channels", "", offsetof(AlsaData, channels), AV_OPT_TYPE_INT, {.dbl = 2}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, { NULL }, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/alsa-audio.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/alsa-audio.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/alsa-audio.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/alsa-audio.h 2011-11-04 12:38:27.000000000 +0000 @@ -33,7 +33,7 @@ #include #include "config.h" #include "libavutil/log.h" -#include "libavformat/timefilter.h" +#include "timefilter.h" #include "avdevice.h" /* XXX: we make the assumption that the soundcard accepts this format */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/bktr.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/bktr.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/bktr.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/bktr.c 2011-11-04 12:38:27.000000000 +0000 @@ -271,7 +271,7 @@ goto out; } - st = av_new_stream(s1, 0); + st = avformat_new_stream(s1, NULL); if (!st) { ret = AVERROR(ENOMEM); goto out; @@ -325,15 +325,15 @@ #define OFFSET(x) offsetof(VideoData, x) #define DEC AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { - { "standard", "", offsetof(VideoData, standard), FF_OPT_TYPE_INT, {.dbl = VIDEO_FORMAT}, PAL, NTSCJ, AV_OPT_FLAG_DECODING_PARAM, "standard" }, - { "PAL", "", 0, FF_OPT_TYPE_CONST, {.dbl = PAL}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, - { "NTSC", "", 0, FF_OPT_TYPE_CONST, {.dbl = NTSC}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, - { "SECAM", "", 0, FF_OPT_TYPE_CONST, {.dbl = SECAM}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, - { "PALN", "", 0, FF_OPT_TYPE_CONST, {.dbl = PALN}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, - { "PALM", "", 0, FF_OPT_TYPE_CONST, {.dbl = PALM}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, - { "NTSCJ", "", 0, FF_OPT_TYPE_CONST, {.dbl = NTSCJ}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, - { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = "vga"}, 0, 0, DEC }, - { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, + { "standard", "", offsetof(VideoData, standard), AV_OPT_TYPE_INT, {.dbl = VIDEO_FORMAT}, PAL, NTSCJ, AV_OPT_FLAG_DECODING_PARAM, "standard" }, + { "PAL", "", 0, AV_OPT_TYPE_CONST, {.dbl = PAL}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, + { "NTSC", "", 0, AV_OPT_TYPE_CONST, {.dbl = NTSC}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, + { "SECAM", "", 0, AV_OPT_TYPE_CONST, {.dbl = SECAM}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, + { "PALN", "", 0, AV_OPT_TYPE_CONST, {.dbl = PALN}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, + { "PALM", "", 0, AV_OPT_TYPE_CONST, {.dbl = PALM}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, + { "NTSCJ", "", 0, AV_OPT_TYPE_CONST, {.dbl = NTSCJ}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, + { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), AV_OPT_TYPE_STRING, {.str = "vga"}, 0, 0, DEC }, + { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, { NULL }, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/dshow.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/dshow.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/dshow.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/dshow.c 2011-11-04 12:38:27.000000000 +0000 @@ -926,17 +926,17 @@ #define OFFSET(x) offsetof(struct dshow_ctx, x) #define DEC AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { - { "video_size", "set video size given a string such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, - { "framerate", "set video frame rate", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, - { "sample_rate", "set audio sample rate", OFFSET(sample_rate), FF_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, DEC }, - { "sample_size", "set audio sample size", OFFSET(sample_size), FF_OPT_TYPE_INT, {.dbl = 0}, 0, 16, DEC }, - { "channels", "set number of audio channels, such as 1 or 2", OFFSET(channels), FF_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, DEC }, - { "list_devices", "list available devices", OFFSET(list_devices), FF_OPT_TYPE_INT, {.dbl=0}, 0, 1, DEC, "list_devices" }, - { "true", "", 0, FF_OPT_TYPE_CONST, {.dbl=1}, 0, 0, DEC, "list_devices" }, - { "false", "", 0, FF_OPT_TYPE_CONST, {.dbl=0}, 0, 0, DEC, "list_devices" }, - { "list_options", "list available options for specified device", OFFSET(list_options), FF_OPT_TYPE_INT, {.dbl=0}, 0, 1, DEC, "list_options" }, - { "true", "", 0, FF_OPT_TYPE_CONST, {.dbl=1}, 0, 0, DEC, "list_options" }, - { "false", "", 0, FF_OPT_TYPE_CONST, {.dbl=0}, 0, 0, DEC, "list_options" }, + { "video_size", "set video size given a string such as 640x480 or hd720.", OFFSET(video_size), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, + { "framerate", "set video frame rate", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, + { "sample_rate", "set audio sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, DEC }, + { "sample_size", "set audio sample size", OFFSET(sample_size), AV_OPT_TYPE_INT, {.dbl = 0}, 0, 16, DEC }, + { "channels", "set number of audio channels, such as 1 or 2", OFFSET(channels), AV_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, DEC }, + { "list_devices", "list available devices", OFFSET(list_devices), AV_OPT_TYPE_INT, {.dbl=0}, 0, 1, DEC, "list_devices" }, + { "true", "", 0, AV_OPT_TYPE_CONST, {.dbl=1}, 0, 0, DEC, "list_devices" }, + { "false", "", 0, AV_OPT_TYPE_CONST, {.dbl=0}, 0, 0, DEC, "list_devices" }, + { "list_options", "list available options for specified device", OFFSET(list_options), AV_OPT_TYPE_INT, {.dbl=0}, 0, 1, DEC, "list_options" }, + { "true", "", 0, AV_OPT_TYPE_CONST, {.dbl=1}, 0, 0, DEC, "list_options" }, + { "false", "", 0, AV_OPT_TYPE_CONST, {.dbl=0}, 0, 0, DEC, "list_options" }, { NULL }, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/dv1394.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/dv1394.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/dv1394.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/dv1394.c 2011-11-04 12:38:27.000000000 +0000 @@ -86,7 +86,7 @@ { struct dv1394_data *dv = context->priv_data; - dv->dv_demux = dv_init_demux(context); + dv->dv_demux = avpriv_dv_init_demux(context); if (!dv->dv_demux) goto failed; @@ -124,7 +124,7 @@ struct dv1394_data *dv = context->priv_data; int size; - size = dv_get_packet(dv->dv_demux, pkt); + size = avpriv_dv_get_packet(dv->dv_demux, pkt); if (size > 0) return size; @@ -186,7 +186,7 @@ av_dlog(context, "index %d, avail %d, done %d\n", dv->index, dv->avail, dv->done); - size = dv_produce_packet(dv->dv_demux, pkt, + size = avpriv_dv_produce_packet(dv->dv_demux, pkt, dv->ring + (dv->index * DV1394_PAL_FRAME_SIZE), DV1394_PAL_FRAME_SIZE, -1); dv->index = (dv->index + 1) % DV1394_RING_FRAMES; @@ -214,10 +214,10 @@ } static const AVOption options[] = { - { "standard", "", offsetof(struct dv1394_data, format), FF_OPT_TYPE_INT, {.dbl = DV1394_NTSC}, DV1394_PAL, DV1394_NTSC, AV_OPT_FLAG_DECODING_PARAM, "standard" }, - { "PAL", "", 0, FF_OPT_TYPE_CONST, {.dbl = DV1394_PAL}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, - { "NTSC", "", 0, FF_OPT_TYPE_CONST, {.dbl = DV1394_NTSC}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, - { "channel", "", offsetof(struct dv1394_data, channel), FF_OPT_TYPE_INT, {.dbl = DV1394_DEFAULT_CHANNEL}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, + { "standard", "", offsetof(struct dv1394_data, format), AV_OPT_TYPE_INT, {.dbl = DV1394_NTSC}, DV1394_PAL, DV1394_NTSC, AV_OPT_FLAG_DECODING_PARAM, "standard" }, + { "PAL", "", 0, AV_OPT_TYPE_CONST, {.dbl = DV1394_PAL}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, + { "NTSC", "", 0, AV_OPT_TYPE_CONST, {.dbl = DV1394_NTSC}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, + { "channel", "", offsetof(struct dv1394_data, channel), AV_OPT_TYPE_INT, {.dbl = DV1394_DEFAULT_CHANNEL}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, { NULL }, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/fbdev.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/fbdev.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/fbdev.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/fbdev.c 2011-11-04 12:38:27.000000000 +0000 @@ -108,7 +108,7 @@ return ret; } - if (!(st = av_new_stream(avctx, 0))) + if (!(st = avformat_new_stream(avctx, NULL))) return AVERROR(ENOMEM); av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in microseconds */ @@ -247,7 +247,7 @@ #define OFFSET(x) offsetof(FBDevContext, x) #define DEC AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { - { "framerate","", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC }, + { "framerate","", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC }, { NULL }, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/jack_audio.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/jack_audio.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/jack_audio.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/jack_audio.c 2011-11-04 12:38:27.000000000 +0000 @@ -28,7 +28,8 @@ #include "libavutil/fifo.h" #include "libavutil/opt.h" #include "libavcodec/avcodec.h" -#include "libavformat/timefilter.h" +#include "libavformat/avformat.h" +#include "timefilter.h" #include "avdevice.h" /** @@ -229,7 +230,7 @@ if ((test = start_jack(context))) return test; - stream = av_new_stream(context, 0); + stream = avformat_new_stream(context, NULL); if (!stream) { stop_jack(self); return AVERROR(ENOMEM); @@ -314,7 +315,7 @@ #define OFFSET(x) offsetof(JackData, x) static const AVOption options[] = { - { "channels", "Number of audio channels.", OFFSET(nports), FF_OPT_TYPE_INT, { 2 }, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, + { "channels", "Number of audio channels.", OFFSET(nports), AV_OPT_TYPE_INT, { 2 }, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, { NULL }, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/lavfi.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/lavfi.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/lavfi.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/lavfi.c 2011-11-04 12:38:27.000000000 +0000 @@ -299,7 +299,9 @@ avpicture_layout(&pict, ref->format, ref->video->w, ref->video->h, pkt->data, size); } else if (ref->audio) { - size = ref->linesize[0]; + size = ref->audio->nb_samples * + av_get_bytes_per_sample(ref->format) * + av_get_channel_layout_nb_channels(ref->audio->channel_layout); if ((ret = av_new_packet(pkt, size)) < 0) return ret; memcpy(pkt->data, ref->data[0], size); @@ -319,7 +321,7 @@ #define DEC AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { - { "graph", "Libavfilter graph", OFFSET(graph_str), FF_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC }, + { "graph", "Libavfilter graph", OFFSET(graph_str), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, DEC }, { NULL }, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/libcdio.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/libcdio.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/libcdio.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/libcdio.c 2011-11-04 12:38:27.000000000 +0000 @@ -54,7 +54,7 @@ int ret, i; char *err = NULL; - if (!(st = av_new_stream(ctx, 0))) + if (!(st = avformat_new_stream(ctx, NULL))) return AVERROR(ENOMEM); s->drive = cdio_cddap_identify(ctx->filename, CDDA_MESSAGE_LOGIT, &err); if (!s->drive) { @@ -98,7 +98,7 @@ for (i = 0; i < s->drive->tracks; i++) { char title[16]; snprintf(title, sizeof(title), "track %02d", s->drive->disc_toc[i].bTrack); - ff_new_chapter(ctx, i, st->time_base, s->drive->disc_toc[i].dwStartSector, + avpriv_new_chapter(ctx, i, st->time_base, s->drive->disc_toc[i].dwStartSector, s->drive->disc_toc[i+1].dwStartSector, title); } @@ -160,11 +160,11 @@ #define OFFSET(x) offsetof(CDIOContext, x) #define DEC AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { - { "speed", "Drive reading speed.", OFFSET(speed), FF_OPT_TYPE_INT, { 0 }, 0, INT_MAX, DEC }, - { "paranoia_mode", "Error recovery mode.", OFFSET(paranoia_mode), FF_OPT_TYPE_FLAGS, { 0 }, INT_MIN, INT_MAX, DEC, "paranoia_mode" }, - { "verify", "Verify data integrity in overlap area", 0, FF_OPT_TYPE_CONST, { PARANOIA_MODE_VERIFY }, 0, 0, DEC, "paranoia_mode" }, - { "overlap", "Perform overlapped reads.", 0, FF_OPT_TYPE_CONST, { PARANOIA_MODE_OVERLAP }, 0, 0, DEC, "paranoia_mode" }, - { "neverskip", "Do not skip failed reads.", 0, FF_OPT_TYPE_CONST, { PARANOIA_MODE_NEVERSKIP }, 0, 0, DEC, "paranoia_mode" }, + { "speed", "Drive reading speed.", OFFSET(speed), AV_OPT_TYPE_INT, { 0 }, 0, INT_MAX, DEC }, + { "paranoia_mode", "Error recovery mode.", OFFSET(paranoia_mode), AV_OPT_TYPE_FLAGS, { 0 }, INT_MIN, INT_MAX, DEC, "paranoia_mode" }, + { "verify", "Verify data integrity in overlap area", 0, AV_OPT_TYPE_CONST, { PARANOIA_MODE_VERIFY }, 0, 0, DEC, "paranoia_mode" }, + { "overlap", "Perform overlapped reads.", 0, AV_OPT_TYPE_CONST, { PARANOIA_MODE_OVERLAP }, 0, 0, DEC, "paranoia_mode" }, + { "neverskip", "Do not skip failed reads.", 0, AV_OPT_TYPE_CONST, { PARANOIA_MODE_NEVERSKIP }, 0, 0, DEC, "paranoia_mode" }, { NULL }, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/libdc1394.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/libdc1394.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/libdc1394.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/libdc1394.c 2011-11-04 12:38:27.000000000 +0000 @@ -85,9 +85,9 @@ #define OFFSET(x) offsetof(dc1394_data, x) #define DEC AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { - { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = "qvga"}, 0, 0, DEC }, - { "pixel_format", "", OFFSET(pixel_format), FF_OPT_TYPE_STRING, {.str = "uyvy422"}, 0, 0, DEC }, - { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "ntsc"}, 0, 0, DEC }, + { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), AV_OPT_TYPE_STRING, {.str = "qvga"}, 0, 0, DEC }, + { "pixel_format", "", OFFSET(pixel_format), AV_OPT_TYPE_STRING, {.str = "uyvy422"}, 0, 0, DEC }, + { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = "ntsc"}, 0, 0, DEC }, { NULL }, }; @@ -154,7 +154,7 @@ goto out; } } - + /* Choose the best mode. */ rate = (ap->time_base.num ? av_rescale(1000, ap->time_base.den, ap->time_base.num) : -1); max_score = -1; @@ -253,7 +253,7 @@ } /* create a video stream */ - vst = av_new_stream(c, 0); + vst = avformat_new_stream(c, NULL); if (!vst) goto out_camera; av_set_pts_info(vst, 64, 1, 1000); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/Makefile ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/Makefile --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/Makefile 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/Makefile 2011-11-04 12:38:27.000000000 +0000 @@ -10,7 +10,7 @@ # input/output devices OBJS-$(CONFIG_ALSA_INDEV) += alsa-audio-common.o \ - alsa-audio-dec.o + alsa-audio-dec.o timefilter.o OBJS-$(CONFIG_ALSA_OUTDEV) += alsa-audio-common.o \ alsa-audio-enc.o OBJS-$(CONFIG_BKTR_INDEV) += bktr.o @@ -19,11 +19,12 @@ dshow_pin.o dshow_common.o OBJS-$(CONFIG_DV1394_INDEV) += dv1394.o OBJS-$(CONFIG_FBDEV_INDEV) += fbdev.o -OBJS-$(CONFIG_JACK_INDEV) += jack_audio.o +OBJS-$(CONFIG_JACK_INDEV) += jack_audio.o timefilter.o OBJS-$(CONFIG_LAVFI_INDEV) += lavfi.o OBJS-$(CONFIG_OPENAL_INDEV) += openal-dec.o OBJS-$(CONFIG_OSS_INDEV) += oss_audio.o OBJS-$(CONFIG_OSS_OUTDEV) += oss_audio.o +OBJS-$(CONFIG_PULSE_INDEV) += pulse.o OBJS-$(CONFIG_SDL_OUTDEV) += sdl.o OBJS-$(CONFIG_SNDIO_INDEV) += sndio_common.o sndio_dec.o OBJS-$(CONFIG_SNDIO_OUTDEV) += sndio_common.o sndio_enc.o @@ -39,4 +40,6 @@ SKIPHEADERS-$(HAVE_ALSA_ASOUNDLIB_H) += alsa-audio.h SKIPHEADERS-$(HAVE_SNDIO_H) += sndio_common.h +TESTPROGS = timefilter + include $(SRC_PATH)/subdir.mak diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/openal-dec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/openal-dec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/openal-dec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/openal-dec.c 2011-11-04 12:38:27.000000000 +0000 @@ -221,12 +221,12 @@ #define OFFSET(x) offsetof(al_data, x) static const AVOption options[] = { - {"channels", "set number of channels", OFFSET(channels), FF_OPT_TYPE_INT, {.dbl=2}, 1, 2, AV_OPT_FLAG_DECODING_PARAM }, - {"sample_rate", "set sample rate", OFFSET(sample_rate), FF_OPT_TYPE_INT, {.dbl=44100}, 1, 192000, AV_OPT_FLAG_DECODING_PARAM }, - {"sample_size", "set sample size", OFFSET(sample_size), FF_OPT_TYPE_INT, {.dbl=16}, 8, 16, AV_OPT_FLAG_DECODING_PARAM }, - {"list_devices", "list available devices", OFFSET(list_devices), FF_OPT_TYPE_INT, {.dbl=0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM, "list_devices" }, - {"true", "", 0, FF_OPT_TYPE_CONST, {.dbl=1}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "list_devices" }, - {"false", "", 0, FF_OPT_TYPE_CONST, {.dbl=0}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "list_devices" }, + {"channels", "set number of channels", OFFSET(channels), AV_OPT_TYPE_INT, {.dbl=2}, 1, 2, AV_OPT_FLAG_DECODING_PARAM }, + {"sample_rate", "set sample rate", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.dbl=44100}, 1, 192000, AV_OPT_FLAG_DECODING_PARAM }, + {"sample_size", "set sample size", OFFSET(sample_size), AV_OPT_TYPE_INT, {.dbl=16}, 8, 16, AV_OPT_FLAG_DECODING_PARAM }, + {"list_devices", "list available devices", OFFSET(list_devices), AV_OPT_TYPE_INT, {.dbl=0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM, "list_devices" }, + {"true", "", 0, AV_OPT_TYPE_CONST, {.dbl=1}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "list_devices" }, + {"false", "", 0, AV_OPT_TYPE_CONST, {.dbl=0}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "list_devices" }, {NULL}, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/oss_audio.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/oss_audio.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/oss_audio.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/oss_audio.c 2011-11-04 12:38:27.000000000 +0000 @@ -209,7 +209,7 @@ AVStream *st; int ret; - st = av_new_stream(s1, 0); + st = avformat_new_stream(s1, NULL); if (!st) { return AVERROR(ENOMEM); } @@ -282,8 +282,8 @@ #if CONFIG_OSS_INDEV static const AVOption options[] = { - { "sample_rate", "", offsetof(AudioData, sample_rate), FF_OPT_TYPE_INT, {.dbl = 48000}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, - { "channels", "", offsetof(AudioData, channels), FF_OPT_TYPE_INT, {.dbl = 2}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, + { "sample_rate", "", offsetof(AudioData, sample_rate), AV_OPT_TYPE_INT, {.dbl = 48000}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, + { "channels", "", offsetof(AudioData, channels), AV_OPT_TYPE_INT, {.dbl = 2}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, { NULL }, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/pulse.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/pulse.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/pulse.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/pulse.c 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,190 @@ +/* + * Pulseaudio input + * Copyright (c) 2011 Luca Barbato + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * PulseAudio input using the simple API. + * @author Luca Barbato + * + */ + +#include +#include +#include + +#include "libavformat/avformat.h" +#include "libavutil/opt.h" + +#define DEFAULT_CODEC_ID AV_NE(CODEC_ID_PCM_S16BE, CODEC_ID_PCM_S16LE) + +typedef struct PulseData { + AVClass *class; + char *server; + char *name; + char *stream_name; + int sample_rate; + int channels; + int frame_size; + int fragment_size; + pa_simple *s; + int64_t pts; +} PulseData; + +static pa_sample_format_t codec_id_to_pulse_format(int codec_id) { + switch (codec_id) { + case CODEC_ID_PCM_U8: return PA_SAMPLE_U8; + case CODEC_ID_PCM_ALAW: return PA_SAMPLE_ALAW; + case CODEC_ID_PCM_MULAW: return PA_SAMPLE_ULAW; + case CODEC_ID_PCM_S16LE: return PA_SAMPLE_S16LE; + case CODEC_ID_PCM_S16BE: return PA_SAMPLE_S16BE; + case CODEC_ID_PCM_F32LE: return PA_SAMPLE_FLOAT32LE; + case CODEC_ID_PCM_F32BE: return PA_SAMPLE_FLOAT32BE; + case CODEC_ID_PCM_S32LE: return PA_SAMPLE_S32LE; + case CODEC_ID_PCM_S32BE: return PA_SAMPLE_S32BE; + case CODEC_ID_PCM_S24LE: return PA_SAMPLE_S24LE; + case CODEC_ID_PCM_S24BE: return PA_SAMPLE_S24BE; + default: return PA_SAMPLE_INVALID; + } +} + +static av_cold int pulse_read_header(AVFormatContext *s, + AVFormatParameters *ap) +{ + PulseData *pd = s->priv_data; + AVStream *st; + char *device = NULL; + int ret; + enum CodecID codec_id = + s->audio_codec_id == CODEC_ID_NONE ? DEFAULT_CODEC_ID : s->audio_codec_id; + const pa_sample_spec ss = { codec_id_to_pulse_format(codec_id), + pd->sample_rate, + pd->channels }; + + pa_buffer_attr attr = { -1 }; + + st = avformat_new_stream(s, NULL); + + if (!st) { + av_log(s, AV_LOG_ERROR, "Cannot add stream\n"); + return AVERROR(ENOMEM); + } + + attr.fragsize = pd->fragment_size; + + if (strcmp(s->filename, "default")) + device = s->filename; + + pd->s = pa_simple_new(pd->server, pd->name, + PA_STREAM_RECORD, + device, pd->stream_name, &ss, + NULL, &attr, &ret); + + if (!pd->s) { + av_log(s, AV_LOG_ERROR, "pa_simple_new failed: %s\n", + pa_strerror(ret)); + return AVERROR(EIO); + } + /* take real parameters */ + st->codec->codec_type = AVMEDIA_TYPE_AUDIO; + st->codec->codec_id = codec_id; + st->codec->sample_rate = pd->sample_rate; + st->codec->channels = pd->channels; + av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ + + pd->pts = AV_NOPTS_VALUE; + + return 0; +} + +static int pulse_read_packet(AVFormatContext *s, AVPacket *pkt) +{ + PulseData *pd = s->priv_data; + int res; + pa_usec_t latency; + uint64_t frame_duration = + (pd->frame_size*1000000LL) / (pd->sample_rate * pd->channels); + + if (av_new_packet(pkt, pd->frame_size) < 0) { + return AVERROR(ENOMEM); + } + + if ((pa_simple_read(pd->s, pkt->data, pkt->size, &res)) < 0) { + av_log(s, AV_LOG_ERROR, "pa_simple_read failed: %s\n", + pa_strerror(res)); + av_free_packet(pkt); + return AVERROR(EIO); + } + + if ((latency = pa_simple_get_latency(pd->s, &res)) == (pa_usec_t) -1) { + av_log(s, AV_LOG_ERROR, "pa_simple_get_latency() failed: %s\n", + pa_strerror(res)); + return AVERROR(EIO); + } + + if (pd->pts == AV_NOPTS_VALUE) { + pd->pts = -latency; + } + + pkt->pts = pd->pts; + + pd->pts += frame_duration; + + return 0; +} + +static av_cold int pulse_close(AVFormatContext *s) +{ + PulseData *pd = s->priv_data; + pa_simple_free(pd->s); + return 0; +} + +#define OFFSET(a) offsetof(PulseData, a) +#define D AV_OPT_FLAG_DECODING_PARAM + +static const AVOption options[] = { + { "server", "pulse server name", OFFSET(server), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, D }, + { "name", "application name", OFFSET(name), AV_OPT_TYPE_STRING, {.str = LIBAVFORMAT_IDENT}, 0, 0, D }, + { "stream_name", "stream description", OFFSET(stream_name), AV_OPT_TYPE_STRING, {.str = "record"}, 0, 0, D }, + { "sample_rate", "sample rate in Hz", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.dbl = 48000}, 1, INT_MAX, D }, + { "channels", "number of audio channels", OFFSET(channels), AV_OPT_TYPE_INT, {.dbl = 2}, 1, INT_MAX, D }, + { "frame_size", "number of bytes per frame", OFFSET(frame_size), AV_OPT_TYPE_INT, {.dbl = 1024}, 1, INT_MAX, D }, + { "fragment_size", "buffering size, affects latency and cpu usage", OFFSET(fragment_size), AV_OPT_TYPE_INT, {.dbl = -1}, -1, INT_MAX, D }, + { NULL }, +}; + +static const AVClass pulse_demuxer_class = { + .class_name = "Pulse demuxer", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + +AVInputFormat ff_pulse_demuxer = { + .name = "pulse", + .long_name = NULL_IF_CONFIG_SMALL("Pulse audio input"), + .priv_data_size = sizeof(PulseData), + .read_header = pulse_read_header, + .read_packet = pulse_read_packet, + .read_close = pulse_close, + .flags = AVFMT_NOFILE, + .priv_class = &pulse_demuxer_class, +}; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/sdl.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/sdl.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/sdl.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/sdl.c 2011-11-04 12:38:27.000000000 +0000 @@ -203,9 +203,9 @@ #define OFFSET(x) offsetof(SDLContext,x) static const AVOption options[] = { - { "window_title", "SDL window title", OFFSET(window_title), FF_OPT_TYPE_STRING, {.str = NULL }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM }, - { "icon_title", "SDL iconified window title", OFFSET(icon_title) , FF_OPT_TYPE_STRING, {.str = NULL }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM }, - { "window_size", "SDL window forced size", OFFSET(window_size) , FF_OPT_TYPE_STRING, {.str = NULL }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM }, + { "window_title", "SDL window title", OFFSET(window_title), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM }, + { "icon_title", "SDL iconified window title", OFFSET(icon_title) , AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM }, + { "window_size", "SDL window forced size", OFFSET(window_size) , AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, AV_OPT_FLAG_ENCODING_PARAM }, { NULL }, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/sndio_dec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/sndio_dec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/sndio_dec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/sndio_dec.c 2011-11-04 12:38:27.000000000 +0000 @@ -34,7 +34,7 @@ AVStream *st; int ret; - st = av_new_stream(s1, 0); + st = avformat_new_stream(s1, NULL); if (!st) return AVERROR(ENOMEM); @@ -93,8 +93,8 @@ } static const AVOption options[] = { - { "sample_rate", "", offsetof(SndioData, sample_rate), FF_OPT_TYPE_INT, {.dbl = 48000}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, - { "channels", "", offsetof(SndioData, channels), FF_OPT_TYPE_INT, {.dbl = 2}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, + { "sample_rate", "", offsetof(SndioData, sample_rate), AV_OPT_TYPE_INT, {.dbl = 48000}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, + { "channels", "", offsetof(SndioData, channels), AV_OPT_TYPE_INT, {.dbl = 2}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, { NULL }, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/timefilter.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/timefilter.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/timefilter.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/timefilter.c 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,151 @@ +/* + * Delay Locked Loop based time filter + * Copyright (c) 2009 Samalyse + * Copyright (c) 2009 Michael Niedermayer + * Author: Olivier Guilyardi + * Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +#include "config.h" +#include "timefilter.h" +#include "libavutil/mem.h" + +struct TimeFilter { + /// Delay Locked Loop data. These variables refer to mathematical + /// concepts described in: http://www.kokkinizita.net/papers/usingdll.pdf + double cycle_time; + double feedback2_factor; + double feedback3_factor; + double clock_period; + int count; +}; + +TimeFilter * ff_timefilter_new(double clock_period, double feedback2_factor, double feedback3_factor) +{ + TimeFilter *self = av_mallocz(sizeof(TimeFilter)); + self->clock_period = clock_period; + self->feedback2_factor = feedback2_factor; + self->feedback3_factor = feedback3_factor; + return self; +} + +void ff_timefilter_destroy(TimeFilter *self) +{ + av_freep(&self); +} + +void ff_timefilter_reset(TimeFilter *self) +{ + self->count = 0; +} + +double ff_timefilter_update(TimeFilter *self, double system_time, double period) +{ + self->count++; + if (self->count==1) { + /// init loop + self->cycle_time = system_time; + } else { + double loop_error; + self->cycle_time += self->clock_period * period; + /// calculate loop error + loop_error = system_time - self->cycle_time; + + /// update loop + self->cycle_time += FFMAX(self->feedback2_factor, 1.0/(self->count)) * loop_error; + self->clock_period += self->feedback3_factor * loop_error / period; + } + return self->cycle_time; +} + +#ifdef TEST +#include "libavutil/lfg.h" +#define LFG_MAX ((1LL << 32) - 1) + +#undef printf + +int main(void) +{ + AVLFG prng; + double n0,n1; +#define SAMPLES 1000 + double ideal[SAMPLES]; + double samples[SAMPLES]; +#if 1 + for(n0= 0; n0<40; n0=2*n0+1){ + for(n1= 0; n1<10; n1=2*n1+1){ +#else + {{ + n0=7; + n1=1; +#endif + double best_error= 1000000000; + double bestpar0=1; + double bestpar1=0.001; + int better, i; + + av_lfg_init(&prng, 123); + for(i=0; i + * Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVDEVICE_TIMEFILTER_H +#define AVDEVICE_TIMEFILTER_H + +/** + * Opaque type representing a time filter state + * + * The purpose of this filter is to provide a way to compute accurate time + * stamps that can be compared to wall clock time, especially when dealing + * with two clocks: the system clock and a hardware device clock, such as + * a soundcard. + */ +typedef struct TimeFilter TimeFilter; + + +/** + * Create a new Delay Locked Loop time filter + * + * feedback2_factor and feedback3_factor are the factors used for the + * multiplications that are respectively performed in the second and third + * feedback paths of the loop. + * + * Unless you know what you are doing, you should set these as follow: + * + * o = 2 * M_PI * bandwidth * period + * feedback2_factor = sqrt(2 * o) + * feedback3_factor = o * o + * + * Where bandwidth is up to you to choose. Smaller values will filter out more + * of the jitter, but also take a longer time for the loop to settle. A good + * starting point is something between 0.3 and 3 Hz. + * + * @param clock_period period of the hardware clock in seconds + * (for example 1.0/44100) + * + * For more details about these parameters and background concepts please see: + * http://www.kokkinizita.net/papers/usingdll.pdf + */ +TimeFilter * ff_timefilter_new(double clock_period, double feedback2_factor, double feedback3_factor); + +/** + * Update the filter + * + * This function must be called in real time, at each process cycle. + * + * @param period the device cycle duration in clock_periods. For example, at + * 44.1kHz and a buffer size of 512 frames, period = 512 when clock_period + * was 1.0/44100, or 512/44100 if clock_period was 1. + * + * system_time, in seconds, should be the value of the system clock time, + * at (or as close as possible to) the moment the device hardware interrupt + * occured (or any other event the device clock raises at the beginning of a + * cycle). + * + * @return the filtered time, in seconds + */ +double ff_timefilter_update(TimeFilter *self, double system_time, double period); + +/** + * Reset the filter + * + * This function should mainly be called in case of XRUN. + * + * Warning: after calling this, the filter is in an undetermined state until + * the next call to ff_timefilter_update() + */ +void ff_timefilter_reset(TimeFilter *); + +/** + * Free all resources associated with the filter + */ +void ff_timefilter_destroy(TimeFilter *); + +#endif /* AVDEVICE_TIMEFILTER_H */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/v4l2.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/v4l2.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/v4l2.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/v4l2.c 2011-11-04 12:38:27.000000000 +0000 @@ -44,13 +44,13 @@ #include #endif #include -#include #include "libavutil/imgutils.h" #include "libavutil/log.h" #include "libavutil/opt.h" #include "avdevice.h" #include "libavutil/parseutils.h" #include "libavutil/pixdesc.h" +#include "libavutil/avstring.h" static const int desired_video_buffers = 256; @@ -470,7 +470,7 @@ for (i = 0;; i++) { standard.index = i; ret = ioctl(s->fd, VIDIOC_ENUMSTD, &standard); - if (ret < 0 || !strcasecmp(standard.name, s->standard)) + if (ret < 0 || !av_strcasecmp(standard.name, s->standard)) break; } if (ret < 0) { @@ -560,7 +560,7 @@ enum CodecID codec_id; enum PixelFormat pix_fmt = PIX_FMT_NONE; - st = av_new_stream(s1, 0); + st = avformat_new_stream(s1, NULL); if (!st) { res = AVERROR(ENOMEM); goto out; @@ -689,11 +689,11 @@ #define DEC AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { - { "standard", "", OFFSET(standard), FF_OPT_TYPE_STRING, {.str = NULL }, 0, 0, AV_OPT_FLAG_DECODING_PARAM }, - { "channel", "", OFFSET(channel), FF_OPT_TYPE_INT, {.dbl = 0 }, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, - { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, - { "pixel_format", "", OFFSET(pixel_format), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, - { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, + { "standard", "", OFFSET(standard), AV_OPT_TYPE_STRING, {.str = NULL }, 0, 0, AV_OPT_FLAG_DECODING_PARAM }, + { "channel", "", OFFSET(channel), AV_OPT_TYPE_INT, {.dbl = 0 }, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, + { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, + { "pixel_format", "", OFFSET(pixel_format), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, + { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, { NULL }, }; @@ -705,7 +705,7 @@ }; AVInputFormat ff_v4l2_demuxer = { - .name = "video4linux2", + .name = "video4linux2,v4l2", .long_name = NULL_IF_CONFIG_SMALL("Video4Linux2 device grab"), .priv_data_size = sizeof(struct video_data), .read_header = v4l2_read_header, diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/v4l.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/v4l.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/v4l.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/v4l.c 2011-11-04 12:38:27.000000000 +0000 @@ -98,7 +98,7 @@ s->video_win.width = ap->width; s->video_win.height = ap->height; - st = av_new_stream(s1, 0); + st = avformat_new_stream(s1, NULL); if (!st) return AVERROR(ENOMEM); av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ @@ -339,10 +339,10 @@ } static const AVOption options[] = { - { "standard", "", offsetof(VideoData, standard), FF_OPT_TYPE_INT, {.dbl = VIDEO_MODE_NTSC}, VIDEO_MODE_PAL, VIDEO_MODE_NTSC, AV_OPT_FLAG_DECODING_PARAM, "standard" }, - { "PAL", "", 0, FF_OPT_TYPE_CONST, {.dbl = VIDEO_MODE_PAL}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, - { "SECAM", "", 0, FF_OPT_TYPE_CONST, {.dbl = VIDEO_MODE_SECAM}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, - { "NTSC", "", 0, FF_OPT_TYPE_CONST, {.dbl = VIDEO_MODE_NTSC}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, + { "standard", "", offsetof(VideoData, standard), AV_OPT_TYPE_INT, {.dbl = VIDEO_MODE_NTSC}, VIDEO_MODE_PAL, VIDEO_MODE_NTSC, AV_OPT_FLAG_DECODING_PARAM, "standard" }, + { "PAL", "", 0, AV_OPT_TYPE_CONST, {.dbl = VIDEO_MODE_PAL}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, + { "SECAM", "", 0, AV_OPT_TYPE_CONST, {.dbl = VIDEO_MODE_SECAM}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, + { "NTSC", "", 0, AV_OPT_TYPE_CONST, {.dbl = VIDEO_MODE_NTSC}, 0, 0, AV_OPT_FLAG_DECODING_PARAM, "standard" }, { NULL }, }; @@ -354,7 +354,7 @@ }; AVInputFormat ff_v4l_demuxer = { - .name = "video4linux", + .name = "video4linux,v4l", .long_name = NULL_IF_CONFIG_SMALL("Video4Linux device grab"), .priv_data_size = sizeof(VideoData), .read_header = grab_read_header, diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/vfwcap.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/vfwcap.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/vfwcap.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/vfwcap.c 2011-11-04 12:38:27.000000000 +0000 @@ -293,7 +293,7 @@ SetWindowLongPtr(ctx->hwnd, GWLP_USERDATA, (LONG_PTR) s); - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if(!st) { vfw_read_close(s); return AVERROR(ENOMEM); @@ -458,8 +458,8 @@ #define OFFSET(x) offsetof(struct vfw_ctx, x) #define DEC AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { - { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, - { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "ntsc"}, 0, 0, DEC }, + { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, + { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = "ntsc"}, 0, 0, DEC }, { NULL }, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/x11grab.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/x11grab.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavdevice/x11grab.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavdevice/x11grab.c 2011-11-04 12:38:27.000000000 +0000 @@ -194,7 +194,7 @@ goto out; } - st = av_new_stream(s1, 0); + st = avformat_new_stream(s1, NULL); if (!st) { ret = AVERROR(ENOMEM); goto out; @@ -581,13 +581,13 @@ #define OFFSET(x) offsetof(struct x11_grab, x) #define DEC AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { - { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = "vga"}, 0, 0, DEC }, - { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "ntsc"}, 0, 0, DEC }, - { "draw_mouse", "Draw the mouse pointer.", OFFSET(draw_mouse), FF_OPT_TYPE_INT, { 1 }, 0, 1, DEC }, + { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), AV_OPT_TYPE_STRING, {.str = "vga"}, 0, 0, DEC }, + { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = "ntsc"}, 0, 0, DEC }, + { "draw_mouse", "Draw the mouse pointer.", OFFSET(draw_mouse), AV_OPT_TYPE_INT, { 1 }, 0, 1, DEC }, { "follow_mouse", "Move the grabbing region when the mouse pointer reaches within specified amount of pixels to the edge of region.", - OFFSET(follow_mouse), FF_OPT_TYPE_INT, { 0 }, -1, INT_MAX, DEC, "follow_mouse" }, - { "centered", "Keep the mouse pointer at the center of grabbing region when following.", 0, FF_OPT_TYPE_CONST, { -1 }, INT_MIN, INT_MAX, DEC, "follow_mouse" }, - { "show_region", "Show the grabbing region.", OFFSET(show_region), FF_OPT_TYPE_INT, { 0 }, 0, 1, DEC }, + OFFSET(follow_mouse), AV_OPT_TYPE_INT, { 0 }, -1, INT_MAX, DEC, "follow_mouse" }, + { "centered", "Keep the mouse pointer at the center of grabbing region when following.", 0, AV_OPT_TYPE_CONST, { -1 }, INT_MIN, INT_MAX, DEC, "follow_mouse" }, + { "show_region", "Show the grabbing region.", OFFSET(show_region), AV_OPT_TYPE_INT, { 0 }, 0, 1, DEC }, { NULL }, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/af_aconvert.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/af_aconvert.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/af_aconvert.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/af_aconvert.c 2011-11-04 12:38:27.000000000 +0000 @@ -28,6 +28,7 @@ */ #include "libavutil/audioconvert.h" +#include "libavutil/avstring.h" #include "libavcodec/audioconvert.h" #include "avfilter.h" #include "internal.h" @@ -125,15 +126,15 @@ aconvert->out_chlayout = 0; aconvert->out_packing_fmt = -1; - if ((arg = strtok_r(args, ":", &ptr)) && strcmp(arg, "auto")) { + if ((arg = av_strtok(args, ":", &ptr)) && strcmp(arg, "auto")) { if ((ret = ff_parse_sample_format(&aconvert->out_sample_fmt, arg, ctx)) < 0) goto end; } - if ((arg = strtok_r(NULL, ":", &ptr)) && strcmp(arg, "auto")) { + if ((arg = av_strtok(NULL, ":", &ptr)) && strcmp(arg, "auto")) { if ((ret = ff_parse_channel_layout(&aconvert->out_chlayout, arg, ctx)) < 0) goto end; } - if ((arg = strtok_r(NULL, ":", &ptr)) && strcmp(arg, "auto")) { + if ((arg = av_strtok(NULL, ":", &ptr)) && strcmp(arg, "auto")) { if ((ret = ff_parse_packing_format((int *)&aconvert->out_packing_fmt, arg, ctx)) < 0) goto end; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/af_aformat.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/af_aformat.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/af_aformat.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/af_aformat.c 2011-11-04 12:38:27.000000000 +0000 @@ -50,7 +50,7 @@ aformat->fmts_list = all_formats; \ } else { \ for (fmt_str = fmts_str; \ - fmt_str = strtok_r(fmt_str, ",", &ptr); fmt_str = NULL) { \ + fmt_str = av_strtok(fmt_str, ",", &ptr); fmt_str = NULL) { \ if ((ret = ff_parse_##fmt_name((fmt_type *)&fmt, \ fmt_str, ctx)) < 0) { \ av_freep(&fmts_str); \ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/af_aresample.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/af_aresample.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/af_aresample.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/af_aresample.c 2011-11-04 12:38:27.000000000 +0000 @@ -83,6 +83,7 @@ aresample->out_rate = outlink->sample_rate; else outlink->sample_rate = aresample->out_rate; + outlink->time_base = (AVRational) {1, aresample->out_rate}; //TODO: make the resampling parameters configurable aresample->resample = av_resample_init(aresample->out_rate, inlink->sample_rate, @@ -270,13 +271,14 @@ aresample->outsamplesref = avfilter_get_audio_buffer(outlink, AV_PERM_WRITE, requested_out_nb_samples); - avfilter_copy_buffer_ref_props(aresample->outsamplesref, insamplesref); - aresample->outsamplesref->pts = - insamplesref->pts / inlink->sample_rate * outlink->sample_rate; - aresample->outsamplesref->audio->sample_rate = outlink->sample_rate; outlink->out_buf = aresample->outsamplesref; } + avfilter_copy_buffer_ref_props(aresample->outsamplesref, insamplesref); + aresample->outsamplesref->audio->sample_rate = outlink->sample_rate; + aresample->outsamplesref->pts = + av_rescale(outlink->sample_rate, insamplesref->pts, inlink->sample_rate); + /* av_resample() works with planar audio buffers */ if (!inlink->planar && nb_channels > 1) { int16_t *out[8]; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/af_ashowinfo.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/af_ashowinfo.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/af_ashowinfo.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/af_ashowinfo.c 2011-11-04 12:38:27.000000000 +0000 @@ -20,7 +20,7 @@ /** * @file - * filter fow showing textual audio frame information + * filter for showing textual audio frame information */ #include "libavutil/adler32.h" @@ -45,10 +45,14 @@ uint32_t plane_checksum[8] = {0}, checksum = 0; char chlayout_str[128]; int plane; + int linesize = + samplesref->audio->nb_samples * + av_get_bytes_per_sample(samplesref->format); + if (!samplesref->audio->planar) /* packed layout */ + linesize *= av_get_channel_layout_nb_channels(samplesref->audio->channel_layout); for (plane = 0; samplesref->data[plane] && plane < 8; plane++) { uint8_t *data = samplesref->data[plane]; - int linesize = samplesref->linesize[plane]; plane_checksum[plane] = av_adler32_update(plane_checksum[plane], data, linesize); @@ -61,7 +65,7 @@ av_log(ctx, AV_LOG_INFO, "n:%d pts:%"PRId64" pts_time:%f pos:%"PRId64" " "fmt:%s chlayout:%s nb_samples:%d rate:%d planar:%d " - "checksum:%u plane_checksum[%u %u %u %u %u %u %u %u]\n", + "checksum:%08X plane_checksum[%08X %08X %08X %08X %08X %08X %08X %08X]\n", showinfo->frame, samplesref->pts, samplesref->pts * av_q2d(inlink->time_base), samplesref->pos, diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/allfilters.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/allfilters.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/allfilters.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/allfilters.c 2011-11-04 12:38:27.000000000 +0000 @@ -41,6 +41,7 @@ REGISTER_FILTER (ASHOWINFO, ashowinfo, af); REGISTER_FILTER (ABUFFER, abuffer, asrc); + REGISTER_FILTER (AEVALSRC, aevalsrc, asrc); REGISTER_FILTER (AMOVIE, amovie, asrc); REGISTER_FILTER (ANULLSRC, anullsrc, asrc); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/asrc_abuffer.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/asrc_abuffer.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/asrc_abuffer.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/asrc_abuffer.c 2011-11-04 12:38:27.000000000 +0000 @@ -25,6 +25,7 @@ */ #include "libavutil/audioconvert.h" +#include "libavutil/avstring.h" #include "libavutil/fifo.h" #include "asrc_abuffer.h" #include "internal.h" @@ -256,7 +257,7 @@ char *args = av_strdup(args0); int ret; - arg = strtok_r(args, ":", &ptr); + arg = av_strtok(args, ":", &ptr); #define ADD_FORMAT(fmt_name) \ if (!arg) \ @@ -266,7 +267,7 @@ return ret; \ } \ if (*args) \ - arg = strtok_r(NULL, ":", &ptr) + arg = av_strtok(NULL, ":", &ptr) ADD_FORMAT(sample_rate); ADD_FORMAT(sample_format); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/asrc_aevalsrc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/asrc_aevalsrc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/asrc_aevalsrc.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/asrc_aevalsrc.c 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,226 @@ +/* + * Copyright (c) 2011 Stefano Sabatini + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * eval audio source + */ + +#include "libavutil/audioconvert.h" +#include "libavutil/avassert.h" +#include "libavutil/avstring.h" +#include "libavutil/eval.h" +#include "libavutil/opt.h" +#include "avfilter.h" +#include "internal.h" + +static const char *var_names[] = { + "n", ///< number of frame + "t", ///< timestamp expressed in seconds + "s", ///< sample rate + NULL +}; + +enum var_name { + VAR_N, + VAR_T, + VAR_S, + VAR_VARS_NB +}; + +typedef struct { + const AVClass *class; + char *sample_rate_str; + int sample_rate; + int64_t chlayout; + int nb_channels; + int64_t pts; + AVExpr *expr[8]; + char *expr_str[8]; + int nb_samples; ///< number of samples per requested frame + uint64_t n; + double var_values[VAR_VARS_NB]; +} EvalContext; + +#define OFFSET(x) offsetof(EvalContext, x) + +static const AVOption eval_options[]= { + { "nb_samples", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.dbl = 1024}, 0, INT_MAX }, + { "n", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.dbl = 1024}, 0, INT_MAX }, + { "sample_rate", "set the sample rate", OFFSET(sample_rate_str), AV_OPT_TYPE_STRING, {.str = "44100"}, CHAR_MIN, CHAR_MAX }, + { "s", "set the sample rate", OFFSET(sample_rate_str), AV_OPT_TYPE_STRING, {.str = "44100"}, CHAR_MIN, CHAR_MAX }, +{NULL}, +}; + +static const char *eval_get_name(void *ctx) +{ + return "aevalsrc"; +} + +static const AVClass eval_class = { + "AEvalSrcContext", + eval_get_name, + eval_options +}; + +static int init(AVFilterContext *ctx, const char *args, void *opaque) +{ + EvalContext *eval = ctx->priv; + char *args1 = av_strdup(args); + char *expr, *buf, *bufptr; + int ret, i; + + eval->class = &eval_class; + av_opt_set_defaults(eval); + + /* parse expressions */ + buf = args1; + i = 0; + while (expr = av_strtok(buf, ":", &bufptr)) { + if (i >= 8) { + av_log(ctx, AV_LOG_ERROR, + "More than 8 expressions provided, unsupported.\n"); + ret = AVERROR(EINVAL); + return ret; + } + ret = av_expr_parse(&eval->expr[i], expr, var_names, + NULL, NULL, NULL, NULL, 0, ctx); + if (ret < 0) + goto end; + i++; + if (bufptr && *bufptr == ':') { /* found last expression */ + bufptr++; + break; + } + buf = NULL; + } + + /* guess channel layout from nb expressions/channels */ + eval->nb_channels = i; + eval->chlayout = av_get_default_channel_layout(eval->nb_channels); + if (!eval->chlayout) { + av_log(ctx, AV_LOG_ERROR, "Invalid number of channels '%d' provided\n", + eval->nb_channels); + ret = AVERROR(EINVAL); + goto end; + } + + if (bufptr && (ret = av_set_options_string(eval, bufptr, "=", ":")) < 0) + goto end; + + if ((ret = ff_parse_sample_rate(&eval->sample_rate, eval->sample_rate_str, ctx))) + goto end; + eval->n = 0; + +end: + av_free(args1); + return ret; +} + +static void uninit(AVFilterContext *ctx) +{ + EvalContext *eval = ctx->priv; + int i; + + for (i = 0; i < 8; i++) { + av_expr_free(eval->expr[i]); + eval->expr[i] = NULL; + } + av_freep(&eval->sample_rate_str); +} + +static int config_props(AVFilterLink *outlink) +{ + EvalContext *eval = outlink->src->priv; + char buf[128]; + + outlink->time_base = (AVRational){1, eval->sample_rate}; + outlink->sample_rate = eval->sample_rate; + + eval->var_values[VAR_S] = eval->sample_rate; + + av_get_channel_layout_string(buf, sizeof(buf), 0, eval->chlayout); + + av_log(outlink->src, AV_LOG_INFO, + "sample_rate:%d chlayout:%s\n", eval->sample_rate, buf); + + return 0; +} + +static int query_formats(AVFilterContext *ctx) +{ + EvalContext *eval = ctx->priv; + enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_NONE }; + int64_t chlayouts[] = { eval->chlayout, -1 }; + int packing_fmts[] = { AVFILTER_PLANAR, -1 }; + + avfilter_set_common_sample_formats (ctx, avfilter_make_format_list(sample_fmts)); + avfilter_set_common_channel_layouts(ctx, avfilter_make_format64_list(chlayouts)); + avfilter_set_common_packing_formats(ctx, avfilter_make_format_list(packing_fmts)); + + return 0; +} + +static int request_frame(AVFilterLink *outlink) +{ + EvalContext *eval = outlink->src->priv; + AVFilterBufferRef *samplesref; + int i, j; + + samplesref = avfilter_get_audio_buffer(outlink, AV_PERM_WRITE, eval->nb_samples); + + /* evaluate expression for each single sample and for each channel */ + for (i = 0; i < eval->nb_samples; i++, eval->n++) { + eval->var_values[VAR_N] = eval->n; + eval->var_values[VAR_T] = eval->var_values[VAR_N] * (double)1/eval->sample_rate; + + for (j = 0; j < eval->nb_channels; j++) { + *((double *) samplesref->data[j] + i) = + av_expr_eval(eval->expr[j], eval->var_values, NULL); + } + } + + samplesref->pts = eval->pts; + samplesref->pos = -1; + samplesref->audio->sample_rate = eval->sample_rate; + eval->pts += eval->nb_samples; + + avfilter_filter_samples(outlink, samplesref); + + return 0; +} + +AVFilter avfilter_asrc_aevalsrc = { + .name = "aevalsrc", + .description = NULL_IF_CONFIG_SMALL("Generate an audio signal generated by an expression."), + + .query_formats = query_formats, + .init = init, + .uninit = uninit, + .priv_size = sizeof(EvalContext), + + .inputs = (AVFilterPad[]) {{ .name = NULL}}, + + .outputs = (AVFilterPad[]) {{ .name = "default", + .type = AVMEDIA_TYPE_AUDIO, + .config_props = config_props, + .request_frame = request_frame, }, + { .name = NULL}}, +}; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/asrc_anullsrc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/asrc_anullsrc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/asrc_anullsrc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/asrc_anullsrc.c 2011-11-04 12:38:27.000000000 +0000 @@ -40,12 +40,12 @@ #define OFFSET(x) offsetof(ANullContext, x) static const AVOption anullsrc_options[]= { - { "channel_layout", "set channel_layout", OFFSET(channel_layout_str), FF_OPT_TYPE_STRING, {.str = "stereo"}, 0, 0 }, - { "cl", "set channel_layout", OFFSET(channel_layout_str), FF_OPT_TYPE_STRING, {.str = "stereo"}, 0, 0 }, - { "sample_rate", "set sample rate", OFFSET(sample_rate_str) , FF_OPT_TYPE_STRING, {.str = "44100"}, 0, 0 }, - { "r", "set sample rate", OFFSET(sample_rate_str) , FF_OPT_TYPE_STRING, {.str = "44100"}, 0, 0 }, - { "nb_samples", "set the number of samples per requested frame", OFFSET(nb_samples), FF_OPT_TYPE_INT, {.dbl = 1024}, 0, INT_MAX }, - { "n", "set the number of samples per requested frame", OFFSET(nb_samples), FF_OPT_TYPE_INT, {.dbl = 1024}, 0, INT_MAX }, + { "channel_layout", "set channel_layout", OFFSET(channel_layout_str), AV_OPT_TYPE_STRING, {.str = "stereo"}, 0, 0 }, + { "cl", "set channel_layout", OFFSET(channel_layout_str), AV_OPT_TYPE_STRING, {.str = "stereo"}, 0, 0 }, + { "sample_rate", "set sample rate", OFFSET(sample_rate_str) , AV_OPT_TYPE_STRING, {.str = "44100"}, 0, 0 }, + { "r", "set sample rate", OFFSET(sample_rate_str) , AV_OPT_TYPE_STRING, {.str = "44100"}, 0, 0 }, + { "nb_samples", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.dbl = 1024}, 0, INT_MAX }, + { "n", "set the number of samples per requested frame", OFFSET(nb_samples), AV_OPT_TYPE_INT, {.dbl = 1024}, 0, INT_MAX }, { NULL }, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/avfilter.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/avfilter.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/avfilter.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/avfilter.c 2011-11-04 12:38:27.000000000 +0000 @@ -438,8 +438,8 @@ picref->type = AVMEDIA_TYPE_VIDEO; pic->format = picref->format = format; - memcpy(pic->data, data, sizeof(pic->data)); - memcpy(pic->linesize, linesize, sizeof(pic->linesize)); + memcpy(pic->data, data, 4*sizeof(data[0])); + memcpy(pic->linesize, linesize, 4*sizeof(linesize[0])); memcpy(picref->data, pic->data, sizeof(picref->data)); memcpy(picref->linesize, pic->linesize, sizeof(picref->linesize)); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/avfilter.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/avfilter.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/avfilter.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/avfilter.h 2011-11-04 12:38:27.000000000 +0000 @@ -29,8 +29,8 @@ #include "libavutil/rational.h" #define LIBAVFILTER_VERSION_MAJOR 2 -#define LIBAVFILTER_VERSION_MINOR 43 -#define LIBAVFILTER_VERSION_MICRO 6 +#define LIBAVFILTER_VERSION_MINOR 45 +#define LIBAVFILTER_VERSION_MICRO 3 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \ LIBAVFILTER_VERSION_MINOR, \ @@ -100,6 +100,9 @@ #define AV_PERM_REUSE 0x08 ///< can output the buffer multiple times, with the same contents each time #define AV_PERM_REUSE2 0x10 ///< can output the buffer multiple times, modified each time #define AV_PERM_NEG_LINESIZES 0x20 ///< the buffer requested can have negative linesizes +#define AV_PERM_ALIGN 0x40 ///< the buffer must be aligned + +#define AVFILTER_ALIGN 16 //not part of ABI /** * Audio specific properties in a reference to an AVFilterBuffer. Since diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/drawutils.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/drawutils.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/drawutils.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/drawutils.c 2011-11-04 12:38:27.000000000 +0000 @@ -23,16 +23,8 @@ enum { RED = 0, GREEN, BLUE, ALPHA }; -int ff_fill_line_with_color(uint8_t *line[4], int pixel_step[4], int w, uint8_t dst_color[4], - enum PixelFormat pix_fmt, uint8_t rgba_color[4], - int *is_packed_rgba, uint8_t rgba_map_ptr[4]) +int ff_fill_rgba_map(uint8_t *rgba_map, enum PixelFormat pix_fmt) { - uint8_t rgba_map[4] = {0}; - int i; - const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[pix_fmt]; - int hsub = pix_desc->log2_chroma_w; - - *is_packed_rgba = 1; switch (pix_fmt) { case PIX_FMT_ARGB: rgba_map[ALPHA] = 0; rgba_map[RED ] = 1; rgba_map[GREEN] = 2; rgba_map[BLUE ] = 3; break; case PIX_FMT_ABGR: rgba_map[ALPHA] = 0; rgba_map[BLUE ] = 1; rgba_map[GREEN] = 2; rgba_map[RED ] = 3; break; @@ -40,9 +32,22 @@ case PIX_FMT_RGB24: rgba_map[RED ] = 0; rgba_map[GREEN] = 1; rgba_map[BLUE ] = 2; rgba_map[ALPHA] = 3; break; case PIX_FMT_BGRA: case PIX_FMT_BGR24: rgba_map[BLUE ] = 0; rgba_map[GREEN] = 1; rgba_map[RED ] = 2; rgba_map[ALPHA] = 3; break; - default: - *is_packed_rgba = 0; + default: /* unsupported */ + return AVERROR(EINVAL); } + return 0; +} + +int ff_fill_line_with_color(uint8_t *line[4], int pixel_step[4], int w, uint8_t dst_color[4], + enum PixelFormat pix_fmt, uint8_t rgba_color[4], + int *is_packed_rgba, uint8_t rgba_map_ptr[4]) +{ + uint8_t rgba_map[4] = {0}; + int i; + const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[pix_fmt]; + int hsub = pix_desc->log2_chroma_w; + + *is_packed_rgba = ff_fill_rgba_map(rgba_map, pix_fmt) >= 0; if (*is_packed_rgba) { pixel_step[0] = (av_get_bits_per_pixel(pix_desc))>>3; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/drawutils.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/drawutils.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/drawutils.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/drawutils.h 2011-11-04 12:38:27.000000000 +0000 @@ -27,6 +27,8 @@ #include #include "libavutil/pixfmt.h" +int ff_fill_rgba_map(uint8_t *rgba_map, enum PixelFormat pix_fmt); + int ff_fill_line_with_color(uint8_t *line[4], int pixel_step[4], int w, uint8_t dst_color[4], enum PixelFormat pix_fmt, uint8_t rgba_color[4], diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/libmpcodecs/vf_palette.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/libmpcodecs/vf_palette.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/libmpcodecs/vf_palette.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/libmpcodecs/vf_palette.c 2011-11-04 12:38:27.000000000 +0000 @@ -16,10 +16,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#define _BSD_SOURCE //strcasecmp #include #include -#include #include #include "config.h" @@ -33,6 +31,8 @@ #include "libswscale/swscale.h" +#include "libavutil/avstring.h" + //===========================================================================// // commented out 16 and 15 bit output support, because the conversion @@ -208,14 +208,14 @@ for(i=0;i<256;i++) gray_pal[i]=0x01010101*i; if (args) { - if (!strcasecmp(args,"rgb15")) vf->priv->fmt=IMGFMT_RGB15; else - if (!strcasecmp(args,"rgb16")) vf->priv->fmt=IMGFMT_RGB16; else - if (!strcasecmp(args,"rgb24")) vf->priv->fmt=IMGFMT_RGB24; else - if (!strcasecmp(args,"rgb32")) vf->priv->fmt=IMGFMT_RGB32; else - if (!strcasecmp(args,"bgr15")) vf->priv->fmt=IMGFMT_BGR15; else - if (!strcasecmp(args,"bgr16")) vf->priv->fmt=IMGFMT_BGR16; else - if (!strcasecmp(args,"bgr24")) vf->priv->fmt=IMGFMT_BGR24; else - if (!strcasecmp(args,"bgr32")) vf->priv->fmt=IMGFMT_BGR32; else + if (!av_strcasecmp(args,"rgb15")) vf->priv->fmt=IMGFMT_RGB15; else + if (!av_strcasecmp(args,"rgb16")) vf->priv->fmt=IMGFMT_RGB16; else + if (!av_strcasecmp(args,"rgb24")) vf->priv->fmt=IMGFMT_RGB24; else + if (!av_strcasecmp(args,"rgb32")) vf->priv->fmt=IMGFMT_RGB32; else + if (!av_strcasecmp(args,"bgr15")) vf->priv->fmt=IMGFMT_BGR15; else + if (!av_strcasecmp(args,"bgr16")) vf->priv->fmt=IMGFMT_BGR16; else + if (!av_strcasecmp(args,"bgr24")) vf->priv->fmt=IMGFMT_BGR24; else + if (!av_strcasecmp(args,"bgr32")) vf->priv->fmt=IMGFMT_BGR32; else { mp_msg(MSGT_VFILTER, MSGL_WARN, MSGTR_MPCODECS_UnknownFormatName, args); return 0; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/Makefile ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/Makefile --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/Makefile 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/Makefile 2011-11-04 12:38:27.000000000 +0000 @@ -30,6 +30,7 @@ OBJS-$(CONFIG_ASHOWINFO_FILTER) += af_ashowinfo.o OBJS-$(CONFIG_ABUFFER_FILTER) += asrc_abuffer.o +OBJS-$(CONFIG_AEVALSRC_FILTER) += asrc_aevalsrc.o OBJS-$(CONFIG_AMOVIE_FILTER) += src_movie.o OBJS-$(CONFIG_ANULLSRC_FILTER) += asrc_anullsrc.o @@ -83,7 +84,7 @@ OBJS-$(CONFIG_FREI0R_SRC_FILTER) += vf_frei0r.o OBJS-$(CONFIG_MOVIE_FILTER) += src_movie.o OBJS-$(CONFIG_MPTESTSRC_FILTER) += vsrc_mptestsrc.o -OBJS-$(CONFIG_NULLSRC_FILTER) += vsrc_nullsrc.o +OBJS-$(CONFIG_NULLSRC_FILTER) += vsrc_testsrc.o OBJS-$(CONFIG_RGBTESTSRC_FILTER) += vsrc_testsrc.o OBJS-$(CONFIG_TESTSRC_FILTER) += vsrc_testsrc.o diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/src_movie.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/src_movie.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/src_movie.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/src_movie.c 2011-11-04 12:38:27.000000000 +0000 @@ -67,12 +67,12 @@ #define OFFSET(x) offsetof(MovieContext, x) static const AVOption movie_options[]= { -{"format_name", "set format name", OFFSET(format_name), FF_OPT_TYPE_STRING, {.str = 0}, CHAR_MIN, CHAR_MAX }, -{"f", "set format name", OFFSET(format_name), FF_OPT_TYPE_STRING, {.str = 0}, CHAR_MIN, CHAR_MAX }, -{"stream_index", "set stream index", OFFSET(stream_index), FF_OPT_TYPE_INT, {.dbl = -1}, -1, INT_MAX }, -{"si", "set stream index", OFFSET(stream_index), FF_OPT_TYPE_INT, {.dbl = -1}, -1, INT_MAX }, -{"seek_point", "set seekpoint (seconds)", OFFSET(seek_point_d), FF_OPT_TYPE_DOUBLE, {.dbl = 0}, 0, (INT64_MAX-1) / 1000000 }, -{"sp", "set seekpoint (seconds)", OFFSET(seek_point_d), FF_OPT_TYPE_DOUBLE, {.dbl = 0}, 0, (INT64_MAX-1) / 1000000 }, +{"format_name", "set format name", OFFSET(format_name), AV_OPT_TYPE_STRING, {.str = 0}, CHAR_MIN, CHAR_MAX }, +{"f", "set format name", OFFSET(format_name), AV_OPT_TYPE_STRING, {.str = 0}, CHAR_MIN, CHAR_MAX }, +{"stream_index", "set stream index", OFFSET(stream_index), AV_OPT_TYPE_INT, {.dbl = -1}, -1, INT_MAX }, +{"si", "set stream index", OFFSET(stream_index), AV_OPT_TYPE_INT, {.dbl = -1}, -1, INT_MAX }, +{"seek_point", "set seekpoint (seconds)", OFFSET(seek_point_d), AV_OPT_TYPE_DOUBLE, {.dbl = 0}, 0, (INT64_MAX-1) / 1000000 }, +{"sp", "set seekpoint (seconds)", OFFSET(seek_point_d), AV_OPT_TYPE_DOUBLE, {.dbl = 0}, 0, (INT64_MAX-1) / 1000000 }, {NULL}, }; @@ -258,7 +258,7 @@ movie->picref = avfilter_get_video_buffer(outlink, AV_PERM_WRITE | AV_PERM_PRESERVE | AV_PERM_REUSE2, outlink->w, outlink->h); av_image_copy(movie->picref->data, movie->picref->linesize, - movie->frame->data, movie->frame->linesize, + (void*)movie->frame->data, movie->frame->linesize, movie->picref->format, outlink->w, outlink->h); avfilter_copy_frame_props(movie->picref, movie->frame); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/transform.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/transform.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/transform.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/transform.h 2011-11-04 12:38:27.000000000 +0000 @@ -19,6 +19,9 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#ifndef AVFILTER_TRANSFORM_H +#define AVFILTER_TRANSFORM_H + /** * @file * transform input video @@ -60,44 +63,40 @@ * * [ zoom * cos(angle), -sin(angle), x_shift, * sin(angle), zoom * cos(angle), y_shift, - 0, 0, 1 ] + * 0, 0, 1 ] * - * Paramters: - * x_shift: Horizontal translation - * y_shift: Vertical translation - * angle: Rotation in radians - * zoom: Scale percent (1.0 = 100%) - * matrix: 9-item affine transformation matrix + * @param x_shift horizontal translation + * @param y_shift vertical translation + * @param angle rotation in radians + * @param zoom scale percent (1.0 = 100%) + * @param matrix 9-item affine transformation matrix */ void avfilter_get_matrix(float x_shift, float y_shift, float angle, float zoom, float *matrix); /** * Add two matrices together. result = m1 + m2. * - * Parameters: - * m1: 9-item transformation matrix - * m2: 9-item transformation matrix - * result: 9-item transformation matrix + * @param m1 9-item transformation matrix + * @param m2 9-item transformation matrix + * @param result 9-item transformation matrix */ void avfilter_add_matrix(const float *m1, const float *m2, float *result); /** * Subtract one matrix from another. result = m1 - m2. * - * Parameters: - * m1: 9-item transformation matrix - * m2: 9-item transformation matrix - * result: 9-item transformation matrix + * @param m1 9-item transformation matrix + * @param m2 9-item transformation matrix + * @param result 9-item transformation matrix */ void avfilter_sub_matrix(const float *m1, const float *m2, float *result); /** * Multiply a matrix by a scalar value. result = m1 * scalar. * - * Parameters: - * m1: 9-item transformation matrix - * scalar: A number - * result: 9-item transformation matrix + * @param m1 9-item transformation matrix + * @param scalar a number + * @param result 9-item transformation matrix */ void avfilter_mul_matrix(const float *m1, float scalar, float *result); @@ -106,16 +105,15 @@ * multiplies each vector [x,y,1] by the matrix and then interpolates to * get the final value. * - * Parameters: - * src: Source image - * dst: Destination image - * src_stride: Source image line size in bytes - * dst_stride: Destination image line size in bytes - * width: Image width in pixels - * height: Image height in pixels - * matrix: 9-item affine transformation matrix - * interpolate: Pixel interpolation method - * fill: Edge fill method + * @param src source image + * @param dst destination image + * @param src_stride source image line size in bytes + * @param dst_stride destination image line size in bytes + * @param width image width in pixels + * @param height image height in pixels + * @param matrix 9-item affine transformation matrix + * @param interpolate pixel interpolation method + * @param fill edge fill method */ void avfilter_transform(const uint8_t *src, uint8_t *dst, int src_stride, int dst_stride, @@ -123,3 +121,4 @@ enum InterpolateMethod interpolate, enum FillMethod fill); +#endif /* AVFILTER_TRANSFORM_H */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_boxblur.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_boxblur.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_boxblur.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_boxblur.c 2011-11-04 12:38:27.000000000 +0000 @@ -81,7 +81,7 @@ if (!args) { av_log(ctx, AV_LOG_ERROR, - "Filter expects 2 or 4 arguments, none provided\n"); + "Filter expects 2 or 4 or 6 arguments, none provided\n"); return AVERROR(EINVAL); } @@ -298,7 +298,9 @@ h, radius, power, temp); } -static void draw_slice(AVFilterLink *inlink, int y0, int h0, int slice_dir) +static void null_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir) { } + +static void end_frame(AVFilterLink *inlink) { AVFilterContext *ctx = inlink->dst; BoxBlurContext *boxblur = ctx->priv; @@ -306,9 +308,9 @@ AVFilterBufferRef *inpicref = inlink ->cur_buf; AVFilterBufferRef *outpicref = outlink->out_buf; int plane; - int cw = inlink->w >> boxblur->hsub, ch = h0 >> boxblur->vsub; + int cw = inlink->w >> boxblur->hsub, ch = inlink->h >> boxblur->vsub; int w[4] = { inlink->w, cw, cw, inlink->w }; - int h[4] = { h0, ch, ch, h0 }; + int h[4] = { inlink->h, ch, ch, inlink->h }; for (plane = 0; inpicref->data[plane] && plane < 4; plane++) hblur(outpicref->data[plane], outpicref->linesize[plane], @@ -322,7 +324,8 @@ w[plane], h[plane], boxblur->radius[plane], boxblur->power[plane], boxblur->temp); - avfilter_draw_slice(outlink, y0, h0, slice_dir); + avfilter_draw_slice(outlink, 0, inlink->h, 1); + avfilter_end_frame(outlink); } AVFilter avfilter_vf_boxblur = { @@ -336,7 +339,8 @@ .inputs = (AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_VIDEO, .config_props = config_input, - .draw_slice = draw_slice, + .draw_slice = null_draw_slice, + .end_frame = end_frame, .min_perms = AV_PERM_READ }, { .name = NULL}}, .outputs = (AVFilterPad[]) {{ .name = "default", diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_crop.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_crop.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_crop.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_crop.c 2011-11-04 12:38:27.000000000 +0000 @@ -33,9 +33,6 @@ #include "libavutil/mathematics.h" static const char *var_names[] = { - "E", - "PHI", - "PI", "in_w", "iw", ///< width of the input video "in_h", "ih", ///< height of the input video "out_w", "ow", ///< width of the cropped video @@ -54,9 +51,6 @@ }; enum var_name { - VAR_E, - VAR_PHI, - VAR_PI, VAR_IN_W, VAR_IW, VAR_IN_H, VAR_IH, VAR_OUT_W, VAR_OW, @@ -167,9 +161,6 @@ const char *expr; double res; - crop->var_values[VAR_E] = M_E; - crop->var_values[VAR_PHI] = M_PHI; - crop->var_values[VAR_PI] = M_PI; crop->var_values[VAR_IN_W] = crop->var_values[VAR_IW] = ctx->inputs[0]->w; crop->var_values[VAR_IN_H] = crop->var_values[VAR_IH] = ctx->inputs[0]->h; crop->var_values[VAR_A] = (float) link->w / link->h; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_delogo.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_delogo.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_delogo.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_delogo.c 2011-11-04 12:38:27.000000000 +0000 @@ -138,13 +138,13 @@ #define OFFSET(x) offsetof(DelogoContext, x) static const AVOption delogo_options[]= { - {"x", "set logo x position", OFFSET(x), FF_OPT_TYPE_INT, {.dbl=-1}, -1, INT_MAX }, - {"y", "set logo y position", OFFSET(y), FF_OPT_TYPE_INT, {.dbl=-1}, -1, INT_MAX }, - {"w", "set logo width", OFFSET(w), FF_OPT_TYPE_INT, {.dbl=-1}, -1, INT_MAX }, - {"h", "set logo height", OFFSET(h), FF_OPT_TYPE_INT, {.dbl=-1}, -1, INT_MAX }, - {"band", "set delogo area band size", OFFSET(band), FF_OPT_TYPE_INT, {.dbl= 4}, -1, INT_MAX }, - {"t", "set delogo area band size", OFFSET(band), FF_OPT_TYPE_INT, {.dbl= 4}, -1, INT_MAX }, - {"show", "show delogo area", OFFSET(show), FF_OPT_TYPE_INT, {.dbl= 0}, 0, 1 }, + {"x", "set logo x position", OFFSET(x), AV_OPT_TYPE_INT, {.dbl=-1}, -1, INT_MAX }, + {"y", "set logo y position", OFFSET(y), AV_OPT_TYPE_INT, {.dbl=-1}, -1, INT_MAX }, + {"w", "set logo width", OFFSET(w), AV_OPT_TYPE_INT, {.dbl=-1}, -1, INT_MAX }, + {"h", "set logo height", OFFSET(h), AV_OPT_TYPE_INT, {.dbl=-1}, -1, INT_MAX }, + {"band", "set delogo area band size", OFFSET(band), AV_OPT_TYPE_INT, {.dbl= 4}, -1, INT_MAX }, + {"t", "set delogo area band size", OFFSET(band), AV_OPT_TYPE_INT, {.dbl= 4}, -1, INT_MAX }, + {"show", "show delogo area", OFFSET(show), AV_OPT_TYPE_INT, {.dbl= 0}, 0, 1 }, {NULL}, }; @@ -154,9 +154,9 @@ } static const AVClass delogo_class = { - "DelogoContext", - delogo_get_name, - delogo_options + .class_name = "DelogoContext", + .item_name = delogo_get_name, + .option = delogo_options, }; static int query_formats(AVFilterContext *ctx) @@ -285,4 +285,4 @@ .outputs = (AVFilterPad[]) {{ .name = "default", .type = AVMEDIA_TYPE_VIDEO, }, { .name = NULL}}, -}; +}; \ No newline at end of file diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_deshake.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_deshake.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_deshake.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_deshake.c 2011-11-04 12:38:27.000000000 +0000 @@ -92,12 +92,14 @@ int refcount; ///< Number of reference frames (defines averaging window) FILE *fp; Transform avg; + int cw; ///< Crop motion search to this box + int ch; + int cx; + int cy; } DeshakeContext; -static int cmp(void const *ca, void const *cb) +static int cmp(const double *a, const double *b) { - double *a = (double *) ca; - double *b = (double *) cb; return *a < *b ? -1 : ( *a > *b ? 1 : 0 ); } @@ -110,7 +112,7 @@ int cut = count / 5; int x; - qsort(values, count, sizeof(double), cmp); + qsort(values, count, sizeof(double), (void*)cmp); for (x = cut; x < count - cut; x++) { mean += values[x]; @@ -343,8 +345,15 @@ deshake->search = EXHAUSTIVE; deshake->refcount = 20; + deshake->cw = -1; + deshake->ch = -1; + deshake->cx = -1; + deshake->cy = -1; + if (args) { - sscanf(args, "%d:%d:%d:%d:%d:%d:%255s", &deshake->rx, &deshake->ry, (int *)&deshake->edge, + sscanf(args, "%d:%d:%d:%d:%d:%d:%d:%d:%d:%d:%255s", + &deshake->cx, &deshake->cy, &deshake->cw, &deshake->ch, + &deshake->rx, &deshake->ry, (int *)&deshake->edge, &deshake->blocksize, &deshake->contrast, (int *)&deshake->search, filename); deshake->blocksize /= 2; @@ -355,13 +364,22 @@ deshake->blocksize = av_clip(deshake->blocksize, 4, 128); deshake->contrast = av_clip(deshake->contrast, 1, 255); deshake->search = av_clip(deshake->search, EXHAUSTIVE, SEARCH_COUNT - 1); + } if (*filename) deshake->fp = fopen(filename, "w"); if (deshake->fp) fwrite("Ori x, Avg x, Fin x, Ori y, Avg y, Fin y, Ori angle, Avg angle, Fin angle, Ori zoom, Avg zoom, Fin zoom\n", sizeof(char), 104, deshake->fp); - av_log(ctx, AV_LOG_INFO, "rx: %d, ry: %d, edge: %d blocksize: %d contrast: %d search: %d\n", + // Quadword align left edge of box for MMX code, adjust width if necessary + // to keep right margin + if (deshake->cx > 0) { + deshake->cw += deshake->cx - (deshake->cx & ~15); + deshake->cx &= ~15; + } + + av_log(ctx, AV_LOG_INFO, "cx: %d, cy: %d, cw: %d, ch: %d, rx: %d, ry: %d, edge: %d blocksize: %d contrast: %d search: %d\n", + deshake->cx, deshake->cy, deshake->cw, deshake->ch, deshake->rx, deshake->ry, deshake->edge, deshake->blocksize * 2, deshake->contrast, deshake->search); return 0; @@ -416,8 +434,28 @@ char tmp[256]; Transform orig; - // Find the most likely global motion for the current frame - find_motion(deshake, (deshake->ref == NULL) ? in->data[0] : deshake->ref->data[0], in->data[0], link->w, link->h, in->linesize[0], &t); + if (deshake->cx < 0 || deshake->cy < 0 || deshake->cw < 0 || deshake->ch < 0) { + // Find the most likely global motion for the current frame + find_motion(deshake, (deshake->ref == NULL) ? in->data[0] : deshake->ref->data[0], in->data[0], link->w, link->h, in->linesize[0], &t); + } else { + uint8_t *src1 = (deshake->ref == NULL) ? in->data[0] : deshake->ref->data[0]; + uint8_t *src2 = in->data[0]; + + deshake->cx = FFMIN(deshake->cx, link->w); + deshake->cy = FFMIN(deshake->cy, link->h); + + if ((unsigned)deshake->cx + (unsigned)deshake->cw > link->w) deshake->cw = link->w - deshake->cx; + if ((unsigned)deshake->cy + (unsigned)deshake->ch > link->h) deshake->ch = link->h - deshake->cy; + + // Quadword align right margin + deshake->cw &= ~15; + + src1 += deshake->cy * in->linesize[0] + deshake->cx; + src2 += deshake->cy * in->linesize[0] + deshake->cx; + + find_motion(deshake, src1, src2, deshake->cw, deshake->ch, in->linesize[0], &t); + } + // Copy transform so we can output it later to compare to the smoothed value orig.vector.x = t.vector.x; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_drawtext.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_drawtext.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_drawtext.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_drawtext.c 2011-11-04 12:38:27.000000000 +0000 @@ -22,7 +22,7 @@ /** * @file - * drawtext filter, based on the original FFmpeg vhook/drawtext.c + * drawtext filter, based on the original vhook/drawtext.c * filter by Gustavo Sverzut Barbieri */ @@ -47,9 +47,6 @@ #include FT_GLYPH_H static const char *var_names[] = { - "E", - "PHI", - "PI", "w", ///< width of the input video "h", ///< height of the input video "tw", "text_w", ///< width of the rendered text @@ -71,9 +68,6 @@ }; enum var_name { - VAR_E, - VAR_PHI, - VAR_PI, VAR_W, VAR_H, VAR_TW, VAR_TEXT_W, @@ -143,39 +137,39 @@ #define OFFSET(x) offsetof(DrawTextContext, x) static const AVOption drawtext_options[]= { -{"fontfile", "set font file", OFFSET(fontfile), FF_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX }, -{"text", "set text", OFFSET(text), FF_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX }, -{"textfile", "set text file", OFFSET(textfile), FF_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX }, -{"fontcolor", "set foreground color", OFFSET(fontcolor_string), FF_OPT_TYPE_STRING, {.str="black"}, CHAR_MIN, CHAR_MAX }, -{"boxcolor", "set box color", OFFSET(boxcolor_string), FF_OPT_TYPE_STRING, {.str="white"}, CHAR_MIN, CHAR_MAX }, -{"shadowcolor", "set shadow color", OFFSET(shadowcolor_string), FF_OPT_TYPE_STRING, {.str="black"}, CHAR_MIN, CHAR_MAX }, -{"box", "set box", OFFSET(draw_box), FF_OPT_TYPE_INT, {.dbl=0}, 0, 1 }, -{"fontsize", "set font size", OFFSET(fontsize), FF_OPT_TYPE_INT, {.dbl=16}, 1, INT_MAX }, -{"x", "set x expression", OFFSET(x_expr), FF_OPT_TYPE_STRING, {.str="0"}, CHAR_MIN, CHAR_MAX }, -{"y", "set y expression", OFFSET(y_expr), FF_OPT_TYPE_STRING, {.str="0"}, CHAR_MIN, CHAR_MAX }, -{"shadowx", "set x", OFFSET(shadowx), FF_OPT_TYPE_INT, {.dbl=0}, INT_MIN, INT_MAX }, -{"shadowy", "set y", OFFSET(shadowy), FF_OPT_TYPE_INT, {.dbl=0}, INT_MIN, INT_MAX }, -{"tabsize", "set tab size", OFFSET(tabsize), FF_OPT_TYPE_INT, {.dbl=4}, 0, INT_MAX }, -{"basetime", "set base time", OFFSET(basetime), FF_OPT_TYPE_INT64, {.dbl=AV_NOPTS_VALUE}, INT64_MIN, INT64_MAX }, +{"fontfile", "set font file", OFFSET(fontfile), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX }, +{"text", "set text", OFFSET(text), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX }, +{"textfile", "set text file", OFFSET(textfile), AV_OPT_TYPE_STRING, {.str=NULL}, CHAR_MIN, CHAR_MAX }, +{"fontcolor", "set foreground color", OFFSET(fontcolor_string), AV_OPT_TYPE_STRING, {.str="black"}, CHAR_MIN, CHAR_MAX }, +{"boxcolor", "set box color", OFFSET(boxcolor_string), AV_OPT_TYPE_STRING, {.str="white"}, CHAR_MIN, CHAR_MAX }, +{"shadowcolor", "set shadow color", OFFSET(shadowcolor_string), AV_OPT_TYPE_STRING, {.str="black"}, CHAR_MIN, CHAR_MAX }, +{"box", "set box", OFFSET(draw_box), AV_OPT_TYPE_INT, {.dbl=0}, 0, 1 }, +{"fontsize", "set font size", OFFSET(fontsize), AV_OPT_TYPE_INT, {.dbl=16}, 1, INT_MAX }, +{"x", "set x expression", OFFSET(x_expr), AV_OPT_TYPE_STRING, {.str="0"}, CHAR_MIN, CHAR_MAX }, +{"y", "set y expression", OFFSET(y_expr), AV_OPT_TYPE_STRING, {.str="0"}, CHAR_MIN, CHAR_MAX }, +{"shadowx", "set x", OFFSET(shadowx), AV_OPT_TYPE_INT, {.dbl=0}, INT_MIN, INT_MAX }, +{"shadowy", "set y", OFFSET(shadowy), AV_OPT_TYPE_INT, {.dbl=0}, INT_MIN, INT_MAX }, +{"tabsize", "set tab size", OFFSET(tabsize), AV_OPT_TYPE_INT, {.dbl=4}, 0, INT_MAX }, +{"basetime", "set base time", OFFSET(basetime), AV_OPT_TYPE_INT64, {.dbl=AV_NOPTS_VALUE}, INT64_MIN, INT64_MAX }, /* FT_LOAD_* flags */ -{"ft_load_flags", "set font loading flags for libfreetype", OFFSET(ft_load_flags), FF_OPT_TYPE_FLAGS, {.dbl=FT_LOAD_DEFAULT|FT_LOAD_RENDER}, 0, INT_MAX, 0, "ft_load_flags" }, -{"default", "set default", 0, FF_OPT_TYPE_CONST, {.dbl=FT_LOAD_DEFAULT}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, -{"no_scale", "set no_scale", 0, FF_OPT_TYPE_CONST, {.dbl=FT_LOAD_NO_SCALE}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, -{"no_hinting", "set no_hinting", 0, FF_OPT_TYPE_CONST, {.dbl=FT_LOAD_NO_HINTING}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, -{"render", "set render", 0, FF_OPT_TYPE_CONST, {.dbl=FT_LOAD_RENDER}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, -{"no_bitmap", "set no_bitmap", 0, FF_OPT_TYPE_CONST, {.dbl=FT_LOAD_NO_BITMAP}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, -{"vertical_layout", "set vertical_layout", 0, FF_OPT_TYPE_CONST, {.dbl=FT_LOAD_VERTICAL_LAYOUT}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, -{"force_autohint", "set force_autohint", 0, FF_OPT_TYPE_CONST, {.dbl=FT_LOAD_FORCE_AUTOHINT}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, -{"crop_bitmap", "set crop_bitmap", 0, FF_OPT_TYPE_CONST, {.dbl=FT_LOAD_CROP_BITMAP}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, -{"pedantic", "set pedantic", 0, FF_OPT_TYPE_CONST, {.dbl=FT_LOAD_PEDANTIC}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, -{"ignore_global_advance_width", "set ignore_global_advance_width", 0, FF_OPT_TYPE_CONST, {.dbl=FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, -{"no_recurse", "set no_recurse", 0, FF_OPT_TYPE_CONST, {.dbl=FT_LOAD_NO_RECURSE}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, -{"ignore_transform", "set ignore_transform", 0, FF_OPT_TYPE_CONST, {.dbl=FT_LOAD_IGNORE_TRANSFORM}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, -{"monochrome", "set monochrome", 0, FF_OPT_TYPE_CONST, {.dbl=FT_LOAD_MONOCHROME}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, -{"linear_design", "set linear_design", 0, FF_OPT_TYPE_CONST, {.dbl=FT_LOAD_LINEAR_DESIGN}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, -{"no_autohint", "set no_autohint", 0, FF_OPT_TYPE_CONST, {.dbl=FT_LOAD_NO_AUTOHINT}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, +{"ft_load_flags", "set font loading flags for libfreetype", OFFSET(ft_load_flags), AV_OPT_TYPE_FLAGS, {.dbl=FT_LOAD_DEFAULT|FT_LOAD_RENDER}, 0, INT_MAX, 0, "ft_load_flags" }, +{"default", "set default", 0, AV_OPT_TYPE_CONST, {.dbl=FT_LOAD_DEFAULT}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, +{"no_scale", "set no_scale", 0, AV_OPT_TYPE_CONST, {.dbl=FT_LOAD_NO_SCALE}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, +{"no_hinting", "set no_hinting", 0, AV_OPT_TYPE_CONST, {.dbl=FT_LOAD_NO_HINTING}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, +{"render", "set render", 0, AV_OPT_TYPE_CONST, {.dbl=FT_LOAD_RENDER}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, +{"no_bitmap", "set no_bitmap", 0, AV_OPT_TYPE_CONST, {.dbl=FT_LOAD_NO_BITMAP}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, +{"vertical_layout", "set vertical_layout", 0, AV_OPT_TYPE_CONST, {.dbl=FT_LOAD_VERTICAL_LAYOUT}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, +{"force_autohint", "set force_autohint", 0, AV_OPT_TYPE_CONST, {.dbl=FT_LOAD_FORCE_AUTOHINT}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, +{"crop_bitmap", "set crop_bitmap", 0, AV_OPT_TYPE_CONST, {.dbl=FT_LOAD_CROP_BITMAP}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, +{"pedantic", "set pedantic", 0, AV_OPT_TYPE_CONST, {.dbl=FT_LOAD_PEDANTIC}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, +{"ignore_global_advance_width", "set ignore_global_advance_width", 0, AV_OPT_TYPE_CONST, {.dbl=FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, +{"no_recurse", "set no_recurse", 0, AV_OPT_TYPE_CONST, {.dbl=FT_LOAD_NO_RECURSE}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, +{"ignore_transform", "set ignore_transform", 0, AV_OPT_TYPE_CONST, {.dbl=FT_LOAD_IGNORE_TRANSFORM}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, +{"monochrome", "set monochrome", 0, AV_OPT_TYPE_CONST, {.dbl=FT_LOAD_MONOCHROME}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, +{"linear_design", "set linear_design", 0, AV_OPT_TYPE_CONST, {.dbl=FT_LOAD_LINEAR_DESIGN}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, +{"no_autohint", "set no_autohint", 0, AV_OPT_TYPE_CONST, {.dbl=FT_LOAD_NO_AUTOHINT}, INT_MIN, INT_MAX, 0, "ft_load_flags" }, {NULL}, }; @@ -459,9 +453,6 @@ dtext->shadowcolor[3] = rgba[3]; } - dtext->var_values[VAR_E] = M_E; - dtext->var_values[VAR_PHI] = M_PHI; - dtext->var_values[VAR_PI] = M_PI; dtext->var_values[VAR_W] = inlink->w; dtext->var_values[VAR_H] = inlink->h; dtext->var_values[VAR_SAR] = inlink->sample_aspect_ratio.num ? av_q2d(inlink->sample_aspect_ratio) : 1; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_fade.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_fade.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_fade.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_fade.c 2011-11-04 12:38:27.000000000 +0000 @@ -27,11 +27,13 @@ #include "libavutil/pixdesc.h" #include "avfilter.h" +#include "internal.h" typedef struct { int factor, fade_per_frame; unsigned int frame_index, start_frame, stop_frame; int hsub, vsub, bpp; + unsigned int black_level, black_level_scaled; } FadeContext; static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) @@ -82,6 +84,13 @@ return 0; } +const static enum PixelFormat studio_level_pix_fmts[] = { + PIX_FMT_YUV444P, PIX_FMT_YUV422P, PIX_FMT_YUV420P, + PIX_FMT_YUV411P, PIX_FMT_YUV410P, + PIX_FMT_YUV440P, + PIX_FMT_NONE +}; + static int config_props(AVFilterLink *inlink) { FadeContext *fade = inlink->dst->priv; @@ -91,6 +100,11 @@ fade->vsub = pixdesc->log2_chroma_h; fade->bpp = av_get_bits_per_pixel(pixdesc) >> 3; + + fade->black_level = ff_fmt_is_in(inlink->format, studio_level_pix_fmts) ? 16 : 0; + /* 32768 = 1 << 15, it is an integer representation + * of 0.5 and is for rounding. */ + fade->black_level_scaled = (fade->black_level << 16) + 32768; return 0; } @@ -106,10 +120,8 @@ for (i = 0; i < h; i++) { p = outpic->data[0] + (y+i) * outpic->linesize[0]; for (j = 0; j < inlink->w * fade->bpp; j++) { - /* fade->factor is using 16 lower-order bits for decimal - * places. 32768 = 1 << 15, it is an integer representation - * of 0.5 and is for rounding. */ - *p = (*p * fade->factor + 32768) >> 16; + /* fade->factor is using 16 lower-order bits for decimal places. */ + *p = ((*p - fade->black_level) * fade->factor + fade->black_level_scaled) >> 16; p++; } } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_frei0r.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_frei0r.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_frei0r.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_frei0r.c 2011-11-04 12:38:27.000000000 +0000 @@ -216,7 +216,7 @@ /* see: http://piksel.org/frei0r/1.2/spec/1.2/spec/group__pluglocations.html */ if ((path = av_strdup(getenv("FREI0R_PATH")))) { char *p, *ptr = NULL; - for (p = path; p = strtok_r(p, ":", &ptr); p = NULL) + for (p = path; p = av_strtok(p, ":", &ptr); p = NULL) if (frei0r->dl_handle = load_path(ctx, p, dl_name)) break; av_free(path); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_lut.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_lut.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_lut.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_lut.c 2011-11-04 12:38:27.000000000 +0000 @@ -31,9 +31,6 @@ #include "internal.h" static const char *var_names[] = { - "E", - "PHI", - "PI", "w", ///< width of the input video "h", ///< height of the input video "val", ///< input value for the pixel @@ -45,9 +42,6 @@ }; enum var_name { - VAR_E, - VAR_PHI, - VAR_PI, VAR_W, VAR_H, VAR_VAL, @@ -82,17 +76,17 @@ #define OFFSET(x) offsetof(LutContext, x) static const AVOption lut_options[] = { - {"c0", "set component #0 expression", OFFSET(comp_expr_str[0]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX}, - {"c1", "set component #1 expression", OFFSET(comp_expr_str[1]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX}, - {"c2", "set component #2 expression", OFFSET(comp_expr_str[2]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX}, - {"c3", "set component #3 expression", OFFSET(comp_expr_str[3]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX}, - {"y", "set Y expression", OFFSET(comp_expr_str[Y]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX}, - {"u", "set U expression", OFFSET(comp_expr_str[U]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX}, - {"v", "set V expression", OFFSET(comp_expr_str[V]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX}, - {"r", "set R expression", OFFSET(comp_expr_str[R]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX}, - {"g", "set G expression", OFFSET(comp_expr_str[G]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX}, - {"b", "set B expression", OFFSET(comp_expr_str[B]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX}, - {"a", "set A expression", OFFSET(comp_expr_str[A]), FF_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX}, + {"c0", "set component #0 expression", OFFSET(comp_expr_str[0]), AV_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX}, + {"c1", "set component #1 expression", OFFSET(comp_expr_str[1]), AV_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX}, + {"c2", "set component #2 expression", OFFSET(comp_expr_str[2]), AV_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX}, + {"c3", "set component #3 expression", OFFSET(comp_expr_str[3]), AV_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX}, + {"y", "set Y expression", OFFSET(comp_expr_str[Y]), AV_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX}, + {"u", "set U expression", OFFSET(comp_expr_str[U]), AV_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX}, + {"v", "set V expression", OFFSET(comp_expr_str[V]), AV_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX}, + {"r", "set R expression", OFFSET(comp_expr_str[R]), AV_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX}, + {"g", "set G expression", OFFSET(comp_expr_str[G]), AV_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX}, + {"b", "set B expression", OFFSET(comp_expr_str[B]), AV_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX}, + {"a", "set A expression", OFFSET(comp_expr_str[A]), AV_OPT_TYPE_STRING, {.str="val"}, CHAR_MIN, CHAR_MAX}, {NULL}, }; @@ -115,10 +109,6 @@ lut->class = &lut_class; av_opt_set_defaults(lut); - lut->var_values[VAR_PHI] = M_PHI; - lut->var_values[VAR_PI] = M_PI; - lut->var_values[VAR_E ] = M_E; - lut->is_rgb = !strcmp(ctx->filter->name, "lutrgb"); lut->is_yuv = !strcmp(ctx->filter->name, "lutyuv"); if (args && (ret = av_set_options_string(lut, args, "=", ":")) < 0) @@ -360,21 +350,27 @@ { .name = NULL}}, \ } +#if CONFIG_LUT_FILTER DEFINE_LUT_FILTER(lut, "Compute and apply a lookup table to the RGB/YUV input video.", init); +#endif +#if CONFIG_LUTYUV_FILTER DEFINE_LUT_FILTER(lutyuv, "Compute and apply a lookup table to the YUV input video.", init); +#endif +#if CONFIG_LUTRGB_FILTER DEFINE_LUT_FILTER(lutrgb, "Compute and apply a lookup table to the RGB input video.", init); +#endif #if CONFIG_NEGATE_FILTER static int negate_init(AVFilterContext *ctx, const char *args, void *opaque) { LutContext *lut = ctx->priv; - char lut_params[1024]; + char lut_params[64]; if (args) sscanf(args, "%d", &lut->negate_alpha); - av_log(ctx, AV_LOG_INFO, "negate_alpha:%d\n", lut->negate_alpha); + av_log(ctx, AV_LOG_DEBUG, "negate_alpha:%d\n", lut->negate_alpha); snprintf(lut_params, sizeof(lut_params), "c0=negval:c1=negval:c2=negval:a=%s", lut->negate_alpha ? "negval" : "val"); @@ -384,4 +380,4 @@ DEFINE_LUT_FILTER(negate, "Negate input video.", negate_init); -#endif +#endif \ No newline at end of file diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_mp.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_mp.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_mp.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_mp.c 2011-11-04 12:38:27.000000000 +0000 @@ -443,7 +443,7 @@ } mp_image_t* vf_get_image(vf_instance_t* vf, unsigned int outfmt, int mp_imgtype, int mp_imgflag, int w, int h){ - MPContext *m= ((uint8_t*)vf) - offsetof(MPContext, next_vf); + MPContext *m= (MPContext*)(((uint8_t*)vf) - offsetof(MPContext, next_vf)); mp_image_t* mpi=NULL; int w2; int number = mp_imgtype >> 16; @@ -615,7 +615,7 @@ goto fail; picref->buf = pic; - picref->buf->please_use_av_free= av_free; + picref->buf->please_use_av_free= (void*)av_free; if (!(picref->video = av_mallocz(sizeof(AVFilterBufferRefVideoProps)))) goto fail; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_overlay.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_overlay.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_overlay.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_overlay.c 2011-11-04 12:38:27.000000000 +0000 @@ -28,15 +28,14 @@ #include "avfilter.h" #include "libavutil/eval.h" #include "libavutil/avstring.h" +#include "libavutil/opt.h" #include "libavutil/pixdesc.h" #include "libavutil/imgutils.h" #include "libavutil/mathematics.h" #include "internal.h" +#include "drawutils.h" static const char *var_names[] = { - "E", - "PHI", - "PI", "main_w", "W", ///< width of the main video "main_h", "H", ///< height of the main video "overlay_w", "w", ///< width of the overlay video @@ -45,9 +44,6 @@ }; enum var_name { - VAR_E, - VAR_PHI, - VAR_PI, VAR_MAIN_W, VAR_MW, VAR_MAIN_H, VAR_MH, VAR_OVERLAY_W, VAR_OW, @@ -58,61 +54,153 @@ #define MAIN 0 #define OVERLAY 1 +#define R 0 +#define G 1 +#define B 2 +#define A 3 + +#define Y 0 +#define U 1 +#define V 2 + typedef struct { + const AVClass *class; int x, y; ///< position of overlayed picture + int allow_packed_rgb; + uint8_t main_is_packed_rgb; + uint8_t main_rgba_map[4]; + uint8_t main_has_alpha; + uint8_t overlay_is_packed_rgb; + uint8_t overlay_rgba_map[4]; + uint8_t overlay_has_alpha; + AVFilterBufferRef *overpicref; - int max_plane_step[4]; ///< steps per pixel for each plane + int main_pix_step[4]; ///< steps per pixel for each plane of the main output + int overlay_pix_step[4]; ///< steps per pixel for each plane of the overlay int hsub, vsub; ///< chroma subsampling values - char x_expr[256], y_expr[256]; + char *x_expr, *y_expr; } OverlayContext; +#define OFFSET(x) offsetof(OverlayContext, x) + +static const AVOption overlay_options[] = { + { "x", "set the x expression", OFFSET(x_expr), AV_OPT_TYPE_STRING, {.str = "0"}, CHAR_MIN, CHAR_MAX }, + { "y", "set the y expression", OFFSET(y_expr), AV_OPT_TYPE_STRING, {.str = "0"}, CHAR_MIN, CHAR_MAX }, + {"rgb", "force packed RGB in input and output", OFFSET(allow_packed_rgb), AV_OPT_TYPE_INT, {.dbl=0}, 0, 1 }, + {NULL}, +}; + +static const char *overlay_get_name(void *ctx) +{ + return "overlay"; +} + +static const AVClass overlay_class = { + "OverlayContext", + overlay_get_name, + overlay_options +}; + static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) { OverlayContext *over = ctx->priv; + char *args1 = av_strdup(args); + char *expr, *bufptr = NULL; + int ret = 0; + + over->class = &overlay_class; + av_opt_set_defaults(over); + + if (expr = av_strtok(args1, ":", &bufptr)) { + if (!(over->x_expr = av_strdup(expr))) { + ret = AVERROR(ENOMEM); + goto end; + } + } + if (expr = av_strtok(NULL, ":", &bufptr)) { + if (!(over->y_expr = av_strdup(expr))) { + ret = AVERROR(ENOMEM); + goto end; + } + } - av_strlcpy(over->x_expr, "0", sizeof(over->x_expr)); - av_strlcpy(over->y_expr, "0", sizeof(over->y_expr)); - - if (args) - sscanf(args, "%255[^:]:%255[^:]", over->x_expr, over->y_expr); + if (bufptr && (ret = av_set_options_string(over, bufptr, "=", ":")) < 0) + goto end; - return 0; +end: + av_free(args1); + return ret; } static av_cold void uninit(AVFilterContext *ctx) { OverlayContext *over = ctx->priv; + av_freep(&over->x_expr); + av_freep(&over->y_expr); + if (over->overpicref) avfilter_unref_buffer(over->overpicref); } static int query_formats(AVFilterContext *ctx) { - const enum PixelFormat inout_pix_fmts[] = { PIX_FMT_YUV420P, PIX_FMT_NONE }; - const enum PixelFormat blend_pix_fmts[] = { PIX_FMT_YUVA420P, PIX_FMT_NONE }; - AVFilterFormats *inout_formats = avfilter_make_format_list(inout_pix_fmts); - AVFilterFormats *blend_formats = avfilter_make_format_list(blend_pix_fmts); - - avfilter_formats_ref(inout_formats, &ctx->inputs [MAIN ]->out_formats); - avfilter_formats_ref(blend_formats, &ctx->inputs [OVERLAY]->out_formats); - avfilter_formats_ref(inout_formats, &ctx->outputs[MAIN ]->in_formats ); + OverlayContext *over = ctx->priv; + + /* overlay formats contains alpha, for avoiding conversion with alpha information loss */ + const enum PixelFormat main_pix_fmts_yuv[] = { PIX_FMT_YUV420P, PIX_FMT_NONE }; + const enum PixelFormat overlay_pix_fmts_yuv[] = { PIX_FMT_YUVA420P, PIX_FMT_NONE }; + const enum PixelFormat main_pix_fmts_rgb[] = { + PIX_FMT_ARGB, PIX_FMT_RGBA, + PIX_FMT_ABGR, PIX_FMT_BGRA, + PIX_FMT_RGB24, PIX_FMT_BGR24, + PIX_FMT_NONE + }; + const enum PixelFormat overlay_pix_fmts_rgb[] = { + PIX_FMT_ARGB, PIX_FMT_RGBA, + PIX_FMT_ABGR, PIX_FMT_BGRA, + PIX_FMT_NONE + }; + + AVFilterFormats *main_formats; + AVFilterFormats *overlay_formats; + + if (over->allow_packed_rgb) { + main_formats = avfilter_make_format_list(main_pix_fmts_rgb); + overlay_formats = avfilter_make_format_list(overlay_pix_fmts_rgb); + } else { + main_formats = avfilter_make_format_list(main_pix_fmts_yuv); + overlay_formats = avfilter_make_format_list(overlay_pix_fmts_yuv); + } + + avfilter_formats_ref(main_formats, &ctx->inputs [MAIN ]->out_formats); + avfilter_formats_ref(overlay_formats, &ctx->inputs [OVERLAY]->out_formats); + avfilter_formats_ref(main_formats, &ctx->outputs[MAIN ]->in_formats ); return 0; } +static enum PixelFormat alpha_pix_fmts[] = { + PIX_FMT_YUVA420P, PIX_FMT_ARGB, PIX_FMT_ABGR, PIX_FMT_RGBA, + PIX_FMT_BGRA, PIX_FMT_NONE +}; + static int config_input_main(AVFilterLink *inlink) { OverlayContext *over = inlink->dst->priv; const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[inlink->format]; - av_image_fill_max_pixsteps(over->max_plane_step, NULL, pix_desc); + av_image_fill_max_pixsteps(over->main_pix_step, NULL, pix_desc); + over->hsub = pix_desc->log2_chroma_w; over->vsub = pix_desc->log2_chroma_h; + over->main_is_packed_rgb = + ff_fill_rgba_map(over->main_rgba_map, inlink->format) >= 0; + over->main_has_alpha = ff_fmt_is_in(inlink->format, alpha_pix_fmts); return 0; } @@ -123,13 +211,12 @@ char *expr; double var_values[VAR_VARS_NB], res; int ret; + const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[inlink->format]; + + av_image_fill_max_pixsteps(over->overlay_pix_step, NULL, pix_desc); /* Finish the configuration by evaluating the expressions now when both inputs are configured. */ - var_values[VAR_E ] = M_E; - var_values[VAR_PHI] = M_PHI; - var_values[VAR_PI ] = M_PI; - var_values[VAR_MAIN_W ] = var_values[VAR_MW] = ctx->inputs[MAIN ]->w; var_values[VAR_MAIN_H ] = var_values[VAR_MH] = ctx->inputs[MAIN ]->h; var_values[VAR_OVERLAY_W] = var_values[VAR_OW] = ctx->inputs[OVERLAY]->w; @@ -149,6 +236,10 @@ goto fail; over->x = res; + over->overlay_is_packed_rgb = + ff_fill_rgba_map(over->overlay_rgba_map, inlink->format) >= 0; + over->overlay_has_alpha = ff_fmt_is_in(inlink->format, alpha_pix_fmts); + av_log(ctx, AV_LOG_INFO, "main w:%d h:%d fmt:%s overlay x:%d y:%d w:%d h:%d fmt:%s\n", ctx->inputs[MAIN]->w, ctx->inputs[MAIN]->h, @@ -240,6 +331,10 @@ ctx->outputs[0]->time_base); } +// divide by 255 and round to nearest +// apply a fast variant: (X+127)/255 = ((X+127)*257+257)>>16 = ((X+128)*257)>>16 +#define FAST_DIV255(x) ((((x) + 128) * 257) >> 16) + static void blend_slice(AVFilterContext *ctx, AVFilterBufferRef *dst, AVFilterBufferRef *src, int x, int y, int w, int h, @@ -257,21 +352,72 @@ start_y = FFMAX(y, slice_y); height = end_y - start_y; - if (dst->format == PIX_FMT_BGR24 || dst->format == PIX_FMT_RGB24) { - uint8_t *dp = dst->data[0] + x * 3 + start_y * dst->linesize[0]; + if (over->main_is_packed_rgb) { + uint8_t *dp = dst->data[0] + x * over->main_pix_step[0] + + start_y * dst->linesize[0]; uint8_t *sp = src->data[0]; - int b = dst->format == PIX_FMT_BGR24 ? 2 : 0; - int r = dst->format == PIX_FMT_BGR24 ? 0 : 2; + uint8_t alpha; ///< the amount of overlay to blend on to main + const int dr = over->main_rgba_map[R]; + const int dg = over->main_rgba_map[G]; + const int db = over->main_rgba_map[B]; + const int da = over->main_rgba_map[A]; + const int dstep = over->main_pix_step[0]; + const int sr = over->overlay_rgba_map[R]; + const int sg = over->overlay_rgba_map[G]; + const int sb = over->overlay_rgba_map[B]; + const int sa = over->overlay_rgba_map[A]; + const int sstep = over->overlay_pix_step[0]; + const int main_has_alpha = over->main_has_alpha; if (slice_y > y) sp += (slice_y - y) * src->linesize[0]; for (i = 0; i < height; i++) { uint8_t *d = dp, *s = sp; for (j = 0; j < width; j++) { - d[r] = (d[r] * (0xff - s[3]) + s[0] * s[3] + 128) >> 8; - d[1] = (d[1] * (0xff - s[3]) + s[1] * s[3] + 128) >> 8; - d[b] = (d[b] * (0xff - s[3]) + s[2] * s[3] + 128) >> 8; - d += 3; - s += 4; + alpha = s[sa]; + + // if the main channel has an alpha channel, alpha has to be calculated + // to create an un-premultiplied (straight) alpha value + if (main_has_alpha && alpha != 0 && alpha != 255) { + // apply the general equation: + // alpha = alpha_overlay / ( (alpha_main + alpha_overlay) - (alpha_main * alpha_overlay) ) + alpha = + // the next line is a faster version of: 255 * 255 * alpha + ( (alpha << 16) - (alpha << 9) + alpha ) + / + // the next line is a faster version of: 255 * (alpha + d[da]) + ( ((alpha + d[da]) << 8 ) - (alpha + d[da]) + - d[da] * alpha ); + } + + switch (alpha) { + case 0: + break; + case 255: + d[dr] = s[sr]; + d[dg] = s[sg]; + d[db] = s[sb]; + break; + default: + // main_value = main_value * (1 - alpha) + overlay_value * alpha + // since alpha is in the range 0-255, the result must divided by 255 + d[dr] = FAST_DIV255(d[dr] * (255 - alpha) + s[sr] * alpha); + d[dg] = FAST_DIV255(d[dg] * (255 - alpha) + s[sg] * alpha); + d[db] = FAST_DIV255(d[db] * (255 - alpha) + s[sb] * alpha); + } + if (main_has_alpha) { + switch (alpha) { + case 0: + break; + case 255: + d[da] = s[sa]; + break; + default: + // apply alpha compositing: main_alpha += (1-main_alpha) * overlay_alpha + d[da] += FAST_DIV255((255 - d[da]) * s[sa]); + } + } + d += dstep; + s += sstep; } dp += dst->linesize[0]; sp += src->linesize[0]; @@ -306,7 +452,8 @@ alpha = (alpha_v + alpha_h) >> 1; } else alpha = a[0]; - *d = (*d * (0xff - alpha) + *s++ * alpha + 128) >> 8; + *d = FAST_DIV255(*d * (255 - alpha) + *s * alpha); + s++; d++; a += 1 << hsub; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_pad.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_pad.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_pad.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_pad.c 2011-11-04 12:38:27.000000000 +0000 @@ -36,9 +36,6 @@ #include "drawutils.h" static const char *var_names[] = { - "PI", - "PHI", - "E", "in_w", "iw", "in_h", "ih", "out_w", "ow", @@ -54,9 +51,6 @@ }; enum var_name { - VAR_PI, - VAR_PHI, - VAR_E, VAR_IN_W, VAR_IW, VAR_IN_H, VAR_IH, VAR_OUT_W, VAR_OW, @@ -153,9 +147,6 @@ pad->hsub = pix_desc->log2_chroma_w; pad->vsub = pix_desc->log2_chroma_h; - var_values[VAR_PI] = M_PI; - var_values[VAR_PHI] = M_PHI; - var_values[VAR_E] = M_E; var_values[VAR_IN_W] = var_values[VAR_IW] = inlink->w; var_values[VAR_IN_H] = var_values[VAR_IH] = inlink->h; var_values[VAR_OUT_W] = var_values[VAR_OW] = NAN; @@ -260,9 +251,10 @@ static AVFilterBufferRef *get_video_buffer(AVFilterLink *inlink, int perms, int w, int h) { PadContext *pad = inlink->dst->priv; + int align = (perms&AV_PERM_ALIGN) ? AVFILTER_ALIGN : 1; AVFilterBufferRef *picref = avfilter_get_video_buffer(inlink->dst->outputs[0], perms, - w + (pad->w - pad->in_w), + w + (pad->w - pad->in_w) + 4*align, h + (pad->h - pad->in_h)); int plane; @@ -273,7 +265,7 @@ int hsub = (plane == 1 || plane == 2) ? pad->hsub : 0; int vsub = (plane == 1 || plane == 2) ? pad->vsub : 0; - picref->data[plane] += (pad->x >> hsub) * pad->line_step[plane] + + picref->data[plane] += FFALIGN(pad->x >> hsub, align) * pad->line_step[plane] + (pad->y >> vsub) * picref->linesize[plane]; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_pixdesctest.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_pixdesctest.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_pixdesctest.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_pixdesctest.c 2011-11-04 12:38:27.000000000 +0000 @@ -92,7 +92,7 @@ for (i = y1; i < y1 + h1; i++) { av_read_image_line(priv->line, - inpic->data, + (void*)inpic->data, inpic->linesize, priv->pix_desc, 0, i, c, w1, 0); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_scale.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_scale.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_scale.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_scale.c 2011-11-04 12:38:27.000000000 +0000 @@ -32,9 +32,6 @@ #include "libswscale/swscale.h" static const char *var_names[] = { - "PI", - "PHI", - "E", "in_w", "iw", "in_h", "ih", "out_w", "ow", @@ -48,9 +45,6 @@ }; enum var_name { - VAR_PI, - VAR_PHI, - VAR_E, VAR_IN_W, VAR_IW, VAR_IN_H, VAR_IH, VAR_OUT_W, VAR_OW, @@ -155,9 +149,6 @@ char *expr; int ret; - var_values[VAR_PI] = M_PI; - var_values[VAR_PHI] = M_PHI; - var_values[VAR_E] = M_E; var_values[VAR_IN_W] = var_values[VAR_IW] = inlink->w; var_values[VAR_IN_H] = var_values[VAR_IH] = inlink->h; var_values[VAR_OUT_W] = var_values[VAR_OW] = NAN; @@ -262,7 +253,7 @@ scale->hsub = av_pix_fmt_descriptors[link->format].log2_chroma_w; scale->vsub = av_pix_fmt_descriptors[link->format].log2_chroma_h; - outpicref = avfilter_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h); + outpicref = avfilter_get_video_buffer(outlink, AV_PERM_WRITE|AV_PERM_ALIGN, outlink->w, outlink->h); avfilter_copy_buffer_ref_props(outpicref, picref); outpicref->video->w = outlink->w; outpicref->video->h = outlink->h; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_select.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_select.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_select.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_select.c 2011-11-04 12:38:27.000000000 +0000 @@ -28,10 +28,6 @@ #include "avfilter.h" static const char *var_names[] = { - "E", ///< Euler number - "PHI", ///< golden ratio - "PI", ///< greek pi - "TB", ///< timebase "pts", ///< original pts in the file of the frame @@ -69,10 +65,6 @@ }; enum var_name { - VAR_E, - VAR_PHI, - VAR_PI, - VAR_TB, VAR_PTS, @@ -146,10 +138,6 @@ { SelectContext *select = inlink->dst->priv; - select->var_values[VAR_E] = M_E; - select->var_values[VAR_PHI] = M_PHI; - select->var_values[VAR_PI] = M_PI; - select->var_values[VAR_N] = 0.0; select->var_values[VAR_SELECTED_N] = 0.0; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_setpts.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_setpts.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_setpts.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_setpts.c 2011-11-04 12:38:27.000000000 +0000 @@ -31,11 +31,8 @@ #include "avfilter.h" static const char *var_names[] = { - "E", ///< Euler number "INTERLACED", ///< tell if the current frame is interlaced "N", ///< frame number (starting at zero) - "PHI", ///< golden ratio - "PI", ///< greek pi "POS", ///< original position in the file of the frame "PREV_INPTS", ///< previous input PTS "PREV_OUTPTS", ///< previous output PTS @@ -46,11 +43,8 @@ }; enum var_name { - VAR_E, VAR_INTERLACED, VAR_N, - VAR_PHI, - VAR_PI, VAR_POS, VAR_PREV_INPTS, VAR_PREV_OUTPTS, @@ -76,10 +70,7 @@ return ret; } - setpts->var_values[VAR_E ] = M_E; setpts->var_values[VAR_N ] = 0.0; - setpts->var_values[VAR_PHI ] = M_PHI; - setpts->var_values[VAR_PI ] = M_PI; setpts->var_values[VAR_PREV_INPTS ] = NAN; setpts->var_values[VAR_PREV_OUTPTS] = NAN; setpts->var_values[VAR_STARTPTS ] = NAN; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_settb.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_settb.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_settb.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_settb.c 2011-11-04 12:38:27.000000000 +0000 @@ -31,18 +31,12 @@ #include "internal.h" static const char *var_names[] = { - "E", - "PHI", - "PI", "AVTB", /* default timebase 1/AV_TIME_BASE */ "intb", /* input timebase */ NULL }; enum var_name { - VAR_E, - VAR_PHI, - VAR_PI, VAR_AVTB, VAR_INTB, VAR_VARS_NB @@ -73,9 +67,6 @@ int ret; double res; - settb->var_values[VAR_E] = M_E; - settb->var_values[VAR_PHI] = M_PHI; - settb->var_values[VAR_PI] = M_PI; settb->var_values[VAR_AVTB] = av_q2d(AV_TIME_BASE_Q); settb->var_values[VAR_INTB] = av_q2d(inlink->time_base); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_showinfo.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_showinfo.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_showinfo.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_showinfo.c 2011-11-04 12:38:27.000000000 +0000 @@ -61,7 +61,7 @@ av_log(ctx, AV_LOG_INFO, "n:%d pts:%"PRId64" pts_time:%f pos:%"PRId64" " "fmt:%s sar:%d/%d s:%dx%d i:%c iskey:%d type:%c " - "checksum:%u plane_checksum:[%u %u %u %u]\n", + "checksum:%08X plane_checksum:[%08X %08X %08X %08X]\n", showinfo->frame, picref->pts, picref ->pts * av_q2d(inlink->time_base), picref->pos, av_pix_fmt_descriptors[picref->format].name, diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_transpose.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_transpose.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_transpose.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_transpose.c 2011-11-04 12:38:27.000000000 +0000 @@ -69,16 +69,13 @@ PIX_FMT_BGR555BE, PIX_FMT_BGR555LE, PIX_FMT_GRAY16BE, PIX_FMT_GRAY16LE, PIX_FMT_YUV420P16LE, PIX_FMT_YUV420P16BE, - PIX_FMT_YUV422P16LE, PIX_FMT_YUV422P16BE, PIX_FMT_YUV444P16LE, PIX_FMT_YUV444P16BE, PIX_FMT_NV12, PIX_FMT_NV21, PIX_FMT_RGB8, PIX_FMT_BGR8, PIX_FMT_RGB4_BYTE, PIX_FMT_BGR4_BYTE, - PIX_FMT_YUV444P, PIX_FMT_YUV422P, + PIX_FMT_YUV444P, PIX_FMT_YUVJ444P, PIX_FMT_YUV420P, PIX_FMT_YUVJ420P, - PIX_FMT_YUV411P, PIX_FMT_YUV410P, - PIX_FMT_YUVJ444P, PIX_FMT_YUVJ422P, - PIX_FMT_YUV440P, PIX_FMT_YUVJ440P, + PIX_FMT_YUV410P, PIX_FMT_YUVA420P, PIX_FMT_GRAY8, PIX_FMT_NONE }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_unsharp.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_unsharp.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_unsharp.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_unsharp.c 2011-11-04 12:38:27.000000000 +0000 @@ -73,7 +73,7 @@ int32_t res; int x, y, z; - const uint8_t *src2; + const uint8_t *src2 = NULL; //silence a warning if (!fp->amount) { if (dst_stride == src_stride) diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_yadif.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_yadif.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vf_yadif.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vf_yadif.c 2011-11-04 12:38:27.000000000 +0000 @@ -211,7 +211,7 @@ if (!yadif->csp) yadif->csp = &av_pix_fmt_descriptors[link->format]; if (yadif->csp->comp[0].depth_minus1 == 15) - yadif->filter_line = filter_line_c_16bit; + yadif->filter_line = (void*)filter_line_c_16bit; filter(ctx, yadif->out, tff ^ !is_second, tff); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vsrc_buffer.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vsrc_buffer.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vsrc_buffer.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vsrc_buffer.c 2011-11-04 12:38:27.000000000 +0000 @@ -105,7 +105,7 @@ c->picref = avfilter_get_video_buffer(outlink, AV_PERM_WRITE, picref->video->w, picref->video->h); av_image_copy(c->picref->data, c->picref->linesize, - picref->data, picref->linesize, + (void*)picref->data, picref->linesize, picref->format, picref->video->w, picref->video->h); avfilter_copy_buffer_ref_props(c->picref, picref); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vsrc_mptestsrc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vsrc_mptestsrc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vsrc_mptestsrc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vsrc_mptestsrc.c 2011-11-04 12:38:27.000000000 +0000 @@ -60,24 +60,24 @@ #define OFFSET(x) offsetof(MPTestContext, x) static const AVOption mptestsrc_options[]= { - { "rate", "set video rate", OFFSET(rate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0 }, - { "r", "set video rate", OFFSET(rate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0 }, - { "duration", "set video duration", OFFSET(duration), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0 }, - { "d", "set video duration", OFFSET(duration), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0 }, - - { "test", "set test to perform", OFFSET(test), FF_OPT_TYPE_INT, {.dbl=TEST_ALL}, 0, INT_MAX, 0, "test" }, - { "t", "set test to perform", OFFSET(test), FF_OPT_TYPE_INT, {.dbl=TEST_ALL}, 0, INT_MAX, 0, "test" }, - { "dc_luma", "", 0, FF_OPT_TYPE_CONST, {.dbl=TEST_DC_LUMA}, INT_MIN, INT_MAX, 0, "test" }, - { "dc_chroma", "", 0, FF_OPT_TYPE_CONST, {.dbl=TEST_DC_CHROMA}, INT_MIN, INT_MAX, 0, "test" }, - { "freq_luma", "", 0, FF_OPT_TYPE_CONST, {.dbl=TEST_FREQ_LUMA}, INT_MIN, INT_MAX, 0, "test" }, - { "freq_chroma", "", 0, FF_OPT_TYPE_CONST, {.dbl=TEST_FREQ_CHROMA}, INT_MIN, INT_MAX, 0, "test" }, - { "amp_luma", "", 0, FF_OPT_TYPE_CONST, {.dbl=TEST_AMP_LUMA}, INT_MIN, INT_MAX, 0, "test" }, - { "amp_chroma", "", 0, FF_OPT_TYPE_CONST, {.dbl=TEST_AMP_CHROMA}, INT_MIN, INT_MAX, 0, "test" }, - { "cbp", "", 0, FF_OPT_TYPE_CONST, {.dbl=TEST_CBP}, INT_MIN, INT_MAX, 0, "test" }, - { "mv", "", 0, FF_OPT_TYPE_CONST, {.dbl=TEST_MV}, INT_MIN, INT_MAX, 0, "test" }, - { "ring1", "", 0, FF_OPT_TYPE_CONST, {.dbl=TEST_RING1}, INT_MIN, INT_MAX, 0, "test" }, - { "ring2", "", 0, FF_OPT_TYPE_CONST, {.dbl=TEST_RING2}, INT_MIN, INT_MAX, 0, "test" }, - { "all", "", 0, FF_OPT_TYPE_CONST, {.dbl=TEST_ALL}, INT_MIN, INT_MAX, 0, "test" }, + { "rate", "set video rate", OFFSET(rate), AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0 }, + { "r", "set video rate", OFFSET(rate), AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0 }, + { "duration", "set video duration", OFFSET(duration), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0 }, + { "d", "set video duration", OFFSET(duration), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0 }, + + { "test", "set test to perform", OFFSET(test), AV_OPT_TYPE_INT, {.dbl=TEST_ALL}, 0, INT_MAX, 0, "test" }, + { "t", "set test to perform", OFFSET(test), AV_OPT_TYPE_INT, {.dbl=TEST_ALL}, 0, INT_MAX, 0, "test" }, + { "dc_luma", "", 0, AV_OPT_TYPE_CONST, {.dbl=TEST_DC_LUMA}, INT_MIN, INT_MAX, 0, "test" }, + { "dc_chroma", "", 0, AV_OPT_TYPE_CONST, {.dbl=TEST_DC_CHROMA}, INT_MIN, INT_MAX, 0, "test" }, + { "freq_luma", "", 0, AV_OPT_TYPE_CONST, {.dbl=TEST_FREQ_LUMA}, INT_MIN, INT_MAX, 0, "test" }, + { "freq_chroma", "", 0, AV_OPT_TYPE_CONST, {.dbl=TEST_FREQ_CHROMA}, INT_MIN, INT_MAX, 0, "test" }, + { "amp_luma", "", 0, AV_OPT_TYPE_CONST, {.dbl=TEST_AMP_LUMA}, INT_MIN, INT_MAX, 0, "test" }, + { "amp_chroma", "", 0, AV_OPT_TYPE_CONST, {.dbl=TEST_AMP_CHROMA}, INT_MIN, INT_MAX, 0, "test" }, + { "cbp", "", 0, AV_OPT_TYPE_CONST, {.dbl=TEST_CBP}, INT_MIN, INT_MAX, 0, "test" }, + { "mv", "", 0, AV_OPT_TYPE_CONST, {.dbl=TEST_MV}, INT_MIN, INT_MAX, 0, "test" }, + { "ring1", "", 0, AV_OPT_TYPE_CONST, {.dbl=TEST_RING1}, INT_MIN, INT_MAX, 0, "test" }, + { "ring2", "", 0, AV_OPT_TYPE_CONST, {.dbl=TEST_RING2}, INT_MIN, INT_MAX, 0, "test" }, + { "all", "", 0, AV_OPT_TYPE_CONST, {.dbl=TEST_ALL}, INT_MIN, INT_MAX, 0, "test" }, { NULL }, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vsrc_nullsrc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vsrc_nullsrc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vsrc_nullsrc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vsrc_nullsrc.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,130 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * null video source - */ - -#include "libavutil/avstring.h" -#include "libavutil/eval.h" -#include "libavutil/mathematics.h" -#include "libavutil/parseutils.h" -#include "avfilter.h" - -static const char *var_names[] = { - "E", - "PHI", - "PI", - "AVTB", /* default timebase 1/AV_TIME_BASE */ - NULL -}; - -enum var_name { - VAR_E, - VAR_PHI, - VAR_PI, - VAR_AVTB, - VAR_VARS_NB -}; - -typedef struct { - int w, h; - char tb_expr[256]; - double var_values[VAR_VARS_NB]; -} NullContext; - -static int init(AVFilterContext *ctx, const char *args, void *opaque) -{ - NullContext *priv = ctx->priv; - - priv->w = 352; - priv->h = 288; - av_strlcpy(priv->tb_expr, "AVTB", sizeof(priv->tb_expr)); - - if (args) - sscanf(args, "%d:%d:%255[^:]", &priv->w, &priv->h, priv->tb_expr); - - if (priv->w <= 0 || priv->h <= 0) { - av_log(ctx, AV_LOG_ERROR, "Non-positive size values are not acceptable.\n"); - return AVERROR(EINVAL); - } - - return 0; -} - -static int config_props(AVFilterLink *outlink) -{ - AVFilterContext *ctx = outlink->src; - NullContext *priv = ctx->priv; - AVRational tb; - int ret; - double res; - - priv->var_values[VAR_E] = M_E; - priv->var_values[VAR_PHI] = M_PHI; - priv->var_values[VAR_PI] = M_PI; - priv->var_values[VAR_AVTB] = av_q2d(AV_TIME_BASE_Q); - - if ((ret = av_expr_parse_and_eval(&res, priv->tb_expr, var_names, priv->var_values, - NULL, NULL, NULL, NULL, NULL, 0, NULL)) < 0) { - av_log(ctx, AV_LOG_ERROR, "Invalid expression '%s' for timebase.\n", priv->tb_expr); - return ret; - } - tb = av_d2q(res, INT_MAX); - if (tb.num <= 0 || tb.den <= 0) { - av_log(ctx, AV_LOG_ERROR, - "Invalid non-positive value for the timebase %d/%d.\n", - tb.num, tb.den); - return AVERROR(EINVAL); - } - - outlink->w = priv->w; - outlink->h = priv->h; - outlink->time_base = tb; - - av_log(outlink->src, AV_LOG_INFO, "w:%d h:%d tb:%d/%d\n", priv->w, priv->h, - tb.num, tb.den); - - return 0; -} - -static int request_frame(AVFilterLink *link) -{ - return -1; -} - -AVFilter avfilter_vsrc_nullsrc = { - .name = "nullsrc", - .description = NULL_IF_CONFIG_SMALL("Null video source, never return images."), - - .init = init, - .priv_size = sizeof(NullContext), - - .inputs = (AVFilterPad[]) {{ .name = NULL}}, - - .outputs = (AVFilterPad[]) { - { - .name = "default", - .type = AVMEDIA_TYPE_VIDEO, - .config_props = config_props, - .request_frame = request_frame, - }, - { .name = NULL} - }, -}; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vsrc_testsrc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vsrc_testsrc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavfilter/vsrc_testsrc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavfilter/vsrc_testsrc.c 2011-11-04 12:38:27.000000000 +0000 @@ -24,7 +24,7 @@ * Misc test sources. * * testsrc is based on the test pattern generator demuxer by Nicolas George: - * http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/2007-October/037845.html + * http://lists.ffmpeg.org/pipermail/ffmpeg-devel/2007-October/037845.html * * rgbtestsrc is ported from MPlayer libmpcodecs/vf_rgbtest.c by * Michael Niedermayer. @@ -57,12 +57,12 @@ #define OFFSET(x) offsetof(TestSourceContext, x) static const AVOption testsrc_options[]= { - { "size", "set video size", OFFSET(size), FF_OPT_TYPE_STRING, {.str = "320x240"}, 0, 0 }, - { "s", "set video size", OFFSET(size), FF_OPT_TYPE_STRING, {.str = "320x240"}, 0, 0 }, - { "rate", "set video rate", OFFSET(rate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0 }, - { "r", "set video rate", OFFSET(rate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0 }, - { "duration", "set video duration", OFFSET(duration), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0 }, - { "sar", "set video sample aspect ratio", OFFSET(sar), FF_OPT_TYPE_RATIONAL, {.dbl= 1}, 0, INT_MAX }, + { "size", "set video size", OFFSET(size), AV_OPT_TYPE_STRING, {.str = "320x240"}, 0, 0 }, + { "s", "set video size", OFFSET(size), AV_OPT_TYPE_STRING, {.str = "320x240"}, 0, 0 }, + { "rate", "set video rate", OFFSET(rate), AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0 }, + { "r", "set video rate", OFFSET(rate), AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0 }, + { "duration", "set video duration", OFFSET(duration), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0 }, + { "sar", "set video sample aspect ratio", OFFSET(sar), AV_OPT_TYPE_RATIONAL, {.dbl= 1}, 0, INT_MAX }, { NULL }, }; @@ -127,7 +127,7 @@ TestSourceContext *test = outlink->src->priv; AVFilterBufferRef *picref; - if (test->max_pts >= 0 && test->pts > test->max_pts) + if (test->max_pts >= 0 && test->pts >= test->max_pts) return AVERROR_EOF; picref = avfilter_get_video_buffer(outlink, AV_PERM_WRITE, test->w, test->h); @@ -137,8 +137,8 @@ picref->video->interlaced = 0; picref->video->pict_type = AV_PICTURE_TYPE_I; picref->video->sample_aspect_ratio = test->sar; - test->nb_frame++; test->fill_picture_fn(outlink->src, picref); + test->nb_frame++; avfilter_start_frame(outlink, avfilter_ref_buffer(picref, ~0)); avfilter_draw_slice(outlink, 0, picref->video->h, 1); @@ -148,6 +148,46 @@ return 0; } +#if CONFIG_NULLSRC_FILTER + +static const char *nullsrc_get_name(void *ctx) +{ + return "nullsrc"; +} + +static const AVClass nullsrc_class = { + .class_name = "NullSourceContext", + .item_name = nullsrc_get_name, + .option = testsrc_options, +}; + +static void nullsrc_fill_picture(AVFilterContext *ctx, AVFilterBufferRef *picref) { } + +static av_cold int nullsrc_init(AVFilterContext *ctx, const char *args, void *opaque) +{ + TestSourceContext *test = ctx->priv; + + test->class = &nullsrc_class; + test->fill_picture_fn = nullsrc_fill_picture; + return init(ctx, args, opaque); +} + +AVFilter avfilter_vsrc_nullsrc = { + .name = "nullsrc", + .description = NULL_IF_CONFIG_SMALL("Null video source, return unprocessed video frames."), + .init = nullsrc_init, + .priv_size = sizeof(TestSourceContext), + + .inputs = (AVFilterPad[]) {{ .name = NULL}}, + .outputs = (AVFilterPad[]) {{ .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .request_frame = request_frame, + .config_props = config_props, }, + { .name = NULL}}, +}; + +#endif /* CONFIG_NULLSRC_FILTER */ + #if CONFIG_TESTSRC_FILTER static const char *testsrc_get_name(void *ctx) @@ -156,9 +196,9 @@ } static const AVClass testsrc_class = { - "TestSourceContext", - testsrc_get_name, - testsrc_options + .class_name = "TestSourceContext", + .item_name = testsrc_get_name, + .option = testsrc_options, }; /** @@ -283,7 +323,7 @@ } /* draw sliding color line */ - p = data + picref->linesize[0] * height * 3/4; + p0 = p = data + picref->linesize[0] * height * 3/4; grad = (256 * test->nb_frame * test->time_base.num / test->time_base.den) % GRADIENT_SIZE; rgrad = 0; @@ -311,8 +351,9 @@ if (grad >= GRADIENT_SIZE) grad -= GRADIENT_SIZE; } + p = p0; for (y = height / 8; y > 0; y--) { - memcpy(p, p - picref->linesize[0], 3 * width); + memcpy(p+picref->linesize[0], p, 3 * width); p += picref->linesize[0]; } @@ -378,9 +419,9 @@ } static const AVClass rgbtestsrc_class = { - "RGBTestSourceContext", - rgbtestsrc_get_name, - testsrc_options + .class_name = "RGBTestSourceContext", + .item_name = rgbtestsrc_get_name, + .option = testsrc_options, }; #define R 0 diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/4xm.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/4xm.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/4xm.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/4xm.c 2011-11-04 12:38:27.000000000 +0000 @@ -141,7 +141,7 @@ fourxm->height = AV_RL32(&header[i + 40]); /* allocate a new AVStream */ - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st){ ret= AVERROR(ENOMEM); goto fail; @@ -177,7 +177,7 @@ sizeof(AudioTrack), current_track + 1); if (!fourxm->tracks) { - ret= AVERROR(ENOMEM); + ret = AVERROR(ENOMEM); goto fail; } memset(&fourxm->tracks[fourxm->track_count], 0, @@ -199,12 +199,13 @@ i += 8 + size; /* allocate a new AVStream */ - st = av_new_stream(s, current_track); + st = avformat_new_stream(s, NULL); if (!st){ ret= AVERROR(ENOMEM); goto fail; } + st->id = current_track; av_set_pts_info(st, 60, 1, fourxm->tracks[current_track].sample_rate); fourxm->tracks[current_track].stream_index = st->index; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/aacdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/aacdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/aacdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/aacdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -66,7 +66,7 @@ { AVStream *st; - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/ac3dec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/ac3dec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/ac3dec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/ac3dec.c 2011-11-04 12:38:27.000000000 +0000 @@ -41,7 +41,7 @@ for(frames = 0; buf2 < end; frames++) { init_get_bits(&gbc, buf2, 54); - if(ff_ac3_parse_header(&gbc, &hdr) < 0) + if(avpriv_ac3_parse_header(&gbc, &hdr) < 0) break; if(buf2 + hdr.frame_size > end || av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, buf2 + 2, hdr.frame_size - 2)) diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/adtsenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/adtsenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/adtsenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/adtsenc.c 2011-11-04 12:38:27.000000000 +0000 @@ -35,7 +35,7 @@ int off; init_get_bits(&gb, buf, size * 8); - off = ff_mpeg4audio_get_config(&m4ac, buf, size); + off = avpriv_mpeg4audio_get_config(&m4ac, buf, size); if (off < 0) return off; skip_bits_long(&gb, off); @@ -67,7 +67,7 @@ init_put_bits(&pb, adts->pce_data, MAX_PCE_SIZE); put_bits(&pb, 3, 5); //ID_PCE - adts->pce_size = (ff_copy_pce_data(&pb, &gb) + 3) / 8; + adts->pce_size = (avpriv_copy_pce_data(&pb, &gb) + 3) / 8; flush_put_bits(&pb); } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/aea.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/aea.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/aea.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/aea.c 2011-11-04 12:38:27.000000000 +0000 @@ -57,7 +57,7 @@ static int aea_read_header(AVFormatContext *s, AVFormatParameters *ap) { - AVStream *st = av_new_stream(s, 0); + AVStream *st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/aiffdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/aiffdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/aiffdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/aiffdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -198,7 +198,7 @@ filesize -= 4; - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); @@ -275,9 +275,6 @@ got_sound: /* Now positioned, get the sound data start and end */ - if (st->nb_frames) - s->file_size = st->nb_frames * st->codec->block_align; - av_set_pts_info(st, 64, 1, st->codec->sample_rate); st->start_time = 0; st->duration = st->codec->frame_size ? diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/allformats.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/allformats.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/allformats.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/allformats.c 2011-11-04 12:38:27.000000000 +0000 @@ -100,7 +100,8 @@ REGISTER_MUXER (FRAMECRC, framecrc); REGISTER_MUXER (FRAMEMD5, framemd5); REGISTER_MUXDEMUX (G722, g722); - REGISTER_DEMUXER (G723_1, g723_1); + REGISTER_MUXDEMUX (G723_1, g723_1); + REGISTER_DEMUXER (G729, g729); REGISTER_MUXER (GIF, gif); REGISTER_DEMUXER (GSM, gsm); REGISTER_MUXDEMUX (GXF, gxf); @@ -203,6 +204,7 @@ av_register_rdt_dynamic_payload_handlers(); #endif REGISTER_DEMUXER (SEGAFILM, segafilm); + REGISTER_MUXER (SEGMENT, segment); REGISTER_DEMUXER (SHORTEN, shorten); REGISTER_DEMUXER (SIFF, siff); REGISTER_DEMUXER (SMACKER, smacker); @@ -216,6 +218,7 @@ REGISTER_MUXER (TGP, tgp); REGISTER_DEMUXER (THP, thp); REGISTER_DEMUXER (TIERTEXSEQ, tiertexseq); + REGISTER_MUXER (TIMECODE_V2, timecode_v2); REGISTER_DEMUXER (TMV, tmv); REGISTER_MUXDEMUX (TRUEHD, truehd); REGISTER_DEMUXER (TTA, tta); @@ -249,6 +252,7 @@ /* protocols */ REGISTER_PROTOCOL (APPLEHTTP, applehttp); + REGISTER_PROTOCOL (CACHE, cache); REGISTER_PROTOCOL (CONCAT, concat); REGISTER_PROTOCOL (CRYPTO, crypto); REGISTER_PROTOCOL (FILE, file); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/amr.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/amr.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/amr.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/amr.c 2011-11-04 12:38:27.000000000 +0000 @@ -84,7 +84,7 @@ avio_read(pb, header, 6); - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) { return AVERROR(ENOMEM); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/anm.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/anm.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/anm.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/anm.c 2011-11-04 12:38:27.000000000 +0000 @@ -97,7 +97,7 @@ return AVERROR_INVALIDDATA; /* video stream */ - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_VIDEO; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/apc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/apc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/apc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/apc.c 2011-11-04 12:38:27.000000000 +0000 @@ -39,7 +39,7 @@ avio_rl32(pb); /* _APC */ avio_rl32(pb); /* 1.20 */ - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/ape.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/ape.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/ape.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/ape.c 2011-11-04 12:38:27.000000000 +0000 @@ -313,7 +313,7 @@ ape->compressiontype); /* now we are ready: build format streams */ - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return -1; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/applehttp.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/applehttp.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/applehttp.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/applehttp.c 2011-11-04 12:38:27.000000000 +0000 @@ -350,8 +350,8 @@ snprintf(url, sizeof(url), "crypto:%s", seg->url); if ((ret = ffurl_alloc(&var->input, url, AVIO_FLAG_READ)) < 0) return ret; - av_set_string3(var->input->priv_data, "key", key, 0, NULL); - av_set_string3(var->input->priv_data, "iv", iv, 0, NULL); + av_opt_set(var->input->priv_data, "key", key, 0); + av_opt_set(var->input->priv_data, "iv", iv, 0); if ((ret = ffurl_connect(var->input)) < 0) { ffurl_close(var->input); var->input = NULL; @@ -505,11 +505,12 @@ snprintf(bitrate_str, sizeof(bitrate_str), "%d", v->bandwidth); /* Create new AVStreams for each stream in this variant */ for (j = 0; j < v->ctx->nb_streams; j++) { - AVStream *st = av_new_stream(s, i); + AVStream *st = avformat_new_stream(s, NULL); if (!st) { ret = AVERROR(ENOMEM); goto fail; } + st->id = i; avcodec_copy_context(st->codec, v->ctx->streams[j]->codec); if (v->bandwidth) av_dict_set(&st->metadata, "variant_bitrate", bitrate_str, diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/asfdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/asfdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/asfdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/asfdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -165,6 +165,9 @@ if (type == 0) { // UTF16-LE avio_get_str16le(s->pb, len, value, 2*len + 1); + } else if (type == -1) { // ASCII + get_buffer(s->pb, value, len); + value[len]=0; } else if (type > 1 && type <= 5) { // boolean or DWORD or QWORD or WORD uint64_t num = get_value(s->pb, type); snprintf(value, len, "%"PRIu64, num); @@ -221,7 +224,7 @@ pos1 = avio_tell(pb); - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); av_set_pts_info(st, 32, 1, 1000); /* 32 bit pts in ms */ @@ -355,7 +358,7 @@ /* Extract palette from extradata if bpp <= 8 */ /* This code assumes that extradata contains only palette */ - /* This is true for all paletted codecs implemented in ffmpeg */ + /* This is true for all paletted codecs implemented in libavcodec */ if (st->codec->extradata_size && (st->codec->bits_per_coded_sample <= 8)) { int av_unused i; #if HAVE_BIGENDIAN @@ -566,7 +569,7 @@ name_len = avio_rl32(pb); // name length if ((ret = avio_get_str16le(pb, name_len * 2, name, sizeof(name))) < name_len) avio_skip(pb, name_len - ret); - ff_new_chapter(s, i, (AVRational){1, 10000000}, pres_time, AV_NOPTS_VALUE, name ); + avpriv_new_chapter(s, i, (AVRational){1, 10000000}, pres_time, AV_NOPTS_VALUE, name ); } return 0; @@ -636,11 +639,23 @@ } else { if (!s->keylen) { if (!ff_guidcmp(&g, &ff_asf_content_encryption)) { + unsigned int len; + AVPacket pkt; av_log(s, AV_LOG_WARNING, "DRM protected stream detected, decoding will likely fail!\n"); + len= avio_rl32(pb); + av_log(s, AV_LOG_DEBUG, "Secret data:\n"); + av_get_packet(pb, &pkt, len); av_hex_dump_log(s, AV_LOG_DEBUG, pkt.data, pkt.size); av_free_packet(&pkt); + len= avio_rl32(pb); + get_tag(s, "ASF_Protection_Type", -1, len); + len= avio_rl32(pb); + get_tag(s, "ASF_Key_ID", -1, len); + len= avio_rl32(pb); + get_tag(s, "ASF_License_URL", -1, len); } else if (!ff_guidcmp(&g, &ff_asf_ext_content_encryption)) { av_log(s, AV_LOG_WARNING, "Ext DRM protected stream detected, decoding will likely fail!\n"); + av_dict_set(&s->metadata, "encryption", "ASF Extended Content Encryption", 0); } else if (!ff_guidcmp(&g, &ff_asf_digital_signature)) { - av_log(s, AV_LOG_WARNING, "Digital signature detected, decoding will likely fail!\n"); + av_log(s, AV_LOG_INFO, "Digital signature detected!\n"); } } } @@ -807,6 +822,10 @@ DO_2BITS(asf->packet_property >> 2, asf->packet_frag_offset, 0); DO_2BITS(asf->packet_property, asf->packet_replic_size, 0); //printf("key:%d stream:%d seq:%d offset:%d replic_size:%d\n", asf->packet_key_frame, asf->stream_index, asf->packet_seq, //asf->packet_frag_offset, asf->packet_replic_size); + if (rsize+asf->packet_replic_size > asf->packet_size_left) { + av_log(s, AV_LOG_ERROR, "packet_replic_size %d is invalid\n", asf->packet_replic_size); + return -1; + } if (asf->packet_replic_size >= 8) { asf->packet_obj_size = avio_rl32(pb); if(asf->packet_obj_size >= (1<<24) || asf->packet_obj_size <= 0){ @@ -841,10 +860,6 @@ av_log(s, AV_LOG_ERROR, "unexpected packet_replic_size of %d\n", asf->packet_replic_size); return -1; } - if (rsize > asf->packet_size_left) { - av_log(s, AV_LOG_ERROR, "packet_replic_size is invalid\n"); - return -1; - } if (asf->packet_flags & 0x01) { DO_2BITS(asf->packet_segsizetype >> 6, asf->packet_frag_size, 0); // 0 is illegal if (rsize > asf->packet_size_left) { @@ -1282,7 +1297,7 @@ } } /* no index or seeking by index failed */ - if(av_seek_frame_binary(s, stream_index, pts, flags)<0) + if (ff_seek_frame_binary(s, stream_index, pts, flags) < 0) return -1; asf_reset_header(s); return 0; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/asfenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/asfenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/asfenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/asfenc.c 2011-11-04 12:38:27.000000000 +0000 @@ -434,10 +434,6 @@ if (enc->codec_type == AVMEDIA_TYPE_AUDIO) { /* WAVEFORMATEX header */ int wavsize = ff_put_wav_header(pb, enc); - if ((enc->codec_id != CODEC_ID_MP3) && (enc->codec_id != CODEC_ID_MP2) && (enc->codec_id != CODEC_ID_ADPCM_IMA_WAV) && (enc->extradata_size==0)) { - wavsize += 2; - avio_wl16(pb, 0); - } if (wavsize < 0) return -1; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/assdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/assdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/assdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/assdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -83,7 +83,7 @@ uint8_t *p, **dst[2]={0}; int pos[2]={0}; - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return -1; av_set_pts_info(st, 64, 1, 100); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/au.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/au.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/au.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/au.c 2011-11-04 12:38:27.000000000 +0000 @@ -35,7 +35,7 @@ /* if we don't know the size in advance */ #define AU_UNKNOWN_SIZE ((uint32_t)(~0)) -/* The ffmpeg codecs we support, and the IDs they have in the file */ +/* The libavcodec codecs we support, and the IDs they have in the file */ static const AVCodecTag codec_au_tags[] = { { CODEC_ID_PCM_MULAW, 1 }, { CODEC_ID_PCM_S8, 2 }, @@ -156,7 +156,7 @@ } /* now we are ready: build format streams */ - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return -1; st->codec->codec_type = AVMEDIA_TYPE_AUDIO; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/avformat.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/avformat.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/avformat.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/avformat.h 2011-11-04 12:38:27.000000000 +0000 @@ -274,9 +274,10 @@ #define AVFMT_NOSTREAMS 0x1000 /**< Format does not require any streams */ #define AVFMT_NOBINSEARCH 0x2000 /**< Format does not allow to fallback to binary search via read_timestamp */ #define AVFMT_NOGENSEARCH 0x4000 /**< Format does not allow to fallback to generic search */ -#define AVFMT_TS_NONSTRICT 0x8000 /**< Format does not require strictly - increasing timestamps, but they must - still be monotonic */ +#define AVFMT_NO_BYTE_SEEK 0x8000 /**< Format does not allow seeking by bytes */ +#define AVFMT_TS_NONSTRICT 0x8000000 /**< Format does not require strictly + increasing timestamps, but they must + still be monotonic */ typedef struct AVOutputFormat { const char *name; @@ -411,7 +412,9 @@ int64_t *pos, int64_t pos_limit); /** - * Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER. + * Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS, + * AVFMT_GENERIC_INDEX, AVFMT_TS_DISCONT, AVFMT_NOBINSEARCH, + * AVFMT_NOGENSEARCH, AVFMT_NO_BYTE_SEEK. */ int flags; @@ -520,8 +523,10 @@ AVRational r_frame_rate; void *priv_data; +#if FF_API_REORDER_PRIVATE /* internal data used in av_find_stream_info() */ int64_t first_dts; +#endif /** * encoding: pts generation when outputting stream @@ -536,9 +541,13 @@ * encoding: set by libavformat in av_write_header */ AVRational time_base; +#if FF_API_REORDER_PRIVATE int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */ +#endif +#if FF_API_STREAM_COPY /* ffmpeg.c private use */ - int stream_copy; /**< If set, just copy stream. */ + attribute_deprecated int stream_copy; /**< If set, just copy stream. */ +#endif enum AVDiscard discard; ///< Selects which packets can be discarded at will and do not need to be demuxed. #if FF_API_AVSTREAM_QUALITY @@ -567,6 +576,7 @@ */ int64_t duration; +#if FF_API_REORDER_PRIVATE /* av_read_frame() support */ enum AVStreamParseType need_parsing; struct AVCodecParserContext *parser; @@ -579,14 +589,17 @@ support seeking natively. */ int nb_index_entries; unsigned int index_entries_allocated_size; +#endif int64_t nb_frames; ///< number of frames in this stream if known or 0 int disposition; /**< AV_DISPOSITION_* bit field */ +#if FF_API_REORDER_PRIVATE AVProbeData probe_data; #define MAX_REORDER_DELAY 16 int64_t pts_buffer[MAX_REORDER_DELAY+1]; +#endif /** * sample aspect ratio (0 if unknown) @@ -597,6 +610,7 @@ AVDictionary *metadata; +#if FF_API_REORDER_PRIVATE /* Intended mostly for av_read_frame() support. Not supposed to be used by */ /* external applications; try to use something else if at all possible. */ const uint8_t *cur_ptr; @@ -625,12 +639,21 @@ * used internally, NOT PART OF PUBLIC API, dont read or write from outside of libav* */ struct AVPacketList *last_in_packet_buffer; +#endif /** * Average framerate */ AVRational avg_frame_rate; + /***************************************************************** + * All fields below this line are not part of the public API. They + * may not be used outside of libavformat and can be changed and + * removed at will. + * New public fields should be added right above. + ***************************************************************** + */ + /** * Number of frames that have been demuxed during av_find_stream_info() */ @@ -653,6 +676,7 @@ int duration_count; double duration_error[2][2][MAX_STD_TIMEBASES]; int64_t codec_info_duration; + int nb_decoded_frames; } *info; /** @@ -660,6 +684,49 @@ * NOT PART OF PUBLIC API */ int request_probe; +#if !FF_API_REORDER_PRIVATE + const uint8_t *cur_ptr; + int cur_len; + AVPacket cur_pkt; + + // Timestamp generation support: + /** + * Timestamp corresponding to the last dts sync point. + * + * Initialized when AVCodecParserContext.dts_sync_point >= 0 and + * a DTS is received from the underlying container. Otherwise set to + * AV_NOPTS_VALUE by default. + */ + int64_t reference_dts; + int64_t first_dts; + int64_t cur_dts; + int last_IP_duration; + int64_t last_IP_pts; + + /** + * Number of packets to buffer for codec probing + */ +#define MAX_PROBE_PACKETS 2500 + int probe_packets; + + /** + * last packet in packet_buffer for this stream when muxing. + */ + struct AVPacketList *last_in_packet_buffer; + AVProbeData probe_data; +#define MAX_REORDER_DELAY 16 + int64_t pts_buffer[MAX_REORDER_DELAY+1]; + /* av_read_frame() support */ + enum AVStreamParseType need_parsing; + struct AVCodecParserContext *parser; + + AVIndexEntry *index_entries; /**< Only used if the format does not + support seeking natively. */ + int nb_index_entries; + unsigned int index_entries_allocated_size; + + int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */ +#endif } AVStream; #define AV_PROGRAM_RUNNING 1 @@ -719,6 +786,7 @@ #endif int ctx_flags; /**< Format-specific flags, see AVFMTCTX_xx */ +#if FF_API_REORDER_PRIVATE /* private data for pts handling (do not modify directly). */ /** * This buffer is only needed when packets were already buffered but @@ -726,6 +794,7 @@ * streams. */ struct AVPacketList *packet_buffer; +#endif /** * Decoding: position of the first frame of the component, in @@ -742,10 +811,12 @@ */ int64_t duration; +#if FF_API_FILESIZE /** * decoding: total file size, 0 if unknown */ - int64_t file_size; + attribute_deprecated int64_t file_size; +#endif /** * Decoding: total stream bitrate in bit/s, 0 if not @@ -754,15 +825,24 @@ */ int bit_rate; +#if FF_API_REORDER_PRIVATE /* av_read_frame() support */ AVStream *cur_st; /* av_seek_frame() support */ int64_t data_offset; /**< offset of the first packet */ +#endif - int mux_rate; +#if FF_API_MUXRATE + /** + * use mpeg muxer private options instead + */ + attribute_deprecated int mux_rate; +#endif unsigned int packet_size; - int preload; +#if FF_API_PRELOAD + attribute_deprecated int preload; +#endif int max_delay; #if FF_API_LOOP_OUTPUT @@ -862,6 +942,7 @@ int debug; #define FF_FDEBUG_TS 0x0001 +#if FF_API_REORDER_PRIVATE /** * Raw packets from the demuxer, prior to parsing and decoding. * This buffer is used for buffering packets until the codec can @@ -872,15 +953,18 @@ struct AVPacketList *raw_packet_buffer_end; struct AVPacketList *packet_buffer_end; +#endif AVDictionary *metadata; +#if FF_API_REORDER_PRIVATE /** * Remaining size available for raw_packet_buffer, in bytes. * NOT PART OF PUBLIC API */ #define RAW_PACKET_BUFFER_SIZE 2500000 int raw_packet_buffer_remaining_size; +#endif /** * Start time of the stream in real world time, in microseconds @@ -909,6 +993,43 @@ * This will be moved into demuxer private options. Thus no API/ABI compatibility */ int ts_id; + + /***************************************************************** + * All fields below this line are not part of the public API. They + * may not be used outside of libavformat and can be changed and + * removed at will. + * New public fields should be added right above. + ***************************************************************** + */ +#if !FF_API_REORDER_PRIVATE + /** + * Raw packets from the demuxer, prior to parsing and decoding. + * This buffer is used for buffering packets until the codec can + * be identified, as parsing cannot be done without knowing the + * codec. + */ + struct AVPacketList *raw_packet_buffer; + struct AVPacketList *raw_packet_buffer_end; + /** + * Remaining size available for raw_packet_buffer, in bytes. + */ +#define RAW_PACKET_BUFFER_SIZE 2500000 + int raw_packet_buffer_remaining_size; + + /** + * This buffer is only needed when packets were already buffered but + * not decoded, for example to get the codec parameters in MPEG + * streams. + */ + struct AVPacketList *packet_buffer; + struct AVPacketList *packet_buffer_end; + + /* av_read_frame() support */ + AVStream *cur_st; + + /* av_seek_frame() support */ + int64_t data_offset; /**< offset of the first packet */ +#endif } AVFormatContext; typedef struct AVPacketList { @@ -1392,6 +1513,7 @@ */ void avformat_free_context(AVFormatContext *s); +#if FF_API_NEW_STREAM /** * Add a new stream to a media file. * @@ -1402,7 +1524,27 @@ * @param s media file handle * @param id file-format-dependent stream ID */ +attribute_deprecated AVStream *av_new_stream(AVFormatContext *s, int id); +#endif + +/** + * Add a new stream to a media file. + * + * When demuxing, it is called by the demuxer in read_header(). If the + * flag AVFMTCTX_NOHEADER is set in s.ctx_flags, then it may also + * be called in read_packet(). + * + * When muxing, should be called by the user before avformat_write_header(). + * + * @param c If non-NULL, the AVCodecContext corresponding to the new stream + * will be initialized to use this codec. This is needed for e.g. codec-specific + * defaults to be set, so codec should be provided if it is known. + * + * @return newly created stream or NULL on error. + */ +AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c); + AVProgram *av_new_program(AVFormatContext *s, int id); /** @@ -1444,40 +1586,20 @@ int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, int size, int distance, int flags); -/** - * Perform a binary search using av_index_search_timestamp() and - * AVInputFormat.read_timestamp(). - * This is not supposed to be called directly by a user application, - * but by demuxers. - * @param target_ts target timestamp in the time base of the given stream - * @param stream_index stream number - */ +#if FF_API_SEEK_PUBLIC +attribute_deprecated int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags); - -/** - * Update cur_dts of all streams based on the given timestamp and AVStream. - * - * Stream ref_st unchanged, others set cur_dts in their native time base. - * Only needed for timestamp wrapping or if (dts not set and pts!=dts). - * @param timestamp new dts expressed in time_base of param ref_st - * @param ref_st reference stream giving time_base of param timestamp - */ +attribute_deprecated void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp); - -/** - * Perform a binary search using read_timestamp(). - * This is not supposed to be called directly by a user application, - * but by demuxers. - * @param target_ts target timestamp in the time base of the given stream - * @param stream_index stream number - */ +attribute_deprecated int64_t av_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, int64_t pos_min, int64_t pos_max, int64_t pos_limit, int64_t ts_min, int64_t ts_max, int flags, int64_t *ts_ret, int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t )); +#endif /** * media file output diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/avidec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/avidec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/avidec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/avidec.c 2011-11-04 12:38:27.000000000 +0000 @@ -19,12 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include "libavutil/intreadwrite.h" #include "libavutil/mathematics.h" #include "libavutil/bswap.h" #include "libavutil/opt.h" #include "libavutil/dict.h" +#include "libavutil/avstring.h" #include "avformat.h" #include "avi.h" #include "dv.h" @@ -78,7 +78,7 @@ static const AVOption options[] = { - { "use_odml", "use odml index", offsetof(AVIContext, use_odml), FF_OPT_TYPE_INT, {.dbl = 1}, -1, 1, AV_OPT_FLAG_DECODING_PARAM}, + { "use_odml", "use odml index", offsetof(AVIContext, use_odml), AV_OPT_TYPE_INT, {.dbl = 1}, -1, 1, AV_OPT_FLAG_DECODING_PARAM}, { NULL }, }; @@ -236,7 +236,7 @@ } } - avi->index_loaded=1; + avi->index_loaded=2; return 0; } @@ -307,7 +307,7 @@ if (sscanf(date, "%*3s%*[ ]%3s%*[ ]%2d%*[ ]%8s%*[ ]%4d", month, &day, time, &year) == 4) { for (i=0; i<12; i++) - if (!strcasecmp(month, months[i])) { + if (!av_strcasecmp(month, months[i])) { snprintf(buffer, sizeof(buffer), "%.4d-%.2d-%.2d %s", year, i+1, day, time); av_dict_set(metadata, "creation_time", buffer, 0); @@ -454,10 +454,11 @@ break; }else{ stream_index++; - st = av_new_stream(s, stream_index); + st = avformat_new_stream(s, NULL); if (!st) goto fail; + st->id = stream_index; ast = av_mallocz(sizeof(AVIStream)); if (!ast) goto fail; @@ -489,7 +490,7 @@ av_freep(&s->streams[0]); s->nb_streams = 0; if (CONFIG_DV_DEMUXER) { - avi->dv_demux = dv_init_demux(s); + avi->dv_demux = avpriv_dv_init_demux(s); if (!avi->dv_demux) goto fail; } @@ -570,6 +571,8 @@ break; case MKTAG('s', 't', 'r', 'f'): /* stream header */ + if (!size) + break; if (stream_index >= (unsigned)s->nb_streams || avi->dv_demux) { avio_skip(pb, size); } else { @@ -754,7 +757,7 @@ if(!avi->index_loaded && pb->seekable) avi_load_index(s); - avi->index_loaded = 1; + avi->index_loaded |= 1; avi->non_interleaved |= guess_ni_flag(s) | (s->flags & AVFMT_FLAG_SORT_DTS); for(i=0; inb_streams; i++){ AVStream *st = s->streams[i]; @@ -874,12 +877,13 @@ { AVIContext *avi = s->priv_data; AVIOContext *pb = s->pb; - int n, d[8]; + int n; + unsigned int d[8]; unsigned int size; int64_t i, sync; start_sync: - memset(d, -1, sizeof(int)*8); + memset(d, -1, sizeof(d)); for(i=sync=avio_tell(pb); !url_feof(pb); i++) { int j; @@ -891,7 +895,7 @@ n= get_stream_idx(d+2); //av_log(s, AV_LOG_DEBUG, "%X %X %X %X %X %X %X %X %"PRId64" %d %d\n", d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], i, size, n); - if(i + (uint64_t)size > avi->fsize || d[0]<0) + if(i + (uint64_t)size > avi->fsize || d[0] > 127) continue; //parse ix## @@ -997,6 +1001,8 @@ } } + if(pb->error) + return pb->error; return AVERROR_EOF; } @@ -1008,7 +1014,7 @@ void* dstr; if (CONFIG_DV_DEMUXER && avi->dv_demux) { - int size = dv_get_packet(avi->dv_demux, pkt); + int size = avpriv_dv_get_packet(avi->dv_demux, pkt); if (size >= 0) return size; } @@ -1111,7 +1117,7 @@ if (CONFIG_DV_DEMUXER && avi->dv_demux) { dstr = pkt->destruct; - size = dv_produce_packet(avi->dv_demux, pkt, + size = avpriv_dv_produce_packet(avi->dv_demux, pkt, pkt->data, pkt->size, pkt->pos); pkt->destruct = dstr; pkt->flags |= AV_PKT_FLAG_KEY; @@ -1178,7 +1184,7 @@ } ast->seek_pos= 0; - if(!avi->non_interleaved && st->nb_index_entries>1){ + if(!avi->non_interleaved && st->nb_index_entries>1 && avi->index_loaded>1){ int64_t dts= av_rescale_q(pkt->dts, st->time_base, AV_TIME_BASE_Q); if(avi->dts_max - dts > 2*AV_TIME_BASE){ @@ -1314,6 +1320,7 @@ if (tag == MKTAG('i', 'd', 'x', '1') && avi_read_idx1(s, size) >= 0) { + avi->index_loaded=2; ret = 0; break; } @@ -1348,7 +1355,7 @@ if (!avi->index_loaded) { /* we only load the index on demand */ avi_load_index(s); - avi->index_loaded = 1; + avi->index_loaded |= 1; } assert(stream_index>= 0); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/aviobuf.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/aviobuf.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/aviobuf.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/aviobuf.c 2011-11-04 12:38:27.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Buffered I/O for ffmpeg system + * buffered I/O * Copyright (c) 2000,2001 Fabrice Bellard * * This file is part of FFmpeg. @@ -778,13 +778,14 @@ { int i; + if (buflen <= 0) + return AVERROR(EINVAL); // reserve 1 byte for terminating 0 buflen = FFMIN(buflen - 1, maxlen); for (i = 0; i < buflen; i++) if (!(buf[i] = avio_r8(s))) return i + 1; - if (buflen) - buf[i] = 0; + buf[i] = 0; for (; i < maxlen; i++) if (!avio_r8(s)) return i + 1; @@ -796,6 +797,8 @@ {\ char* q = buf;\ int ret = 0;\ + if (buflen <= 0) \ + return AVERROR(EINVAL); \ while (ret + 1 < maxlen) {\ uint8_t tmp;\ uint32_t ch;\ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/avio.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/avio.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/avio.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/avio.c 2011-11-04 12:38:27.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Unbuffered io for ffmpeg system + * unbuffered I/O * Copyright (c) 2001 Fabrice Bellard * * This file is part of FFmpeg. diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/avisynth.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/avisynth.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/avisynth.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/avisynth.c 2011-11-04 12:38:27.000000000 +0000 @@ -1,5 +1,5 @@ /* - * AVISynth support for ffmpeg system + * AVISynth support * Copyright (c) 2006 DivX, Inc. * * This file is part of FFmpeg. @@ -84,7 +84,8 @@ if (AVIStreamReadFormat(stream->handle, 0, &wvfmt, &struct_size) != S_OK) continue; - st = av_new_stream(s, id); + st = avformat_new_stream(s, NULL); + st->id = id; st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->block_align = wvfmt.nBlockAlign; @@ -110,7 +111,8 @@ if (AVIStreamReadFormat(stream->handle, 0, &imgfmt, &struct_size) != S_OK) continue; - st = av_new_stream(s, id); + st = avformat_new_stream(s, NULL); + st->id = id; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->r_frame_rate.num = stream->info.dwRate; st->r_frame_rate.den = stream->info.dwScale; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/avs.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/avs.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/avs.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/avs.c 2011-11-04 12:38:27.000000000 +0000 @@ -179,7 +179,7 @@ case AVS_VIDEO: if (!avs->st_video) { - avs->st_video = av_new_stream(s, AVS_VIDEO); + avs->st_video = avformat_new_stream(s, NULL); if (avs->st_video == NULL) return AVERROR(ENOMEM); avs->st_video->codec->codec_type = AVMEDIA_TYPE_VIDEO; @@ -196,7 +196,7 @@ case AVS_AUDIO: if (!avs->st_audio) { - avs->st_audio = av_new_stream(s, AVS_AUDIO); + avs->st_audio = avformat_new_stream(s, NULL); if (avs->st_audio == NULL) return AVERROR(ENOMEM); avs->st_audio->codec->codec_type = AVMEDIA_TYPE_AUDIO; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/bethsoftvid.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/bethsoftvid.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/bethsoftvid.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/bethsoftvid.c 2011-11-04 12:38:27.000000000 +0000 @@ -70,7 +70,7 @@ avio_skip(pb, 5); vid->nframes = avio_rl16(pb); - stream = av_new_stream(s, 0); + stream = avformat_new_stream(s, NULL); if (!stream) return AVERROR(ENOMEM); av_set_pts_info(stream, 32, 1, 60); // 16 ms increments, i.e. 60 fps @@ -83,7 +83,7 @@ avio_rl16(pb); // done with video codec, set up audio codec - stream = av_new_stream(s, 0); + stream = avformat_new_stream(s, NULL); if (!stream) return AVERROR(ENOMEM); stream->codec->codec_type = AVMEDIA_TYPE_AUDIO; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/bfi.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/bfi.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/bfi.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/bfi.c 2011-11-04 12:38:27.000000000 +0000 @@ -55,12 +55,12 @@ int fps, chunk_header; /* Initialize the video codec... */ - vstream = av_new_stream(s, 0); + vstream = avformat_new_stream(s, NULL); if (!vstream) return AVERROR(ENOMEM); /* Initialize the audio codec... */ - astream = av_new_stream(s, 0); + astream = avformat_new_stream(s, NULL); if (!astream) return AVERROR(ENOMEM); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/bink.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/bink.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/bink.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/bink.c 2011-11-04 12:38:27.000000000 +0000 @@ -78,7 +78,7 @@ uint16_t flags; int keyframe; - vst = av_new_stream(s, 0); + vst = avformat_new_stream(s, NULL); if (!vst) return AVERROR(ENOMEM); @@ -130,7 +130,7 @@ avio_skip(pb, 4 * bink->num_audio_tracks); for (i = 0; i < bink->num_audio_tracks; i++) { - ast = av_new_stream(s, 1); + ast = avformat_new_stream(s, NULL); if (!ast) return AVERROR(ENOMEM); ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/bintext.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/bintext.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/bintext.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/bintext.c 2011-11-04 12:38:27.000000000 +0000 @@ -261,7 +261,9 @@ static int idf_probe(AVProbeData *p) { - if (!memcmp(p->buf, idf_magic, FFMIN(sizeof(idf_magic), p->buf_size))) + if (p->buf_size < sizeof(idf_magic)) + return 0; + if (!memcmp(p->buf, idf_magic, sizeof(idf_magic))) return AVPROBE_SCORE_MAX; return 0; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/bit.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/bit.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/bit.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/bit.c 2011-11-04 12:38:27.000000000 +0000 @@ -1,3 +1,23 @@ +/* + * G.729 bit format muxer and demuxer + * Copyright (c) 2007-2008 Vladimir Voroshilov + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ #include "avformat.h" #include "libavcodec/get_bits.h" #include "libavcodec/put_bits.h" @@ -12,6 +32,9 @@ { int i, j; + if(p->buf_size < 0x40) + return 0; + for(i=0; i+3buf_size && i< 10*0x50; ){ if(AV_RL16(&p->buf[0]) != SYNC_WORD) return 0; @@ -27,7 +50,7 @@ { AVStream* st; - st=av_new_stream(s, 0); + st=avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); @@ -44,7 +67,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) { - ByteIOContext *pb = s->pb; + AVIOContext *pb = s->pb; PutBitContext pbo; uint16_t buf[8 * MAX_FRAME_SIZE + 2]; int packet_size; @@ -55,12 +78,12 @@ if(url_feof(pb)) return AVERROR_EOF; - get_le16(pb); // sync word - packet_size = get_le16(pb) / 8; + avio_rl16(pb); // sync word + packet_size = avio_rl16(pb) / 8; if(packet_size > MAX_FRAME_SIZE) return AVERROR_INVALIDDATA; - ret = get_buffer(pb, (uint8_t*)buf, (8 * packet_size) * sizeof(uint16_t)); + ret = avio_read(pb, (uint8_t*)buf, (8 * packet_size) * sizeof(uint16_t)); if(ret<0) return ret; if(ret != 8 * packet_size * sizeof(uint16_t)) @@ -108,13 +131,13 @@ GetBitContext gb; int i; - put_le16(pb, SYNC_WORD); - put_le16(pb, 8 * 10); + avio_wl16(pb, SYNC_WORD); + avio_wl16(pb, 8 * 10); init_get_bits(&gb, pkt->data, 8*10); for(i=0; i< 8 * 10; i++) - put_le16(pb, get_bits1(&gb) ? BIT_1 : BIT_0); - put_flush_packet(pb); + avio_wl16(pb, get_bits1(&gb) ? BIT_1 : BIT_0); + avio_flush(pb); return 0; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/c93.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/c93.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/c93.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/c93.c 2011-11-04 12:38:27.000000000 +0000 @@ -79,7 +79,7 @@ /* Audio streams are added if audio packets are found */ s->ctx_flags |= AVFMTCTX_NOHEADER; - video = av_new_stream(s, 0); + video = avformat_new_stream(s, NULL); if (!video) return AVERROR(ENOMEM); @@ -117,7 +117,7 @@ datasize = avio_rl16(pb); if (datasize > 42) { if (!c93->audio) { - c93->audio = av_new_stream(s, 1); + c93->audio = avformat_new_stream(s, NULL); if (!c93->audio) return AVERROR(ENOMEM); c93->audio->codec->codec_type = AVMEDIA_TYPE_AUDIO; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/cache.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/cache.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/cache.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/cache.c 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,144 @@ +/* + * Input cache protocol. + * Copyright (c) 2011 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Based on file.c by Fabrice Bellard + */ + +/** + * @TODO + * support non continuous caching + * support keeping files + * support filling with a background thread + */ + +#include "libavutil/avassert.h" +#include "libavutil/avstring.h" +#include "libavutil/file.h" +#include "avformat.h" +#include +#if HAVE_SETMODE +#include +#endif +#include +#include +#include +#include "os_support.h" +#include "url.h" + +typedef struct Context { + int fd; + int64_t end; + int64_t pos; + URLContext *inner; +} Context; + +static int cache_open(URLContext *h, const char *arg, int flags) +{ + int access; + const char *buffername; + Context *c; + + c = av_mallocz(sizeof(Context)); + if (!c) { + return AVERROR(ENOMEM); + } + h->priv_data = c; + + av_strstart(arg, "cache:", &arg); + + c->fd = av_tempfile("ffcache", &buffername, 0, h); + if (c->fd < 0){ + av_log(h, AV_LOG_ERROR, "Failed to create tempfile\n"); + return c->fd; + } + + unlink(buffername); + av_free(buffername); + + return ffurl_open(&c->inner, arg, flags); +} + +static int cache_read(URLContext *h, unsigned char *buf, int size) +{ + Context *c= h->priv_data; + int r; + + if(c->posend){ + r = read(c->fd, buf, FFMIN(size, c->end - c->pos)); + if(r>0) + c->pos += r; + return (-1 == r)?AVERROR(errno):r; + }else{ + r = ffurl_read(c->inner, buf, size); + if(r > 0){ + int r2= write(c->fd, buf, r); + av_assert0(r2==r); // FIXME handle cache failure + c->pos += r; + c->end += r; + } + return r; + } +} + +static int64_t cache_seek(URLContext *h, int64_t pos, int whence) +{ + Context *c= h->priv_data; + + if (whence == AVSEEK_SIZE) { + pos= ffurl_seek(c->inner, pos, whence); + if(pos <= 0){ + pos= ffurl_seek(c->inner, -1, SEEK_END); + ffurl_seek(c->inner, c->end, SEEK_SET); + if(pos <= 0) + return c->end; + } + return pos; + } + + pos= lseek(c->fd, pos, whence); + if(pos<0){ + return pos; + }else if(pos <= c->end){ + c->pos= pos; + return pos; + }else{ + lseek(c->fd, c->pos, SEEK_SET); + return AVERROR(EPIPE); + } +} + +static int cache_close(URLContext *h) +{ + Context *c= h->priv_data; + close(c->fd); + ffurl_close(c->inner); + + av_freep(&h->priv_data); + + return 0; +} + +URLProtocol ff_cache_protocol = { + .name = "cache", + .url_open = cache_open, + .url_read = cache_read, + .url_seek = cache_seek, + .url_close = cache_close, +}; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/cafdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/cafdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/cafdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/cafdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -61,7 +61,7 @@ int flags; /* new audio stream */ - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); @@ -120,18 +120,28 @@ } else if (st->codec->codec_id == CODEC_ID_ALAC) { #define ALAC_PREAMBLE 12 #define ALAC_HEADER 36 - if (size < ALAC_PREAMBLE + ALAC_HEADER) { - av_log(s, AV_LOG_ERROR, "invalid ALAC magic cookie\n"); - avio_skip(pb, size); - return AVERROR_INVALIDDATA; +#define ALAC_NEW_KUKI 24 + if (size == ALAC_NEW_KUKI) { + st->codec->extradata = av_mallocz(ALAC_HEADER + FF_INPUT_BUFFER_PADDING_SIZE); + if (!st->codec->extradata) + return AVERROR(ENOMEM); + memcpy(st->codec->extradata, "\0\0\0\24alac", 8); + avio_read(pb, st->codec->extradata + ALAC_HEADER - ALAC_NEW_KUKI, ALAC_NEW_KUKI); + st->codec->extradata_size = ALAC_HEADER; + } else { + if (size < ALAC_PREAMBLE + ALAC_HEADER) { + av_log(s, AV_LOG_ERROR, "invalid ALAC magic cookie\n"); + avio_skip(pb, size); + return AVERROR_INVALIDDATA; + } + avio_skip(pb, ALAC_PREAMBLE); + st->codec->extradata = av_mallocz(ALAC_HEADER + FF_INPUT_BUFFER_PADDING_SIZE); + if (!st->codec->extradata) + return AVERROR(ENOMEM); + avio_read(pb, st->codec->extradata, ALAC_HEADER); + st->codec->extradata_size = ALAC_HEADER; + avio_skip(pb, size - ALAC_PREAMBLE - ALAC_HEADER); } - avio_skip(pb, ALAC_PREAMBLE); - st->codec->extradata = av_mallocz(ALAC_HEADER + FF_INPUT_BUFFER_PADDING_SIZE); - if (!st->codec->extradata) - return AVERROR(ENOMEM); - avio_read(pb, st->codec->extradata, ALAC_HEADER); - st->codec->extradata_size = ALAC_HEADER; - avio_skip(pb, size - ALAC_PREAMBLE - ALAC_HEADER); } else { st->codec->extradata = av_mallocz(size + FF_INPUT_BUFFER_PADDING_SIZE); if (!st->codec->extradata) @@ -292,8 +302,6 @@ "block size or frame size are variable.\n"); return AVERROR_INVALIDDATA; } - s->file_size = avio_size(pb); - s->file_size = FFMAX(0, s->file_size); av_set_pts_info(st, 64, 1, st->codec->sample_rate); st->start_time = 0; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/cdg.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/cdg.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/cdg.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/cdg.c 2011-11-04 12:38:27.000000000 +0000 @@ -28,7 +28,7 @@ AVStream *vst; int ret; - vst = av_new_stream(s, 0); + vst = avformat_new_stream(s, NULL); if (!vst) return AVERROR(ENOMEM); @@ -52,6 +52,11 @@ ret = av_get_packet(s->pb, pkt, CDG_PACKET_SIZE); pkt->stream_index = 0; + pkt->dts=pkt->pts= s->streams[0]->cur_dts; + + if(ret>5 && (pkt->data[0]&0x3F) == 9 && (pkt->data[1]&0x3F)==1 && !(pkt->data[2+2+1] & 0x0F)){ + pkt->flags = AV_PKT_FLAG_KEY; + } return ret; } @@ -60,5 +65,6 @@ .long_name = NULL_IF_CONFIG_SMALL("CD Graphics Format"), .read_header = read_header, .read_packet = read_packet, + .flags= AVFMT_GENERIC_INDEX, .extensions = "cdg" }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/crypto.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/crypto.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/crypto.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/crypto.c 2011-11-04 12:38:27.000000000 +0000 @@ -46,8 +46,8 @@ #define OFFSET(x) offsetof(CryptoContext, x) static const AVOption options[] = { - {"key", "AES decryption key", OFFSET(key), FF_OPT_TYPE_BINARY }, - {"iv", "AES decryption initialization vector", OFFSET(iv), FF_OPT_TYPE_BINARY }, + {"key", "AES decryption key", OFFSET(key), AV_OPT_TYPE_BINARY }, + {"iv", "AES decryption initialization vector", OFFSET(iv), AV_OPT_TYPE_BINARY }, { NULL } }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/cutils.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/cutils.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/cutils.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/cutils.c 2011-11-04 12:38:27.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Various simple utilities for ffmpeg system + * various simple utilities for libavformat * Copyright (c) 2000, 2001, 2002 Fabrice Bellard * * This file is part of FFmpeg. diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/daud.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/daud.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/daud.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/daud.c 2011-11-04 12:38:27.000000000 +0000 @@ -21,7 +21,7 @@ #include "avformat.h" static int daud_header(AVFormatContext *s, AVFormatParameters *ap) { - AVStream *st = av_new_stream(s, 0); + AVStream *st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/dfa.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/dfa.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/dfa.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/dfa.c 2011-11-04 12:38:27.000000000 +0000 @@ -45,7 +45,7 @@ avio_skip(pb, 2); // unused frames = avio_rl16(pb); - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/dsicin.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/dsicin.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/dsicin.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/dsicin.c 2011-11-04 12:38:27.000000000 +0000 @@ -107,7 +107,7 @@ cin->audio_buffer_size = 0; /* initialize the video decoder stream */ - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); @@ -120,7 +120,7 @@ st->codec->height = hdr->video_frame_height; /* initialize the audio decoder stream */ - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); @@ -131,9 +131,8 @@ st->codec->codec_tag = 0; /* no tag */ st->codec->channels = 1; st->codec->sample_rate = 22050; - st->codec->bits_per_coded_sample = 16; + st->codec->bits_per_coded_sample = 8; st->codec->bit_rate = st->codec->sample_rate * st->codec->bits_per_coded_sample * st->codec->channels; - st->codec->block_align = st->codec->channels * st->codec->bits_per_coded_sample; return 0; } @@ -211,7 +210,8 @@ pkt->stream_index = cin->audio_stream_index; pkt->pts = cin->audio_stream_pts; - cin->audio_stream_pts += cin->audio_buffer_size * 2 / cin->file_header.audio_frame_size; + pkt->duration = cin->audio_buffer_size - (pkt->pts == 0); + cin->audio_stream_pts += pkt->duration; cin->audio_buffer_size = 0; return 0; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/dv.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/dv.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/dv.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/dv.c 2011-11-04 12:38:27.000000000 +0000 @@ -96,7 +96,7 @@ /* * There's a couple of assumptions being made here: * 1. By default we silence erroneous (0x8000/16bit 0x800/12bit) audio samples. - * We can pass them upwards when ffmpeg will be ready to deal with them. + * We can pass them upwards when libavcodec will be ready to deal with them. * 2. We don't do software emphasis. * 3. Audio is always returned as 16bit linear samples: 12bit nonlinear samples * are converted into 16bit linear ones. @@ -211,7 +211,7 @@ /* Dynamic handling of the audio streams in DV */ for (i = 0; i < ach; i++) { if (!c->ast[i]) { - c->ast[i] = av_new_stream(c->fctx, 0); + c->ast[i] = avformat_new_stream(c->fctx, NULL); if (!c->ast[i]) break; av_set_pts_info(c->ast[i], 64, 1, 30000); @@ -270,7 +270,7 @@ * The following 3 functions constitute our interface to the world */ -DVDemuxContext* dv_init_demux(AVFormatContext *s) +DVDemuxContext* avpriv_dv_init_demux(AVFormatContext *s) { DVDemuxContext *c; @@ -278,7 +278,7 @@ if (!c) return NULL; - c->vst = av_new_stream(s, 0); + c->vst = avformat_new_stream(s, NULL); if (!c->vst) { av_free(c); return NULL; @@ -299,7 +299,7 @@ return c; } -int dv_get_packet(DVDemuxContext *c, AVPacket *pkt) +int avpriv_dv_get_packet(DVDemuxContext *c, AVPacket *pkt) { int size = -1; int i; @@ -316,14 +316,14 @@ return size; } -int dv_produce_packet(DVDemuxContext *c, AVPacket *pkt, +int avpriv_dv_produce_packet(DVDemuxContext *c, AVPacket *pkt, uint8_t* buf, int buf_size, int64_t pos) { int size, i; uint8_t *ppcm[4] = {0}; if (buf_size < DV_PROFILE_BYTES || - !(c->sys = ff_dv_frame_profile(c->sys, buf, buf_size)) || + !(c->sys = avpriv_dv_frame_profile(c->sys, buf, buf_size)) || buf_size < c->sys->frame_size) { return -1; /* Broken frame, or not enough data */ } @@ -371,7 +371,7 @@ int64_t timestamp, int flags) { // FIXME: sys may be wrong if last dv_read_packet() failed (buffer is junk) - const DVprofile* sys = ff_dv_codec_profile(c->vst->codec); + const DVprofile* sys = avpriv_dv_codec_profile(c->vst->codec); int64_t offset; int64_t size = avio_size(s->pb) - s->data_offset; int64_t max_offset = ((size-1) / sys->frame_size) * sys->frame_size; @@ -409,7 +409,7 @@ unsigned state, marker_pos = 0; RawDVContext *c = s->priv_data; - c->dv_demux = dv_init_demux(s); + c->dv_demux = avpriv_dv_init_demux(s); if (!c->dv_demux) return -1; @@ -434,7 +434,7 @@ avio_seek(s->pb, -DV_PROFILE_BYTES, SEEK_CUR) < 0) return AVERROR(EIO); - c->dv_demux->sys = ff_dv_frame_profile(c->dv_demux->sys, c->buf, DV_PROFILE_BYTES); + c->dv_demux->sys = avpriv_dv_frame_profile(c->dv_demux->sys, c->buf, DV_PROFILE_BYTES); if (!c->dv_demux->sys) { av_log(s, AV_LOG_ERROR, "Can't determine profile of DV input stream.\n"); return -1; @@ -452,7 +452,7 @@ int size; RawDVContext *c = s->priv_data; - size = dv_get_packet(c->dv_demux, pkt); + size = avpriv_dv_get_packet(c->dv_demux, pkt); if (size < 0) { int64_t pos = avio_tell(s->pb); @@ -462,7 +462,7 @@ if (avio_read(s->pb, c->buf, size) <= 0) return AVERROR(EIO); - size = dv_produce_packet(c->dv_demux, pkt, c->buf, size, pos); + size = avpriv_dv_produce_packet(c->dv_demux, pkt, c->buf, size, pos); } return size; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/dvenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/dvenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/dvenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/dvenc.c 2011-11-04 12:38:27.000000000 +0000 @@ -320,7 +320,7 @@ c->ast[i]->codec->channels != 2)) goto bail_out; } - c->sys = ff_dv_codec_profile(vst->codec); + c->sys = avpriv_dv_codec_profile(vst->codec); if (!c->sys) goto bail_out; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/dv.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/dv.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/dv.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/dv.h 2011-11-04 12:38:27.000000000 +0000 @@ -31,9 +31,9 @@ #include "avformat.h" typedef struct DVDemuxContext DVDemuxContext; -DVDemuxContext* dv_init_demux(AVFormatContext* s); -int dv_get_packet(DVDemuxContext*, AVPacket *); -int dv_produce_packet(DVDemuxContext*, AVPacket*, uint8_t*, int, int64_t); +DVDemuxContext* avpriv_dv_init_demux(AVFormatContext* s); +int avpriv_dv_get_packet(DVDemuxContext*, AVPacket *); +int avpriv_dv_produce_packet(DVDemuxContext*, AVPacket*, uint8_t*, int, int64_t); void dv_offset_reset(DVDemuxContext *c, int64_t frame_offset); typedef struct DVMuxContext DVMuxContext; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/dxa.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/dxa.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/dxa.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/dxa.c 2011-11-04 12:38:27.000000000 +0000 @@ -87,7 +87,7 @@ h = avio_rb16(pb); c->has_sound = 0; - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return -1; @@ -100,7 +100,7 @@ avio_skip(pb, 16); fsize = avio_rl32(pb); - ast = av_new_stream(s, 0); + ast = avformat_new_stream(s, NULL); if (!ast) return -1; ret = ff_get_wav_header(pb, ast->codec, fsize); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/eacdata.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/eacdata.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/eacdata.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/eacdata.c 2011-11-04 12:38:27.000000000 +0000 @@ -66,7 +66,7 @@ sample_rate = avio_rb16(pb); avio_skip(pb, (avio_r8(pb) & 0x20) ? 15 : 11); - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/electronicarts.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/electronicarts.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/electronicarts.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/electronicarts.c 2011-11-04 12:38:27.000000000 +0000 @@ -408,7 +408,7 @@ if (ea->video_codec) { /* initialize the video decoder stream */ - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); ea->video_stream_index = st->index; @@ -437,7 +437,7 @@ } /* initialize the audio decoder stream */ - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); av_set_pts_info(st, 33, 1, ea->sample_rate); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/ffmdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/ffmdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/ffmdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/ffmdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -295,7 +295,7 @@ for(i=0;inb_chapters, tb, start, end, NULL); + return avpriv_new_chapter(s, s->nb_chapters, tb, start, end, NULL); } static uint8_t *unescape(uint8_t *buf, int size) @@ -132,7 +132,7 @@ get_line(s->pb, line, sizeof(line)); if (!memcmp(line, ID_STREAM, strlen(ID_STREAM))) { - AVStream *st = av_new_stream(s, 0); + AVStream *st = avformat_new_stream(s, NULL); if (!st) return -1; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/file.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/file.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/file.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/file.c 2011-11-04 12:38:27.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Buffered file io for ffmpeg system + * buffered file I/O * Copyright (c) 2001 Fabrice Bellard * * This file is part of FFmpeg. @@ -37,13 +37,15 @@ static int file_read(URLContext *h, unsigned char *buf, int size) { int fd = (intptr_t) h->priv_data; - return read(fd, buf, size); + int r = read(fd, buf, size); + return (-1 == r)?AVERROR(errno):r; } static int file_write(URLContext *h, const unsigned char *buf, int size) { int fd = (intptr_t) h->priv_data; - return write(fd, buf, size); + int r = write(fd, buf, size); + return (-1 == r)?AVERROR(errno):r; } static int file_get_handle(URLContext *h) diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/filmstripdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/filmstripdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/filmstripdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/filmstripdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -49,7 +49,7 @@ return AVERROR_INVALIDDATA; } - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/flacdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/flacdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/flacdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/flacdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -31,7 +31,7 @@ int ret, metadata_last=0, metadata_type, metadata_size, found_streaminfo=0; uint8_t header[4]; uint8_t *buffer=NULL; - AVStream *st = av_new_stream(s, 0); + AVStream *st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; @@ -48,7 +48,7 @@ /* process metadata blocks */ while (!url_feof(s->pb) && !metadata_last) { avio_read(s->pb, header, 4); - ff_flac_parse_block_header(header, &metadata_last, &metadata_type, + avpriv_flac_parse_block_header(header, &metadata_last, &metadata_type, &metadata_size); switch (metadata_type) { /* allocate and read metadata block for supported types */ @@ -87,7 +87,7 @@ buffer = NULL; /* get codec params from STREAMINFO header */ - ff_flac_parse_streaminfo(st->codec, &si, st->codec->extradata); + avpriv_flac_parse_streaminfo(st->codec, &si, st->codec->extradata); /* set time base and duration */ if (si.samplerate > 0) { diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/flacenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/flacenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/flacenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/flacenc.c 2011-11-04 12:38:27.000000000 +0000 @@ -94,7 +94,7 @@ enum FLACExtradataFormat format; int64_t file_size; - if (!ff_flac_is_extradata_valid(s->streams[0]->codec, &format, &streaminfo)) + if (!avpriv_flac_is_extradata_valid(s->streams[0]->codec, &format, &streaminfo)) return -1; if (pb->seekable) { diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/flacenc_header.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/flacenc_header.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/flacenc_header.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/flacenc_header.c 2011-11-04 12:38:27.000000000 +0000 @@ -34,7 +34,7 @@ enum FLACExtradataFormat format; header[4] = last_block ? 0x80 : 0x00; - if (!ff_flac_is_extradata_valid(codec, &format, &streaminfo)) + if (!avpriv_flac_is_extradata_valid(codec, &format, &streaminfo)) return -1; /* write "fLaC" stream marker and first metadata block header if needed */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/flic.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/flic.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/flic.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/flic.c 2011-11-04 12:38:27.000000000 +0000 @@ -105,7 +105,7 @@ speed = FLIC_DEFAULT_SPEED; /* initialize the decoder streams */ - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); flic->video_stream_index = st->index; @@ -145,7 +145,7 @@ */ if (AV_RL16(&preamble[4]) == FLIC_TFTD_CHUNK_AUDIO) { /* TFTD videos have an extra 22050 Hz 8-bit mono audio stream */ - ast = av_new_stream(s, 1); + ast = avformat_new_stream(s, NULL); if (!ast) return AVERROR(ENOMEM); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/flvdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/flvdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/flvdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/flvdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -228,8 +228,9 @@ case AMF_DATA_TYPE_OBJECT: { unsigned int keylen; - if (ioc->seekable && key && !strcmp(KEYFRAMES_TAG, key) && depth == 1) - if (parse_keyframes_index(s, ioc, vstream, max_pos) < 0) + if ((vstream || astream) && ioc->seekable && key && !strcmp(KEYFRAMES_TAG, key) && depth == 1) + if (parse_keyframes_index(s, ioc, vstream ? vstream : astream, + max_pos) < 0) av_log(s, AV_LOG_ERROR, "Keyframe index parsing failed\n"); while(avio_tell(ioc) < max_pos - 2 && (keylen = avio_rb16(ioc))) { @@ -276,17 +277,35 @@ acodec = astream ? astream->codec : NULL; vcodec = vstream ? vstream->codec : NULL; + if (amf_type == AMF_DATA_TYPE_NUMBER) { + if (!strcmp(key, "duration")) + s->duration = num_val * AV_TIME_BASE; + else if (!strcmp(key, "videodatarate") && vcodec && 0 <= (int)(num_val * 1024.0)) + vcodec->bit_rate = num_val * 1024.0; + else if (!strcmp(key, "audiodatarate") && acodec && 0 <= (int)(num_val * 1024.0)) + acodec->bit_rate = num_val * 1024.0; + } + + if (!strcmp(key, "duration") || + !strcmp(key, "filesize") || + !strcmp(key, "width") || + !strcmp(key, "height") || + !strcmp(key, "videodatarate") || + !strcmp(key, "framerate") || + !strcmp(key, "videocodecid") || + !strcmp(key, "audiodatarate") || + !strcmp(key, "audiosamplerate") || + !strcmp(key, "audiosamplesize") || + !strcmp(key, "stereo") || + !strcmp(key, "audiocodecid")) + return 0; + if(amf_type == AMF_DATA_TYPE_BOOL) { av_strlcpy(str_val, num_val > 0 ? "true" : "false", sizeof(str_val)); av_dict_set(&s->metadata, key, str_val, 0); } else if(amf_type == AMF_DATA_TYPE_NUMBER) { snprintf(str_val, sizeof(str_val), "%.f", num_val); av_dict_set(&s->metadata, key, str_val, 0); - if(!strcmp(key, "duration")) s->duration = num_val * AV_TIME_BASE; - else if(!strcmp(key, "videodatarate") && vcodec && 0 <= (int)(num_val * 1024.0)) - vcodec->bit_rate = num_val * 1024.0; - else if(!strcmp(key, "audiodatarate") && acodec && 0 <= (int)(num_val * 1024.0)) - acodec->bit_rate = num_val * 1024.0; } else if(amf_type == AMF_DATA_TYPE_OBJECT){ if(s->nb_streams==1 && ((!acodec && !strcmp(key, "audiocodecid")) || (!vcodec && !strcmp(key, "videocodecid")))){ s->ctx_flags &= ~AVFMTCTX_NOHEADER; //If there is either audio/video missing, codecid will be an empty object @@ -329,9 +348,10 @@ } static AVStream *create_stream(AVFormatContext *s, int stream_type){ - AVStream *st = av_new_stream(s, stream_type); + AVStream *st = avformat_new_stream(s, NULL); if (!st) return NULL; + st->id = stream_type; switch(stream_type) { case FLV_STREAM_TYPE_VIDEO: st->codec->codec_type = AVMEDIA_TYPE_VIDEO; break; case FLV_STREAM_TYPE_AUDIO: st->codec->codec_type = AVMEDIA_TYPE_AUDIO; break; @@ -523,7 +543,7 @@ return ret; if (st->codec->codec_id == CODEC_ID_AAC) { MPEG4AudioConfig cfg; - ff_mpeg4audio_get_config(&cfg, st->codec->extradata, + avpriv_mpeg4audio_get_config(&cfg, st->codec->extradata, st->codec->extradata_size); st->codec->channels = cfg.channels; if (cfg.ext_sample_rate) diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/flvenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/flvenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/flvenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/flvenc.c 2011-11-04 12:38:27.000000000 +0000 @@ -60,10 +60,13 @@ int64_t duration_offset; int64_t filesize_offset; int64_t duration; - int delay; ///< first dts delay for AVC - int64_t last_video_ts; + int64_t delay; ///< first dts delay (needed for AVC & Speex) } FLVContext; +typedef struct FLVStreamContext { + int64_t last_ts; ///< last timestamp for each stream +} FLVStreamContext; + static int get_audio_flags(AVCodecContext *enc){ int flags = (enc->bits_per_coded_sample == 16) ? FLV_SAMPLESSIZE_16BIT : FLV_SAMPLESSIZE_8BIT; @@ -78,11 +81,6 @@ av_log(enc, AV_LOG_ERROR, "flv only supports mono Speex audio\n"); return -1; } - if (enc->frame_size / 320 > 8) { - av_log(enc, AV_LOG_WARNING, "Warning: Speex stream has more than " - "8 frames per packet. Adobe Flash " - "Player cannot handle this!\n"); - } return FLV_CODECID_SPEEX | FLV_SAMPLERATE_11025HZ | FLV_SAMPLESSIZE_16BIT; } else { switch (enc->sample_rate) { @@ -180,13 +178,14 @@ AVIOContext *pb = s->pb; FLVContext *flv = s->priv_data; AVCodecContext *audio_enc = NULL, *video_enc = NULL; - int i; + int i, metadata_count = 0; double framerate = 0.0; - int64_t metadata_size_pos, data_size; + int64_t metadata_size_pos, data_size, metadata_count_pos; AVDictionaryEntry *tag = NULL; for(i=0; inb_streams; i++){ AVCodecContext *enc = s->streams[i]->codec; + FLVStreamContext *sc; if (enc->codec_type == AVMEDIA_TYPE_VIDEO) { if (s->streams[i]->r_frame_rate.den && s->streams[i]->r_frame_rate.num) { framerate = av_q2d(s->streams[i]->r_frame_rate); @@ -204,7 +203,15 @@ return -1; } av_set_pts_info(s->streams[i], 32, 1, 1000); /* 32 bit pts in ms */ + + sc = av_mallocz(sizeof(FLVStreamContext)); + if (!sc) + return AVERROR(ENOMEM); + s->streams[i]->priv_data = sc; + sc->last_ts = -1; } + flv->delay = AV_NOPTS_VALUE; + avio_write(pb, "FLV", 3); avio_w8(pb,1); avio_w8(pb, FLV_HEADER_FLAG_HASAUDIO * !!audio_enc @@ -223,8 +230,6 @@ } } - flv->last_video_ts = -1; - /* write meta_tag */ avio_w8(pb, 18); // tag type META metadata_size_pos= avio_tell(pb); @@ -240,7 +245,9 @@ /* mixed array (hash) with size and string/type/data tuples */ avio_w8(pb, AMF_DATA_TYPE_MIXEDARRAY); - avio_wb32(pb, 5*!!video_enc + 5*!!audio_enc + 2); // +2 for duration and file size + metadata_count_pos = avio_tell(pb); + metadata_count = 5*!!video_enc + 5*!!audio_enc + 2; // +2 for duration and file size + avio_wb32(pb, metadata_count); put_amf_string(pb, "duration"); flv->duration_offset= avio_tell(pb); @@ -300,6 +307,7 @@ put_amf_string(pb, tag->key); avio_w8(pb, AMF_DATA_TYPE_STRING); put_amf_string(pb, tag->value); + metadata_count++; } put_amf_string(pb, "filesize"); @@ -311,6 +319,10 @@ /* write total size of tag */ data_size= avio_tell(pb) - metadata_size_pos - 10; + + avio_seek(pb, metadata_count_pos, SEEK_SET); + avio_wb32(pb, metadata_count); + avio_seek(pb, metadata_size_pos, SEEK_SET); avio_wb24(pb, data_size); avio_skip(pb, data_size + 10 - 3); @@ -359,9 +371,10 @@ /* Add EOS tag */ for (i = 0; i < s->nb_streams; i++) { AVCodecContext *enc = s->streams[i]->codec; + FLVStreamContext *sc = s->streams[i]->priv_data; if (enc->codec_type == AVMEDIA_TYPE_VIDEO && (enc->codec_id == CODEC_ID_H264 || enc->codec_id == CODEC_ID_MPEG4)) { - put_avc_eos_tag(pb, flv->last_video_ts); + put_avc_eos_tag(pb, sc->last_ts); } } @@ -382,6 +395,7 @@ AVIOContext *pb = s->pb; AVCodecContext *enc = s->streams[pkt->stream_index]->codec; FLVContext *flv = s->priv_data; + FLVStreamContext *sc = s->streams[pkt->stream_index]->priv_data; unsigned ts; int size= pkt->size; uint8_t *data= NULL; @@ -427,19 +441,31 @@ if (ff_avc_parse_nal_units_buf(pkt->data, &data, &size) < 0) return -1; } - if (!flv->delay && pkt->dts < 0) - flv->delay = -pkt->dts; } else if (enc->codec_id == CODEC_ID_AAC && pkt->size > 2 && (AV_RB16(pkt->data) & 0xfff0) == 0xfff0) { av_log(s, AV_LOG_ERROR, "malformated aac bitstream, use -absf aac_adtstoasc\n"); return -1; } + if (flv->delay == AV_NOPTS_VALUE) + flv->delay = -pkt->dts; + if (pkt->dts < -flv->delay) { + av_log(s, AV_LOG_WARNING, "Packets are not in the proper order with " + "respect to DTS\n"); + return AVERROR(EINVAL); + } ts = pkt->dts + flv->delay; // add delay to force positive dts - if (enc->codec_type == AVMEDIA_TYPE_VIDEO) { - if (flv->last_video_ts < ts) - flv->last_video_ts = ts; + + /* check Speex packet duration */ + if (enc->codec_id == CODEC_ID_SPEEX && ts - sc->last_ts > 160) { + av_log(s, AV_LOG_WARNING, "Warning: Speex stream has more than " + "8 frames per packet. Adobe Flash " + "Player cannot handle this!\n"); } + + if (sc->last_ts < ts) + sc->last_ts = ts; + avio_wb24(pb,size + flags_size); avio_wb24(pb,ts); avio_w8(pb,(ts >> 24) & 0x7F); // timestamps are 32bits _signed_ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/g729dec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/g729dec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/g729dec.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/g729dec.c 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,102 @@ +/* + * G.729 raw format demuxer + * Copyright (c) 2011 Vladimir Voroshilov + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "avformat.h" +#include "libavutil/log.h" +#include "libavutil/opt.h" + +typedef struct G729DemuxerContext { + AVClass *class; + int bit_rate; +} G729DemuxerContext; + +static int g729_read_header(AVFormatContext *s, AVFormatParameters *ap) +{ + AVStream* st; + G729DemuxerContext *s1 = s->priv_data; + + st = avformat_new_stream(s, NULL); + if (!st) + return AVERROR(ENOMEM); + + st->codec->codec_type = AVMEDIA_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_G729; + st->codec->sample_rate = 8000; + st->codec->channels = 1; + + if (s1 && s1->bit_rate) { + s->bit_rate = s1->bit_rate; + } + + if (s->bit_rate == 0) { + av_log(s, AV_LOG_DEBUG, "No bitrate specified. Assuming 8000 b/s\n"); + s->bit_rate = 8000; + } + + if (s->bit_rate == 6400) { + st->codec->block_align = 8; + } else if (s->bit_rate == 8000) { + st->codec->block_align = 10; + } else { + av_log(s, AV_LOG_ERROR, "Only 8000 b/s and 6400 b/s bitrates are supported. Provided: %d b/s\n", s->bit_rate); + return AVERROR_INVALIDDATA; + } + + av_set_pts_info(st, st->codec->block_align << 3, 1, st->codec->sample_rate); + return 0; +} +static int g729_read_packet(AVFormatContext *s, AVPacket *pkt) +{ + int ret; + + ret = av_get_packet(s->pb, pkt, s->streams[0]->codec->block_align); + + pkt->stream_index = 0; + if (ret < 0) + return ret; + + pkt->dts = pkt->pts = pkt->pos / s->streams[0]->codec->block_align; + + return ret; +} + +static const AVOption g729_options[] = { + { "bit_rate", "", offsetof(G729DemuxerContext, bit_rate), AV_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, + { NULL }, +}; + +static const AVClass g729_demuxer_class = { + .class_name = "g729 demuxer", + .item_name = av_default_item_name, + .option = g729_options, + .version = LIBAVUTIL_VERSION_INT, +}; + +AVInputFormat ff_g729_demuxer = { + .name = "g729", + .long_name = NULL_IF_CONFIG_SMALL("G.729 raw format demuxer"), + .priv_data_size = sizeof(G729DemuxerContext), + .read_header = g729_read_header, + .read_packet = g729_read_packet, + .flags = AVFMT_GENERIC_INDEX, + .extensions = "g729", + .priv_class = &g729_demuxer_class, +}; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/gif.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/gif.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/gif.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/gif.c 2011-11-04 12:38:27.000000000 +0000 @@ -351,7 +351,7 @@ #define OFFSET(x) offsetof(GIFContext, x) #define ENC AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { - { "loop", "Number of times to loop the output.", OFFSET(loop), FF_OPT_TYPE_INT, {0}, 0, 65535, ENC }, + { "loop", "Number of times to loop the output.", OFFSET(loop), AV_OPT_TYPE_INT, {0}, 0, 65535, ENC }, { NULL }, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/gsmdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/gsmdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/gsmdec.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/gsmdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,132 @@ +/* + * RAW GSM demuxer + * Copyright (c) 2011 Justin Ruggles + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/mathematics.h" +#include "libavutil/opt.h" +#include "avformat.h" + +#define GSM_BLOCK_SIZE 33 +#define GSM_BLOCK_SAMPLES 160 +#define GSM_SAMPLE_RATE 8000 + +typedef struct { + AVClass *class; + int sample_rate; +} GSMDemuxerContext; + +static int gsm_read_packet(AVFormatContext *s, AVPacket *pkt) +{ + int ret, size; + + size = GSM_BLOCK_SIZE * 32; + + pkt->pos = avio_tell(s->pb); + pkt->stream_index = 0; + + ret = av_get_packet(s->pb, pkt, size); + if (ret < GSM_BLOCK_SIZE) { + av_free_packet(pkt); + return ret < 0 ? ret : AVERROR(EIO); + } + pkt->size = ret; + pkt->duration = ret / GSM_BLOCK_SIZE; + pkt->pts = pkt->pos / GSM_BLOCK_SIZE; + + return 0; +} + +static int gsm_read_header(AVFormatContext *s, AVFormatParameters *ap) +{ + GSMDemuxerContext *c = s->priv_data; + AVStream *st = avformat_new_stream(s, NULL); + if (!st) + return AVERROR(ENOMEM); + + st->codec->codec_type = AVMEDIA_TYPE_AUDIO; + st->codec->codec_id = s->iformat->value; + st->codec->channels = 1; + st->codec->sample_rate = c->sample_rate; + st->codec->block_align = GSM_BLOCK_SIZE; + st->codec->bit_rate = GSM_BLOCK_SIZE * 8 * c->sample_rate / GSM_BLOCK_SAMPLES; + + av_set_pts_info(st, 64, GSM_BLOCK_SAMPLES, GSM_SAMPLE_RATE); + + return 0; +} + +static int gsm_read_seek2(AVFormatContext *s, int stream_index, int64_t min_ts, + int64_t ts, int64_t max_ts, int flags) +{ + GSMDemuxerContext *c = s->priv_data; + + /* convert timestamps to file positions */ + if (!(flags & AVSEEK_FLAG_BYTE)) { + if (stream_index < 0) { + AVRational bitrate_q = { GSM_BLOCK_SAMPLES, c->sample_rate * GSM_BLOCK_SIZE }; + ts = av_rescale_q(ts, AV_TIME_BASE_Q, bitrate_q); + min_ts = av_rescale_q(min_ts, AV_TIME_BASE_Q, bitrate_q); + max_ts = av_rescale_q(max_ts, AV_TIME_BASE_Q, bitrate_q); + } else { + ts *= GSM_BLOCK_SIZE; + min_ts *= GSM_BLOCK_SIZE; + max_ts *= GSM_BLOCK_SIZE; + } + } + /* round to nearest block boundary */ + ts = (ts + GSM_BLOCK_SIZE / 2) / GSM_BLOCK_SIZE * GSM_BLOCK_SIZE; + ts = FFMAX(0, ts); + + /* handle min/max */ + while (ts < min_ts) + ts += GSM_BLOCK_SIZE; + while (ts > max_ts) + ts -= GSM_BLOCK_SIZE; + if (ts < min_ts || ts > max_ts) + return -1; + + return avio_seek(s->pb, ts, SEEK_SET); +} + +static const AVOption options[] = { + { "sample_rate", "", offsetof(GSMDemuxerContext, sample_rate), + AV_OPT_TYPE_INT, {.dbl = GSM_SAMPLE_RATE}, 1, INT_MAX / GSM_BLOCK_SIZE, + AV_OPT_FLAG_DECODING_PARAM }, + { NULL }, +}; + +static const AVClass class = { + .class_name = "gsm demuxer", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + +AVInputFormat ff_gsm_demuxer = { + .name = "gsm", + .long_name = NULL_IF_CONFIG_SMALL("raw GSM"), + .priv_data_size = sizeof(GSMDemuxerContext), + .read_header = gsm_read_header, + .read_packet = gsm_read_packet, + .read_seek2 = gsm_read_seek2, + .extensions = "gsm", + .value = CODEC_ID_GSM, + .priv_class = &class, +}; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/gxf.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/gxf.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/gxf.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/gxf.c 2011-11-04 12:38:27.000000000 +0000 @@ -29,9 +29,31 @@ int64_t last_field; AVRational frames_per_second; int32_t fields_per_frame; + int64_t track_aux_data; }; /** + * @brief parse gxf timecode and add it to metadata + */ +static int add_timecode_metadata(AVDictionary **pm, const char *key, uint32_t timecode, int fields_per_frame) +{ + char tmp[128]; + int field = timecode & 0xff; + int frame = fields_per_frame ? field / fields_per_frame : field; + int second = (timecode >> 8) & 0xff; + int minute = (timecode >> 16) & 0xff; + int hour = (timecode >> 24) & 0x1f; + int drop = (timecode >> 29) & 1; + // bit 30: color_frame, unused + // ignore invalid time code + if (timecode >> 31) + return 0; + snprintf(tmp, sizeof(tmp), "%02d:%02d:%02d%c%02d", + hour, minute, second, drop ? ';' : ':', frame); + return av_dict_set(pm, key, tmp, 0); +} + +/** * @brief parses a packet header, extracting type and length * @param pb AVIOContext to read header from * @param type detected packet type is stored here @@ -81,9 +103,10 @@ i = ff_find_stream_index(s, id); if (i >= 0) return i; - st = av_new_stream(s, id); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); + st->id = id; switch (format) { case 3: case 4: @@ -184,9 +207,9 @@ * @return fps as AVRational, or 0 / 0 if unknown */ static AVRational fps_tag2avr(int32_t fps) { - extern const AVRational ff_frame_rate_tab[]; + extern const AVRational avpriv_frame_rate_tab[]; if (fps < 1 || fps > 9) fps = 9; - return ff_frame_rate_tab[9 - fps]; // values have opposite order + return avpriv_frame_rate_tab[9 - fps]; // values have opposite order } /** @@ -209,6 +232,7 @@ static void gxf_track_tags(AVIOContext *pb, int *len, struct gxf_stream_info *si) { si->frames_per_second = (AVRational){0, 0}; si->fields_per_frame = 0; + si->track_aux_data = 0x80000000; while (*len >= 2) { GXFTrackTag tag = avio_r8(pb); int tlen = avio_r8(pb); @@ -222,7 +246,9 @@ si->frames_per_second = fps_tag2avr(value); else if (tag == TRACK_FPF && (value == 1 || value == 2)) si->fields_per_frame = value; - } else + } else if (tlen == 8 && tag == TRACK_AUX) + si->track_aux_data = avio_rl64(pb); + else avio_skip(pb, tlen); } } @@ -300,8 +326,6 @@ track_id = avio_r8(pb); track_len = avio_rb16(pb); len -= track_len; - gxf_track_tags(pb, &track_len, si); - avio_skip(pb, track_len); if (!(track_type & 0x80)) { av_log(s, AV_LOG_ERROR, "invalid track type %x\n", track_type); continue; @@ -312,6 +336,16 @@ continue; } track_id &= 0x3f; + gxf_track_tags(pb, &track_len, si); + // check for timecode tracks + if (track_type == 7 || track_type == 8 || track_type == 24) { + add_timecode_metadata(&s->metadata, "gxf_timecode", + si->track_aux_data & 0xffffffff, + si->fields_per_frame); + + } + avio_skip(pb, track_len); + idx = get_sindex(s, track_id, track_type); if (idx < 0) continue; st = s->streams[idx]; @@ -352,6 +386,15 @@ main_timebase.num = fps.den; main_timebase.den = fps.num * 2; } + + if (len >= 0x18) { + len -= 0x18; + avio_skip(pb, 0x10); + add_timecode_metadata(&s->metadata, "gxf_timecode_at_mark_in", + avio_rl32(pb), si->fields_per_frame); + add_timecode_metadata(&s->metadata, "gxf_timecode_at_mark_out", + avio_rl32(pb), si->fields_per_frame); + } } else av_log(s, AV_LOG_INFO, "UMF packet too short\n"); } else diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/http.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/http.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/http.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/http.c 2011-11-04 12:38:27.000000000 +0000 @@ -22,7 +22,6 @@ #include "libavutil/avstring.h" #include "avformat.h" #include -#include #include "internal.h" #include "network.h" #include "http.h" @@ -54,7 +53,7 @@ #define OFFSET(x) offsetof(HTTPContext, x) static const AVOption options[] = { -{"chunksize", "use chunked transfer-encoding for posts, -1 disables it, 0 enables it", OFFSET(chunksize), FF_OPT_TYPE_INT64, {.dbl = 0}, -1, 0 }, /* Default to 0, for chunked POSTs */ +{"chunksize", "use chunked transfer-encoding for posts, -1 disables it, 0 enables it", OFFSET(chunksize), AV_OPT_TYPE_INT64, {.dbl = 0}, -1, 0 }, /* Default to 0, for chunked POSTs */ {NULL} }; static const AVClass httpcontext_class = { @@ -250,12 +249,12 @@ p++; while (isspace(*p)) p++; - if (!strcasecmp(tag, "Location")) { + if (!av_strcasecmp(tag, "Location")) { strcpy(s->location, p); *new_location = 1; - } else if (!strcasecmp (tag, "Content-Length") && s->filesize == -1) { + } else if (!av_strcasecmp (tag, "Content-Length") && s->filesize == -1) { s->filesize = atoll(p); - } else if (!strcasecmp (tag, "Content-Range")) { + } else if (!av_strcasecmp (tag, "Content-Range")) { /* "bytes $from-$to/$document_size" */ const char *slash; if (!strncmp (p, "bytes ", 6)) { @@ -265,16 +264,16 @@ s->filesize = atoll(slash+1); } h->is_streamed = 0; /* we _can_ in fact seek */ - } else if (!strcasecmp(tag, "Accept-Ranges") && !strncmp(p, "bytes", 5)) { + } else if (!av_strcasecmp(tag, "Accept-Ranges") && !strncmp(p, "bytes", 5)) { h->is_streamed = 0; - } else if (!strcasecmp (tag, "Transfer-Encoding") && !strncasecmp(p, "chunked", 7)) { + } else if (!av_strcasecmp (tag, "Transfer-Encoding") && !av_strncasecmp(p, "chunked", 7)) { s->filesize = -1; s->chunksize = 0; - } else if (!strcasecmp (tag, "WWW-Authenticate")) { + } else if (!av_strcasecmp (tag, "WWW-Authenticate")) { ff_http_auth_handle_header(&s->auth_state, tag, p); - } else if (!strcasecmp (tag, "Authentication-Info")) { + } else if (!av_strcasecmp (tag, "Authentication-Info")) { ff_http_auth_handle_header(&s->auth_state, tag, p); - } else if (!strcasecmp (tag, "Connection")) { + } else if (!av_strcasecmp (tag, "Connection")) { if (!strcmp(p, "close")) s->willclose = 1; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/id3v2.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/id3v2.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/id3v2.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/id3v2.c 2011-11-04 12:38:27.000000000 +0000 @@ -33,6 +33,66 @@ #include "libavutil/dict.h" #include "avio_internal.h" +const AVMetadataConv ff_id3v2_34_metadata_conv[] = { + { "TALB", "album"}, + { "TCOM", "composer"}, + { "TCON", "genre"}, + { "TCOP", "copyright"}, + { "TENC", "encoded_by"}, + { "TIT2", "title"}, + { "TLAN", "language"}, + { "TPE1", "artist"}, + { "TPE2", "album_artist"}, + { "TPE3", "performer"}, + { "TPOS", "disc"}, + { "TPUB", "publisher"}, + { "TRCK", "track"}, + { "TSSE", "encoder"}, + { 0 } +}; + +const AVMetadataConv ff_id3v2_4_metadata_conv[] = { + { "TDRL", "date"}, + { "TDRC", "date"}, + { "TDEN", "creation_time"}, + { "TSOA", "album-sort"}, + { "TSOP", "artist-sort"}, + { "TSOT", "title-sort"}, + { 0 } +}; + +static const AVMetadataConv id3v2_2_metadata_conv[] = { + { "TAL", "album"}, + { "TCO", "genre"}, + { "TT2", "title"}, + { "TEN", "encoded_by"}, + { "TP1", "artist"}, + { "TP2", "album_artist"}, + { "TP3", "performer"}, + { "TRK", "track"}, + { 0 } +}; + + +const char ff_id3v2_tags[][4] = { + "TALB", "TBPM", "TCOM", "TCON", "TCOP", "TDLY", "TENC", "TEXT", + "TFLT", "TIT1", "TIT2", "TIT3", "TKEY", "TLAN", "TLEN", "TMED", + "TOAL", "TOFN", "TOLY", "TOPE", "TOWN", "TPE1", "TPE2", "TPE3", + "TPE4", "TPOS", "TPUB", "TRCK", "TRSN", "TRSO", "TSRC", "TSSE", + { 0 }, +}; + +const char ff_id3v2_4_tags[][4] = { + "TDEN", "TDOR", "TDRC", "TDRL", "TDTG", "TIPL", "TMCL", "TMOO", + "TPRO", "TSOA", "TSOP", "TSOT", "TSST", + { 0 }, +}; + +const char ff_id3v2_3_tags[][4] = { + "TDAT", "TIME", "TORY", "TRDA", "TSIZ", "TYER", + { 0 }, +}; + int ff_id3v2_match(const uint8_t *buf, const char * magic) { return buf[0] == magic[0] && @@ -328,6 +388,18 @@ av_dict_set(m, "date", date, 0); } +typedef struct ID3v2EMFunc { + const char *tag3; + const char *tag4; + void (*read)(AVFormatContext*, AVIOContext*, int, char*, ID3v2ExtraMeta **); + void (*free)(void *obj); +} ID3v2EMFunc; + +static const ID3v2EMFunc id3v2_extra_meta_funcs[] = { + { "GEO", "GEOB", read_geobtag, free_geobtag }, + { NULL } +}; + /** * Get the corresponding ID3v2EMFunc struct for a tag. * @param isv34 Determines if v2.2 or v2.3/4 strings are used @@ -336,16 +408,15 @@ static const ID3v2EMFunc *get_extra_meta_func(const char *tag, int isv34) { int i = 0; - while (ff_id3v2_extra_meta_funcs[i].tag3) { + while (id3v2_extra_meta_funcs[i].tag3) { if (!memcmp(tag, - (isv34 ? - ff_id3v2_extra_meta_funcs[i].tag4 : - ff_id3v2_extra_meta_funcs[i].tag3), + (isv34 ? id3v2_extra_meta_funcs[i].tag4 : + id3v2_extra_meta_funcs[i].tag3), (isv34 ? 4 : 3))) - return &ff_id3v2_extra_meta_funcs[i]; + return &id3v2_extra_meta_funcs[i]; i++; } - return &ff_id3v2_extra_meta_funcs[i]; + return &id3v2_extra_meta_funcs[i]; } static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t flags, ID3v2ExtraMeta **extra_meta) @@ -360,7 +431,7 @@ AVIOContext *pbx; unsigned char *buffer = NULL; int buffer_size = 0; - void (*extra_func)(AVFormatContext*, AVIOContext*, int, char*, ID3v2ExtraMeta**) = NULL; + const ID3v2EMFunc *extra_func; switch (version) { case 2: @@ -432,7 +503,7 @@ av_log(s, AV_LOG_WARNING, "Skipping encrypted/compressed ID3v2 frame %s.\n", tag); avio_skip(s->pb, tlen); /* check for text tag or supported special meta tag */ - } else if (tag[0] == 'T' || (extra_meta && (extra_func = get_extra_meta_func(tag, isv34)->read))) { + } else if (tag[0] == 'T' || (extra_meta && (extra_func = get_extra_meta_func(tag, isv34)))) { if (unsync || tunsync) { int i, j; av_fast_malloc(&buffer, &buffer_size, tlen); @@ -458,7 +529,7 @@ read_ttag(s, pbx, tlen, tag); else /* parse special meta tag */ - extra_func(s, pbx, tlen, tag, extra_meta); + extra_func->read(s, pbx, tlen, tag, extra_meta); } else if (!tag[0]) { if (tag[1]) @@ -508,7 +579,7 @@ } } while (found_header); ff_metadata_conv(&s->metadata, NULL, ff_id3v2_34_metadata_conv); - ff_metadata_conv(&s->metadata, NULL, ff_id3v2_2_metadata_conv); + ff_metadata_conv(&s->metadata, NULL, id3v2_2_metadata_conv); ff_metadata_conv(&s->metadata, NULL, ff_id3v2_4_metadata_conv); merge_date(&s->metadata); } @@ -521,78 +592,13 @@ void ff_id3v2_free_extra_meta(ID3v2ExtraMeta **extra_meta) { ID3v2ExtraMeta *current = *extra_meta, *next; - void (*free_func)(void *); + const ID3v2EMFunc *extra_func; while (current) { - if ((free_func = get_extra_meta_func(current->tag, 1)->free)) - free_func(current->data); + if ((extra_func = get_extra_meta_func(current->tag, 1))) + extra_func->free(current->data); next = current->next; av_freep(¤t); current = next; } } - -const ID3v2EMFunc ff_id3v2_extra_meta_funcs[] = { - { "GEO", "GEOB", read_geobtag, free_geobtag }, - { NULL, NULL, NULL, NULL } -}; - -const AVMetadataConv ff_id3v2_34_metadata_conv[] = { - { "TALB", "album"}, - { "TCOM", "composer"}, - { "TCON", "genre"}, - { "TCOP", "copyright"}, - { "TENC", "encoded_by"}, - { "TIT2", "title"}, - { "TLAN", "language"}, - { "TPE1", "artist"}, - { "TPE2", "album_artist"}, - { "TPE3", "performer"}, - { "TPOS", "disc"}, - { "TPUB", "publisher"}, - { "TRCK", "track"}, - { "TSSE", "encoder"}, - { 0 } -}; - -const AVMetadataConv ff_id3v2_4_metadata_conv[] = { - { "TDRL", "date"}, - { "TDRC", "date"}, - { "TDEN", "creation_time"}, - { "TSOA", "album-sort"}, - { "TSOP", "artist-sort"}, - { "TSOT", "title-sort"}, - { 0 } -}; - -const AVMetadataConv ff_id3v2_2_metadata_conv[] = { - { "TAL", "album"}, - { "TCO", "genre"}, - { "TT2", "title"}, - { "TEN", "encoded_by"}, - { "TP1", "artist"}, - { "TP2", "album_artist"}, - { "TP3", "performer"}, - { "TRK", "track"}, - { 0 } -}; - - -const char ff_id3v2_tags[][4] = { - "TALB", "TBPM", "TCOM", "TCON", "TCOP", "TDLY", "TENC", "TEXT", - "TFLT", "TIT1", "TIT2", "TIT3", "TKEY", "TLAN", "TLEN", "TMED", - "TOAL", "TOFN", "TOLY", "TOPE", "TOWN", "TPE1", "TPE2", "TPE3", - "TPE4", "TPOS", "TPUB", "TRCK", "TRSN", "TRSO", "TSRC", "TSSE", - { 0 }, -}; - -const char ff_id3v2_4_tags[][4] = { - "TDEN", "TDOR", "TDRC", "TDRL", "TDTG", "TIPL", "TMCL", "TMOO", - "TPRO", "TSOA", "TSOP", "TSOT", "TSST", - { 0 }, -}; - -const char ff_id3v2_3_tags[][4] = { - "TDAT", "TIME", "TORY", "TRDA", "TSIZ", "TYER", - { 0 }, -}; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/id3v2enc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/id3v2enc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/id3v2enc.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/id3v2enc.c 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,186 @@ +/* + * ID3v2 header writer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include "libavutil/avstring.h" +#include "libavutil/dict.h" +#include "libavutil/intreadwrite.h" +#include "avformat.h" +#include "avio.h" +#include "id3v2.h" + +static void id3v2_put_size(AVFormatContext *s, int size) +{ + avio_w8(s->pb, size >> 21 & 0x7f); + avio_w8(s->pb, size >> 14 & 0x7f); + avio_w8(s->pb, size >> 7 & 0x7f); + avio_w8(s->pb, size & 0x7f); +} + +static int string_is_ascii(const uint8_t *str) +{ + while (*str && *str < 128) str++; + return !*str; +} + +/** + * Write a text frame with one (normal frames) or two (TXXX frames) strings + * according to encoding (only UTF-8 or UTF-16+BOM supported). + * @return number of bytes written or a negative error code. + */ +static int id3v2_put_ttag(AVFormatContext *s, const char *str1, const char *str2, + uint32_t tag, enum ID3v2Encoding enc) +{ + int len; + uint8_t *pb; + int (*put)(AVIOContext*, const char*); + AVIOContext *dyn_buf; + if (avio_open_dyn_buf(&dyn_buf) < 0) + return AVERROR(ENOMEM); + + /* check if the strings are ASCII-only and use UTF16 only if + * they're not */ + if (enc == ID3v2_ENCODING_UTF16BOM && string_is_ascii(str1) && + (!str2 || string_is_ascii(str2))) + enc = ID3v2_ENCODING_ISO8859; + + avio_w8(dyn_buf, enc); + if (enc == ID3v2_ENCODING_UTF16BOM) { + avio_wl16(dyn_buf, 0xFEFF); /* BOM */ + put = avio_put_str16le; + } else + put = avio_put_str; + + put(dyn_buf, str1); + if (str2) + put(dyn_buf, str2); + len = avio_close_dyn_buf(dyn_buf, &pb); + + avio_wb32(s->pb, tag); + id3v2_put_size(s, len); + avio_wb16(s->pb, 0); + avio_write(s->pb, pb, len); + + av_freep(&pb); + return len + ID3v2_HEADER_SIZE; +} + +static int id3v2_check_write_tag(AVFormatContext *s, AVDictionaryEntry *t, const char table[][4], + enum ID3v2Encoding enc) +{ + uint32_t tag; + int i; + + if (t->key[0] != 'T' || strlen(t->key) != 4) + return -1; + tag = AV_RB32(t->key); + for (i = 0; *table[i]; i++) + if (tag == AV_RB32(table[i])) + return id3v2_put_ttag(s, t->value, NULL, tag, enc); + return -1; +} + +static void id3v2_3_metadata_split_date(AVDictionary **pm) +{ + AVDictionaryEntry *mtag = NULL; + AVDictionary *dst = NULL; + const char *key, *value; + char year[5] = {0}, day_month[5] = {0}; + int i; + + while ((mtag = av_dict_get(*pm, "", mtag, AV_DICT_IGNORE_SUFFIX))) { + key = mtag->key; + if (!av_strcasecmp(key, "date")) { + /* split date tag using "YYYY-MM-DD" format into year and month/day segments */ + value = mtag->value; + i = 0; + while (value[i] >= '0' && value[i] <= '9') i++; + if (value[i] == '\0' || value[i] == '-') { + av_strlcpy(year, value, sizeof(year)); + av_dict_set(&dst, "TYER", year, 0); + + if (value[i] == '-' && + value[i+1] >= '0' && value[i+1] <= '1' && + value[i+2] >= '0' && value[i+2] <= '9' && + value[i+3] == '-' && + value[i+4] >= '0' && value[i+4] <= '3' && + value[i+5] >= '0' && value[i+5] <= '9' && + (value[i+6] == '\0' || value[i+6] == ' ')) { + snprintf(day_month, sizeof(day_month), "%.2s%.2s", value + i + 4, value + i + 1); + av_dict_set(&dst, "TDAT", day_month, 0); + } + } else + av_dict_set(&dst, key, value, 0); + } else + av_dict_set(&dst, key, mtag->value, 0); + } + av_dict_free(pm); + *pm = dst; +} + +int ff_id3v2_write(struct AVFormatContext *s, int id3v2_version, + const char *magic) +{ + int64_t size_pos, cur_pos; + AVDictionaryEntry *t = NULL; + + int totlen = 0, enc = id3v2_version == 3 ? ID3v2_ENCODING_UTF16BOM : + ID3v2_ENCODING_UTF8; + + + avio_wb32(s->pb, MKBETAG(magic[0], magic[1], magic[2], id3v2_version)); + avio_w8(s->pb, 0); + avio_w8(s->pb, 0); /* flags */ + + /* reserve space for size */ + size_pos = avio_tell(s->pb); + avio_wb32(s->pb, 0); + + ff_metadata_conv(&s->metadata, ff_id3v2_34_metadata_conv, NULL); + if (id3v2_version == 3) + id3v2_3_metadata_split_date(&s->metadata); + else if (id3v2_version == 4) + ff_metadata_conv(&s->metadata, ff_id3v2_4_metadata_conv, NULL); + + while ((t = av_dict_get(s->metadata, "", t, AV_DICT_IGNORE_SUFFIX))) { + int ret; + + if ((ret = id3v2_check_write_tag(s, t, ff_id3v2_tags, enc)) > 0) { + totlen += ret; + continue; + } + if ((ret = id3v2_check_write_tag(s, t, id3v2_version == 3 ? + ff_id3v2_3_tags : ff_id3v2_4_tags, enc)) > 0) { + totlen += ret; + continue; + } + + /* unknown tag, write as TXXX frame */ + if ((ret = id3v2_put_ttag(s, t->key, t->value, MKBETAG('T', 'X', 'X', 'X'), enc)) < 0) + return ret; + totlen += ret; + } + + cur_pos = avio_tell(s->pb); + avio_seek(s->pb, size_pos, SEEK_SET); + id3v2_put_size(s, totlen); + avio_seek(s->pb, cur_pos, SEEK_SET); + return 0; +} diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/id3v2.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/id3v2.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/id3v2.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/id3v2.h 2011-11-04 12:38:27.000000000 +0000 @@ -59,17 +59,10 @@ uint8_t *data; } ID3v2ExtraMetaGEOB; -typedef struct ID3v2EMFunc { - const char *tag3; - const char *tag4; - void (*read)(AVFormatContext*, AVIOContext*, int, char*, ID3v2ExtraMeta **); - void (*free)(void *); -} ID3v2EMFunc; - /** * Detect ID3v2 Header. * @param buf must be ID3v2_HEADER_SIZE byte long - * @param magic magic bytes to identify the header, machine byte order. + * @param magic magic bytes to identify the header. * If in doubt, use ID3v2_DEFAULT_MAGIC. */ int ff_id3v2_match(const uint8_t *buf, const char *magic); @@ -94,16 +87,21 @@ void ff_id3v2_read_all(AVFormatContext *s, const char *magic, ID3v2ExtraMeta **extra_meta); /** + * Write an ID3v2 tag. + * @param id3v2_version Subversion of ID3v2; supported values are 3 and 4 + * @param magic magic bytes to identify the header + * If in doubt, use ID3v2_DEFAULT_MAGIC. + */ +int ff_id3v2_write(struct AVFormatContext *s, int id3v2_version, const char *magic); + +/** * Free memory allocated parsing special (non-text) metadata. * @param extra_meta Pointer to a pointer to the head of a ID3v2ExtraMeta list, *extra_meta is set to NULL. */ void ff_id3v2_free_extra_meta(ID3v2ExtraMeta **extra_meta); -extern const ID3v2EMFunc ff_id3v2_extra_meta_funcs[]; - extern const AVMetadataConv ff_id3v2_34_metadata_conv[]; extern const AVMetadataConv ff_id3v2_4_metadata_conv[]; -extern const AVMetadataConv ff_id3v2_2_metadata_conv[]; /** * A list of text information frames allowed in both ID3 v2.3 and v2.4 diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/idcin.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/idcin.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/idcin.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/idcin.c 2011-11-04 12:38:27.000000000 +0000 @@ -153,7 +153,7 @@ bytes_per_sample = avio_rl32(pb); channels = avio_rl32(pb); - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); av_set_pts_info(st, 33, 1, IDCIN_FPS); @@ -174,7 +174,7 @@ /* if sample rate is 0, assume no audio */ if (sample_rate) { idcin->audio_present = 1; - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); av_set_pts_info(st, 33, 1, IDCIN_FPS); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/idroqdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/idroqdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/idroqdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/idroqdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -84,7 +84,7 @@ roq->audio_frame_count = 0; roq->audio_stream_index = -1; - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); av_set_pts_info(st, 63, 1, framerate); @@ -166,7 +166,7 @@ case RoQ_SOUND_MONO: case RoQ_SOUND_STEREO: if (roq->audio_stream_index == -1) { - AVStream *st = av_new_stream(s, 1); + AVStream *st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); av_set_pts_info(st, 32, 1, RoQ_AUDIO_SAMPLE_RATE); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/iff.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/iff.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/iff.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/iff.c 2011-11-04 12:38:27.000000000 +0000 @@ -135,7 +135,7 @@ unsigned transparency = 0; unsigned masking = 0; // no mask - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/img2.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/img2.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/img2.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/img2.c 2011-11-04 12:38:27.000000000 +0000 @@ -29,7 +29,6 @@ #include "avformat.h" #include "avio_internal.h" #include "internal.h" -#include typedef struct { const AVClass *class; /**< Class for private options. */ @@ -125,7 +124,7 @@ str++; while (tags->id) { - if (!strcasecmp(str, tags->str)) + if (!av_strcasecmp(str, tags->str)) return tags->id; tags++; @@ -220,7 +219,7 @@ s1->ctx_flags |= AVFMTCTX_NOHEADER; - st = av_new_stream(s1, 0); + st = avformat_new_stream(s1, NULL); if (!st) { return AVERROR(ENOMEM); } @@ -281,7 +280,7 @@ st->codec->codec_id = s1->audio_codec_id; }else{ const char *str= strrchr(s->path, '.'); - s->split_planes = str && !strcasecmp(str + 1, "y"); + s->split_planes = str && !av_strcasecmp(str + 1, "y"); st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = av_str2id(img_tags, s->path); } @@ -377,7 +376,7 @@ img->is_pipe = 1; str = strrchr(img->path, '.'); - img->split_planes = str && !strcasecmp(str + 1, "y"); + img->split_planes = str && !av_strcasecmp(str + 1, "y"); return 0; } @@ -462,10 +461,10 @@ #define OFFSET(x) offsetof(VideoData, x) #define DEC AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { - { "pixel_format", "", OFFSET(pixel_format), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, - { "video_size", "", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, - { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC }, - { "loop", "", OFFSET(loop), FF_OPT_TYPE_INT, {.dbl = 0}, 0, 1, DEC }, + { "pixel_format", "", OFFSET(pixel_format), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, + { "video_size", "", OFFSET(video_size), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, + { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC }, + { "loop", "", OFFSET(loop), AV_OPT_TYPE_INT, {.dbl = 0}, 0, 1, DEC }, { NULL }, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/internal.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/internal.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/internal.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/internal.h 2011-11-04 12:38:27.000000000 +0000 @@ -223,8 +223,8 @@ * * @return AVChapter or NULL on error */ -AVChapter *ff_new_chapter(AVFormatContext *s, int id, AVRational time_base, - int64_t start, int64_t end, const char *title); +AVChapter *avpriv_new_chapter(AVFormatContext *s, int id, AVRational time_base, + int64_t start, int64_t end, const char *title); /** * Ensure the index uses less memory than the maximum specified in @@ -251,4 +251,37 @@ */ int64_t ff_iso8601_to_unix_time(const char *datestr); +/** + * Perform a binary search using av_index_search_timestamp() and + * AVInputFormat.read_timestamp(). + * + * @param target_ts target timestamp in the time base of the given stream + * @param stream_index stream number + */ +int ff_seek_frame_binary(AVFormatContext *s, int stream_index, + int64_t target_ts, int flags); + +/** + * Update cur_dts of all streams based on the given timestamp and AVStream. + * + * Stream ref_st unchanged, others set cur_dts in their native time base. + * Only needed for timestamp wrapping or if (dts not set and pts!=dts). + * @param timestamp new dts expressed in time_base of param ref_st + * @param ref_st reference stream giving time_base of param timestamp + */ +void ff_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp); + +/** + * Perform a binary search using read_timestamp(). + * + * @param target_ts target timestamp in the time base of the given stream + * @param stream_index stream number + */ +int64_t ff_gen_search(AVFormatContext *s, int stream_index, + int64_t target_ts, int64_t pos_min, + int64_t pos_max, int64_t pos_limit, + int64_t ts_min, int64_t ts_max, + int flags, int64_t *ts_ret, + int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t )); + #endif /* AVFORMAT_INTERNAL_H */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/ipmovie.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/ipmovie.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/ipmovie.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/ipmovie.c 2011-11-04 12:38:27.000000000 +0000 @@ -559,7 +559,7 @@ return AVERROR_INVALIDDATA; /* initialize the stream decoders */ - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); av_set_pts_info(st, 63, 1, 1000000); @@ -572,7 +572,7 @@ st->codec->bits_per_coded_sample = ipmovie->video_bpp; if (ipmovie->audio_type) { - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); av_set_pts_info(st, 32, 1, ipmovie->audio_sample_rate); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/isom.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/isom.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/isom.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/isom.c 2011-11-04 12:38:27.000000000 +0000 @@ -61,6 +61,8 @@ { CODEC_ID_VORBIS , 0xDD }, /* non standard, gpac uses it */ { CODEC_ID_DVD_SUBTITLE, 0xE0 }, /* non standard, see unsupported-embedded-subs-2.mp4 */ { CODEC_ID_QCELP , 0xE1 }, + { CODEC_ID_MPEG4SYSTEMS, 0x01 }, + { CODEC_ID_MPEG4SYSTEMS, 0x02 }, { CODEC_ID_NONE , 0 }, }; @@ -204,7 +206,7 @@ { CODEC_ID_DIRAC, MKTAG('d', 'r', 'a', 'c') }, { CODEC_ID_DNXHD, MKTAG('A', 'V', 'd', 'n') }, /* AVID DNxHD */ - { CODEC_ID_FLV1, MKTAG('H', '2', '6', '3') }, /* Flash Media Server */ +// { CODEC_ID_FLV1, MKTAG('H', '2', '6', '3') }, /* Flash Media Server */ { CODEC_ID_MSMPEG4V3, MKTAG('3', 'I', 'V', 'D') }, /* 3ivx DivX Doctor */ { CODEC_ID_RAWVIDEO, MKTAG('A', 'V', '1', 'x') }, /* AVID 1:1x */ { CODEC_ID_RAWVIDEO, MKTAG('A', 'V', 'u', 'p') }, @@ -256,6 +258,7 @@ { CODEC_ID_AC3, MKTAG('s', 'a', 'c', '3') }, /* Nero Recode */ { CODEC_ID_DTS, MKTAG('d', 't', 's', 'c') }, /* mp4ra.org */ { CODEC_ID_DTS, MKTAG('D', 'T', 'S', ' ') }, /* non-standard */ + { CODEC_ID_EAC3, MKTAG('e', 'c', '-', '3') }, /* ETSI TS 102 366 Annex F */ { CODEC_ID_AMR_NB, MKTAG('s', 'a', 'm', 'r') }, /* AMR-NB 3gp */ { CODEC_ID_AMR_WB, MKTAG('s', 'a', 'w', 'b') }, /* AMR-WB 3gp */ @@ -433,11 +436,11 @@ st->codec->extradata_size = len; if (st->codec->codec_id == CODEC_ID_AAC) { MPEG4AudioConfig cfg; - ff_mpeg4audio_get_config(&cfg, st->codec->extradata, + avpriv_mpeg4audio_get_config(&cfg, st->codec->extradata, st->codec->extradata_size); st->codec->channels = cfg.channels; if (cfg.object_type == 29 && cfg.sampling_index < 3) // old mp3on4 - st->codec->sample_rate = ff_mpa_freq_tab[cfg.sampling_index]; + st->codec->sample_rate = avpriv_mpa_freq_tab[cfg.sampling_index]; else if (cfg.ext_sample_rate) st->codec->sample_rate = cfg.ext_sample_rate; else diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/isom.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/isom.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/isom.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/isom.h 2011-11-04 12:38:27.000000000 +0000 @@ -109,7 +109,9 @@ unsigned int keyframe_count; int *keyframes; int time_scale; - int64_t time_offset; ///< time offset of the first edit list entry + int64_t empty_duration; ///< empty duration of the first edit list entry + int64_t start_time; ///< start time of the media + int64_t time_offset; ///< time offset of the edit list entries int current_sample; unsigned int bytes_per_frame; unsigned int samples_per_frame; @@ -148,10 +150,12 @@ int ff_mp4_read_dec_config_descr(AVFormatContext *fc, AVStream *st, AVIOContext *pb); void ff_mp4_parse_es_descr(AVIOContext *pb, int *es_id); +#define MP4ODescrTag 0x01 #define MP4IODescrTag 0x02 #define MP4ESDescrTag 0x03 #define MP4DecConfigDescrTag 0x04 #define MP4DecSpecificDescrTag 0x05 +#define MP4SLDescrTag 0x06 int ff_mov_read_esds(AVFormatContext *fc, AVIOContext *pb, MOVAtom atom); enum CodecID ff_mov_get_lpcm_codec_id(int bps, int flags); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/iss.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/iss.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/iss.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/iss.c 2011-11-04 12:38:27.000000000 +0000 @@ -88,7 +88,7 @@ iss->sample_start_pos = avio_tell(pb); - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/iv8.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/iv8.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/iv8.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/iv8.c 2011-11-04 12:38:27.000000000 +0000 @@ -40,7 +40,7 @@ { AVStream *st; - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); @@ -55,33 +55,56 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) { - int ret, size, pts, type; -retry: - type= avio_rb16(s->pb); // 257 or 258 - size= avio_rb16(s->pb); - - avio_rb16(s->pb); //some flags, 0x80 indicates end of frame - avio_rb16(s->pb); //packet number - pts=avio_rb32(s->pb); - avio_rb32(s->pb); //6A 13 E3 88 - - size -= 12; - if(size<1) - return -1; - - if(type==258){ - avio_skip(s->pb, size); - goto retry; + int ret, size, pts, type, flags; + int first_pkt = 0; + int frame_complete = 0; + + while (!frame_complete) { + + type = avio_rb16(s->pb); // 257 or 258 + size = avio_rb16(s->pb); + flags = avio_rb16(s->pb); //some flags, 0x80 indicates end of frame + avio_rb16(s->pb); //packet number + pts = avio_rb32(s->pb); + avio_rb32(s->pb); //6A 13 E3 88 + + frame_complete = flags & 0x80; + + size -= 12; + if (size < 1) + return -1; + + if (type == 258) { + avio_skip(s->pb, size); + frame_complete = 0; + continue; + } + + if (!first_pkt) { + ret = av_get_packet(s->pb, pkt, size); + if (ret < 0) + return ret; + first_pkt = 1; + pkt->pts = pts; + pkt->pos -= 16; + } else { + ret = av_append_packet(s->pb, pkt, size); + if (ret < 0) { + av_log(s, AV_LOG_ERROR, "failed to grow packet\n"); + av_free_packet(pkt); + return ret; + } + } + if (ret < size) { + av_log(s, AV_LOG_ERROR, "Truncated packet! Read %d of %d bytes\n", + ret, size); + pkt->flags |= AV_PKT_FLAG_CORRUPT; + break; + } } - - ret= av_get_packet(s->pb, pkt, size); - - pkt->pts= pts; - pkt->pos-=16; - pkt->stream_index = 0; - return ret; + return 0; } AVInputFormat ff_iv8_demuxer = { diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/ivfdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/ivfdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/ivfdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/ivfdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -40,7 +40,7 @@ avio_rl16(s->pb); // version avio_rl16(s->pb); // header size - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/jvdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/jvdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/jvdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/jvdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -69,8 +69,8 @@ avio_skip(pb, 80); - ast = av_new_stream(s, 0); - vst = av_new_stream(s, 1); + ast = avformat_new_stream(s, NULL); + vst = avformat_new_stream(s, NULL); if (!ast || !vst) return AVERROR(ENOMEM); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/latmenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/latmenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/latmenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/latmenc.c 2011-11-04 12:38:27.000000000 +0000 @@ -38,7 +38,7 @@ static const AVOption options[] = { {"smc-interval", "StreamMuxConfig interval.", - offsetof(LATMContext, mod), FF_OPT_TYPE_INT, {.dbl = 0x0014}, 0x0001, 0xffff, AV_OPT_FLAG_ENCODING_PARAM}, + offsetof(LATMContext, mod), AV_OPT_TYPE_INT, {.dbl = 0x0014}, 0x0001, 0xffff, AV_OPT_FLAG_ENCODING_PARAM}, {NULL}, }; @@ -55,7 +55,7 @@ MPEG4AudioConfig m4ac; init_get_bits(&gb, buf, size * 8); - ctx->off = ff_mpeg4audio_get_config(&m4ac, buf, size); + ctx->off = avpriv_mpeg4audio_get_config(&m4ac, buf, size); if (ctx->off < 0) return ctx->off; skip_bits_long(&gb, ctx->off); @@ -110,12 +110,12 @@ /* AudioSpecificConfig */ if (ctx->object_type == AOT_ALS) { header_size = avctx->extradata_size-(ctx->off + 7) >> 3; - ff_copy_bits(bs, &avctx->extradata[ctx->off], header_size); + avpriv_copy_bits(bs, &avctx->extradata[ctx->off], header_size); } else { - ff_copy_bits(bs, avctx->extradata, ctx->off + 3); + avpriv_copy_bits(bs, avctx->extradata, ctx->off + 3); if (!ctx->channel_conf) { - ff_copy_pce_data(bs, &gb); + avpriv_copy_pce_data(bs, &gb); } } @@ -168,7 +168,7 @@ for (i = 0; i < pkt->size; i++) put_bits(&bs, 8, pkt->data[i]); - align_put_bits(&bs); + avpriv_align_put_bits(&bs); flush_put_bits(&bs); len = put_bits_count(&bs) >> 3; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/libavformat.v ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/libavformat.v --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/libavformat.v 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/libavformat.v 2011-11-04 12:38:27.000000000 +0000 @@ -1,7 +1,33 @@ LIBAVFORMAT_$MAJOR { - global: *; - local: - ff_*_demuxer; - ff_*_muxer; - ff_*_protocol; + global: av*; + #FIXME those are for avserver + ff_inet_aton; + ff_socket_nonblock; + ffm_set_write_index; + ffm_read_write_index; + ffm_write_write_index; + ff_rtsp_parse_line; + ff_rtp_get_local_rtp_port; + ff_rtp_get_local_rtcp_port; + ffio_open_dyn_packet_buf; + url_open; + url_close; + url_write; + url_get_max_packet_size; + #those are deprecated, remove on next bump + find_info_tag; + parse_date; + dump_format; + url_*; + ff_timefilter_destroy; + ff_timefilter_new; + ff_timefilter_update; + ff_timefilter_reset; + get_*; + put_*; + udp_set_remote_url; + udp_get_local_port; + init_checksum; + init_put_byte; + local: *; }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/libmodplug.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/libmodplug.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/libmodplug.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/libmodplug.c 2011-11-04 12:38:27.000000000 +0000 @@ -24,6 +24,7 @@ #include #include "libavutil/avstring.h" +#include "libavutil/eval.h" #include "libavutil/opt.h" #include "avformat.h" @@ -42,23 +43,57 @@ int surround_delay; int max_size; ///< max file size to allocate + + /* optional video stream */ + double ts_per_packet; ///< used to define the pts/dts using packet_count; + int packet_count; ///< total number of audio packets + int print_textinfo; ///< bool flag for printing speed, tempo, order, ... + int video_stream; ///< 1 if the user want a video stream, otherwise 0 + int w; ///< video stream width in char (one char = 8x8px) + int h; ///< video stream height in char (one char = 8x8px) + int video_switch; ///< 1 if current packet is video, otherwise 0 + int fsize; ///< constant frame size + int linesize; ///< line size in bytes + char *color_eval; ///< color eval user input expression + AVExpr *expr; ///< parsed color eval expression } ModPlugContext; +static const char *var_names[] = { + "x", "y", + "w", "h", + "t", + "speed", "tempo", "order", "pattern", "row", + NULL +}; + +enum var_name { + VAR_X, VAR_Y, + VAR_W, VAR_H, + VAR_TIME, + VAR_SPEED, VAR_TEMPO, VAR_ORDER, VAR_PATTERN, VAR_ROW, + VAR_VARS_NB +}; + #define FF_MODPLUG_MAX_FILE_SIZE (100 * 1<<20) // 100M #define FF_MODPLUG_DEF_FILE_SIZE ( 5 * 1<<20) // 5M #define OFFSET(x) offsetof(ModPlugContext, x) #define D AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { - {"noise_reduction", "Enable noise reduction 0(off)-1(on)", OFFSET(noise_reduction), FF_OPT_TYPE_INT, {.dbl = 0}, 0, 1, D}, - {"reverb_depth", "Reverb level 0(quiet)-100(loud)", OFFSET(reverb_depth), FF_OPT_TYPE_INT, {.dbl = 0}, 0, 100, D}, - {"reverb_delay", "Reverb delay in ms, usually 40-200ms", OFFSET(reverb_delay), FF_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, D}, - {"bass_amount", "XBass level 0(quiet)-100(loud)", OFFSET(bass_amount), FF_OPT_TYPE_INT, {.dbl = 0}, 0, 100, D}, - {"bass_range", "XBass cutoff in Hz 10-100", OFFSET(bass_range), FF_OPT_TYPE_INT, {.dbl = 0}, 0, 100, D}, - {"surround_depth", "Surround level 0(quiet)-100(heavy)", OFFSET(surround_depth), FF_OPT_TYPE_INT, {.dbl = 0}, 0, 100, D}, - {"surround_delay", "Surround delay in ms, usually 5-40ms", OFFSET(surround_delay), FF_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, D}, + {"noise_reduction", "Enable noise reduction 0(off)-1(on)", OFFSET(noise_reduction), AV_OPT_TYPE_INT, {.dbl = 0}, 0, 1, D}, + {"reverb_depth", "Reverb level 0(quiet)-100(loud)", OFFSET(reverb_depth), AV_OPT_TYPE_INT, {.dbl = 0}, 0, 100, D}, + {"reverb_delay", "Reverb delay in ms, usually 40-200ms", OFFSET(reverb_delay), AV_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, D}, + {"bass_amount", "XBass level 0(quiet)-100(loud)", OFFSET(bass_amount), AV_OPT_TYPE_INT, {.dbl = 0}, 0, 100, D}, + {"bass_range", "XBass cutoff in Hz 10-100", OFFSET(bass_range), AV_OPT_TYPE_INT, {.dbl = 0}, 0, 100, D}, + {"surround_depth", "Surround level 0(quiet)-100(heavy)", OFFSET(surround_depth), AV_OPT_TYPE_INT, {.dbl = 0}, 0, 100, D}, + {"surround_delay", "Surround delay in ms, usually 5-40ms", OFFSET(surround_delay), AV_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, D}, {"max_size", "Max file size supported (in bytes). Default is 5MB. Set to 0 for no limit (not recommended)", - OFFSET(max_size), FF_OPT_TYPE_INT, {.dbl = FF_MODPLUG_DEF_FILE_SIZE}, 0, FF_MODPLUG_MAX_FILE_SIZE, D}, + OFFSET(max_size), AV_OPT_TYPE_INT, {.dbl = FF_MODPLUG_DEF_FILE_SIZE}, 0, FF_MODPLUG_MAX_FILE_SIZE, D}, + {"video_stream_expr", "Color formula", OFFSET(color_eval), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, D}, + {"video_stream", "Make demuxer output a video stream", OFFSET(video_stream), AV_OPT_TYPE_INT, {.dbl = 0}, 0, 1, D}, + {"video_stream_w", "Video stream width in char (one char = 8x8px)", OFFSET(w), AV_OPT_TYPE_INT, {.dbl = 30}, 20, 512, D}, + {"video_stream_h", "Video stream height in char (one char = 8x8px)", OFFSET(h), AV_OPT_TYPE_INT, {.dbl = 30}, 20, 512, D}, + {"video_stream_ptxt", "Print speed, tempo, order, ... in video stream", OFFSET(print_textinfo), AV_OPT_TYPE_INT, {.dbl = 1}, 0, 1, D}, {NULL}, }; @@ -122,6 +157,8 @@ return 0; } +#define AUDIO_PKT_SIZE 512 + static int modplug_read_header(AVFormatContext *s, AVFormatParameters *ap) { AVStream *st; @@ -139,6 +176,14 @@ "but demuxing is likely to fail due to incomplete buffer\n", sz == FF_MODPLUG_DEF_FILE_SIZE ? " (see -max_size)" : "", sz); } + + if (modplug->color_eval) { + int r = av_expr_parse(&modplug->expr, modplug->color_eval, var_names, + NULL, NULL, NULL, NULL, 0, s); + if (r < 0) + return r; + } + modplug->buf = av_malloc(modplug->max_size); if (!modplug->buf) return AVERROR(ENOMEM); @@ -182,17 +227,101 @@ st->codec->channels = settings.mChannels; st->codec->sample_rate = settings.mFrequency; + // timebase = 1/1000, 2ch 16bits 44.1kHz-> 2*2*44100 + modplug->ts_per_packet = 1000*AUDIO_PKT_SIZE / (4*44100.); + + if (modplug->video_stream) { + AVStream *vst = av_new_stream(s, 1); + if (!vst) + return AVERROR(ENOMEM); + av_set_pts_info(vst, 64, 1, 1000); + vst->duration = st->duration; + vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; + vst->codec->codec_id = CODEC_ID_XBIN; + vst->codec->width = modplug->w << 3; + vst->codec->height = modplug->h << 3; + modplug->linesize = modplug->w * 3; + modplug->fsize = modplug->linesize * modplug->h; + } + return modplug_load_metadata(s); } +static void write_text(uint8_t *dst, const char *s, int linesize, int x, int y) +{ + int i; + dst += y*linesize + x*3; + for (i = 0; s[i]; i++, dst += 3) { + dst[0] = 0x0; // count - 1 + dst[1] = s[i]; // char + dst[2] = 0x0f; // background / foreground + } +} + +#define PRINT_INFO(line, name, idvalue) do { \ + snprintf(intbuf, sizeof(intbuf), "%.0f", var_values[idvalue]); \ + write_text(pkt->data, name ":", modplug->linesize, 0+1, line+1); \ + write_text(pkt->data, intbuf, modplug->linesize, 10+1, line+1); \ +} while (0) + static int modplug_read_packet(AVFormatContext *s, AVPacket *pkt) { ModPlugContext *modplug = s->priv_data; - if (av_new_packet(pkt, 512) < 0) + if (modplug->video_stream) { + modplug->video_switch ^= 1; // one video packet for one audio packet + if (modplug->video_switch) { + double var_values[VAR_VARS_NB]; + + var_values[VAR_W ] = modplug->w; + var_values[VAR_H ] = modplug->h; + var_values[VAR_TIME ] = modplug->packet_count * modplug->ts_per_packet; + var_values[VAR_SPEED ] = ModPlug_GetCurrentSpeed (modplug->f); + var_values[VAR_TEMPO ] = ModPlug_GetCurrentTempo (modplug->f); + var_values[VAR_ORDER ] = ModPlug_GetCurrentOrder (modplug->f); + var_values[VAR_PATTERN] = ModPlug_GetCurrentPattern(modplug->f); + var_values[VAR_ROW ] = ModPlug_GetCurrentRow (modplug->f); + + if (av_new_packet(pkt, modplug->fsize) < 0) + return AVERROR(ENOMEM); + pkt->stream_index = 1; + memset(pkt->data, 0, modplug->fsize); + + if (modplug->print_textinfo) { + char intbuf[32]; + PRINT_INFO(0, "speed", VAR_SPEED); + PRINT_INFO(1, "tempo", VAR_TEMPO); + PRINT_INFO(2, "order", VAR_ORDER); + PRINT_INFO(3, "pattern", VAR_PATTERN); + PRINT_INFO(4, "row", VAR_ROW); + PRINT_INFO(5, "ts", VAR_TIME); + } + + if (modplug->expr) { + int x, y; + for (y = 0; y < modplug->h; y++) { + for (x = 0; x < modplug->w; x++) { + double color; + var_values[VAR_X] = x; + var_values[VAR_Y] = y; + color = av_expr_eval(modplug->expr, var_values, NULL); + pkt->data[y*modplug->linesize + x*3 + 2] |= av_clip((int)color, 0, 0xf)<<4; + } + } + } + pkt->pts = pkt->dts = var_values[VAR_TIME]; + pkt->flags |= AV_PKT_FLAG_KEY; + return 0; + } + } + + if (av_new_packet(pkt, AUDIO_PKT_SIZE) < 0) return AVERROR(ENOMEM); - pkt->size = ModPlug_Read(modplug->f, pkt->data, 512); + if (modplug->video_stream) + pkt->pts = pkt->dts = modplug->packet_count++ * modplug->ts_per_packet; + + pkt->size = ModPlug_Read(modplug->f, pkt->data, AUDIO_PKT_SIZE); if (pkt->size <= 0) { av_free_packet(pkt); return pkt->size == 0 ? AVERROR_EOF : AVERROR(EIO); @@ -210,8 +339,10 @@ static int modplug_read_seek(AVFormatContext *s, int stream_idx, int64_t ts, int flags) { - const ModPlugContext *modplug = s->priv_data; + ModPlugContext *modplug = s->priv_data; ModPlug_Seek(modplug->f, (int)ts); + if (modplug->video_stream) + modplug->packet_count = ts / modplug->ts_per_packet; return 0; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/libnut.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/libnut.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/libnut.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/libnut.c 2011-11-04 12:38:27.000000000 +0000 @@ -213,7 +213,7 @@ priv->s = s; for (i = 0; s[i].type != -1 && i < 2; i++) { - AVStream * st = av_new_stream(avf, i); + AVStream * st = avformat_new_stream(avf, NULL); int j; for (j = 0; j < s[i].fourcc_len && j < 8; j++) st->codec->codec_tag |= s[i].fourcc[j]<<(j*8); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/lmlm4.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/lmlm4.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/lmlm4.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/lmlm4.c 2011-11-04 12:38:27.000000000 +0000 @@ -60,14 +60,14 @@ static int lmlm4_read_header(AVFormatContext *s, AVFormatParameters *ap) { AVStream *st; - if (!(st = av_new_stream(s, 0))) + if (!(st = avformat_new_stream(s, NULL))) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = CODEC_ID_MPEG4; st->need_parsing = AVSTREAM_PARSE_HEADERS; av_set_pts_info(st, 64, 1001, 30000); - if (!(st = av_new_stream(s, 1))) + if (!(st = avformat_new_stream(s, NULL))) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = CODEC_ID_MP2; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/lxfdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/lxfdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/lxfdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/lxfdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -217,7 +217,7 @@ if ((ret = avio_read(pb, header_data, LXF_HEADER_DATA_SIZE)) != LXF_HEADER_DATA_SIZE) return ret < 0 ? ret : AVERROR_EOF; - if (!(st = av_new_stream(s, 0))) + if (!(st = avformat_new_stream(s, NULL))) return AVERROR(ENOMEM); st->duration = AV_RL32(&header_data[32]); @@ -243,7 +243,7 @@ av_log(s, AV_LOG_WARNING, "VBI data not yet supported\n"); if ((lxf->channels = (disk_params >> 2) & 0xF)) { - if (!(st = av_new_stream(s, 1))) + if (!(st = avformat_new_stream(s, NULL))) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/Makefile ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/Makefile --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/Makefile 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/Makefile 2011-11-04 12:38:27.000000000 +0000 @@ -93,12 +93,14 @@ OBJS-$(CONFIG_FRAMECRC_MUXER) += framecrcenc.o OBJS-$(CONFIG_FRAMEMD5_MUXER) += md5enc.o OBJS-$(CONFIG_GIF_MUXER) += gif.o -OBJS-$(CONFIG_GSM_DEMUXER) += rawdec.o +OBJS-$(CONFIG_GSM_DEMUXER) += gsmdec.o OBJS-$(CONFIG_GXF_DEMUXER) += gxf.o OBJS-$(CONFIG_GXF_MUXER) += gxfenc.o audiointerleave.o OBJS-$(CONFIG_G722_DEMUXER) += rawdec.o OBJS-$(CONFIG_G722_MUXER) += rawenc.o OBJS-$(CONFIG_G723_1_DEMUXER) += g723_1.o +OBJS-$(CONFIG_G723_1_MUXER) += rawenc.o +OBJS-$(CONFIG_G729_DEMUXER) += g729dec.o OBJS-$(CONFIG_H261_DEMUXER) += h261dec.o rawdec.o OBJS-$(CONFIG_H261_MUXER) += rawenc.o OBJS-$(CONFIG_H263_DEMUXER) += h263dec.o rawdec.o @@ -146,7 +148,7 @@ movenchint.o rtpenc_chain.o OBJS-$(CONFIG_MP2_MUXER) += mp3enc.o rawenc.o OBJS-$(CONFIG_MP3_DEMUXER) += mp3dec.o -OBJS-$(CONFIG_MP3_MUXER) += mp3enc.o rawenc.o +OBJS-$(CONFIG_MP3_MUXER) += mp3enc.o rawenc.o id3v2enc.o OBJS-$(CONFIG_MPC_DEMUXER) += mpc.o apetag.o OBJS-$(CONFIG_MPC8_DEMUXER) += mpc8.o OBJS-$(CONFIG_MPEG1SYSTEM_MUXER) += mpegenc.o @@ -274,6 +276,7 @@ OBJS-$(CONFIG_SAP_MUXER) += sapenc.o rtpenc_chain.o OBJS-$(CONFIG_SDP_DEMUXER) += rtsp.o OBJS-$(CONFIG_SEGAFILM_DEMUXER) += segafilm.o +OBJS-$(CONFIG_SEGMENT_MUXER) += segment.o OBJS-$(CONFIG_SHORTEN_DEMUXER) += rawdec.o OBJS-$(CONFIG_SIFF_DEMUXER) += siff.o OBJS-$(CONFIG_SMACKER_DEMUXER) += smacker.o @@ -289,6 +292,7 @@ OBJS-$(CONFIG_SWF_MUXER) += swfenc.o OBJS-$(CONFIG_THP_DEMUXER) += thp.o OBJS-$(CONFIG_TIERTEXSEQ_DEMUXER) += tiertexseq.o +OBJS-$(CONFIG_TIMECODE_V2_MUXER) += timecode_v2.o OBJS-$(CONFIG_TMV_DEMUXER) += tmv.o OBJS-$(CONFIG_TRUEHD_DEMUXER) += rawdec.o OBJS-$(CONFIG_TRUEHD_MUXER) += rawenc.o @@ -332,6 +336,7 @@ OBJS+= avio.o aviobuf.o OBJS-$(CONFIG_APPLEHTTP_PROTOCOL) += applehttpproto.o +OBJS-$(CONFIG_CACHE_PROTOCOL) += cache.o OBJS-$(CONFIG_CONCAT_PROTOCOL) += concat.o OBJS-$(CONFIG_CRYPTO_PROTOCOL) += crypto.o OBJS-$(CONFIG_FILE_PROTOCOL) += file.o @@ -351,11 +356,8 @@ OBJS-$(CONFIG_TCP_PROTOCOL) += tcp.o OBJS-$(CONFIG_UDP_PROTOCOL) += udp.o -# libavdevice dependencies -OBJS-$(CONFIG_ALSA_INDEV) += timefilter.o -OBJS-$(CONFIG_JACK_INDEV) += timefilter.o -TESTPROGS = seek timefilter +TESTPROGS = seek TOOLS = pktdumper probetest include $(SRC_PATH)/subdir.mak diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/matroskadec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/matroskadec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/matroskadec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/matroskadec.c 2011-11-04 12:38:27.000000000 +0000 @@ -1303,8 +1303,8 @@ { int sri; - for (sri=0; sristream = av_new_stream(s, 0); + st = track->stream = avformat_new_stream(s, NULL); if (st == NULL) return AVERROR(ENOMEM); @@ -1639,7 +1639,7 @@ attachements[j].bin.data && attachements[j].bin.size > 0)) { av_log(matroska->ctx, AV_LOG_ERROR, "incomplete attachment\n"); } else { - AVStream *st = av_new_stream(s, 0); + AVStream *st = avformat_new_stream(s, NULL); if (st == NULL) break; av_dict_set(&st->metadata, "filename",attachements[j].filename, 0); @@ -1668,7 +1668,7 @@ if (chapters[i].start != AV_NOPTS_VALUE && chapters[i].uid && (max_start==0 || chapters[i].start > max_start)) { chapters[i].chapter = - ff_new_chapter(s, chapters[i].uid, (AVRational){1, 1000000000}, + avpriv_new_chapter(s, chapters[i].uid, (AVRational){1, 1000000000}, chapters[i].start, chapters[i].end, chapters[i].title); av_dict_set(&chapters[i].chapter->metadata, @@ -1753,7 +1753,7 @@ if (size <= 3 || !track || !track->stream) { av_log(matroska->ctx, AV_LOG_INFO, "Invalid stream %"PRIu64" or size %u\n", num, size); - return AVERROR_INVALIDDATA; + return res; } st = track->stream; if (st->discard >= AVDISCARD_ALL) @@ -1854,7 +1854,7 @@ lace_size[n] = lace_size[n - 1] + snum; total += lace_size[n]; } - lace_size[n] = size - total; + lace_size[laces - 1] = size - total; break; } } @@ -1990,7 +1990,7 @@ res = ebml_parse(matroska, matroska_clusters, &cluster); blocks_list = &cluster.blocks; blocks = blocks_list->elem; - for (i=0; inb_elem && !res; i++) + for (i=0; inb_elem; i++) if (blocks[i].bin.size > 0 && blocks[i].bin.data) { int is_keyframe = blocks[i].non_simple ? !blocks[i].reference : -1; res=matroska_parse_block(matroska, @@ -2007,15 +2007,14 @@ static int matroska_read_packet(AVFormatContext *s, AVPacket *pkt) { MatroskaDemuxContext *matroska = s->priv_data; - int ret = 0; - while (!ret && matroska_deliver_packet(matroska, pkt)) { + while (matroska_deliver_packet(matroska, pkt)) { if (matroska->done) return AVERROR_EOF; - ret = matroska_parse_cluster(matroska); + matroska_parse_cluster(matroska); } - return ret; + return 0; } static int matroska_read_seek(AVFormatContext *s, int stream_index, @@ -2071,7 +2070,7 @@ matroska->skip_to_keyframe = !(flags & AVSEEK_FLAG_ANY); matroska->skip_to_timecode = st->index_entries[index].timestamp; matroska->done = 0; - av_update_cur_dts(s, st, st->index_entries[index].timestamp); + ff_update_cur_dts(s, st, st->index_entries[index].timestamp); return 0; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/matroskaenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/matroskaenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/matroskaenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/matroskaenc.c 2011-11-04 12:38:27.000000000 +0000 @@ -33,9 +33,9 @@ #include "libavutil/random_seed.h" #include "libavutil/lfg.h" #include "libavutil/dict.h" +#include "libavutil/avstring.h" #include "libavcodec/xiph.h" #include "libavcodec/mpeg4audio.h" -#include typedef struct ebml_master { int64_t pos; ///< absolute offset in the file where the master's elements start @@ -423,7 +423,7 @@ else first_header_size = 42; - if (ff_split_xiph_headers(codec->extradata, codec->extradata_size, + if (avpriv_split_xiph_headers(codec->extradata, codec->extradata_size, first_header_size, header_start, header_len) < 0) { av_log(s, AV_LOG_ERROR, "Extradata corrupt.\n"); return -1; @@ -443,7 +443,7 @@ { MPEG4AudioConfig mp4ac; - if (ff_mpeg4audio_get_config(&mp4ac, codec->extradata, codec->extradata_size) < 0) { + if (avpriv_mpeg4audio_get_config(&mp4ac, codec->extradata, codec->extradata_size) < 0) { av_log(s, AV_LOG_WARNING, "Error parsing AAC extradata, unable to determine samplerate.\n"); return; } @@ -767,7 +767,7 @@ end_ebml_master(s->pb, targets); while ((t = av_dict_get(m, "", t, AV_DICT_IGNORE_SUFFIX))) - if (strcasecmp(t->key, "title") && strcasecmp(t->key, "stereo_mode")) + if (av_strcasecmp(t->key, "title") && av_strcasecmp(t->key, "stereo_mode")) mkv_write_simpletag(s->pb, t); end_ebml_master(s->pb, tag); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/metadata.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/metadata.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/metadata.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/metadata.c 2011-11-04 12:38:27.000000000 +0000 @@ -18,10 +18,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include "avformat.h" #include "metadata.h" #include "libavutil/dict.h" +#include "libavutil/avstring.h" #if FF_API_OLD_METADATA2 AVDictionaryEntry * @@ -69,13 +69,13 @@ key = mtag->key; if (s_conv) for (sc=s_conv; sc->native; sc++) - if (!strcasecmp(key, sc->native)) { + if (!av_strcasecmp(key, sc->native)) { key = sc->generic; break; } if (d_conv) for (dc=d_conv; dc->native; dc++) - if (!strcasecmp(key, dc->generic)) { + if (!av_strcasecmp(key, dc->generic)) { key = dc->native; break; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mm.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mm.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mm.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mm.c 2011-11-04 12:38:27.000000000 +0000 @@ -105,7 +105,7 @@ avio_skip(pb, length - 10); /* unknown data */ /* video stream */ - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_VIDEO; @@ -117,7 +117,7 @@ /* audio stream */ if (length == MM_HEADER_LEN_AV) { - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mmf.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mmf.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mmf.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mmf.c 2011-11-04 12:38:27.000000000 +0000 @@ -241,7 +241,7 @@ } mmf->data_size = size; - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mmsh.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mmsh.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mmsh.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mmsh.c 2011-11-04 12:38:27.000000000 +0000 @@ -55,6 +55,7 @@ typedef struct { MMSContext mms; + uint8_t location[1024]; int request_seq; ///< request packet sequence int chunk_seq; ///< data packet sequence } MMSHContext; @@ -210,10 +211,10 @@ } } -static int mmsh_open(URLContext *h, const char *uri, int flags) +static int mmsh_open_internal(URLContext *h, const char *uri, int flags, int timestamp, int64_t pos) { int i, port, err; - char httpname[256], path[256], host[128], location[1024]; + char httpname[256], path[256], host[128]; char *stream_selection = NULL; char headers[1024]; MMSHContext *mmsh; @@ -224,10 +225,10 @@ return AVERROR(ENOMEM); mmsh->request_seq = h->is_streamed = 1; mms = &mmsh->mms; - av_strlcpy(location, uri, sizeof(location)); + av_strlcpy(mmsh->location, uri, sizeof(mmsh->location)); av_url_split(NULL, 0, NULL, 0, - host, sizeof(host), &port, path, sizeof(path), location); + host, sizeof(host), &port, path, sizeof(path), mmsh->location); if (port<0) port = 80; // default mmsh protocol port ff_url_join(httpname, sizeof(httpname), "http", NULL, host, port, "%s", path); @@ -283,8 +284,9 @@ CLIENTGUID "Pragma: stream-switch-count=%d\r\n" "Pragma: stream-switch-entry=%s\r\n" + "Pragma: no-cache,rate=1.000000,stream-time=%u" "Connection: Close\r\n", - host, port, mmsh->request_seq++, mms->stream_num, stream_selection); + host, port, mmsh->request_seq++, mms->stream_num, stream_selection, timestamp); av_freep(&stream_selection); if (err < 0) { av_log(NULL, AV_LOG_ERROR, "Build play request failed!\n"); @@ -313,6 +315,11 @@ return err; } +static int mmsh_open(URLContext *h, const char *uri, int flags) +{ + return mmsh_open_internal(h, uri, flags, 0, 0); +} + static int handle_chunk_type(MMSHContext *mmsh) { MMSContext *mms = &mmsh->mms; @@ -359,11 +366,45 @@ return res; } +static int64_t mmsh_read_seek(URLContext *h, int stream_index, + int64_t timestamp, int flags) +{ + MMSHContext *mmsh = h->priv_data; + MMSContext *mms = &mmsh->mms; + int ret; + + ret= mmsh_open_internal(h, mmsh->location, 0, FFMAX(timestamp, 0), 0); + + if(ret>=0){ + if (mms->mms_hd) + ffurl_close(mms->mms_hd); + av_freep(&mms->streams); + av_freep(&mms->asf_header); + av_free(mmsh); + mmsh = h->priv_data; + mms = &mmsh->mms; + mms->asf_header_read_size= mms->asf_header_size; + }else + h->priv_data= mmsh; + return ret; +} + +static int64_t mmsh_seek(URLContext *h, int64_t pos, int whence) +{ + MMSHContext *mmsh = h->priv_data; + MMSContext *mms = &mmsh->mms; + + if(pos == 0 && whence == SEEK_CUR) + return mms->asf_header_read_size + mms->remaining_in_len + mmsh->chunk_seq * mms->asf_packet_len; + return AVERROR(ENOSYS); +} + URLProtocol ff_mmsh_protocol = { .name = "mmsh", .url_open = mmsh_open, .url_read = mmsh_read, .url_write = NULL, - .url_seek = NULL, + .url_seek = mmsh_seek, .url_close = mmsh_close, + .url_read_seek = mmsh_read_seek, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mov.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mov.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mov.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mov.c 2011-11-04 12:38:27.000000000 +0000 @@ -35,6 +35,7 @@ #include "riff.h" #include "isom.h" #include "libavcodec/get_bits.h" +#include "id3v1.h" #if CONFIG_ZLIB #include @@ -81,15 +82,64 @@ static const MOVParseTableEntry mov_default_parse_table[]; -static int mov_metadata_track_or_disc_number(MOVContext *c, AVIOContext *pb, unsigned len, const char *type) +static int mov_metadata_track_or_disc_number(MOVContext *c, AVIOContext *pb, + unsigned len, const char *key) { char buf[16]; + short current, total; avio_rb16(pb); // unknown - snprintf(buf, sizeof(buf), "%d", avio_rb16(pb)); - av_dict_set(&c->fc->metadata, type, buf, 0); + current = avio_rb16(pb); + total = avio_rb16(pb); + if (!total) + snprintf(buf, sizeof(buf), "%d", current); + else + snprintf(buf, sizeof(buf), "%d/%d", current, total); + av_dict_set(&c->fc->metadata, key, buf, 0); - avio_rb16(pb); // total tracks/discs + return 0; +} + +static int mov_metadata_int8_bypass_padding(MOVContext *c, AVIOContext *pb, + unsigned len, const char *key) +{ + char buf[16]; + + /* bypass padding bytes */ + avio_r8(pb); + avio_r8(pb); + avio_r8(pb); + + snprintf(buf, sizeof(buf), "%hu", avio_r8(pb)); + av_dict_set(&c->fc->metadata, key, buf, 0); + + return 0; +} + +static int mov_metadata_int8_no_padding(MOVContext *c, AVIOContext *pb, + unsigned len, const char *key) +{ + char buf[16]; + + snprintf(buf, sizeof(buf), "%hu", avio_r8(pb)); + av_dict_set(&c->fc->metadata, key, buf, 0); + + return 0; +} + +static int mov_metadata_gnre(MOVContext *c, AVIOContext *pb, + unsigned len, const char *key) +{ + short genre; + char buf[20]; + + avio_r8(pb); // unknown + + genre = avio_r8(pb); + if (genre < 1 || genre > ID3v1_GENRE_MAX) + return 0; + snprintf(buf, sizeof(buf), "%s", ff_id3v1_genre_str[genre-1]); + av_dict_set(&c->fc->metadata, key, buf, 0); return 0; } @@ -140,13 +190,13 @@ const char *key = NULL; uint16_t str_size, langcode = 0; uint32_t data_type = 0; - int (*parse)(MOVContext*, AVIOContext*, unsigned, const char *) = NULL; + int (*parse)(MOVContext*, AVIOContext*, unsigned, const char*) = NULL; switch (atom.type) { case MKTAG(0xa9,'n','a','m'): key = "title"; break; case MKTAG(0xa9,'a','u','t'): case MKTAG(0xa9,'A','R','T'): key = "artist"; break; - case MKTAG( 'a','A','R','T'): key = "album_artist";break; + case MKTAG( 'a','A','R','T'): key = "album_artist"; break; case MKTAG(0xa9,'w','r','t'): key = "composer"; break; case MKTAG( 'c','p','r','t'): case MKTAG(0xa9,'c','p','y'): key = "copyright"; break; @@ -157,6 +207,8 @@ case MKTAG(0xa9,'a','l','b'): key = "album"; break; case MKTAG(0xa9,'d','a','y'): key = "date"; break; case MKTAG(0xa9,'g','e','n'): key = "genre"; break; + case MKTAG( 'g','n','r','e'): key = "genre"; + parse = mov_metadata_gnre; break; case MKTAG(0xa9,'t','o','o'): case MKTAG(0xa9,'s','w','r'): key = "encoder"; break; case MKTAG(0xa9,'e','n','c'): key = "encoder"; break; @@ -169,6 +221,16 @@ parse = mov_metadata_track_or_disc_number; break; case MKTAG( 'd','i','s','k'): key = "disc"; parse = mov_metadata_track_or_disc_number; break; + case MKTAG( 't','v','e','s'): key = "episode_sort"; + parse = mov_metadata_int8_bypass_padding; break; + case MKTAG( 't','v','s','n'): key = "season_number"; + parse = mov_metadata_int8_bypass_padding; break; + case MKTAG( 's','t','i','k'): key = "media_type"; + parse = mov_metadata_int8_no_padding; break; + case MKTAG( 'h','d','v','d'): key = "hd_video"; + parse = mov_metadata_int8_no_padding; break; + case MKTAG( 'p','g','a','p'): key = "gapless_playback"; + parse = mov_metadata_int8_no_padding; break; } if (c->itunes_metadata && atom.size > 8) { @@ -251,7 +313,7 @@ avio_read(pb, str, str_len); str[str_len] = 0; - ff_new_chapter(c->fc, i, (AVRational){1,10000000}, start, AV_NOPTS_VALUE, str); + avpriv_new_chapter(c->fc, i, (AVRational){1,10000000}, start, AV_NOPTS_VALUE, str); } return 0; } @@ -268,7 +330,7 @@ int (*parse)(MOVContext*, AVIOContext*, MOVAtom) = NULL; a.size = atom.size; a.type=0; - if(atom.size >= 8) { + if (atom.size >= 8) { a.size = avio_rb32(pb); a.type = avio_rl32(pb); } @@ -285,7 +347,7 @@ break; } a.size -= 8; - if(a.size < 0) + if (a.size < 0) break; a.size = FFMIN(a.size, atom.size - total_size); @@ -434,6 +496,8 @@ AVStream *st; uint32_t type; uint32_t av_unused ctype; + int title_size; + char *title_str; if (c->fc->nb_streams < 1) // meta before first trak return 0; @@ -452,17 +516,28 @@ if (type == MKTAG('v','i','d','e')) st->codec->codec_type = AVMEDIA_TYPE_VIDEO; - else if(type == MKTAG('s','o','u','n')) + else if (type == MKTAG('s','o','u','n')) st->codec->codec_type = AVMEDIA_TYPE_AUDIO; - else if(type == MKTAG('m','1','a',' ')) + else if (type == MKTAG('m','1','a',' ')) st->codec->codec_id = CODEC_ID_MP2; - else if((type == MKTAG('s','u','b','p')) || (type == MKTAG('c','l','c','p'))) + else if ((type == MKTAG('s','u','b','p')) || (type == MKTAG('c','l','c','p'))) st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE; avio_rb32(pb); /* component manufacture */ avio_rb32(pb); /* component flags */ avio_rb32(pb); /* component flags mask */ + title_size = atom.size - 24; + if (title_size > 0) { + title_str = av_malloc(title_size + 1); /* Add null terminator */ + if (!title_str) + return AVERROR(ENOMEM); + avio_read(pb, title_str, title_size); + title_str[title_size] = 0; + av_dict_set(&st->metadata, "handler_name", title_str, 0); + av_freep(&title_str); + } + return 0; } @@ -553,7 +628,7 @@ /* this atom contains actual media data */ static int mov_read_mdat(MOVContext *c, AVIOContext *pb, MOVAtom atom) { - if(atom.size == 0) /* wrong one (MP4) */ + if (atom.size == 0) /* wrong one (MP4) */ return 0; c->found_mdat=1; return 0; /* now go for moov */ @@ -707,7 +782,7 @@ return 0; st = c->fc->streams[c->fc->nb_streams-1]; - if((uint64_t)atom.size > (1<<30)) + if ((uint64_t)atom.size > (1<<30)) return -1; // currently SVQ3 decoder expect full STSD header - so let's fake it @@ -771,10 +846,10 @@ return 0; /* unexpected codec_id - don't mess with extradata */ size= (uint64_t)st->codec->extradata_size + atom.size + 8 + FF_INPUT_BUFFER_PADDING_SIZE; - if(size > INT_MAX || (uint64_t)atom.size > INT_MAX) + if (size > INT_MAX || (uint64_t)atom.size > INT_MAX) return -1; buf= av_realloc(st->codec->extradata, size); - if(!buf) + if (!buf) return -1; st->codec->extradata= buf; buf+= st->codec->extradata_size; @@ -814,7 +889,7 @@ return 0; st = c->fc->streams[c->fc->nb_streams-1]; - if((uint64_t)atom.size > (1<<30)) + if ((uint64_t)atom.size > (1<<30)) return -1; if (st->codec->codec_id == CODEC_ID_QDM2 || st->codec->codec_id == CODEC_ID_QDMC) { @@ -845,7 +920,7 @@ return 0; st = c->fc->streams[c->fc->nb_streams-1]; - if((uint64_t)atom.size > (1<<30)) + if ((uint64_t)atom.size > (1<<30)) return -1; av_free(st->codec->extradata); @@ -872,7 +947,7 @@ return 0; st = c->fc->streams[c->fc->nb_streams-1]; - if((uint64_t)atom.size > (1<<30)) + if ((uint64_t)atom.size > (1<<30)) return -1; av_free(st->codec->extradata); @@ -901,7 +976,7 @@ entries = avio_rb32(pb); - if(entries >= UINT_MAX/sizeof(int64_t)) + if (entries >= UINT_MAX/sizeof(int64_t)) return -1; sc->chunk_offsets = av_malloc(entries * sizeof(int64_t)); @@ -910,10 +985,10 @@ sc->chunk_count = entries; if (atom.type == MKTAG('s','t','c','o')) - for(i=0; ichunk_offsets[i] = avio_rb32(pb); else if (atom.type == MKTAG('c','o','6','4')) - for(i=0; ichunk_offsets[i] = avio_rb64(pb); else return -1; @@ -967,7 +1042,7 @@ st = c->fc->streams[c->fc->nb_streams-1]; sc = st->priv_data; - for(pseudo_stream_id=0; pseudo_stream_id 0) st->codec->codec_type = AVMEDIA_TYPE_VIDEO; - else if(st->codec->codec_type == AVMEDIA_TYPE_DATA){ + else if (st->codec->codec_type == AVMEDIA_TYPE_DATA){ id = ff_codec_get_id(ff_codec_movsubtitle_tags, format); - if(id > 0) + if (id > 0) st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE; } } @@ -1026,7 +1101,7 @@ (format >> 0) & 0xff, (format >> 8) & 0xff, (format >> 16) & 0xff, (format >> 24) & 0xff, st->codec->codec_type); - if(st->codec->codec_type==AVMEDIA_TYPE_VIDEO) { + if (st->codec->codec_type==AVMEDIA_TYPE_VIDEO) { unsigned int color_depth, len; int color_greyscale; @@ -1132,7 +1207,7 @@ } sc->has_palette = 1; } - } else if(st->codec->codec_type==AVMEDIA_TYPE_AUDIO) { + } else if (st->codec->codec_type==AVMEDIA_TYPE_AUDIO) { int bits_per_sample, flags; uint16_t version = avio_rb16(pb); @@ -1151,13 +1226,13 @@ //Read QT version 1 fields. In version 0 these do not exist. av_dlog(c->fc, "version =%d, isom =%d\n",version,c->isom); - if(!c->isom) { - if(version==1) { + if (!c->isom) { + if (version==1) { sc->samples_per_frame = avio_rb32(pb); avio_rb32(pb); /* bytes per packet */ sc->bytes_per_frame = avio_rb32(pb); avio_rb32(pb); /* bytes per sample */ - } else if(version==2) { + } else if (version==2) { avio_rb32(pb); /* sizeof struct only */ st->codec->sample_rate = av_int2dbl(avio_rb64(pb)); /* float 64 */ st->codec->channels = avio_rb32(pb); @@ -1212,7 +1287,7 @@ st->codec->bits_per_coded_sample = bits_per_sample; sc->sample_size = (bits_per_sample >> 3) * st->codec->channels; } - } else if(st->codec->codec_type==AVMEDIA_TYPE_SUBTITLE){ + } else if (st->codec->codec_type==AVMEDIA_TYPE_SUBTITLE){ // ttxt stsd contains display flags, justification, background // color, fonts, and default styles, so fake an atom to read it MOVAtom fake_atom = { .size = size - (avio_tell(pb) - start_pos) }; @@ -1245,7 +1320,7 @@ avio_skip(pb, a.size); } - if(st->codec->codec_type==AVMEDIA_TYPE_AUDIO && st->codec->sample_rate==0 && sc->time_scale>1) + if (st->codec->codec_type==AVMEDIA_TYPE_AUDIO && st->codec->sample_rate==0 && sc->time_scale>1) st->codec->sample_rate= sc->time_scale; /* special codec parameters handling */ @@ -1253,7 +1328,7 @@ #if CONFIG_DV_DEMUXER case CODEC_ID_DVAUDIO: c->dv_fctx = avformat_alloc_context(); - c->dv_demux = dv_init_demux(c->dv_fctx); + c->dv_demux = avpriv_dv_init_demux(c->dv_fctx); if (!c->dv_demux) { av_log(c->fc, AV_LOG_ERROR, "dv demux context init error\n"); return -1; @@ -1275,10 +1350,13 @@ st->codec->frame_size= sc->samples_per_frame; st->codec->channels= 1; /* really needed */ /* force sample rate for amr, stsd in 3gp does not store sample rate */ - if (st->codec->codec_id == CODEC_ID_AMR_NB) + if (st->codec->codec_id == CODEC_ID_AMR_NB) { st->codec->sample_rate = 8000; - else if (st->codec->codec_id == CODEC_ID_AMR_WB) + st->codec->frame_size = 160; + } else if (st->codec->codec_id == CODEC_ID_AMR_WB) { st->codec->sample_rate = 16000; + st->codec->frame_size = 320; + } break; case CODEC_ID_MP2: case CODEC_ID_MP3: @@ -1337,14 +1415,14 @@ av_dlog(c->fc, "track[%i].stsc.entries = %i\n", c->fc->nb_streams-1, entries); - if(entries >= UINT_MAX / sizeof(*sc->stsc_data)) + if (entries >= UINT_MAX / sizeof(*sc->stsc_data)) return -1; sc->stsc_data = av_malloc(entries * sizeof(*sc->stsc_data)); if (!sc->stsc_data) return AVERROR(ENOMEM); sc->stsc_count = entries; - for(i=0; istsc_data[i].first = avio_rb32(pb); sc->stsc_data[i].count = avio_rb32(pb); sc->stsc_data[i].id = avio_rb32(pb); @@ -1399,14 +1477,14 @@ av_dlog(c->fc, "keyframe_count = %d\n", entries); - if(entries >= UINT_MAX / sizeof(int)) + if (entries >= UINT_MAX / sizeof(int)) return -1; sc->keyframes = av_malloc(entries * sizeof(int)); if (!sc->keyframes) return AVERROR(ENOMEM); sc->keyframe_count = entries; - for(i=0; ikeyframes[i] = avio_rb32(pb); //av_dlog(c->fc, "keyframes[]=%d\n", sc->keyframes[i]); } @@ -1474,7 +1552,7 @@ init_get_bits(&gb, buf, 8*num_bytes); - for(i=0; isample_sizes[i] = get_bits_long(&gb, field_size); av_free(buf); @@ -1498,16 +1576,19 @@ avio_rb24(pb); /* flags */ entries = avio_rb32(pb); - av_dlog(c->fc, "track[%i].stts.entries = %i\n", c->fc->nb_streams-1, entries); + av_dlog(c->fc, "track[%i].stts.entries = %i\n", + c->fc->nb_streams-1, entries); - if(entries >= UINT_MAX / sizeof(*sc->stts_data)) + if (entries >= UINT_MAX / sizeof(*sc->stts_data)) return -1; + sc->stts_data = av_malloc(entries * sizeof(*sc->stts_data)); if (!sc->stts_data) return AVERROR(ENOMEM); + sc->stts_count = entries; - for(i=0; istts_data[i].count= sample_count; sc->stts_data[i].duration= sample_duration; - av_dlog(c->fc, "sample_count=%d, sample_duration=%d\n",sample_count,sample_duration); + av_dlog(c->fc, "sample_count=%d, sample_duration=%d\n", + sample_count, sample_duration); duration+=(int64_t)sample_duration*sample_count; total_sample_count+=sample_count; } st->nb_frames= total_sample_count; - if(duration) + if (duration) st->duration= duration; return 0; } @@ -1550,20 +1632,20 @@ av_dlog(c->fc, "track[%i].ctts.entries = %i\n", c->fc->nb_streams-1, entries); - if(entries >= UINT_MAX / sizeof(*sc->ctts_data)) + if (entries >= UINT_MAX / sizeof(*sc->ctts_data)) return -1; sc->ctts_data = av_malloc(entries * sizeof(*sc->ctts_data)); if (!sc->ctts_data) return AVERROR(ENOMEM); sc->ctts_count = entries; - for(i=0; ictts_data[i].count = count; sc->ctts_data[i].duration= duration; - if (duration < 0 && i+1dts_shift = FFMAX(sc->dts_shift, -duration); } @@ -1585,9 +1667,10 @@ uint64_t stream_size = 0; /* adjust first dts according to edit list */ - if (sc->time_offset && mov->time_scale > 0) { - if (sc->time_offset < 0) - sc->time_offset = av_rescale(sc->time_offset, sc->time_scale, mov->time_scale); + if ((sc->empty_duration || sc->start_time) && mov->time_scale > 0) { + if (sc->empty_duration) + sc->empty_duration = av_rescale(sc->empty_duration, sc->time_scale, mov->time_scale); + sc->time_offset = sc->start_time - sc->empty_duration; current_dts = -sc->time_offset; if (sc->ctts_data && sc->stts_data && sc->ctts_data[0].duration / FFMAX(sc->stts_data[0].duration, 1) > 16) { @@ -1640,7 +1723,7 @@ if (keyframe) distance = 0; sample_size = sc->sample_size > 0 ? sc->sample_size : sc->sample_sizes[current_sample]; - if(sc->pseudo_stream_id == -1 || + if (sc->pseudo_stream_id == -1 || sc->stsc_data[stsc_index].id - 1 == sc->pseudo_stream_id) { AVIndexEntry *e = &st->index_entries[st->nb_index_entries++]; e->pos = current_offset; @@ -1801,8 +1884,9 @@ MOVStreamContext *sc; int ret; - st = av_new_stream(c->fc, c->fc->nb_streams); + st = avformat_new_stream(c->fc, NULL); if (!st) return AVERROR(ENOMEM); + st->id = c->fc->nb_streams; sc = av_mallocz(sizeof(MOVStreamContext)); if (!sc) return AVERROR(ENOMEM); @@ -2209,9 +2293,9 @@ return AVERROR(ENOMEM); } avio_read(pb, cmov_data, cmov_len); - if(uncompress (moov_data, (uLongf *) &moov_len, (const Bytef *)cmov_data, cmov_len) != Z_OK) + if (uncompress (moov_data, (uLongf *) &moov_len, (const Bytef *)cmov_data, cmov_len) != Z_OK) goto free_and_return; - if(ffio_init_context(&ctx, moov_data, moov_len, 0, NULL, NULL, NULL, NULL) != 0) + if (ffio_init_context(&ctx, moov_data, moov_len, 0, NULL, NULL, NULL, NULL) != 0) goto free_and_return; atom.type = MKTAG('m','o','o','v'); atom.size = moov_len; @@ -2230,7 +2314,7 @@ static int mov_read_elst(MOVContext *c, AVIOContext *pb, MOVAtom atom) { MOVStreamContext *sc; - int i, edit_count, version; + int i, edit_count, version, edit_start_index = 0; if (c->fc->nb_streams < 1) return 0; @@ -2240,10 +2324,10 @@ avio_rb24(pb); /* flags */ edit_count = avio_rb32(pb); /* entries */ - if((uint64_t)edit_count*12+8 > atom.size) + if ((uint64_t)edit_count*12+8 > atom.size) return -1; - for(i=0; i= -1) { - sc->time_offset = time != -1 ? time : -duration; - } + if (i == 0 && time == -1) { + sc->empty_duration = duration; + edit_start_index = 1; + } else if (i == edit_start_index && time >= 0) + sc->start_time = time; } - if(edit_count > 1) + if (edit_count > 1) av_log(c->fc, AV_LOG_WARNING, "multiple edit list entries, " "a/v desync might occur, patch welcome\n"); @@ -2342,7 +2428,7 @@ /* check file header */ offset = 0; - for(;;) { + for (;;) { /* ignore invalid offset */ if ((offset + 8) > (unsigned int)p->buf_size) return score; @@ -2424,17 +2510,24 @@ // The samples could theoretically be in any encoding if there's an encd // atom following, but in practice are only utf-8 or utf-16, distinguished // instead by the presence of a BOM - ch = avio_rb16(sc->pb); - if (ch == 0xfeff) - avio_get_str16be(sc->pb, len, title, title_len); - else if (ch == 0xfffe) - avio_get_str16le(sc->pb, len, title, title_len); - else { - AV_WB16(title, ch); - get_strz(sc->pb, title + 2, len - 1); + if (!len) { + title[0] = 0; + } else { + ch = avio_rb16(sc->pb); + if (ch == 0xfeff) + avio_get_str16be(sc->pb, len, title, title_len); + else if (ch == 0xfffe) + avio_get_str16le(sc->pb, len, title, title_len); + else { + AV_WB16(title, ch); + if (len == 1 || len == 2) + title[len] = 0; + else + get_strz(sc->pb, title + 2, len - 1); + } } - ff_new_chapter(s, i, st->time_base, sample->timestamp, end, title); + avpriv_new_chapter(s, i, st->time_base, sample->timestamp, end, title); av_freep(&title); } finish: @@ -2450,7 +2543,7 @@ mov->fc = s; /* .mov and .mp4 aren't streamable anyway (only progressive download if moov is before mdat) */ - if(pb->seekable) + if (pb->seekable) atom.size = avio_size(pb); else atom.size = INT64_MAX; @@ -2542,10 +2635,10 @@ } #if CONFIG_DV_DEMUXER if (mov->dv_demux && sc->dv_audio_container) { - dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos); + avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos); av_free(pkt->data); pkt->size = 0; - ret = dv_get_packet(mov->dv_demux, pkt); + ret = avpriv_dv_get_packet(mov->dv_demux, pkt); if (ret < 0) return ret; } @@ -2661,7 +2754,7 @@ } if (mov->dv_demux) { - for(i = 0; i < mov->dv_fctx->nb_streams; i++) { + for (i = 0; i < mov->dv_fctx->nb_streams; i++) { av_freep(&mov->dv_fctx->streams[i]->codec); av_freep(&mov->dv_fctx->streams[i]); } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/movenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/movenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/movenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/movenc.c 2011-11-04 12:38:27.000000000 +0000 @@ -42,8 +42,9 @@ #include static const AVOption options[] = { - { "movflags", "MOV muxer flags", offsetof(MOVMuxContext, flags), FF_OPT_TYPE_FLAGS, {.dbl = 0}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, - { "rtphint", "Add RTP hint tracks", 0, FF_OPT_TYPE_CONST, {.dbl = FF_MOV_FLAG_RTP_HINT}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, + { "movflags", "MOV muxer flags", offsetof(MOVMuxContext, flags), AV_OPT_TYPE_FLAGS, {.dbl = 0}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, + { "rtphint", "Add RTP hint tracks", 0, AV_OPT_TYPE_CONST, {.dbl = FF_MOV_FLAG_RTP_HINT}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "movflags" }, + { "moov_size", "maximum moov size so it can be placed at the begin", offsetof(MOVMuxContext, reserved_moov_size), AV_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, 0 }, FF_RTP_FLAG_OPTS(MOVMuxContext, rtp_flags), { NULL }, }; @@ -2013,7 +2014,7 @@ if (enc->codec_id == CODEC_ID_AMR_NB) { /* We must find out how many AMR blocks there are in one packet */ static uint16_t packed_size[16] = - {13, 14, 16, 18, 20, 21, 27, 32, 6, 0, 0, 0, 0, 0, 0, 0}; + {13, 14, 16, 18, 20, 21, 27, 32, 6, 0, 0, 0, 0, 0, 0, 1}; int len = 0; while (len < size && samplesInChunk < 100) { @@ -2274,6 +2275,11 @@ av_set_pts_info(st, 64, 1, track->timescale); } + if(mov->reserved_moov_size){ + mov->reserved_moov_pos= avio_tell(pb); + avio_skip(pb, mov->reserved_moov_size); + } + mov_write_mdat_tag(pb, mov); #if FF_API_TIMESTAMP @@ -2328,9 +2334,21 @@ ffio_wfourcc(pb, "mdat"); avio_wb64(pb, mov->mdat_size+16); } - avio_seek(pb, moov_pos, SEEK_SET); + avio_seek(pb, mov->reserved_moov_size ? mov->reserved_moov_pos : moov_pos, SEEK_SET); mov_write_moov_tag(pb, mov, s); + if(mov->reserved_moov_size){ + int64_t size= mov->reserved_moov_size - (avio_tell(pb) - mov->reserved_moov_pos); + if(size < 8){ + av_log(s, AV_LOG_ERROR, "reserved_moov_size is too small, needed %Ld additional\n", 8-size); + return -1; + } + avio_wb32(pb, size); + ffio_wfourcc(pb, "free"); + for(i=0; ichapter_track) av_freep(&mov->tracks[mov->chapter_track].enc); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/movenc.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/movenc.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/movenc.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/movenc.h 2011-11-04 12:38:27.000000000 +0000 @@ -112,6 +112,8 @@ int flags; int rtp_flags; + int reserved_moov_size; + int64_t reserved_moov_pos; } MOVMuxContext; #define FF_MOV_FLAG_RTP_HINT 1 diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mp3dec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mp3dec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mp3dec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mp3dec.c 2011-11-04 12:38:27.000000000 +0000 @@ -51,7 +51,7 @@ for(frames = 0; buf2 < end; frames++) { header = AV_RB32(buf2); - fsize = ff_mpa_decode_header(&avctx, header, &sample_rate, &sample_rate, &sample_rate, &sample_rate); + fsize = avpriv_mpa_decode_header(&avctx, header, &sample_rate, &sample_rate, &sample_rate, &sample_rate); if(fsize < 0) break; buf2 += fsize; @@ -86,7 +86,7 @@ if(ff_mpa_check_header(v) < 0) return -1; - if (ff_mpegaudio_decode_header(&c, v) == 0) + if (avpriv_mpegaudio_decode_header(&c, v) == 0) vbrtag_size = c.frame_size; if(c.layer != 3) return -1; @@ -137,7 +137,7 @@ AVStream *st; int64_t off; - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mp3enc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mp3enc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mp3enc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mp3enc.c 2011-11-04 12:38:27.000000000 +0000 @@ -19,7 +19,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include "avformat.h" #include "avio_internal.h" #include "id3v1.h" @@ -55,11 +54,12 @@ buf[0] = 'T'; buf[1] = 'A'; buf[2] = 'G'; - count += id3v1_set_string(s, "TIT2", buf + 3, 30); //title - count += id3v1_set_string(s, "TPE1", buf + 33, 30); //author|artist - count += id3v1_set_string(s, "TALB", buf + 63, 30); //album - count += id3v1_set_string(s, "TDRL", buf + 93, 4); //date - count += id3v1_set_string(s, "comment", buf + 97, 30); + /* we knowingly overspecify each tag length by one byte to compensate for the mandatory null byte added by av_strlcpy */ + count += id3v1_set_string(s, "TIT2", buf + 3, 30 + 1); //title + count += id3v1_set_string(s, "TPE1", buf + 33, 30 + 1); //author|artist + count += id3v1_set_string(s, "TALB", buf + 63, 30 + 1); //album + count += id3v1_set_string(s, "TDRL", buf + 93, 4 + 1); //date + count += id3v1_set_string(s, "comment", buf + 97, 30 + 1); if ((tag = av_dict_get(s->metadata, "TRCK", NULL, 0))) { //track buf[125] = 0; buf[126] = atoi(tag->value); @@ -68,7 +68,7 @@ buf[127] = 0xFF; /* default to unknown genre */ if ((tag = av_dict_get(s->metadata, "TCON", NULL, 0))) { //genre for(i = 0; i <= ID3v1_GENRE_MAX; i++) { - if (!strcasecmp(tag->value, ff_id3v1_genre_str[i])) { + if (!av_strcasecmp(tag->value, ff_id3v1_genre_str[i])) { buf[127] = i; count++; break; @@ -78,66 +78,9 @@ return count; } -/* simple formats */ - -static void id3v2_put_size(AVFormatContext *s, int size) -{ - avio_w8(s->pb, size >> 21 & 0x7f); - avio_w8(s->pb, size >> 14 & 0x7f); - avio_w8(s->pb, size >> 7 & 0x7f); - avio_w8(s->pb, size & 0x7f); -} - -static int string_is_ascii(const uint8_t *str) -{ - while (*str && *str < 128) str++; - return !*str; -} - -/** - * Write a text frame with one (normal frames) or two (TXXX frames) strings - * according to encoding (only UTF-8 or UTF-16+BOM supported). - * @return number of bytes written or a negative error code. - */ -static int id3v2_put_ttag(AVFormatContext *s, const char *str1, const char *str2, - uint32_t tag, enum ID3v2Encoding enc) -{ - int len; - uint8_t *pb; - int (*put)(AVIOContext*, const char*); - AVIOContext *dyn_buf; - if (avio_open_dyn_buf(&dyn_buf) < 0) - return AVERROR(ENOMEM); - - /* check if the strings are ASCII-only and use UTF16 only if - * they're not */ - if (enc == ID3v2_ENCODING_UTF16BOM && string_is_ascii(str1) && - (!str2 || string_is_ascii(str2))) - enc = ID3v2_ENCODING_ISO8859; - - avio_w8(dyn_buf, enc); - if (enc == ID3v2_ENCODING_UTF16BOM) { - avio_wl16(dyn_buf, 0xFEFF); /* BOM */ - put = avio_put_str16le; - } else - put = avio_put_str; - - put(dyn_buf, str1); - if (str2) - put(dyn_buf, str2); - len = avio_close_dyn_buf(dyn_buf, &pb); - - avio_wb32(s->pb, tag); - id3v2_put_size(s, len); - avio_wb16(s->pb, 0); - avio_write(s->pb, pb, len); - - av_freep(&pb); - return len + ID3v2_HEADER_SIZE; -} - #define VBR_NUM_BAGS 400 #define VBR_TOC_SIZE 100 + typedef struct MP3Context { const AVClass *class; int id3v2_version; @@ -191,9 +134,9 @@ static const AVOption options[] = { { "id3v2_version", "Select ID3v2 version to write. Currently 3 and 4 are supported.", - offsetof(MP3Context, id3v2_version), FF_OPT_TYPE_INT, {.dbl = 4}, 3, 4, AV_OPT_FLAG_ENCODING_PARAM}, + offsetof(MP3Context, id3v2_version), AV_OPT_TYPE_INT, {.dbl = 4}, 3, 4, AV_OPT_FLAG_ENCODING_PARAM}, { "write_id3v1", "Enable ID3v1 writing. ID3v1 tags are written in UTF-8 which may not be supported by most software.", - offsetof(MP3Context, write_id3v1), FF_OPT_TYPE_INT, {.dbl = 0}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM}, + offsetof(MP3Context, write_id3v1), AV_OPT_TYPE_INT, {.dbl = 0}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM}, { NULL }, }; @@ -204,21 +147,6 @@ .version = LIBAVUTIL_VERSION_INT, }; -static int id3v2_check_write_tag(AVFormatContext *s, AVDictionaryEntry *t, const char table[][4], - enum ID3v2Encoding enc) -{ - uint32_t tag; - int i; - - if (t->key[0] != 'T' || strlen(t->key) != 4) - return -1; - tag = AV_RB32(t->key); - for (i = 0; *table[i]; i++) - if (tag == AV_RB32(table[i])) - return id3v2_put_ttag(s, t->value, NULL, tag, enc); - return -1; -} - static const int64_t xing_offtbl[2][2] = {{32, 17}, {17,9}}; /* @@ -235,12 +163,12 @@ int srate_idx, i, channels; int needed; - for (i = 0; i < FF_ARRAY_ELEMS(ff_mpa_freq_tab); i++) - if (ff_mpa_freq_tab[i] == codec->sample_rate) { + for (i = 0; i < FF_ARRAY_ELEMS(avpriv_mpa_freq_tab); i++) + if (avpriv_mpa_freq_tab[i] == codec->sample_rate) { srate_idx = i; break; } - if (i == FF_ARRAY_ELEMS(ff_mpa_freq_tab)) { + if (i == FF_ARRAY_ELEMS(avpriv_mpa_freq_tab)) { av_log(s, AV_LOG_ERROR, "Unsupported sample rate.\n"); return -1; } @@ -263,7 +191,7 @@ mask = (bitrate_idx << 4) << 8; header |= mask; - ff_mpegaudio_decode_header(&c, header); + avpriv_mpegaudio_decode_header(&c, header); xing_offset=xing_offtbl[c.lsf == 1][c.nb_channels == 1]; needed = 4 // header + xing_offset @@ -363,46 +291,11 @@ static int mp3_write_header(struct AVFormatContext *s) { MP3Context *mp3 = s->priv_data; - AVDictionaryEntry *t = NULL; - int totlen = 0, enc = mp3->id3v2_version == 3 ? ID3v2_ENCODING_UTF16BOM : - ID3v2_ENCODING_UTF8; - int64_t size_pos, cur_pos; - - avio_wb32(s->pb, MKBETAG('I', 'D', '3', mp3->id3v2_version)); - avio_w8(s->pb, 0); - avio_w8(s->pb, 0); /* flags */ - - /* reserve space for size */ - size_pos = avio_tell(s->pb); - avio_wb32(s->pb, 0); - - ff_metadata_conv(&s->metadata, ff_id3v2_34_metadata_conv, NULL); - if (mp3->id3v2_version == 4) - ff_metadata_conv(&s->metadata, ff_id3v2_4_metadata_conv, NULL); - - while ((t = av_dict_get(s->metadata, "", t, AV_DICT_IGNORE_SUFFIX))) { - int ret; - - if ((ret = id3v2_check_write_tag(s, t, ff_id3v2_tags, enc)) > 0) { - totlen += ret; - continue; - } - if ((ret = id3v2_check_write_tag(s, t, mp3->id3v2_version == 3 ? - ff_id3v2_3_tags : ff_id3v2_4_tags, enc)) > 0) { - totlen += ret; - continue; - } - - /* unknown tag, write as TXXX frame */ - if ((ret = id3v2_put_ttag(s, t->key, t->value, MKBETAG('T', 'X', 'X', 'X'), enc)) < 0) - return ret; - totlen += ret; - } + int ret; - cur_pos = avio_tell(s->pb); - avio_seek(s->pb, size_pos, SEEK_SET); - id3v2_put_size(s, totlen); - avio_seek(s->pb, cur_pos, SEEK_SET); + ret = ff_id3v2_write(s, mp3->id3v2_version, ID3v2_DEFAULT_MAGIC); + if (ret < 0) + return ret; if (s->pb->seekable) mp3_write_xing(s); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mpc8.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mpc8.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mpc8.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mpc8.c 2011-11-04 12:38:27.000000000 +0000 @@ -222,7 +222,7 @@ c->samples = ffio_read_varlen(pb); ffio_read_varlen(pb); //silence samples at the beginning - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mpc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mpc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mpc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mpc.c 2011-11-04 12:38:27.000000000 +0000 @@ -84,7 +84,7 @@ c->curbits = 8; c->frames_noted = 0; - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mpeg.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mpeg.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mpeg.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mpeg.c 2011-11-04 12:38:27.000000000 +0000 @@ -537,9 +537,10 @@ goto redo; } /* no stream found: add a new stream */ - st = av_new_stream(s, startcode); + st = avformat_new_stream(s, NULL); if (!st) goto skip; + st->id = startcode; st->codec->codec_type = type; st->codec->codec_id = codec_id; st->request_probe = request_probe; @@ -572,14 +573,7 @@ else if (st->codec->bits_per_coded_sample == 28) return AVERROR(EINVAL); } - av_new_packet(pkt, len); - ret = avio_read(s->pb, pkt->data, pkt->size); - if (ret < 0) { - pkt->size = 0; - } else if (ret < pkt->size) { - pkt->size = ret; - memset(pkt->data + ret, 0, FF_INPUT_BUFFER_PADDING_SIZE); - } + ret = av_get_packet(s->pb, pkt, len); pkt->pts = pts; pkt->dts = dts; pkt->pos = dummy_pos; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mpegenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mpegenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mpegenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mpegenc.c 2011-11-04 12:38:27.000000000 +0000 @@ -20,7 +20,9 @@ */ #include "libavutil/fifo.h" +#include "libavutil/log.h" #include "libavutil/mathematics.h" +#include "libavutil/opt.h" #include "libavcodec/put_bits.h" #include "avformat.h" #include "mpeg.h" @@ -56,6 +58,7 @@ } StreamInfo; typedef struct { + const AVClass *class; int packet_size; /* required packet size */ int packet_number; int pack_header_freq; /* frequency (in packets^-1) at which we send pack headers */ @@ -74,6 +77,7 @@ double vcd_padding_bitrate; //FIXME floats int64_t vcd_padding_bytes_written; + int preload; } MpegMuxContext; extern AVOutputFormat ff_mpeg1vcd_muxer; @@ -416,9 +420,12 @@ video_bitrate += codec_rate; } +#if FF_API_MUXRATE if(ctx->mux_rate){ s->mux_rate= (ctx->mux_rate + (8 * 50) - 1) / (8 * 50); - } else { + } else +#endif + if (!s->mux_rate) { /* we increase slightly the bitrate to take into account the headers. XXX: compute it exactly */ bitrate += bitrate*5/100; @@ -1152,9 +1159,15 @@ StreamInfo *stream = st->priv_data; int64_t pts, dts; PacketDesc *pkt_desc; - const int preload= av_rescale(ctx->preload, 90000, AV_TIME_BASE); + int preload; const int is_iframe = st->codec->codec_type == AVMEDIA_TYPE_VIDEO && (pkt->flags & AV_PKT_FLAG_KEY); +#if FF_API_PRELOAD + if (ctx->preload) + s->preload = ctx->preload; +#endif + preload = av_rescale(s->preload, 90000, AV_TIME_BASE); + pts= pkt->pts; dts= pkt->dts; @@ -1227,7 +1240,24 @@ return 0; } +#define OFFSET(x) offsetof(MpegMuxContext, x) +#define E AV_OPT_FLAG_ENCODING_PARAM +static const AVOption options[] = { + { "muxrate", NULL, OFFSET(mux_rate), AV_OPT_TYPE_INT, {0}, 0, INT_MAX, E }, + { "preload", "Initial demux-decode delay in microseconds.", OFFSET(preload), AV_OPT_TYPE_INT, {500000}, 0, INT_MAX, E}, + { NULL }, +}; + +#define MPEGENC_CLASS(flavor)\ +static const AVClass flavor ## _class = {\ + .class_name = #flavor " muxer",\ + .item_name = av_default_item_name,\ + .version = LIBAVUTIL_VERSION_INT,\ + .option = options,\ +}; + #if CONFIG_MPEG1SYSTEM_MUXER +MPEGENC_CLASS(mpeg) AVOutputFormat ff_mpeg1system_muxer = { .name = "mpeg", .long_name = NULL_IF_CONFIG_SMALL("MPEG-1 System format"), @@ -1239,9 +1269,11 @@ .write_header = mpeg_mux_init, .write_packet = mpeg_mux_write_packet, .write_trailer = mpeg_mux_end, + .priv_class = &mpeg_class, }; #endif #if CONFIG_MPEG1VCD_MUXER +MPEGENC_CLASS(vcd) AVOutputFormat ff_mpeg1vcd_muxer = { .name = "vcd", .long_name = NULL_IF_CONFIG_SMALL("MPEG-1 System format (VCD)"), @@ -1252,9 +1284,11 @@ .write_header = mpeg_mux_init, .write_packet = mpeg_mux_write_packet, .write_trailer = mpeg_mux_end, + .priv_class = &vcd_class, }; #endif #if CONFIG_MPEG2VOB_MUXER +MPEGENC_CLASS(vob) AVOutputFormat ff_mpeg2vob_muxer = { .name = "vob", .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 PS format (VOB)"), @@ -1266,11 +1300,13 @@ .write_header = mpeg_mux_init, .write_packet = mpeg_mux_write_packet, .write_trailer = mpeg_mux_end, + .priv_class = &vob_class, }; #endif /* Same as mpeg2vob_mux except that the pack size is 2324 */ #if CONFIG_MPEG2SVCD_MUXER +MPEGENC_CLASS(svcd) AVOutputFormat ff_mpeg2svcd_muxer = { .name = "svcd", .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 PS format (VOB)"), @@ -1282,11 +1318,13 @@ .write_header = mpeg_mux_init, .write_packet = mpeg_mux_write_packet, .write_trailer = mpeg_mux_end, + .priv_class = &svcd_class, }; #endif /* Same as mpeg2vob_mux except the 'is_dvd' flag is set to produce NAV pkts */ #if CONFIG_MPEG2DVD_MUXER +MPEGENC_CLASS(dvd) AVOutputFormat ff_mpeg2dvd_muxer = { .name = "dvd", .long_name = NULL_IF_CONFIG_SMALL("MPEG-2 PS format (DVD VOB)"), @@ -1298,5 +1336,6 @@ .write_header = mpeg_mux_init, .write_packet = mpeg_mux_write_packet, .write_trailer = mpeg_mux_end, + .priv_class = &dvd_class, }; #endif diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mpegts.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mpegts.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mpegts.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mpegts.c 2011-11-04 12:38:27.000000000 +0000 @@ -27,7 +27,9 @@ #include "libavutil/dict.h" #include "libavutil/mathematics.h" #include "libavutil/opt.h" +#include "libavutil/avassert.h" #include "libavcodec/bytestream.h" +#include "libavcodec/get_bits.h" #include "avformat.h" #include "mpegts.h" #include "internal.h" @@ -42,6 +44,8 @@ #define MAX_PES_PAYLOAD 200*1024 +#define MAX_MP4_DESCR_COUNT 16 + enum MpegTSFilterType { MPEGTS_PES, MPEGTS_SECTION, @@ -72,6 +76,7 @@ struct MpegTSFilter { int pid; + int es_id; int last_cc; /* last cc code (-1 if first packet) */ enum MpegTSFilterType type; union { @@ -126,7 +131,7 @@ }; static const AVOption options[] = { - {"compute_pcr", "Compute exact PCR for each transport stream packet.", offsetof(MpegTSContext, mpeg2ts_compute_pcr), FF_OPT_TYPE_INT, + {"compute_pcr", "Compute exact PCR for each transport stream packet.", offsetof(MpegTSContext, mpeg2ts_compute_pcr), AV_OPT_TYPE_INT, {.dbl = 0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM }, { NULL }, }; @@ -172,6 +177,7 @@ int64_t ts_packet_pos; /**< position of first TS packet of this PES packet */ uint8_t header[MAX_PES_HEADER_SIZE]; uint8_t *buffer; + SLConfigDescr sl; } PESContext; extern AVInputFormat ff_mpegts_demuxer; @@ -326,6 +332,7 @@ ts->pids[pid] = filter; filter->type = MPEGTS_SECTION; filter->pid = pid; + filter->es_id = -1; filter->last_cc = -1; sec = &filter->u.section_filter; sec->section_cb = section_cb; @@ -354,6 +361,7 @@ ts->pids[pid] = filter; filter->type = MPEGTS_PES; filter->pid = pid; + filter->es_id = -1; filter->last_cc = -1; pes = &filter->u.pes_filter; pes->pes_cb = pes_cb; @@ -460,7 +468,7 @@ return c; } -/* read and allocate a DVB string preceeded by its length */ +/* read and allocate a DVB string preceded by its length */ static char *getstr8(const uint8_t **pp, const uint8_t *p_end) { int len; @@ -542,6 +550,8 @@ { 0x84, AVMEDIA_TYPE_AUDIO, CODEC_ID_EAC3 }, { 0x85, AVMEDIA_TYPE_AUDIO, CODEC_ID_DTS }, /* DTS HD */ { 0x86, AVMEDIA_TYPE_AUDIO, CODEC_ID_DTS }, /* DTS HD MASTER*/ + { 0xa1, AVMEDIA_TYPE_AUDIO, CODEC_ID_EAC3 }, /* E-AC3 Secondary Audio */ + { 0xa2, AVMEDIA_TYPE_AUDIO, CODEC_ID_DTS }, /* DTS Express Secondary Audio */ { 0x90, AVMEDIA_TYPE_SUBTITLE, CODEC_ID_HDMV_PGS_SUBTITLE }, { 0 }, }; @@ -620,12 +630,13 @@ return AVERROR(ENOMEM); memcpy(sub_pes, pes, sizeof(*sub_pes)); - sub_st = av_new_stream(pes->stream, pes->pid); + sub_st = avformat_new_stream(pes->stream, NULL); if (!sub_st) { av_free(sub_pes); return AVERROR(ENOMEM); } + sub_st->id = pes->pid; av_set_pts_info(sub_st, 33, 1, 90000); sub_st->priv_data = sub_pes; sub_st->codec->codec_type = AVMEDIA_TYPE_AUDIO; @@ -678,6 +689,83 @@ pes->flags = 0; } +static uint64_t get_bits64(GetBitContext *gb, int bits) +{ + uint64_t ret = 0; + while (bits > 17) { + ret <<= 17; + ret |= get_bits(gb, 17); + bits -= 17; + } + ret <<= bits; + ret |= get_bits(gb, bits); + return ret; +} + +static int read_sl_header(PESContext *pes, SLConfigDescr *sl, const uint8_t *buf, int buf_size) +{ + GetBitContext gb; + int au_start_flag = 0, au_end_flag = 0, ocr_flag = 0, idle_flag = 0; + int padding_flag = 0, padding_bits = 0, inst_bitrate_flag = 0; + int dts_flag = -1, cts_flag = -1; + int64_t dts = AV_NOPTS_VALUE, cts = AV_NOPTS_VALUE; + init_get_bits(&gb, buf, buf_size*8); + + if (sl->use_au_start) + au_start_flag = get_bits1(&gb); + if (sl->use_au_end) + au_end_flag = get_bits1(&gb); + if (!sl->use_au_start && !sl->use_au_end) + au_start_flag = au_end_flag = 1; + if (sl->ocr_len > 0) + ocr_flag = get_bits1(&gb); + if (sl->use_idle) + idle_flag = get_bits1(&gb); + if (sl->use_padding) + padding_flag = get_bits1(&gb); + if (padding_flag) + padding_bits = get_bits(&gb, 3); + + if (!idle_flag && (!padding_flag || padding_bits != 0)) { + if (sl->packet_seq_num_len) + skip_bits_long(&gb, sl->packet_seq_num_len); + if (sl->degr_prior_len) + if (get_bits1(&gb)) + skip_bits(&gb, sl->degr_prior_len); + if (ocr_flag) + skip_bits_long(&gb, sl->ocr_len); + if (au_start_flag) { + if (sl->use_rand_acc_pt) + get_bits1(&gb); + if (sl->au_seq_num_len > 0) + skip_bits_long(&gb, sl->au_seq_num_len); + if (sl->use_timestamps) { + dts_flag = get_bits1(&gb); + cts_flag = get_bits1(&gb); + } + } + if (sl->inst_bitrate_len) + inst_bitrate_flag = get_bits1(&gb); + if (dts_flag == 1) + dts = get_bits64(&gb, sl->timestamp_len); + if (cts_flag == 1) + cts = get_bits64(&gb, sl->timestamp_len); + if (sl->au_len > 0) + skip_bits_long(&gb, sl->au_len); + if (inst_bitrate_flag) + skip_bits_long(&gb, sl->inst_bitrate_len); + } + + if (dts != AV_NOPTS_VALUE) + pes->dts = dts; + if (cts != AV_NOPTS_VALUE) + pes->pts = cts; + + av_set_pts_info(pes->st, sl->timestamp_len, 1, sl->timestamp_res); + + return (get_bits_count(&gb) + 7) >> 3; +} + /* return non zero if a packet could be constructed */ static int mpegts_push_data(MpegTSFilter *filter, const uint8_t *buf, int buf_size, int is_start, @@ -726,9 +814,10 @@ /* stream not present in PMT */ if (!pes->st) { - pes->st = av_new_stream(ts->stream, pes->pid); + pes->st = avformat_new_stream(ts->stream, NULL); if (!pes->st) return AVERROR(ENOMEM); + pes->st->id = pes->pid; mpegts_set_stream_info(pes->st, pes, 0, 0); } @@ -828,6 +917,12 @@ /* we got the full header. We parse it and get the payload */ pes->state = MPEGTS_PAYLOAD; pes->data_index = 0; + if (pes->stream_type == 0x12) { + int sl_header_bytes = read_sl_header(pes, &pes->sl, p, buf_size); + pes->pes_header_size += sl_header_bytes; + p += sl_header_bytes; + buf_size -= sl_header_bytes; + } } break; case MPEGTS_PAYLOAD: @@ -892,48 +987,289 @@ return pes; } +#define MAX_LEVEL 4 +typedef struct { + AVFormatContext *s; + AVIOContext pb; + Mp4Descr *descr; + Mp4Descr *active_descr; + int descr_count; + int max_descr_count; + int level; +} MP4DescrParseContext; + +static int init_MP4DescrParseContext( + MP4DescrParseContext *d, AVFormatContext *s, const uint8_t *buf, + unsigned size, Mp4Descr *descr, int max_descr_count) +{ + int ret; + if (size > (1<<30)) + return AVERROR_INVALIDDATA; + + if ((ret = ffio_init_context(&d->pb, (unsigned char*)buf, size, 0, + NULL, NULL, NULL, NULL)) < 0) + return ret; + + d->s = s; + d->level = 0; + d->descr_count = 0; + d->descr = descr; + d->active_descr = NULL; + d->max_descr_count = max_descr_count; + + return 0; +} + +static void update_offsets(AVIOContext *pb, int64_t *off, int *len) { + int64_t new_off = avio_tell(pb); + (*len) -= new_off - *off; + *off = new_off; +} + +static int parse_mp4_descr(MP4DescrParseContext *d, int64_t off, int len, + int target_tag); + +static int parse_mp4_descr_arr(MP4DescrParseContext *d, int64_t off, int len) +{ + while (len > 0) { + if (parse_mp4_descr(d, off, len, 0) < 0) + return -1; + update_offsets(&d->pb, &off, &len); + } + return 0; +} + +static int parse_MP4IODescrTag(MP4DescrParseContext *d, int64_t off, int len) +{ + avio_rb16(&d->pb); // ID + avio_r8(&d->pb); + avio_r8(&d->pb); + avio_r8(&d->pb); + avio_r8(&d->pb); + avio_r8(&d->pb); + update_offsets(&d->pb, &off, &len); + return parse_mp4_descr_arr(d, off, len); +} + +static int parse_MP4ODescrTag(MP4DescrParseContext *d, int64_t off, int len) +{ + int id_flags; + if (len < 2) + return 0; + id_flags = avio_rb16(&d->pb); + if (!(id_flags & 0x0020)) { //URL_Flag + update_offsets(&d->pb, &off, &len); + return parse_mp4_descr_arr(d, off, len); //ES_Descriptor[] + } else { + return 0; + } +} + +static int parse_MP4ESDescrTag(MP4DescrParseContext *d, int64_t off, int len) +{ + int es_id = 0; + if (d->descr_count >= d->max_descr_count) + return -1; + ff_mp4_parse_es_descr(&d->pb, &es_id); + d->active_descr = d->descr + (d->descr_count++); + + d->active_descr->es_id = es_id; + update_offsets(&d->pb, &off, &len); + parse_mp4_descr(d, off, len, MP4DecConfigDescrTag); + update_offsets(&d->pb, &off, &len); + if (len > 0) + parse_mp4_descr(d, off, len, MP4SLDescrTag); + d->active_descr = NULL; + return 0; +} + +static int parse_MP4DecConfigDescrTag(MP4DescrParseContext *d, int64_t off, int len) +{ + Mp4Descr *descr = d->active_descr; + if (!descr) + return -1; + d->active_descr->dec_config_descr = av_malloc(len); + if (!descr->dec_config_descr) + return AVERROR(ENOMEM); + descr->dec_config_descr_len = len; + avio_read(&d->pb, descr->dec_config_descr, len); + return 0; +} + +static int parse_MP4SLDescrTag(MP4DescrParseContext *d, int64_t off, int len) +{ + Mp4Descr *descr = d->active_descr; + int predefined; + if (!descr) + return -1; + + predefined = avio_r8(&d->pb); + if (!predefined) { + int lengths; + int flags = avio_r8(&d->pb); + descr->sl.use_au_start = !!(flags & 0x80); + descr->sl.use_au_end = !!(flags & 0x40); + descr->sl.use_rand_acc_pt = !!(flags & 0x20); + descr->sl.use_padding = !!(flags & 0x08); + descr->sl.use_timestamps = !!(flags & 0x04); + descr->sl.use_idle = !!(flags & 0x02); + descr->sl.timestamp_res = avio_rb32(&d->pb); + avio_rb32(&d->pb); + descr->sl.timestamp_len = avio_r8(&d->pb); + descr->sl.ocr_len = avio_r8(&d->pb); + descr->sl.au_len = avio_r8(&d->pb); + descr->sl.inst_bitrate_len = avio_r8(&d->pb); + lengths = avio_rb16(&d->pb); + descr->sl.degr_prior_len = lengths >> 12; + descr->sl.au_seq_num_len = (lengths >> 7) & 0x1f; + descr->sl.packet_seq_num_len = (lengths >> 2) & 0x1f; + } else { + av_log_missing_feature(d->s, "Predefined SLConfigDescriptor\n", 0); + } + return 0; +} + +static int parse_mp4_descr(MP4DescrParseContext *d, int64_t off, int len, + int target_tag) { + int tag; + int len1 = ff_mp4_read_descr(d->s, &d->pb, &tag); + update_offsets(&d->pb, &off, &len); + if (len < 0 || len1 > len || len1 <= 0) { + av_log(d->s, AV_LOG_ERROR, "Tag %x length violation new length %d bytes remaining %d\n", tag, len1, len); + return -1; + } + + if (d->level++ >= MAX_LEVEL) { + av_log(d->s, AV_LOG_ERROR, "Maximum MP4 descriptor level exceeded\n"); + goto done; + } + + if (target_tag && tag != target_tag) { + av_log(d->s, AV_LOG_ERROR, "Found tag %x expected %x\n", tag, target_tag); + goto done; + } + + switch (tag) { + case MP4IODescrTag: + parse_MP4IODescrTag(d, off, len1); + break; + case MP4ODescrTag: + parse_MP4ODescrTag(d, off, len1); + break; + case MP4ESDescrTag: + parse_MP4ESDescrTag(d, off, len1); + break; + case MP4DecConfigDescrTag: + parse_MP4DecConfigDescrTag(d, off, len1); + break; + case MP4SLDescrTag: + parse_MP4SLDescrTag(d, off, len1); + break; + } + +done: + d->level--; + avio_seek(&d->pb, off + len1, SEEK_SET); + return 0; +} + static int mp4_read_iods(AVFormatContext *s, const uint8_t *buf, unsigned size, - int *es_id, uint8_t **dec_config_descr, - int *dec_config_descr_size) + Mp4Descr *descr, int *descr_count, int max_descr_count) { + MP4DescrParseContext d; + if (init_MP4DescrParseContext(&d, s, buf, size, descr, max_descr_count) < 0) + return -1; + + parse_mp4_descr(&d, avio_tell(&d.pb), size, MP4IODescrTag); + + *descr_count = d.descr_count; + return 0; +} + +static int mp4_read_od(AVFormatContext *s, const uint8_t *buf, unsigned size, + Mp4Descr *descr, int *descr_count, int max_descr_count) +{ + MP4DescrParseContext d; + if (init_MP4DescrParseContext(&d, s, buf, size, descr, max_descr_count) < 0) + return -1; + + parse_mp4_descr_arr(&d, avio_tell(&d.pb), size); + + *descr_count = d.descr_count; + return 0; +} + +static void m4sl_cb(MpegTSFilter *filter, const uint8_t *section, int section_len) +{ + MpegTSContext *ts = filter->u.section_filter.opaque; + SectionHeader h; + const uint8_t *p, *p_end; AVIOContext pb; - int tag; - unsigned len; + Mp4Descr mp4_descr[MAX_MP4_DESCR_COUNT] = {{ 0 }}; + int mp4_descr_count = 0; + int i, pid; + AVFormatContext *s = ts->stream; - ffio_init_context(&pb, buf, size, 0, NULL, NULL, NULL, NULL); + p_end = section + section_len - 4; + p = section; + if (parse_section_header(&h, &p, p_end) < 0) + return; + if (h.tid != M4OD_TID) + return; + + mp4_read_od(s, p, (unsigned)(p_end - p), mp4_descr, &mp4_descr_count, MAX_MP4_DESCR_COUNT); - len = ff_mp4_read_descr(s, &pb, &tag); - if (tag == MP4IODescrTag) { - avio_rb16(&pb); // ID - avio_r8(&pb); - avio_r8(&pb); - avio_r8(&pb); - avio_r8(&pb); - avio_r8(&pb); - len = ff_mp4_read_descr(s, &pb, &tag); - if (tag == MP4ESDescrTag) { - ff_mp4_parse_es_descr(&pb, es_id); - av_dlog(s, "ES_ID %#x\n", *es_id); - len = ff_mp4_read_descr(s, &pb, &tag); - if (tag == MP4DecConfigDescrTag) { - *dec_config_descr = av_malloc(len); - if (!*dec_config_descr) - return AVERROR(ENOMEM); - *dec_config_descr_size = len; - avio_read(&pb, *dec_config_descr, len); + for (pid = 0; pid < NB_PID_MAX; pid++) { + if (!ts->pids[pid]) + continue; + for (i = 0; i < mp4_descr_count; i++) { + PESContext *pes; + AVStream *st; + if (ts->pids[pid]->es_id != mp4_descr[i].es_id) + continue; + if (!(ts->pids[pid] && ts->pids[pid]->type == MPEGTS_PES)) { + av_log(s, AV_LOG_ERROR, "pid %x is not PES\n", pid); + continue; + } + pes = ts->pids[pid]->u.pes_filter.opaque; + st = pes->st; + if (!st) { + continue; + } + + pes->sl = mp4_descr[i].sl; + + ffio_init_context(&pb, mp4_descr[i].dec_config_descr, + mp4_descr[i].dec_config_descr_len, 0, NULL, NULL, NULL, NULL); + ff_mp4_read_dec_config_descr(s, st, &pb); + if (st->codec->codec_id == CODEC_ID_AAC && + st->codec->extradata_size > 0) + st->need_parsing = 0; + if (st->codec->codec_id == CODEC_ID_H264 && + st->codec->extradata_size > 0) + st->need_parsing = 0; + + if (st->codec->codec_id <= CODEC_ID_NONE) { + } else if (st->codec->codec_id < CODEC_ID_FIRST_AUDIO) { + st->codec->codec_type = AVMEDIA_TYPE_VIDEO; + } else if (st->codec->codec_id < CODEC_ID_FIRST_SUBTITLE) { + st->codec->codec_type = AVMEDIA_TYPE_AUDIO; + } else if (st->codec->codec_id < CODEC_ID_FIRST_UNKNOWN) { + st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE; } } } - return 0; + for (i = 0; i < mp4_descr_count; i++) + av_free(mp4_descr[i].dec_config_descr); } int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type, const uint8_t **pp, const uint8_t *desc_list_end, - int mp4_dec_config_descr_len, int mp4_es_id, int pid, - uint8_t *mp4_dec_config_descr) + Mp4Descr *mp4_descr, int mp4_descr_count, int pid, + MpegTSContext *ts) { const uint8_t *desc_end; - int desc_len, desc_tag; + int desc_len, desc_tag, desc_es_id; char language[252]; int i; @@ -954,17 +1290,37 @@ mpegts_find_stream_type(st, desc_tag, DESC_types); switch(desc_tag) { - case 0x1F: /* FMC descriptor */ - get16(pp, desc_end); - if (st->codec->codec_id == CODEC_ID_AAC_LATM && - mp4_dec_config_descr_len && mp4_es_id == pid) { + case 0x1E: /* SL descriptor */ + desc_es_id = get16(pp, desc_end); + if (ts && ts->pids[pid]) + ts->pids[pid]->es_id = desc_es_id; + for (i = 0; i < mp4_descr_count; i++) + if (mp4_descr[i].dec_config_descr_len && + mp4_descr[i].es_id == desc_es_id) { AVIOContext pb; - ffio_init_context(&pb, mp4_dec_config_descr, - mp4_dec_config_descr_len, 0, NULL, NULL, NULL, NULL); + ffio_init_context(&pb, mp4_descr[i].dec_config_descr, + mp4_descr[i].dec_config_descr_len, 0, NULL, NULL, NULL, NULL); ff_mp4_read_dec_config_descr(fc, st, &pb); if (st->codec->codec_id == CODEC_ID_AAC && st->codec->extradata_size > 0) st->need_parsing = 0; + if (st->codec->codec_id == CODEC_ID_MPEG4SYSTEMS) + mpegts_open_section_filter(ts, pid, m4sl_cb, ts, 1); + } + break; + case 0x1F: /* FMC descriptor */ + get16(pp, desc_end); + if (mp4_descr_count > 0 && (st->codec->codec_id == CODEC_ID_AAC_LATM || st->request_probe>0) && + mp4_descr->dec_config_descr_len && mp4_descr->es_id == pid) { + AVIOContext pb; + ffio_init_context(&pb, mp4_descr->dec_config_descr, + mp4_descr->dec_config_descr_len, 0, NULL, NULL, NULL, NULL); + ff_mp4_read_dec_config_descr(fc, st, &pb); + if (st->codec->codec_id == CODEC_ID_AAC && + st->codec->extradata_size > 0){ + st->request_probe= st->need_parsing = 0; + st->codec->codec_type= AVMEDIA_TYPE_AUDIO; + } } break; case 0x56: /* DVB teletext descriptor */ @@ -1047,9 +1403,10 @@ int program_info_length, pcr_pid, pid, stream_type; int desc_list_len; uint32_t prog_reg_desc = 0; /* registration descriptor */ - uint8_t *mp4_dec_config_descr = NULL; - int mp4_dec_config_descr_len = 0; - int mp4_es_id = 0; + + Mp4Descr mp4_descr[MAX_MP4_DESCR_COUNT] = {{ 0 }}; + int mp4_descr_count = 0; + int i; av_dlog(ts->stream, "PMT: len %i\n", section_len); hex_dump_debug(ts->stream, (uint8_t *)section, section_len); @@ -1092,8 +1449,8 @@ get8(&p, p_end); // scope get8(&p, p_end); // label len -= 2; - mp4_read_iods(ts->stream, p, len, &mp4_es_id, - &mp4_dec_config_descr, &mp4_dec_config_descr_len); + mp4_read_iods(ts->stream, p, len, mp4_descr + mp4_descr_count, + &mp4_descr_count, MAX_MP4_DESCR_COUNT); } else if (tag == 0x05 && len >= 4) { // registration descriptor prog_reg_desc = bytestream_get_le32(&p); len -= 4; @@ -1106,10 +1463,11 @@ // stop parsing after pmt, we found header if (!ts->stream->nb_streams) - ts->stop_parse = 1; + ts->stop_parse = 2; for(;;) { st = 0; + pes = NULL; stream_type = get8(&p, p_end); if (stream_type < 0) break; @@ -1117,23 +1475,36 @@ if (pid < 0) break; - /* now create ffmpeg stream */ + /* now create stream */ if (ts->pids[pid] && ts->pids[pid]->type == MPEGTS_PES) { pes = ts->pids[pid]->u.pes_filter.opaque; - if (!pes->st) - pes->st = av_new_stream(pes->stream, pes->pid); + if (!pes->st) { + pes->st = avformat_new_stream(pes->stream, NULL); + pes->st->id = pes->pid; + } st = pes->st; - } else { + } else if (stream_type != 0x13) { if (ts->pids[pid]) mpegts_close_filter(ts, ts->pids[pid]); //wrongly added sdt filter probably pes = add_pes_stream(ts, pid, pcr_pid); - if (pes) - st = av_new_stream(pes->stream, pes->pid); + if (pes) { + st = avformat_new_stream(pes->stream, NULL); + st->id = pes->pid; + } + } else { + int idx = ff_find_stream_index(ts->stream, pid); + if (idx >= 0) { + st = ts->stream->streams[idx]; + } else { + st = avformat_new_stream(pes->stream, NULL); + st->id = pid; + st->codec->codec_type = AVMEDIA_TYPE_DATA; + } } if (!st) goto out; - if (!pes->stream_type) + if (pes && !pes->stream_type) mpegts_set_stream_info(st, pes, stream_type, prog_reg_desc); add_pid_to_pmt(ts, h->id, pid); @@ -1148,10 +1519,10 @@ break; for(;;) { if (ff_parse_mpeg2_descriptor(ts->stream, st, stream_type, &p, desc_list_end, - mp4_dec_config_descr_len, mp4_es_id, pid, mp4_dec_config_descr) < 0) + mp4_descr, mp4_descr_count, pid, ts) < 0) break; - if (prog_reg_desc == AV_RL32("HDMV") && stream_type == 0x83 && pes->sub_st) { + if (pes && prog_reg_desc == AV_RL32("HDMV") && stream_type == 0x83 && pes->sub_st) { ff_program_add_stream_index(ts->stream, h->id, pes->sub_st->index); pes->sub_st->codec->codec_tag = st->codec->codec_tag; } @@ -1160,7 +1531,8 @@ } out: - av_free(mp4_dec_config_descr); + for (i = 0; i < mp4_descr_count; i++) + av_free(mp4_descr[i].dec_config_descr); } static void pat_cb(MpegTSFilter *filter, const uint8_t *section, int section_len) @@ -1327,7 +1699,7 @@ tss->last_cc = cc; if (!cc_ok) { - av_log(ts->stream, AV_LOG_WARNING, + av_log(ts->stream, AV_LOG_DEBUG, "Continuity check failed for pid %d expected %d got %d\n", pid, expected_cc, cc); if(tss->type == MPEGTS_PES) { @@ -1340,7 +1712,7 @@ return 0; p = packet + 4; if (has_adaptation) { - /* skip adapation field */ + /* skip adaptation field */ p += p[0] + 1; } /* if past the end of packet, ignore */ @@ -1418,7 +1790,7 @@ len = avio_read(pb, buf, TS_PACKET_SIZE); if (len != TS_PACKET_SIZE) return len < 0 ? len : AVERROR_EOF; - /* check paquet sync byte */ + /* check packet sync byte */ if (buf[0] != 0x47) { /* find a new packet start */ avio_seek(pb, -TS_PACKET_SIZE, SEEK_CUR); @@ -1462,11 +1834,15 @@ ts->stop_parse = 0; packet_num = 0; for(;;) { - if (ts->stop_parse>0) - break; packet_num++; - if (nb_packets != 0 && packet_num >= nb_packets) + if (nb_packets != 0 && packet_num >= nb_packets || + ts->stop_parse > 1) { + ret = AVERROR(EAGAIN); + break; + } + if (ts->stop_parse > 0) break; + ret = read_packet(s, packet, ts->raw_packet_size); if (ret != 0) break; @@ -1562,9 +1938,12 @@ if (s->iformat == &ff_mpegts_demuxer) { /* normal demux */ - /* first do a scaning to get all the services */ - if (pb->seekable && avio_seek(pb, pos, SEEK_SET) < 0) - av_log(s, AV_LOG_ERROR, "Unable to seek back to the start\n"); + /* first do a scanning to get all the services */ + /* NOTE: We attempt to seek on non-seekable files as well, as the + * probe buffer usually is big enough. Only warn if the seek failed + * on files where the seek should work. */ + if (avio_seek(pb, pos, SEEK_SET) < 0) + av_log(s, pb->seekable ? AV_LOG_ERROR : AV_LOG_INFO, "Unable to seek back to the start\n"); mpegts_open_section_filter(ts, SDT_PID, sdt_cb, ts, 1); @@ -1587,7 +1966,7 @@ /* only read packets */ - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) goto fail; av_set_pts_info(st, 60, 1, 27000000); @@ -1731,7 +2110,7 @@ if (avio_read(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE) return AV_NOPTS_VALUE; if (buf[0] != 0x47) { - if (mpegts_resync(s->pb) < 0) + if (mpegts_resync(s) < 0) return AV_NOPTS_VALUE; pos = url_ftell(s->pb); continue; @@ -1747,6 +2126,37 @@ return AV_NOPTS_VALUE; } +static int64_t mpegts_get_dts(AVFormatContext *s, int stream_index, + int64_t *ppos, int64_t pos_limit) +{ + MpegTSContext *ts = s->priv_data; + int64_t pos, timestamp; + pos = ((*ppos + ts->raw_packet_size - 1 - ts->pos47) / ts->raw_packet_size) * ts->raw_packet_size + ts->pos47; + ff_read_frame_flush(s); + if (avio_seek(s->pb, pos, SEEK_SET) < 0) + return AV_NOPTS_VALUE; + while(pos < pos_limit) { + int ret; + AVPacket pkt; + av_init_packet(&pkt); + ret= av_read_frame(s, &pkt); + if(ret < 0) + return AV_NOPTS_VALUE; + av_free_packet(&pkt); + if(pkt.dts != AV_NOPTS_VALUE && pkt.pos >= 0){ + ff_reduce_index(s, pkt.stream_index); + av_add_index_entry(s->streams[pkt.stream_index], pkt.pos, pkt.dts, 0, 0, AVINDEX_KEYFRAME /* FIXME keyframe? */); + if(pkt.stream_index == stream_index){ + *ppos= pkt.pos; + return pkt.dts; + } + } + pos = pkt.pos; + } + + return AV_NOPTS_VALUE; +} + #ifdef USE_SYNCPOINT_SEARCH static int read_seek2(AVFormatContext *s, @@ -1790,7 +2200,7 @@ ts_adj = target_ts; stream_index_gen_search = stream_index; } - pos = av_gen_search(s, stream_index_gen_search, ts_adj, + pos = ff_gen_search(s, stream_index_gen_search, ts_adj, 0, INT64_MAX, -1, AV_NOPTS_VALUE, AV_NOPTS_VALUE, @@ -1831,31 +2241,6 @@ return ret; } -#else - -static int read_seek(AVFormatContext *s, int stream_index, int64_t target_ts, int flags){ - MpegTSContext *ts = s->priv_data; - uint8_t buf[TS_PACKET_SIZE]; - int64_t pos; - - if(av_seek_frame_binary(s, stream_index, target_ts, flags) < 0) - return -1; - - pos= avio_tell(s->pb); - - for(;;) { - avio_seek(s->pb, pos, SEEK_SET); - if (avio_read(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE) - return -1; -// pid = AV_RB16(buf + 1) & 0x1fff; - if(buf[1] & 0x40) break; - pos += ts->raw_packet_size; - } - avio_seek(s->pb, pos, SEEK_SET); - - return 0; -} - #endif /**************************************************************/ @@ -1887,10 +2272,8 @@ len1 = len; ts->pkt = pkt; - ts->stop_parse = 0; for(;;) { - if (ts->stop_parse>0) - break; + ts->stop_parse = 0; if (len < TS_PACKET_SIZE) return -1; if (buf[0] != 0x47) { @@ -1900,6 +2283,8 @@ handle_packet(ts, buf); buf += TS_PACKET_SIZE; len -= TS_PACKET_SIZE; + if (ts->stop_parse == 1) + break; } } return len1 - len; @@ -1922,8 +2307,7 @@ .read_header = mpegts_read_header, .read_packet = mpegts_read_packet, .read_close = mpegts_read_close, - .read_seek = read_seek, - .read_timestamp = mpegts_get_pcr, + .read_timestamp = mpegts_get_dts, .flags = AVFMT_SHOW_IDS|AVFMT_TS_DISCONT, #ifdef USE_SYNCPOINT_SEARCH .read_seek2 = read_seek2, @@ -1937,8 +2321,7 @@ .read_header = mpegts_read_header, .read_packet = mpegts_raw_read_packet, .read_close = mpegts_read_close, - .read_seek = read_seek, - .read_timestamp = mpegts_get_pcr, + .read_timestamp = mpegts_get_dts, .flags = AVFMT_SHOW_IDS|AVFMT_TS_DISCONT, #ifdef USE_SYNCPOINT_SEARCH .read_seek2 = read_seek2, diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mpegtsenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mpegtsenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mpegtsenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mpegtsenc.c 2011-11-04 12:38:27.000000000 +0000 @@ -24,6 +24,7 @@ #include "libavutil/dict.h" #include "libavutil/mathematics.h" #include "libavutil/opt.h" +#include "libavutil/avassert.h" #include "libavcodec/mpegvideo.h" #include "avformat.h" #include "internal.h" @@ -80,18 +81,19 @@ static const AVOption options[] = { { "mpegts_transport_stream_id", "Set transport_stream_id field.", - offsetof(MpegTSWrite, transport_stream_id), FF_OPT_TYPE_INT, {.dbl = 0x0001 }, 0x0001, 0xffff, AV_OPT_FLAG_ENCODING_PARAM}, + offsetof(MpegTSWrite, transport_stream_id), AV_OPT_TYPE_INT, {.dbl = 0x0001 }, 0x0001, 0xffff, AV_OPT_FLAG_ENCODING_PARAM}, { "mpegts_original_network_id", "Set original_network_id field.", - offsetof(MpegTSWrite, original_network_id), FF_OPT_TYPE_INT, {.dbl = 0x0001 }, 0x0001, 0xffff, AV_OPT_FLAG_ENCODING_PARAM}, + offsetof(MpegTSWrite, original_network_id), AV_OPT_TYPE_INT, {.dbl = 0x0001 }, 0x0001, 0xffff, AV_OPT_FLAG_ENCODING_PARAM}, { "mpegts_service_id", "Set service_id field.", - offsetof(MpegTSWrite, service_id), FF_OPT_TYPE_INT, {.dbl = 0x0001 }, 0x0001, 0xffff, AV_OPT_FLAG_ENCODING_PARAM}, + offsetof(MpegTSWrite, service_id), AV_OPT_TYPE_INT, {.dbl = 0x0001 }, 0x0001, 0xffff, AV_OPT_FLAG_ENCODING_PARAM}, { "mpegts_pmt_start_pid", "Set the first pid of the PMT.", - offsetof(MpegTSWrite, pmt_start_pid), FF_OPT_TYPE_INT, {.dbl = 0x1000 }, 0x0010, 0x1f00, AV_OPT_FLAG_ENCODING_PARAM}, + offsetof(MpegTSWrite, pmt_start_pid), AV_OPT_TYPE_INT, {.dbl = 0x1000 }, 0x0010, 0x1f00, AV_OPT_FLAG_ENCODING_PARAM}, { "mpegts_start_pid", "Set the first pid.", - offsetof(MpegTSWrite, start_pid), FF_OPT_TYPE_INT, {.dbl = 0x0100 }, 0x0100, 0x0f00, AV_OPT_FLAG_ENCODING_PARAM}, + offsetof(MpegTSWrite, start_pid), AV_OPT_TYPE_INT, {.dbl = 0x0100 }, 0x0100, 0x0f00, AV_OPT_FLAG_ENCODING_PARAM}, {"mpegts_m2ts_mode", "Enable m2ts mode.", - offsetof(MpegTSWrite, m2ts_mode), FF_OPT_TYPE_INT, {.dbl = -1 }, + offsetof(MpegTSWrite, m2ts_mode), AV_OPT_TYPE_INT, {.dbl = -1 }, -1,1, AV_OPT_FLAG_ENCODING_PARAM}, + { "muxrate", NULL, offsetof(MpegTSWrite, mux_rate), AV_OPT_TYPE_INT, {1}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, { NULL }, }; @@ -291,6 +293,12 @@ /* write optional descriptors here */ switch(st->codec->codec_type) { case AVMEDIA_TYPE_AUDIO: + if(st->codec->codec_id==CODEC_ID_EAC3){ + *q++=0x7a; // EAC3 descriptor see A038 DVB SI + *q++=1; // 1 byte, all flags sets to 0 + *q++=0; // omit all fields... + } + if (lang) { char *p; char *next = lang->value; @@ -562,7 +570,10 @@ service->pcr_pid = ts_st->pid; } - ts->mux_rate = s->mux_rate ? s->mux_rate : 1; +#if FF_API_MUXRATE + if (s->mux_rate) + ts->mux_rate = s->mux_rate; +#endif if (ts->mux_rate > 1) { service->pcr_packet_period = (ts->mux_rate * PCR_RETRANS_TIME) / @@ -974,7 +985,7 @@ } do { - p = ff_find_start_code(p, buf_end, &state); + p = avpriv_mpv_find_start_code(p, buf_end, &state); //av_log(s, AV_LOG_INFO, "nal %d\n", state & 0x1f); } while (p < buf_end && (state & 0x1f) != 9 && (state & 0x1f) != 5 && (state & 0x1f) != 1); @@ -1018,20 +1029,21 @@ } } - if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO) { - // for video and subtitle, write a single pes packet - mpegts_write_pes(s, st, buf, size, pts, dts, pkt->flags & AV_PKT_FLAG_KEY); - av_free(data); - return 0; - } - - if (ts_st->payload_index + size > DEFAULT_PES_PAYLOAD_SIZE) { + if (ts_st->payload_index && ts_st->payload_index + size > DEFAULT_PES_PAYLOAD_SIZE) { mpegts_write_pes(s, st, ts_st->payload, ts_st->payload_index, ts_st->payload_pts, ts_st->payload_dts, ts_st->payload_flags & AV_PKT_FLAG_KEY); ts_st->payload_index = 0; } + if (st->codec->codec_type != AVMEDIA_TYPE_AUDIO || size > DEFAULT_PES_PAYLOAD_SIZE) { + av_assert0(!ts_st->payload_index); + // for video and subtitle, write a single pes packet + mpegts_write_pes(s, st, buf, size, pts, dts, pkt->flags & AV_PKT_FLAG_KEY); + av_free(data); + return 0; + } + if (!ts_st->payload_index) { ts_st->payload_pts = pts; ts_st->payload_dts = dts; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mpegts.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mpegts.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mpegts.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mpegts.h 2011-11-04 12:38:27.000000000 +0000 @@ -39,6 +39,7 @@ /* table ids */ #define PAT_TID 0x00 #define PMT_TID 0x02 +#define M4OD_TID 0x05 #define SDT_TID 0x42 #define STREAM_TYPE_VIDEO_MPEG1 0x01 @@ -64,6 +65,30 @@ const uint8_t *buf, int len); void ff_mpegts_parse_close(MpegTSContext *ts); +typedef struct { + int use_au_start; + int use_au_end; + int use_rand_acc_pt; + int use_padding; + int use_timestamps; + int use_idle; + int timestamp_res; + int timestamp_len; + int ocr_len; + int au_len; + int inst_bitrate_len; + int degr_prior_len; + int au_seq_num_len; + int packet_seq_num_len; +} SLConfigDescr; + +typedef struct { + int es_id; + int dec_config_descr_len; + uint8_t *dec_config_descr; + SLConfigDescr sl; +} Mp4Descr; + /** * Parse an MPEG-2 descriptor * @param[in] fc Format context (used for logging only) @@ -79,7 +104,7 @@ */ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, AVStream *st, int stream_type, const uint8_t **pp, const uint8_t *desc_list_end, - int mp4_dec_config_descr_len, int mp4_es_id, int pid, - uint8_t *mp4_dec_config_descr); + Mp4Descr *mp4_descr, int mp4_descr_count, int pid, + MpegTSContext *ts); #endif /* AVFORMAT_MPEGTS_H */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/msnwc_tcp.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/msnwc_tcp.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/msnwc_tcp.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/msnwc_tcp.c 2011-11-04 12:38:27.000000000 +0000 @@ -75,7 +75,7 @@ AVCodecContext *codec; AVStream *st; - st = av_new_stream(ctx, 0); + st = avformat_new_stream(ctx, NULL); if(!st) return AVERROR(ENOMEM); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mtv.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mtv.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mtv.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mtv.c 2011-11-04 12:38:27.000000000 +0000 @@ -32,8 +32,6 @@ #define MTV_HEADER_SIZE 512 #define MTV_AUDIO_PADDING_SIZE 12 #define AUDIO_SAMPLING_RATE 44100 -#define VIDEO_SID 0 -#define AUDIO_SID 1 typedef struct MTVDemuxContext { @@ -118,7 +116,7 @@ // video - raw rgb565 - st = av_new_stream(s, VIDEO_SID); + st = avformat_new_stream(s, NULL); if(!st) return AVERROR(ENOMEM); @@ -134,7 +132,7 @@ // audio - mp3 - st = av_new_stream(s, AUDIO_SID); + st = avformat_new_stream(s, NULL); if(!st) return AVERROR(ENOMEM); @@ -171,7 +169,7 @@ return ret; pkt->pos -= MTV_AUDIO_PADDING_SIZE; - pkt->stream_index = AUDIO_SID; + pkt->stream_index = 1; }else { @@ -190,7 +188,7 @@ for(i=0;iimg_segment_size/2;i++) *((uint16_t *)pkt->data+i) = av_bswap16(*((uint16_t *)pkt->data+i)); #endif - pkt->stream_index = VIDEO_SID; + pkt->stream_index = 0; } return ret; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mvi.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mvi.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mvi.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mvi.c 2011-11-04 12:38:27.000000000 +0000 @@ -42,11 +42,11 @@ AVStream *ast, *vst; unsigned int version, frames_count, msecs_per_frame, player_version; - ast = av_new_stream(s, 0); + ast = avformat_new_stream(s, NULL); if (!ast) return AVERROR(ENOMEM); - vst = av_new_stream(s, 0); + vst = avformat_new_stream(s, NULL); if (!vst) return AVERROR(ENOMEM); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mxfdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mxfdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mxfdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mxfdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -49,6 +49,7 @@ #include "libavutil/mathematics.h" #include "libavcodec/bytestream.h" #include "avformat.h" +#include "internal.h" #include "mxf.h" typedef enum { @@ -75,7 +76,6 @@ int complete; MXFPartitionType type; uint64_t previous_partition; - uint64_t footer_partition; int index_sid; int body_sid; } MXFPartition; @@ -166,6 +166,7 @@ struct AVAES *aesc; uint8_t *local_tags; int local_tags_count; + uint64_t footer_partition; } MXFContext; enum MXFWrappingScheme { @@ -256,12 +257,13 @@ if (length > 61444) /* worst case PAL 1920 samples 8 channels */ return -1; - av_new_packet(pkt, length); - avio_read(pb, pkt->data, length); + length = av_get_packet(pb, pkt, length); + if (length < 0) + return length; data_ptr = pkt->data; end_ptr = pkt->data + length; buf_ptr = pkt->data + 4; /* skip SMPTE 331M header */ - for (; buf_ptr < end_ptr; ) { + for (; buf_ptr + st->codec->channels*4 < end_ptr; ) { for (i = 0; i < st->codec->channels; i++) { uint32_t sample = bytestream_get_le32(&buf_ptr); if (st->codec->bits_per_coded_sample == 24) @@ -271,7 +273,7 @@ } buf_ptr += 32 - st->codec->channels*4; // always 8 channels stored SMPTE 331M } - pkt->size = data_ptr - pkt->data; + av_shrink_packet(pkt, data_ptr - pkt->data); return 0; } @@ -323,12 +325,16 @@ if (memcmp(tmpbuf, checkv, 16)) av_log(s, AV_LOG_ERROR, "probably incorrect decryption key\n"); size -= 32; - av_get_packet(pb, pkt, size); + size = av_get_packet(pb, pkt, size); + if (size < 0) + return size; + else if (size < plaintext_size) + return AVERROR_INVALIDDATA; size -= plaintext_size; if (mxf->aesc) av_aes_crypt(mxf->aesc, &pkt->data[plaintext_size], &pkt->data[plaintext_size], size >> 4, ivec, 1); - pkt->size = orig_size; + av_shrink_packet(pkt, orig_size); pkt->stream_index = index; avio_skip(pb, end - avio_tell(pb)); return 0; @@ -365,8 +371,11 @@ av_log(s, AV_LOG_ERROR, "error reading D-10 aes3 frame\n"); return -1; } - } else - av_get_packet(s->pb, pkt, klv.length); + } else { + int ret = av_get_packet(s->pb, pkt, klv.length); + if (ret < 0) + return ret; + } pkt->stream_index = index; pkt->pos = klv.offset; return 0; @@ -402,6 +411,7 @@ MXFContext *mxf = arg; MXFPartition *partition; UID op; + uint64_t footer_partition; if (mxf->partitions_count+1 >= UINT_MAX / sizeof(*mxf->partitions)) return AVERROR(ENOMEM); @@ -432,16 +442,26 @@ partition->complete = uid[14] > 2; avio_skip(pb, 16); partition->previous_partition = avio_rb64(pb); - partition->footer_partition = avio_rb64(pb); + footer_partition = avio_rb64(pb); avio_skip(pb, 16); partition->index_sid = avio_rb32(pb); avio_skip(pb, 8); partition->body_sid = avio_rb32(pb); avio_read(pb, op, sizeof(UID)); + /* some files don'thave FooterPartition set in every partition */ + if (footer_partition) { + if (mxf->footer_partition && mxf->footer_partition != footer_partition) { + av_log(mxf->fc, AV_LOG_ERROR, "inconsistent FooterPartition value: %li != %li\n", + mxf->footer_partition, footer_partition); + } else { + mxf->footer_partition = footer_partition; + } + } + av_dlog(mxf->fc, "PartitionPack: PreviousPartition = 0x%lx, " "FooterPartition = 0x%lx, IndexSID = %i, BodySID = %i\n", - partition->previous_partition, partition->footer_partition, + partition->previous_partition, footer_partition, partition->index_sid, partition->body_sid); if (op[12] == 1 && op[13] == 1) mxf->op = OP1a; @@ -833,11 +853,12 @@ if (!source_track) continue; - st = av_new_stream(mxf->fc, source_track->track_id); + st = avformat_new_stream(mxf->fc, NULL); if (!st) { av_log(mxf->fc, AV_LOG_ERROR, "could not allocate stream\n"); return -1; } + st->id = source_track->track_id; st->priv_data = source_track; st->duration = component->duration; if (st->duration == -1) @@ -1121,7 +1142,7 @@ seconds = av_rescale(sample_time, st->time_base.num, st->time_base.den); if (avio_seek(s->pb, (s->bit_rate * seconds) >> 3, SEEK_SET) < 0) return -1; - av_update_cur_dts(s, st, sample_time); + ff_update_cur_dts(s, st, sample_time); return 0; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mxfenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mxfenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mxfenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mxfenc.c 2011-11-04 12:38:27.000000000 +0000 @@ -1871,7 +1871,7 @@ mxf_interleave_get_packet, mxf_compare_timestamps); } -static const AVClass class = { +static const AVClass mxf_class = { .class_name = "mxf", .item_name = av_default_item_name, .version = LIBAVUTIL_VERSION_INT, @@ -1881,6 +1881,16 @@ }, }; +static const AVClass mxf_d10_class = { + .class_name = "mxf_d10", + .item_name = av_default_item_name, + .version = LIBAVUTIL_VERSION_INT, + .option = (const AVOption[]){ + {TIMECODE_OPT(MXFContext, AV_OPT_FLAG_ENCODING_PARAM)}, + {NULL} + }, +}; + AVOutputFormat ff_mxf_muxer = { .name = "mxf", .long_name = NULL_IF_CONFIG_SMALL("Material eXchange Format"), @@ -1894,7 +1904,7 @@ .write_trailer = mxf_write_footer, .flags = AVFMT_NOTIMESTAMPS, .interleave_packet = mxf_interleave, - .priv_class = &class, + .priv_class = &mxf_class, }; AVOutputFormat ff_mxf_d10_muxer = { @@ -1909,5 +1919,5 @@ .write_trailer = mxf_write_footer, .flags = AVFMT_NOTIMESTAMPS, .interleave_packet = mxf_interleave, - .priv_class = &class, + .priv_class = &mxf_d10_class, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mxg.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mxg.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/mxg.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/mxg.c 2011-11-04 12:38:27.000000000 +0000 @@ -24,8 +24,6 @@ #include "avformat.h" #include "avio.h" -#define VIDEO_STREAM_INDEX 0 -#define AUDIO_STREAM_INDEX 1 #define DEFAULT_PACKET_SIZE 1024 #define OVERREAD_SIZE 3 @@ -44,14 +42,14 @@ MXGContext *mxg = s->priv_data; /* video parameters will be extracted from the compressed bitstream */ - video_st = av_new_stream(s, VIDEO_STREAM_INDEX); + video_st = avformat_new_stream(s, NULL); if (!video_st) return AVERROR(ENOMEM); video_st->codec->codec_type = AVMEDIA_TYPE_VIDEO; video_st->codec->codec_id = CODEC_ID_MXPEG; av_set_pts_info(video_st, 64, 1, 1000000); - audio_st = av_new_stream(s, AUDIO_STREAM_INDEX); + audio_st = avformat_new_stream(s, NULL); if (!audio_st) return AVERROR(ENOMEM); audio_st->codec->codec_type = AVMEDIA_TYPE_AUDIO; @@ -166,7 +164,7 @@ } pkt->pts = pkt->dts = mxg->dts; - pkt->stream_index = VIDEO_STREAM_INDEX; + pkt->stream_index = 0; pkt->destruct = NULL; pkt->size = mxg->buffer_ptr - mxg->soi_ptr; pkt->data = mxg->soi_ptr; @@ -204,7 +202,7 @@ if (marker == APP13 && size >= 16) { /* audio data */ /* time (GMT) of first sample in usec since 1970, little-endian */ pkt->pts = pkt->dts = AV_RL64(startmarker_ptr + 8); - pkt->stream_index = AUDIO_STREAM_INDEX; + pkt->stream_index = 1; pkt->destruct = NULL; pkt->size = size - 14; pkt->data = startmarker_ptr + 16; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/ncdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/ncdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/ncdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/ncdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -45,7 +45,7 @@ static int nc_read_header(AVFormatContext *s, AVFormatParameters *ap) { - AVStream *st = av_new_stream(s, 0); + AVStream *st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/nsvdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/nsvdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/nsvdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/nsvdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -438,10 +438,11 @@ nsv->vheight = vwidth; if (vtag != T_NONE) { int i; - st = av_new_stream(s, NSV_ST_VIDEO); + st = avformat_new_stream(s, NULL); if (!st) goto fail; + st->id = NSV_ST_VIDEO; nst = av_mallocz(sizeof(NSVStream)); if (!nst) goto fail; @@ -469,10 +470,11 @@ } if (atag != T_NONE) { #ifndef DISABLE_AUDIO - st = av_new_stream(s, NSV_ST_AUDIO); + st = avformat_new_stream(s, NULL); if (!st) goto fail; + st->id = NSV_ST_AUDIO; nst = av_mallocz(sizeof(NSVStream)); if (!nst) goto fail; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/nutdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/nutdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/nutdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/nutdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -20,7 +20,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include "libavutil/avstring.h" #include "libavutil/bswap.h" #include "libavutil/dict.h" @@ -288,7 +287,7 @@ nut->stream = av_mallocz(sizeof(StreamContext)*stream_count); for(i=0; itime_base_count; - chapter= ff_new_chapter(s, chapter_id, + chapter= avpriv_new_chapter(s, chapter_id, nut->time_base[chapter_start % nut->time_base_count], start, start + chapter_len, NULL); metadata = &chapter->metadata; @@ -459,8 +458,8 @@ set_disposition_bits(s, str_value, stream_id_plus1 - 1); continue; } - if(metadata && strcasecmp(name,"Uses") - && strcasecmp(name,"Depends") && strcasecmp(name,"Replaces")) + if(metadata && av_strcasecmp(name,"Uses") + && av_strcasecmp(name,"Depends") && av_strcasecmp(name,"Replaces")) av_dict_set(metadata, name, str_value, 0); } } @@ -874,16 +873,16 @@ (void **) next_node); av_log(s, AV_LOG_DEBUG, "%"PRIu64"-%"PRIu64" %"PRId64"-%"PRId64"\n", next_node[0]->pos, next_node[1]->pos, next_node[0]->ts , next_node[1]->ts); - pos= av_gen_search(s, -1, dummy.ts, next_node[0]->pos, next_node[1]->pos, next_node[1]->pos, - next_node[0]->ts , next_node[1]->ts, AVSEEK_FLAG_BACKWARD, &ts, nut_read_timestamp); + pos = ff_gen_search(s, -1, dummy.ts, next_node[0]->pos, next_node[1]->pos, next_node[1]->pos, + next_node[0]->ts , next_node[1]->ts, AVSEEK_FLAG_BACKWARD, &ts, nut_read_timestamp); if(!(flags & AVSEEK_FLAG_BACKWARD)){ dummy.pos= pos+16; next_node[1]= &nopts_sp; av_tree_find(nut->syncpoints, &dummy, (void *) ff_nut_sp_pos_cmp, (void **) next_node); - pos2= av_gen_search(s, -2, dummy.pos, next_node[0]->pos , next_node[1]->pos, next_node[1]->pos, - next_node[0]->back_ptr, next_node[1]->back_ptr, flags, &ts, nut_read_timestamp); + pos2 = ff_gen_search(s, -2, dummy.pos, next_node[0]->pos , next_node[1]->pos, next_node[1]->pos, + next_node[0]->back_ptr, next_node[1]->back_ptr, flags, &ts, nut_read_timestamp); if(pos2>=0) pos= pos2; //FIXME dir but I think it does not matter diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/nutenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/nutenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/nutenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/nutenc.c 2011-11-04 12:38:27.000000000 +0000 @@ -59,10 +59,10 @@ else if(sample_rate < (44100 + 48000)/2) sample_rate_index=0; else sample_rate_index=1; - sample_rate= ff_mpa_freq_tab[sample_rate_index] >> (lsf + mpeg25); + sample_rate= avpriv_mpa_freq_tab[sample_rate_index] >> (lsf + mpeg25); for(bitrate_index=2; bitrate_index<30; bitrate_index++){ - frame_size = ff_mpa_bitrate_tab[lsf][layer-1][bitrate_index>>1]; + frame_size = avpriv_mpa_bitrate_tab[lsf][layer-1][bitrate_index>>1]; frame_size = (frame_size * 144000) / (sample_rate << lsf) + (bitrate_index&1); if(frame_size == size) diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/nuv.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/nuv.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/nuv.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/nuv.c 2011-11-04 12:38:27.000000000 +0000 @@ -153,7 +153,7 @@ if (v_packs) { ctx->v_id = stream_nr++; - vst = av_new_stream(s, ctx->v_id); + vst = avformat_new_stream(s, NULL); if (!vst) return AVERROR(ENOMEM); vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; @@ -169,7 +169,7 @@ if (a_packs) { ctx->a_id = stream_nr++; - ast = av_new_stream(s, ctx->a_id); + ast = avformat_new_stream(s, NULL); if (!ast) return AVERROR(ENOMEM); ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/oggdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/oggdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/oggdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/oggdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -32,6 +32,7 @@ #include #include "oggdec.h" #include "avformat.h" +#include "internal.h" #include "vorbiscomment.h" #define MAX_PAGE_SIZE 65307 @@ -171,10 +172,11 @@ os->header = -1; if (new_avstream) { - st = av_new_stream(s, idx); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); + st->id = idx; av_set_pts_info(st, 64, 1, 1000000); } @@ -660,7 +662,7 @@ && !(flags & AVSEEK_FLAG_ANY)) os->keyframe_seek = 1; - ret = av_seek_frame_binary(s, stream_index, timestamp, flags); + ret = ff_seek_frame_binary(s, stream_index, timestamp, flags); os = ogg->streams + stream_index; if (ret < 0) os->keyframe_seek = 0; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/oggenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/oggenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/oggenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/oggenc.c 2011-11-04 12:38:27.000000000 +0000 @@ -72,7 +72,7 @@ static const AVOption options[] = { { "oggpagesize", "Set preferred Ogg page size.", - offsetof(OGGContext, pref_size), FF_OPT_TYPE_INT, {.dbl = 0}, 0, MAX_PAGE_SIZE, AV_OPT_FLAG_ENCODING_PARAM}, + offsetof(OGGContext, pref_size), AV_OPT_TYPE_INT, {.dbl = 0}, 0, MAX_PAGE_SIZE, AV_OPT_FLAG_ENCODING_PARAM}, { NULL }, }; @@ -274,7 +274,7 @@ uint8_t *streaminfo; uint8_t *p; - if (!ff_flac_is_extradata_valid(avctx, &format, &streaminfo)) + if (!avpriv_flac_is_extradata_valid(avctx, &format, &streaminfo)) return -1; // first packet: STREAMINFO @@ -397,7 +397,7 @@ int header_type = st->codec->codec_id == CODEC_ID_VORBIS ? 3 : 0x81; int framing_bit = st->codec->codec_id == CODEC_ID_VORBIS ? 1 : 0; - if (ff_split_xiph_headers(st->codec->extradata, st->codec->extradata_size, + if (avpriv_split_xiph_headers(st->codec->extradata, st->codec->extradata_size, st->codec->codec_id == CODEC_ID_VORBIS ? 30 : 42, oggstream->header, oggstream->header_len) < 0) { av_log(s, AV_LOG_ERROR, "Extradata corrupted\n"); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/oggparsecelt.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/oggparsecelt.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/oggparsecelt.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/oggparsecelt.c 2011-11-04 12:38:27.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Xiph CELT / Opus parser for Ogg + * Xiph CELT parser for Ogg * Copyright (c) 2011 Nicolas George * * This file is part of FFmpeg. diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/oggparsedirac.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/oggparsedirac.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/oggparsedirac.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/oggparsedirac.c 2011-11-04 12:38:27.000000000 +0000 @@ -36,7 +36,7 @@ return 0; init_get_bits(&gb, os->buf + os->pstart + 13, (os->psize - 13) * 8); - if (ff_dirac_parse_sequence_header(st->codec, &gb, &source) < 0) + if (avpriv_dirac_parse_sequence_header(st->codec, &gb, &source) < 0) return -1; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/oggparseflac.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/oggparseflac.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/oggparseflac.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/oggparseflac.c 2011-11-04 12:38:27.000000000 +0000 @@ -55,7 +55,7 @@ if (get_bits_long(&gb, 32) != FLAC_STREAMINFO_SIZE) return -1; - ff_flac_parse_streaminfo(st->codec, &si, streaminfo_start); + avpriv_flac_parse_streaminfo(st->codec, &si, streaminfo_start); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = CODEC_ID_FLAC; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/oggparsespeex.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/oggparsespeex.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/oggparsespeex.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/oggparsespeex.c 2011-11-04 12:38:27.000000000 +0000 @@ -31,6 +31,7 @@ #include "oggdec.h" struct speex_params { + int packet_size; int final_packet_duration; int seq; }; @@ -58,14 +59,10 @@ st->codec->sample_rate = AV_RL32(p + 36); st->codec->channels = AV_RL32(p + 48); - /* We treat the whole Speex packet as a single frame everywhere Speex - is handled in FFmpeg. This avoids the complexities of splitting - and joining individual Speex frames, which are not always - byte-aligned. */ - st->codec->frame_size = AV_RL32(p + 56); - frames_per_packet = AV_RL32(p + 64); + spxp->packet_size = AV_RL32(p + 56); + frames_per_packet = AV_RL32(p + 64); if (frames_per_packet) - st->codec->frame_size *= frames_per_packet; + spxp->packet_size *= frames_per_packet; st->codec->extradata_size = os->psize; st->codec->extradata = av_malloc(st->codec->extradata_size @@ -95,7 +92,7 @@ struct ogg *ogg = s->priv_data; struct ogg_stream *os = ogg->streams + idx; struct speex_params *spxp = os->private; - int packet_size = s->streams[idx]->codec->frame_size; + int packet_size = spxp->packet_size; if (os->flags & OGG_FLAG_EOS && os->lastpts != AV_NOPTS_VALUE && os->granule > 0) { @@ -108,9 +105,10 @@ if (!os->lastpts && os->granule > 0) /* first packet */ - os->pduration = os->granule - packet_size * (ogg_page_packets(os) - 1); - else if (os->flags & OGG_FLAG_EOS && os->segp == os->nsegs && - spxp->final_packet_duration) + os->lastpts = os->lastdts = os->granule - packet_size * + ogg_page_packets(os); + if (os->flags & OGG_FLAG_EOS && os->segp == os->nsegs && + spxp->final_packet_duration) /* final packet */ os->pduration = spxp->final_packet_duration; else diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/oggparsevorbis.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/oggparsevorbis.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/oggparsevorbis.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/oggparsevorbis.c 2011-11-04 12:38:27.000000000 +0000 @@ -45,7 +45,7 @@ if (sscanf(val, "%02d:%02d:%02d.%03d", &h, &m, &s, &ms) < 4) return 0; - ff_new_chapter(as, cnum, (AVRational){1,1000}, + avpriv_new_chapter(as, cnum, (AVRational){1,1000}, ms + 1000*(s + 60*(m + 60*h)), AV_NOPTS_VALUE, NULL); av_free(val); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/oma.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/oma.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/oma.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/oma.c 2011-11-04 12:38:27.000000000 +0000 @@ -307,7 +307,7 @@ codec_params = AV_RB24(&buf[33]); - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/options.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/options.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/options.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/options.c 2011-11-04 12:38:27.000000000 +0000 @@ -33,30 +33,36 @@ else return "NULL"; } -static const AVOption *opt_find(void *obj, const char *name, const char *unit, int opt_flags, int search_flags) +static void *format_child_next(void *obj, void *prev) +{ + AVFormatContext *s = obj; + if (!prev && s->priv_data && + ((s->iformat && s->iformat->priv_class) || + s->oformat && s->oformat->priv_class)) + return s->priv_data; + return NULL; +} + +static const AVClass *format_child_class_next(const AVClass *prev) { - AVFormatContext *s = obj; AVInputFormat *ifmt = NULL; AVOutputFormat *ofmt = NULL; - if (!(search_flags & AV_OPT_SEARCH_FAKE_OBJ) && s->priv_data) { - if ((s->iformat && !s->iformat->priv_class) || - (s->oformat && !s->oformat->priv_class)) - return NULL; - return av_opt_find(s->priv_data, name, unit, opt_flags, search_flags); - } - - while ((ifmt = av_iformat_next(ifmt))) { - const AVOption *o; - - if (ifmt->priv_class && (o = av_opt_find(&ifmt->priv_class, name, unit, opt_flags, search_flags))) - return o; - } - while ((ofmt = av_oformat_next(ofmt))) { - const AVOption *o; - - if (ofmt->priv_class && (o = av_opt_find(&ofmt->priv_class, name, unit, opt_flags, search_flags))) - return o; - } + + while (prev && (ifmt = av_iformat_next(ifmt))) + if (ifmt->priv_class == prev) + break; + if ((prev && ifmt) || (!prev)) + while (ifmt = av_iformat_next(ifmt)) + if (ifmt->priv_class) + return ifmt->priv_class; + + while (prev && (ofmt = av_oformat_next(ofmt))) + if (ofmt->priv_class == prev) + break; + while (ofmt = av_oformat_next(ofmt)) + if (ofmt->priv_class) + return ofmt->priv_class; + return NULL; } @@ -67,33 +73,35 @@ #define D AV_OPT_FLAG_DECODING_PARAM static const AVOption options[]={ -{"probesize", "set probing size", OFFSET(probesize), FF_OPT_TYPE_INT, {.dbl = 5000000 }, 32, INT_MAX, D}, -{"muxrate", "set mux rate", OFFSET(mux_rate), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, E}, -{"packetsize", "set packet size", OFFSET(packet_size), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, E}, -{"fflags", NULL, OFFSET(flags), FF_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, INT_MIN, INT_MAX, D|E, "fflags"}, -{"ignidx", "ignore index", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_IGNIDX }, INT_MIN, INT_MAX, D, "fflags"}, -{"genpts", "generate pts", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_GENPTS }, INT_MIN, INT_MAX, D, "fflags"}, -{"nofillin", "do not fill in missing values that can be exactly calculated", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_NOFILLIN }, INT_MIN, INT_MAX, D, "fflags"}, -{"noparse", "disable AVParsers, this needs nofillin too", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_NOPARSE }, INT_MIN, INT_MAX, D, "fflags"}, -{"igndts", "ignore dts", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_IGNDTS }, INT_MIN, INT_MAX, D, "fflags"}, +{"probesize", "set probing size", OFFSET(probesize), AV_OPT_TYPE_INT, {.dbl = 5000000 }, 32, INT_MAX, D}, +#if FF_API_MUXRATE +{"muxrate", "set mux rate", OFFSET(mux_rate), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, E}, +#endif +{"packetsize", "set packet size", OFFSET(packet_size), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, E}, +{"fflags", NULL, OFFSET(flags), AV_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, INT_MIN, INT_MAX, D|E, "fflags"}, +{"ignidx", "ignore index", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_IGNIDX }, INT_MIN, INT_MAX, D, "fflags"}, +{"genpts", "generate pts", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_GENPTS }, INT_MIN, INT_MAX, D, "fflags"}, +{"nofillin", "do not fill in missing values that can be exactly calculated", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_NOFILLIN }, INT_MIN, INT_MAX, D, "fflags"}, +{"noparse", "disable AVParsers, this needs nofillin too", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_NOPARSE }, INT_MIN, INT_MAX, D, "fflags"}, +{"igndts", "ignore dts", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_IGNDTS }, INT_MIN, INT_MAX, D, "fflags"}, #if FF_API_FLAG_RTP_HINT -{"rtphint", "add rtp hinting (deprecated, use the -movflags rtphint option instead)", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_RTP_HINT }, INT_MIN, INT_MAX, E, "fflags"}, +{"rtphint", "add rtp hinting (deprecated, use the -movflags rtphint option instead)", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_RTP_HINT }, INT_MIN, INT_MAX, E, "fflags"}, #endif -{"discardcorrupt", "discard corrupted frames", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_DISCARD_CORRUPT }, INT_MIN, INT_MAX, D, "fflags"}, -{"sortdts", "try to interleave outputted packets by dts", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_SORT_DTS }, INT_MIN, INT_MAX, D, "fflags"}, -{"keepside", "dont merge side data", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_KEEP_SIDE_DATA }, INT_MIN, INT_MAX, D, "fflags"}, -{"latm", "enable RTP MP4A-LATM payload", 0, FF_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_MP4A_LATM }, INT_MIN, INT_MAX, E, "fflags"}, -{"analyzeduration", "how many microseconds are analyzed to estimate duration", OFFSET(max_analyze_duration), FF_OPT_TYPE_INT, {.dbl = 5*AV_TIME_BASE }, 0, INT_MAX, D}, -{"cryptokey", "decryption key", OFFSET(key), FF_OPT_TYPE_BINARY, {.dbl = 0}, 0, 0, D}, -{"indexmem", "max memory used for timestamp index (per stream)", OFFSET(max_index_size), FF_OPT_TYPE_INT, {.dbl = 1<<20 }, 0, INT_MAX, D}, -{"rtbufsize", "max memory used for buffering real-time frames", OFFSET(max_picture_buffer), FF_OPT_TYPE_INT, {.dbl = 3041280 }, 0, INT_MAX, D}, /* defaults to 1s of 15fps 352x288 YUYV422 video */ -{"fdebug", "print specific debug info", OFFSET(debug), FF_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, 0, INT_MAX, E|D, "fdebug"}, -{"ts", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_FDEBUG_TS }, INT_MIN, INT_MAX, E|D, "fdebug"}, -{"max_delay", "maximum muxing or demuxing delay in microseconds", OFFSET(max_delay), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, E|D}, -{"fer", "set error detection aggressivity", OFFSET(error_recognition), FF_OPT_TYPE_INT, {.dbl = FF_ER_CAREFUL }, INT_MIN, INT_MAX, D, "fer"}, -{"careful", NULL, 0, FF_OPT_TYPE_CONST, {.dbl = FF_ER_CAREFUL }, INT_MIN, INT_MAX, D, "fer"}, -{"explode", "abort decoding on error recognition", 0, FF_OPT_TYPE_CONST, {.dbl = FF_ER_EXPLODE }, INT_MIN, INT_MAX, D, "fer"}, -{"fpsprobesize", "number of frames used to probe fps", OFFSET(fps_probe_size), FF_OPT_TYPE_INT, {.dbl = -1}, -1, INT_MAX-1, D}, +{"discardcorrupt", "discard corrupted frames", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_DISCARD_CORRUPT }, INT_MIN, INT_MAX, D, "fflags"}, +{"sortdts", "try to interleave outputted packets by dts", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_SORT_DTS }, INT_MIN, INT_MAX, D, "fflags"}, +{"keepside", "dont merge side data", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_KEEP_SIDE_DATA }, INT_MIN, INT_MAX, D, "fflags"}, +{"latm", "enable RTP MP4A-LATM payload", 0, AV_OPT_TYPE_CONST, {.dbl = AVFMT_FLAG_MP4A_LATM }, INT_MIN, INT_MAX, E, "fflags"}, +{"analyzeduration", "how many microseconds are analyzed to estimate duration", OFFSET(max_analyze_duration), AV_OPT_TYPE_INT, {.dbl = 5*AV_TIME_BASE }, 0, INT_MAX, D}, +{"cryptokey", "decryption key", OFFSET(key), AV_OPT_TYPE_BINARY, {.dbl = 0}, 0, 0, D}, +{"indexmem", "max memory used for timestamp index (per stream)", OFFSET(max_index_size), AV_OPT_TYPE_INT, {.dbl = 1<<20 }, 0, INT_MAX, D}, +{"rtbufsize", "max memory used for buffering real-time frames", OFFSET(max_picture_buffer), AV_OPT_TYPE_INT, {.dbl = 3041280 }, 0, INT_MAX, D}, /* defaults to 1s of 15fps 352x288 YUYV422 video */ +{"fdebug", "print specific debug info", OFFSET(debug), AV_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, 0, INT_MAX, E|D, "fdebug"}, +{"ts", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_FDEBUG_TS }, INT_MIN, INT_MAX, E|D, "fdebug"}, +{"max_delay", "maximum muxing or demuxing delay in microseconds", OFFSET(max_delay), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, INT_MAX, E|D}, +{"fer", "set error detection aggressivity", OFFSET(error_recognition), AV_OPT_TYPE_INT, {.dbl = FF_ER_CAREFUL }, INT_MIN, INT_MAX, D, "fer"}, +{"careful", NULL, 0, AV_OPT_TYPE_CONST, {.dbl = FF_ER_CAREFUL }, INT_MIN, INT_MAX, D, "fer"}, +{"explode", "abort decoding on error recognition", 0, AV_OPT_TYPE_CONST, {.dbl = FF_ER_EXPLODE }, INT_MIN, INT_MAX, D, "fer"}, +{"fpsprobesize", "number of frames used to probe fps", OFFSET(fps_probe_size), AV_OPT_TYPE_INT, {.dbl = -1}, -1, INT_MAX-1, D}, {NULL}, }; @@ -106,7 +114,8 @@ .item_name = format_to_name, .option = options, .version = LIBAVUTIL_VERSION_INT, - .opt_find = opt_find, + .child_next = format_child_next, + .child_class_next = format_child_class_next, }; static void avformat_get_context_defaults(AVFormatContext *s) diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/os_support.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/os_support.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/os_support.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/os_support.c 2011-11-04 12:38:27.000000000 +0000 @@ -1,5 +1,5 @@ /* - * Various utilities for ffmpeg system + * various OS-feature replacement utilities * Copyright (c) 2000, 2001, 2002 Fabrice Bellard * copyright (c) 2002 Francois Revol * diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/os_support.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/os_support.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/os_support.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/os_support.h 2011-11-04 12:38:27.000000000 +0000 @@ -1,5 +1,5 @@ /* - * various utilities for ffmpeg system + * various OS-feature replacement utilities * copyright (c) 2000, 2001, 2002 Fabrice Bellard * * This file is part of FFmpeg. diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/pcmdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/pcmdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/pcmdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/pcmdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -49,8 +49,8 @@ } static const AVOption pcm_options[] = { - { "sample_rate", "", offsetof(RawAudioDemuxerContext, sample_rate), FF_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, - { "channels", "", offsetof(RawAudioDemuxerContext, channels), FF_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, + { "sample_rate", "", offsetof(RawAudioDemuxerContext, sample_rate), AV_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, + { "channels", "", offsetof(RawAudioDemuxerContext, channels), AV_OPT_TYPE_INT, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM }, { NULL }, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/psxstr.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/psxstr.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/psxstr.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/psxstr.c 2011-11-04 12:38:27.000000000 +0000 @@ -196,7 +196,7 @@ if(str->channels[channel].video_stream_index < 0){ /* allocate a new AVStream */ - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); av_set_pts_info(st, 64, 1, 15); @@ -244,7 +244,7 @@ if(str->channels[channel].audio_stream_index < 0){ int fmt = sector[0x13]; /* allocate a new AVStream */ - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/pva.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/pva.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/pva.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/pva.c 2011-11-04 12:38:27.000000000 +0000 @@ -31,19 +31,32 @@ int continue_pes; } PVAContext; +static int pva_check(uint8_t *p) { + int length = AV_RB16(p + 6); + if (AV_RB16(p) != PVA_MAGIC || !p[2] || p[2] > 2 || p[4] != 0x55 || + (p[5] & 0xe0) || length > PVA_MAX_PAYLOAD_LENGTH) + return -1; + return length + 8; +} + static int pva_probe(AVProbeData * pd) { unsigned char *buf = pd->buf; + int len = pva_check(buf); - if (AV_RB16(buf) == PVA_MAGIC && buf[2] && buf[2] < 3 && buf[4] == 0x55) + if (len < 0) + return 0; + + if (pd->buf_size >= len + 8 && + pva_check(buf + len) >= 0) return AVPROBE_SCORE_MAX / 2; - return 0; + return AVPROBE_SCORE_MAX / 4; } static int pva_read_header(AVFormatContext *s, AVFormatParameters *ap) { AVStream *st; - if (!(st = av_new_stream(s, 0))) + if (!(st = avformat_new_stream(s, NULL))) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = CODEC_ID_MPEG2VIDEO; @@ -51,7 +64,7 @@ av_set_pts_info(st, 32, 1, 90000); av_add_index_entry(st, 0, 0, 0, 0, AVINDEX_KEYFRAME); - if (!(st = av_new_stream(s, 1))) + if (!(st = avformat_new_stream(s, NULL))) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = CODEC_ID_MP2; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/qcp.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/qcp.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/qcp.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/qcp.c 2011-11-04 12:38:27.000000000 +0000 @@ -84,7 +84,7 @@ { AVIOContext *pb = s->pb; QCPContext *c = s->priv_data; - AVStream *st = av_new_stream(s, 0); + AVStream *st = avformat_new_stream(s, NULL); uint8_t buf[16]; int i, nb_rates; @@ -92,8 +92,7 @@ return AVERROR(ENOMEM); avio_rb32(pb); // "RIFF" - s->file_size = avio_rl32(pb) + 8; - avio_skip(pb, 8 + 4 + 1 + 1); // "QLCMfmt " + chunk-size + major-version + minor-version + avio_skip(pb, 4 + 8 + 4 + 1 + 1); // filesize + "QLCMfmt " + chunk-size + major-version + minor-version st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->channels = 1; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/r3d.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/r3d.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/r3d.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/r3d.c 2011-11-04 12:38:27.000000000 +0000 @@ -52,7 +52,7 @@ static int r3d_read_red1(AVFormatContext *s) { - AVStream *st = av_new_stream(s, 0); + AVStream *st = avformat_new_stream(s, NULL); char filename[258]; int tmp; int av_unused tmp2; @@ -89,7 +89,7 @@ tmp = avio_r8(s->pb); // audio channels av_dlog(s, "audio channels %d\n", tmp); if (tmp > 0) { - AVStream *ast = av_new_stream(s, 1); + AVStream *ast = avformat_new_stream(s, NULL); if (!ast) return AVERROR(ENOMEM); ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rawdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rawdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rawdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rawdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -33,7 +33,7 @@ AVStream *st; enum CodecID id; - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); @@ -56,6 +56,12 @@ if (s1 && s1->sample_rate) st->codec->sample_rate = s1->sample_rate; + if (st->codec->sample_rate <= 0) { + av_log(s, AV_LOG_ERROR, "Invalid sample rate %d specified\n", + st->codec->sample_rate); + return AVERROR(EINVAL); + } + if (s1 && s1->channels) st->codec->channels = s1->channels; @@ -122,7 +128,7 @@ int ff_raw_audio_read_header(AVFormatContext *s, AVFormatParameters *ap) { - AVStream *st = av_new_stream(s, 0); + AVStream *st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; @@ -144,7 +150,7 @@ int ret = 0; - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) { ret = AVERROR(ENOMEM); goto fail; @@ -171,7 +177,7 @@ #define OFFSET(x) offsetof(FFRawVideoDemuxerContext, x) #define DEC AV_OPT_FLAG_DECODING_PARAM const AVOption ff_rawvideo_options[] = { - { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC}, + { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC}, { NULL }, }; @@ -187,18 +193,6 @@ }; #endif -#if CONFIG_GSM_DEMUXER -AVInputFormat ff_gsm_demuxer = { - .name = "gsm", - .long_name = NULL_IF_CONFIG_SMALL("raw GSM"), - .read_header = ff_raw_audio_read_header, - .read_packet = ff_raw_read_partial_packet, - .flags= AVFMT_GENERIC_INDEX, - .extensions = "gsm", - .value = CODEC_ID_GSM, -}; -#endif - #if CONFIG_LATM_DEMUXER AVInputFormat ff_latm_demuxer = { .name = "latm", @@ -245,7 +239,7 @@ .long_name = NULL_IF_CONFIG_SMALL("raw Shorten"), .read_header = ff_raw_audio_read_header, .read_packet = ff_raw_read_partial_packet, - .flags= AVFMT_GENERIC_INDEX, + .flags = AVFMT_NOBINSEARCH | AVFMT_NOGENSEARCH | AVFMT_NO_BYTE_SEEK, .extensions = "shn", .value = CODEC_ID_SHORTEN, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rawenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rawenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rawenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rawenc.c 2011-11-04 12:38:27.000000000 +0000 @@ -108,6 +108,19 @@ }; #endif +#if CONFIG_G723_1_MUXER +AVOutputFormat ff_g723_1_muxer = { + .name = "g723_1", + .long_name = NULL_IF_CONFIG_SMALL("raw G.723.1"), + .mime_type = "audio/g723", + .extensions = "tco,rco", + .audio_codec = CODEC_ID_G723_1, + .video_codec = CODEC_ID_NONE, + .write_packet = ff_raw_write_packet, + .flags= AVFMT_NOTIMESTAMPS, +}; +#endif + #if CONFIG_H261_MUXER AVOutputFormat ff_h261_muxer = { .name = "h261", diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rawvideodec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rawvideodec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rawvideodec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rawvideodec.c 2011-11-04 12:38:27.000000000 +0000 @@ -47,9 +47,9 @@ #define OFFSET(x) offsetof(FFRawVideoDemuxerContext, x) #define DEC AV_OPT_FLAG_DECODING_PARAM static const AVOption rawvideo_options[] = { - { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, - { "pixel_format", "", OFFSET(pixel_format), FF_OPT_TYPE_STRING, {.str = "yuv420p"}, 0, 0, DEC }, - { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC }, + { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, + { "pixel_format", "", OFFSET(pixel_format), AV_OPT_TYPE_STRING, {.str = "yuv420p"}, 0, 0, DEC }, + { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC }, { NULL }, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rdt.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rdt.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rdt.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rdt.c 2011-11-04 12:38:27.000000000 +0000 @@ -459,8 +459,9 @@ { AVStream *st; - if (!(st = av_new_stream(s, orig_st->id))) + if (!(st = avformat_new_stream(s, NULL))) return NULL; + st->id = orig_st->id; st->codec->codec_type = orig_st->codec->codec_type; st->first_dts = orig_st->first_dts; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/riff.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/riff.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/riff.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/riff.c 2011-11-04 12:38:27.000000000 +0000 @@ -36,6 +36,7 @@ { CODEC_ID_H264, MKTAG('a', 'v', 'c', '1') }, { CODEC_ID_H264, MKTAG('D', 'A', 'V', 'C') }, { CODEC_ID_H264, MKTAG('V', 'S', 'S', 'H') }, + { CODEC_ID_H264, MKTAG('Q', '2', '6', '4') }, /* QNAP surveillance system */ { CODEC_ID_H263, MKTAG('H', '2', '6', '3') }, { CODEC_ID_H263, MKTAG('X', '2', '6', '3') }, { CODEC_ID_H263, MKTAG('T', '2', '6', '3') }, @@ -88,6 +89,7 @@ { CODEC_ID_MPEG4, MKTAG('S', 'I', 'P', 'P') }, /* Samsung SHR-6040 */ { CODEC_ID_MPEG4, MKTAG('X', 'V', 'I', 'X') }, { CODEC_ID_MPEG4, MKTAG('D', 'r', 'e', 'X') }, + { CODEC_ID_MPEG4, MKTAG('Q', 'M', 'P', '4') }, /* QNAP Systems */ { CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', '4', '3') }, { CODEC_ID_MSMPEG4V3, MKTAG('D', 'I', 'V', '3') }, { CODEC_ID_MSMPEG4V3, MKTAG('M', 'P', 'G', '3') }, @@ -279,6 +281,10 @@ { CODEC_ID_G2M, MKTAG('G', '2', 'M', '3') }, { CODEC_ID_G2M, MKTAG('G', '2', 'M', '4') }, { CODEC_ID_AMV, MKTAG('A', 'M', 'V', 'F') }, + { CODEC_ID_UTVIDEO, MKTAG('U', 'L', 'R', 'A') }, + { CODEC_ID_UTVIDEO, MKTAG('U', 'L', 'R', 'G') }, + { CODEC_ID_UTVIDEO, MKTAG('U', 'L', 'Y', '0') }, + { CODEC_ID_UTVIDEO, MKTAG('U', 'L', 'Y', '2') }, { CODEC_ID_NONE, 0 } }; @@ -394,11 +400,13 @@ avio_wl32(pb, enc->sample_rate); if (enc->codec_id == CODEC_ID_MP2 || enc->codec_id == CODEC_ID_MP3 || enc->codec_id == CODEC_ID_GSM_MS) { bps = 0; - } else if (enc->codec_id == CODEC_ID_ADPCM_G726) { - bps = 4; } else { - if (!(bps = av_get_bits_per_sample(enc->codec_id))) - bps = 16; // default to 16 + if (!(bps = av_get_bits_per_sample(enc->codec_id))) { + if (enc->bits_per_coded_sample) + bps = enc->bits_per_coded_sample; + else + bps = 16; // default to 16 + } } if(bps != enc->bits_per_coded_sample && enc->bits_per_coded_sample){ av_log(enc, AV_LOG_WARNING, "requested bits_per_coded_sample (%d) and actually stored (%d) differ\n", enc->bits_per_coded_sample, bps); @@ -409,12 +417,10 @@ //blkalign = 144 * enc->bit_rate/enc->sample_rate; } else if (enc->codec_id == CODEC_ID_AC3) { blkalign = 3840; //maximum bytes per frame - } else if (enc->codec_id == CODEC_ID_ADPCM_G726) { // - blkalign = 1; } else if (enc->block_align != 0) { /* specified by the codec */ blkalign = enc->block_align; } else - blkalign = enc->channels*bps >> 3; + blkalign = bps * enc->channels / av_gcd(8, bps); if (enc->codec_id == CODEC_ID_PCM_U8 || enc->codec_id == CODEC_ID_PCM_S24LE || enc->codec_id == CODEC_ID_PCM_S32LE || @@ -452,8 +458,6 @@ riff_extradata_start= enc->extradata; riff_extradata= enc->extradata + enc->extradata_size; hdrsize += enc->extradata_size; - } else if (!waveformatextensible){ - hdrsize -= 2; } if(waveformatextensible) { /* write WAVEFORMATEXTENSIBLE extensions */ hdrsize += 22; @@ -464,8 +468,8 @@ avio_wl32(pb, 0x00100000); avio_wl32(pb, 0xAA000080); avio_wl32(pb, 0x719B3800); - } else if(riff_extradata - riff_extradata_start) { - avio_wl16(pb, riff_extradata - riff_extradata_start); + } else { + avio_wl16(pb, riff_extradata - riff_extradata_start); /* cbSize */ } avio_write(pb, riff_extradata_start, riff_extradata - riff_extradata_start); if(hdrsize&1){ @@ -568,6 +572,9 @@ codec->channels = 0; codec->sample_rate = 0; } + /* override bits_per_coded_sample for G.726 */ + if (codec->codec_id == CODEC_ID_ADPCM_G726) + codec->bits_per_coded_sample = codec->bit_rate / codec->sample_rate; return 0; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rl2.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rl2.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rl2.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rl2.c 2011-11-04 12:38:27.000000000 +0000 @@ -110,7 +110,7 @@ def_sound_size = avio_rl16(pb); /** setup video stream */ - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if(!st) return AVERROR(ENOMEM); @@ -140,7 +140,7 @@ pts_num = def_sound_size; pts_den = rate; - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rmdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rmdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rmdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rmdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -397,7 +397,7 @@ AVStream *st; rm->old_format = 1; - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return -1; st->priv_data = ff_rm_alloc_rmstream(); @@ -463,7 +463,7 @@ rm_read_metadata(s, 1); break; case MKTAG('M', 'D', 'P', 'R'): - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); st->id = avio_rb16(pb); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rpl.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rpl.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rpl.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rpl.c 2011-11-04 12:38:27.000000000 +0000 @@ -139,7 +139,7 @@ av_dict_set(&s->metadata, "author" , line, 0); // video headers - vst = av_new_stream(s, 0); + vst = avformat_new_stream(s, NULL); if (!vst) return AVERROR(ENOMEM); vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; @@ -181,7 +181,7 @@ // samples, though. This code will ignore additional tracks. audio_format = read_line_and_int(pb, &error); // audio format ID if (audio_format) { - ast = av_new_stream(s, 0); + ast = avformat_new_stream(s, NULL); if (!ast) return AVERROR(ENOMEM); ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rsodec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rsodec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rsodec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rsodec.c 2011-11-04 12:38:27.000000000 +0000 @@ -54,7 +54,7 @@ } /* now we are ready: build format streams */ - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rso.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rso.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rso.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rso.h 2011-11-04 12:38:27.000000000 +0000 @@ -26,7 +26,7 @@ #define RSO_HEADER_SIZE 8 -/* The ffmpeg codecs we support, and the IDs they have in the file */ +/* The libavcodec codecs we support, and the IDs they have in the file */ extern const AVCodecTag ff_codec_rso_tags[]; #endif /* AVFORMAT_RSO_H */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rtp.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rtp.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rtp.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rtp.c 2011-11-04 12:38:27.000000000 +0000 @@ -97,9 +97,10 @@ /* Was the payload type already specified for the RTP muxer? */ if (ofmt && ofmt->priv_class) { - int payload_type = av_get_int(fmt->priv_data, "payload_type", NULL); - if (payload_type >= 0) - return payload_type; + int64_t payload_type; + if (av_opt_get_int(fmt->priv_data, "payload_type", 0, &payload_type) >= 0 && + payload_type >= 0) + return (int)payload_type; } /* static payload type */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rtpdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rtpdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rtpdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rtpdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -20,13 +20,13 @@ */ #include "libavutil/mathematics.h" +#include "libavutil/avstring.h" #include "libavcodec/get_bits.h" #include "avformat.h" #include "mpegts.h" #include "url.h" #include -#include #include "network.h" #include "rtpdec.h" @@ -91,7 +91,7 @@ RTPDynamicProtocolHandler *handler; for (handler = RTPFirstDynamicPayloadHandler; handler; handler = handler->next) - if (!strcasecmp(name, handler->enc_name) && + if (!av_strcasecmp(name, handler->enc_name) && codec_type == handler->codec_type) return handler; return NULL; @@ -112,14 +112,15 @@ static int rtcp_parse_packet(RTPDemuxContext *s, const unsigned char *buf, int len) { int payload_len; - while (len >= 2) { + while (len >= 4) { + payload_len = FFMIN(len, (AV_RB16(buf + 2) + 1) * 4); + switch (buf[1]) { case RTCP_SR: - if (len < 16) { + if (payload_len < 20) { av_log(NULL, AV_LOG_ERROR, "Invalid length for RTCP SR packet\n"); return AVERROR_INVALIDDATA; } - payload_len = (AV_RB16(buf + 2) + 1) * 4; s->last_rtcp_ntp_time = AV_RB64(buf + 8); s->last_rtcp_timestamp = AV_RB32(buf + 16); @@ -130,14 +131,13 @@ s->rtcp_ts_offset = s->last_rtcp_timestamp - s->base_timestamp; } - buf += payload_len; - len -= payload_len; break; case RTCP_BYE: return -RTCP_BYE; - default: - return -1; } + + buf += payload_len; + len -= payload_len; } return -1; } @@ -218,7 +218,7 @@ return 1; } -int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count) +int ff_rtp_check_and_send_back_rr(RTPDemuxContext *s, int count) { AVIOContext *pb; uint8_t *buf; @@ -315,7 +315,7 @@ return 0; } -void rtp_send_punch_packets(URLContext* rtp_handle) +void ff_rtp_send_punch_packets(URLContext* rtp_handle) { AVIOContext *pb; uint8_t *buf; @@ -359,7 +359,7 @@ * MPEG2TS streams to indicate that they should be demuxed inside the * rtp demux (otherwise CODEC_ID_MPEG2TS packets are returned) */ -RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *rtpc, int payload_type, int queue_size) +RTPDemuxContext *ff_rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *rtpc, int payload_type, int queue_size) { RTPDemuxContext *s; @@ -407,8 +407,8 @@ } void -rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx, - RTPDynamicProtocolHandler *handler) +ff_rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx, + RTPDynamicProtocolHandler *handler) { s->dynamic_protocol_context = ctx; s->parse_packet = handler->parse_packet; @@ -722,8 +722,8 @@ * @return 0 if a packet is returned, 1 if a packet is returned and more can follow * (use buf as NULL to read the next). -1 if no packet (error or no more packet). */ -int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt, - uint8_t **bufptr, int len) +int ff_rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt, + uint8_t **bufptr, int len) { int rv = rtp_parse_one_packet(s, pkt, bufptr, len); s->prev_ret = rv; @@ -732,7 +732,7 @@ return rv ? rv : has_next_packet(s); } -void rtp_parse_close(RTPDemuxContext *s) +void ff_rtp_parse_close(RTPDemuxContext *s) { ff_rtp_reset_packet_queue(s); if (!strcmp(ff_rtp_enc_name(s->payload_type), "MP2T")) { diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rtpdec.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rtpdec.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rtpdec.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rtpdec.h 2011-11-04 12:38:27.000000000 +0000 @@ -38,18 +38,18 @@ #define RTP_NOTS_VALUE ((uint32_t)-1) typedef struct RTPDemuxContext RTPDemuxContext; -RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *rtpc, int payload_type, int queue_size); -void rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx, - RTPDynamicProtocolHandler *handler); -int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt, - uint8_t **buf, int len); -void rtp_parse_close(RTPDemuxContext *s); +RTPDemuxContext *ff_rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *rtpc, int payload_type, int queue_size); +void ff_rtp_parse_set_dynamic_protocol(RTPDemuxContext *s, PayloadContext *ctx, + RTPDynamicProtocolHandler *handler); +int ff_rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt, + uint8_t **buf, int len); +void ff_rtp_parse_close(RTPDemuxContext *s); int64_t ff_rtp_queued_packet_time(RTPDemuxContext *s); void ff_rtp_reset_packet_queue(RTPDemuxContext *s); -int rtp_get_local_rtp_port(URLContext *h); -int rtp_get_local_rtcp_port(URLContext *h); +int ff_rtp_get_local_rtp_port(URLContext *h); +int ff_rtp_get_local_rtcp_port(URLContext *h); -int rtp_set_remote_url(URLContext *h, const char *uri); +int ff_rtp_set_remote_url(URLContext *h, const char *uri); /** * Send a dummy packet on both port pairs to set up the connection @@ -62,19 +62,19 @@ * The same routine is used with RDT too, even if RDT doesn't use normal * RTP packets otherwise. */ -void rtp_send_punch_packets(URLContext* rtp_handle); +void ff_rtp_send_punch_packets(URLContext* rtp_handle); /** * some rtp servers assume client is dead if they don't hear from them... * so we send a Receiver Report to the provided ByteIO context * (we don't have access to the rtcp handle from here) */ -int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count); +int ff_rtp_check_and_send_back_rr(RTPDemuxContext *s, int count); /** * Get the file handle for the RTCP socket. */ -int rtp_get_rtcp_file_handle(URLContext *h); +int ff_rtp_get_rtcp_file_handle(URLContext *h); // these statistics are used for rtcp receiver reports... typedef struct { diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rtpdec_mpeg4.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rtpdec_mpeg4.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rtpdec_mpeg4.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rtpdec_mpeg4.c 2011-11-04 12:38:27.000000000 +0000 @@ -31,7 +31,6 @@ #include "internal.h" #include "libavutil/avstring.h" #include "libavcodec/get_bits.h" -#include /** Structure listing useful vars to parse RTP packet payload*/ struct PayloadContext @@ -206,7 +205,7 @@ if (codec->codec_id == CODEC_ID_AAC) { /* Looking for a known attribute */ for (i = 0; attr_names[i].str; ++i) { - if (!strcasecmp(attr, attr_names[i].str)) { + if (!av_strcasecmp(attr, attr_names[i].str)) { if (attr_names[i].type == ATTR_NAME_TYPE_INT) { *(int *)((char *)data+ attr_names[i].offset) = atoi(value); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rtpenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rtpenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rtpenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rtpenc.c 2011-11-04 12:38:27.000000000 +0000 @@ -32,7 +32,7 @@ static const AVOption options[] = { FF_RTP_FLAG_OPTS(RTPMuxContext, flags), - { "payload_type", "Specify RTP payload type", offsetof(RTPMuxContext, payload_type), FF_OPT_TYPE_INT, {.dbl = -1 }, -1, 127, AV_OPT_FLAG_ENCODING_PARAM }, + { "payload_type", "Specify RTP payload type", offsetof(RTPMuxContext, payload_type), AV_OPT_TYPE_INT, {.dbl = -1 }, -1, 127, AV_OPT_FLAG_ENCODING_PARAM }, { NULL }, }; @@ -465,7 +465,7 @@ .long_name = NULL_IF_CONFIG_SMALL("RTP output format"), .priv_data_size = sizeof(RTPMuxContext), .audio_codec = CODEC_ID_PCM_MULAW, - .video_codec = CODEC_ID_NONE, + .video_codec = CODEC_ID_MPEG4, .write_header = rtp_write_header, .write_packet = rtp_write_packet, .write_trailer = rtp_write_trailer, diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rtpenc_chain.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rtpenc_chain.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rtpenc_chain.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rtpenc_chain.c 2011-11-04 12:38:27.000000000 +0000 @@ -31,6 +31,8 @@ AVFormatContext *rtpctx; int ret; AVOutputFormat *rtp_format = av_guess_format("rtp", NULL, NULL); + uint8_t *rtpflags; + AVDictionary *opts = NULL; if (!rtp_format) return NULL; @@ -41,7 +43,7 @@ return NULL; rtpctx->oformat = rtp_format; - if (!av_new_stream(rtpctx, 0)) { + if (!avformat_new_stream(rtpctx, NULL)) { av_free(rtpctx); return NULL; } @@ -51,12 +53,8 @@ rtpctx->streams[0]->sample_aspect_ratio = st->sample_aspect_ratio; rtpctx->flags |= s->flags & AVFMT_FLAG_MP4A_LATM; - av_set_parameters(rtpctx, NULL); - /* Copy the rtpflags values straight through */ - if (s->oformat->priv_class && - av_find_opt(s->priv_data, "rtpflags", NULL, 0, 0)) - av_set_int(rtpctx->priv_data, "rtpflags", - av_get_int(s->priv_data, "rtpflags", NULL)); + if (av_opt_get(s, "rtpflags", AV_OPT_SEARCH_CHILDREN, &rtpflags) >= 0) + av_dict_set(&opts, "rtpflags", rtpflags, AV_DICT_DONT_STRDUP_VAL); /* Set the synchronized start time. */ rtpctx->start_time_realtime = s->start_time_realtime; @@ -67,7 +65,8 @@ ffio_fdopen(&rtpctx->pb, handle); } else ffio_open_dyn_packet_buf(&rtpctx->pb, packet_size); - ret = avformat_write_header(rtpctx, NULL); + ret = avformat_write_header(rtpctx, &opts); + av_dict_free(&opts); if (ret) { if (handle) { diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rtpenc.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rtpenc.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rtpenc.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rtpenc.h 2011-11-04 12:38:27.000000000 +0000 @@ -66,8 +66,8 @@ #define FF_RTP_FLAG_MP4A_LATM 1 #define FF_RTP_FLAG_OPTS(ctx, fieldname) \ - { "rtpflags", "RTP muxer flags", offsetof(ctx, fieldname), FF_OPT_TYPE_FLAGS, {.dbl = 0}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "rtpflags" }, \ - { "latm", "Use MP4A-LATM packetization instead of MPEG4-GENERIC for AAC", 0, FF_OPT_TYPE_CONST, {.dbl = FF_RTP_FLAG_MP4A_LATM}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "rtpflags" } \ + { "rtpflags", "RTP muxer flags", offsetof(ctx, fieldname), AV_OPT_TYPE_FLAGS, {.dbl = 0}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "rtpflags" }, \ + { "latm", "Use MP4A-LATM packetization instead of MPEG4-GENERIC for AAC", 0, AV_OPT_TYPE_CONST, {.dbl = FF_RTP_FLAG_MP4A_LATM}, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "rtpflags" } \ void ff_rtp_send_data(AVFormatContext *s1, const uint8_t *buf1, int len, int m); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rtpenc_mpv.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rtpenc_mpv.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rtpenc_mpv.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rtpenc_mpv.c 2011-11-04 12:38:27.000000000 +0000 @@ -56,7 +56,7 @@ r1 = buf1; while (1) { start_code = -1; - r = ff_find_start_code(r1, end, &start_code); + r = avpriv_mpv_find_start_code(r1, end, &start_code); if((start_code & 0xFFFFFF00) == 0x100) { /* New start code found */ if (start_code == 0x100) { diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rtpproto.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rtpproto.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rtpproto.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rtpproto.c 2011-11-04 12:38:27.000000000 +0000 @@ -60,7 +60,7 @@ * @return zero if no error. */ -int rtp_set_remote_url(URLContext *h, const char *uri) +int ff_rtp_set_remote_url(URLContext *h, const char *uri) { RTPContext *s = h->priv_data; char hostname[256]; @@ -301,7 +301,7 @@ * @return the local port number */ -int rtp_get_local_rtp_port(URLContext *h) +int ff_rtp_get_local_rtp_port(URLContext *h) { RTPContext *s = h->priv_data; return ff_udp_get_local_port(s->rtp_hd); @@ -313,7 +313,7 @@ * @return the local port number */ -int rtp_get_local_rtcp_port(URLContext *h) +int ff_rtp_get_local_rtcp_port(URLContext *h) { RTPContext *s = h->priv_data; return ff_udp_get_local_port(s->rtcp_hd); @@ -325,7 +325,7 @@ return s->rtp_fd; } -int rtp_get_rtcp_file_handle(URLContext *h) { +int ff_rtp_get_rtcp_file_handle(URLContext *h) { RTPContext *s = h->priv_data; return s->rtcp_fd; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rtsp.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rtsp.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rtsp.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rtsp.c 2011-11-04 12:38:27.000000000 +0000 @@ -33,7 +33,6 @@ #if HAVE_POLL_H #include #endif -#include #include "internal.h" #include "network.h" #include "os_support.h" @@ -45,6 +44,7 @@ #include "rtpdec_formats.h" #include "rtpenc_chain.h" #include "url.h" +#include "rtpenc.h" //#define DEBUG @@ -56,6 +56,44 @@ #define SDP_MAX_SIZE 16384 #define RECVBUF_SIZE 10 * RTP_MAX_PACKET_LENGTH +#define OFFSET(x) offsetof(RTSPState, x) +#define DEC AV_OPT_FLAG_DECODING_PARAM +#define ENC AV_OPT_FLAG_ENCODING_PARAM + +#define RTSP_FLAG_OPTS(name, longname) \ + { name, longname, OFFSET(rtsp_flags), AV_OPT_TYPE_FLAGS, {0}, INT_MIN, INT_MAX, DEC, "rtsp_flags" }, \ + { "filter_src", "Only receive packets from the negotiated peer IP", 0, AV_OPT_TYPE_CONST, {RTSP_FLAG_FILTER_SRC}, 0, 0, DEC, "rtsp_flags" } + +#define RTSP_MEDIATYPE_OPTS(name, longname) \ + { name, longname, OFFSET(media_type_mask), AV_OPT_TYPE_FLAGS, { (1 << (AVMEDIA_TYPE_DATA+1)) - 1 }, INT_MIN, INT_MAX, DEC, "allowed_media_types" }, \ + { "video", "Video", 0, AV_OPT_TYPE_CONST, {1 << AVMEDIA_TYPE_VIDEO}, 0, 0, DEC, "allowed_media_types" }, \ + { "audio", "Audio", 0, AV_OPT_TYPE_CONST, {1 << AVMEDIA_TYPE_AUDIO}, 0, 0, DEC, "allowed_media_types" }, \ + { "data", "Data", 0, AV_OPT_TYPE_CONST, {1 << AVMEDIA_TYPE_DATA}, 0, 0, DEC, "allowed_media_types" } + +const AVOption ff_rtsp_options[] = { + { "initial_pause", "Don't start playing the stream immediately", OFFSET(initial_pause), AV_OPT_TYPE_INT, {0}, 0, 1, DEC }, + FF_RTP_FLAG_OPTS(RTSPState, rtp_muxer_flags), + { "rtsp_transport", "RTSP transport protocols", OFFSET(lower_transport_mask), AV_OPT_TYPE_FLAGS, {0}, INT_MIN, INT_MAX, DEC|ENC, "rtsp_transport" }, \ + { "udp", "UDP", 0, AV_OPT_TYPE_CONST, {1 << RTSP_LOWER_TRANSPORT_UDP}, 0, 0, DEC|ENC, "rtsp_transport" }, \ + { "tcp", "TCP", 0, AV_OPT_TYPE_CONST, {1 << RTSP_LOWER_TRANSPORT_TCP}, 0, 0, DEC|ENC, "rtsp_transport" }, \ + { "udp_multicast", "UDP multicast", 0, AV_OPT_TYPE_CONST, {1 << RTSP_LOWER_TRANSPORT_UDP_MULTICAST}, 0, 0, DEC, "rtsp_transport" }, + { "http", "HTTP tunneling", 0, AV_OPT_TYPE_CONST, {(1 << RTSP_LOWER_TRANSPORT_HTTP)}, 0, 0, DEC, "rtsp_transport" }, + RTSP_FLAG_OPTS("rtsp_flags", "RTSP flags"), + RTSP_MEDIATYPE_OPTS("allowed_media_types", "Media types to accept from the server"), + { NULL }, +}; + +static const AVOption sdp_options[] = { + RTSP_FLAG_OPTS("sdp_flags", "SDP flags"), + RTSP_MEDIATYPE_OPTS("allowed_media_types", "Media types to accept from the server"), + { NULL }, +}; + +static const AVOption rtp_options[] = { + RTSP_FLAG_OPTS("rtp_flags", "RTP flags"), + { NULL }, +}; + static void get_word_until_chars(char *buf, int buf_size, const char *sep, const char **pp) { @@ -294,6 +332,7 @@ case 'm': /* new stream */ s1->skip_media = 0; + codec_type = AVMEDIA_TYPE_UNKNOWN; get_word(st_type, sizeof(st_type), &p); if (!strcmp(st_type, "audio")) { codec_type = AVMEDIA_TYPE_AUDIO; @@ -301,7 +340,8 @@ codec_type = AVMEDIA_TYPE_VIDEO; } else if (!strcmp(st_type, "application")) { codec_type = AVMEDIA_TYPE_DATA; - } else { + } + if (codec_type == AVMEDIA_TYPE_UNKNOWN || !(rt->media_type_mask & (1 << codec_type))) { s1->skip_media = 1; return; } @@ -326,9 +366,10 @@ if (!strcmp(ff_rtp_enc_name(rtsp_st->sdp_payload_type), "MP2T")) { /* no corresponding stream */ } else { - st = av_new_stream(s, rt->nb_rtsp_streams - 1); + st = avformat_new_stream(s, NULL); if (!st) return; + st->id = rt->nb_rtsp_streams - 1; rtsp_st->stream_index = st->index; st->codec->codec_type = codec_type; if (rtsp_st->sdp_payload_type < RTP_PT_PRIVATE) { @@ -501,7 +542,7 @@ } else if (rt->transport == RTSP_TRANSPORT_RDT && CONFIG_RTPDEC) ff_rdt_parse_close(rtsp_st->transport_priv); else if (CONFIG_RTPDEC) - rtp_parse_close(rtsp_st->transport_priv); + ff_rtp_parse_close(rtsp_st->transport_priv); } rtsp_st->transport_priv = NULL; if (rtsp_st->rtp_handle) @@ -558,7 +599,7 @@ rtsp_st->dynamic_protocol_context, rtsp_st->dynamic_handler); else if (CONFIG_RTPDEC) - rtsp_st->transport_priv = rtp_parse_open(s, st, rtsp_st->rtp_handle, + rtsp_st->transport_priv = ff_rtp_parse_open(s, st, rtsp_st->rtp_handle, rtsp_st->sdp_payload_type, (rt->lower_transport == RTSP_LOWER_TRANSPORT_TCP || !s->max_delay) ? 0 : RTP_REORDER_QUEUE_DEFAULT_SIZE); @@ -567,9 +608,9 @@ return AVERROR(ENOMEM); } else if (rt->transport != RTSP_TRANSPORT_RDT && CONFIG_RTPDEC) { if (rtsp_st->dynamic_handler) { - rtp_parse_set_dynamic_protocol(rtsp_st->transport_priv, - rtsp_st->dynamic_protocol_context, - rtsp_st->dynamic_handler); + ff_rtp_parse_set_dynamic_protocol(rtsp_st->transport_priv, + rtsp_st->dynamic_protocol_context, + rtsp_st->dynamic_handler); } } @@ -618,7 +659,7 @@ get_word_sep(transport_protocol, sizeof(transport_protocol), "/", &p); - if (!strcasecmp (transport_protocol, "rtp")) { + if (!av_strcasecmp (transport_protocol, "rtp")) { get_word_sep(profile, sizeof(profile), "/;,", &p); lower_transport[0] = '\0'; /* rtp/avp/ */ @@ -627,14 +668,14 @@ ";,", &p); } th->transport = RTSP_TRANSPORT_RTP; - } else if (!strcasecmp (transport_protocol, "x-pn-tng") || - !strcasecmp (transport_protocol, "x-real-rdt")) { + } else if (!av_strcasecmp (transport_protocol, "x-pn-tng") || + !av_strcasecmp (transport_protocol, "x-real-rdt")) { /* x-pn-tng/ */ get_word_sep(lower_transport, sizeof(lower_transport), "/;,", &p); profile[0] = '\0'; th->transport = RTSP_TRANSPORT_RDT; } - if (!strcasecmp(lower_transport, "TCP")) + if (!av_strcasecmp(lower_transport, "TCP")) th->lower_transport = RTSP_LOWER_TRANSPORT_TCP; else th->lower_transport = RTSP_LOWER_TRANSPORT_UDP; @@ -808,6 +849,9 @@ if (strstr(p, "GET_PARAMETER") && method && !strcmp(method, "OPTIONS")) rt->get_parameter_supported = 1; + } else if (av_stristart(p, "x-Accept-Dynamic-Rate:", &p) && rt) { + p += strspn(p, SPACE_CHARS); + rt->accept_dynamic_rate = atoi(p); } } @@ -1121,7 +1165,7 @@ goto fail; rtp_opened: - port = rtp_get_local_rtp_port(rtsp_st->rtp_handle); + port = ff_rtp_get_local_rtp_port(rtsp_st->rtp_handle); have_port: snprintf(transport, sizeof(transport) - 1, "%s/UDP;", trans_pref); @@ -1165,6 +1209,8 @@ snprintf(cmd, sizeof(cmd), "Transport: %s\r\n", transport); + if (rt->accept_dynamic_rate) + av_strlcat(cmd, "x-Dynamic-Rate: 0\r\n", sizeof(cmd)); if (i == 0 && rt->server_type == RTSP_SERVER_REAL && CONFIG_RTPDEC) { char real_res[41], real_csum[9]; ff_rdt_calc_response_and_checksum(real_res, real_csum, @@ -1213,7 +1259,7 @@ case RTSP_LOWER_TRANSPORT_UDP: { char url[1024], options[30] = ""; - if (rt->filter_source) + if (rt->rtsp_flags & RTSP_FLAG_FILTER_SRC) av_strlcpy(options, "?connect=1", sizeof(options)); /* Use source address if specified */ if (reply->transports[0].source[0]) { @@ -1225,7 +1271,7 @@ reply->transports[0].server_port_min, "%s", options); } if (!(rt->server_type == RTSP_SERVER_WMS && i > 1) && - rtp_set_remote_url(rtsp_st->rtp_handle, url) < 0) { + ff_rtp_set_remote_url(rtsp_st->rtp_handle, url) < 0) { err = AVERROR_INVALIDDATA; goto fail; } @@ -1235,7 +1281,7 @@ */ if (!(rt->server_type == RTSP_SERVER_WMS && i > 1) && s->iformat && CONFIG_RTPDEC) - rtp_send_punch_packets(rtsp_st->rtp_handle); + ff_rtp_send_punch_packets(rtsp_st->rtp_handle); break; } case RTSP_LOWER_TRANSPORT_UDP_MULTICAST: { @@ -1303,8 +1349,17 @@ if (!ff_network_init()) return AVERROR(EIO); -redirect: + rt->control_transport = RTSP_MODE_PLAIN; + if (rt->lower_transport_mask & (1 << RTSP_LOWER_TRANSPORT_HTTP)) { + rt->lower_transport_mask = 1 << RTSP_LOWER_TRANSPORT_TCP; + rt->control_transport = RTSP_MODE_TUNNEL; + } + /* Only pass through valid flags from here */ + rt->lower_transport_mask &= (1 << RTSP_LOWER_TRANSPORT_NB) - 1; + +redirect: + lower_transport_mask = rt->lower_transport_mask; /* extract hostname and port */ av_url_split(NULL, 0, auth, sizeof(auth), host, sizeof(host), &port, path, sizeof(path), s->filename); @@ -1314,6 +1369,7 @@ if (port < 0) port = RTSP_DEFAULT_PORT; +#if FF_API_RTSP_URL_OPTIONS /* search for options */ option_list = strrchr(path, '?'); if (option_list) { @@ -1321,6 +1377,7 @@ * the options back into the same string. */ filename = option_list; while (option_list) { + int handled = 1; /* move the option pointer */ option = ++option_list; option_list = strchr(option_list, '&'); @@ -1338,7 +1395,7 @@ lower_transport_mask |= (1<< RTSP_LOWER_TRANSPORT_TCP); rt->control_transport = RTSP_MODE_TUNNEL; } else if (!strcmp(option, "filter_src")) { - rt->filter_source = 1; + rt->rtsp_flags |= RTSP_FLAG_FILTER_SRC; } else { /* Write options back into the buffer, using memmove instead * of strcpy since the strings may overlap. */ @@ -1346,10 +1403,16 @@ memmove(++filename, option, len); filename += len; if (option_list) *filename = '&'; + handled = 0; } + if (handled) + av_log(s, AV_LOG_WARNING, "Options passed via URL are " + "deprecated, use -rtsp_transport " + "and -rtsp_flags instead.\n"); } *filename = 0; } +#endif if (!lower_transport_mask) lower_transport_mask = (1 << RTSP_LOWER_TRANSPORT_NB) - 1; @@ -1491,7 +1554,7 @@ if (rt->server_type != RTSP_SERVER_REAL && reply->real_challenge[0]) { rt->server_type = RTSP_SERVER_REAL; continue; - } else if (!strncasecmp(reply->server, "WMServer/", 9)) { + } else if (!av_strncasecmp(reply->server, "WMServer/", 9)) { rt->server_type = RTSP_SERVER_WMS; } else if (rt->server_type == RTSP_SERVER_REAL) strcpy(real_challenge, reply->real_challenge); @@ -1569,7 +1632,7 @@ if (rtsp_st->rtp_handle) { p[max_p].fd = ffurl_get_file_handle(rtsp_st->rtp_handle); p[max_p++].events = POLLIN; - p[max_p].fd = rtp_get_rtcp_file_handle(rtsp_st->rtp_handle); + p[max_p].fd = ff_rtp_get_rtcp_file_handle(rtsp_st->rtp_handle); p[max_p++].events = POLLIN; } } @@ -1624,7 +1687,7 @@ if (rt->transport == RTSP_TRANSPORT_RDT) { ret = ff_rdt_parse_packet(rt->cur_transport_priv, pkt, NULL, 0); } else - ret = rtp_parse_packet(rt->cur_transport_priv, pkt, NULL, 0); + ret = ff_rtp_parse_packet(rt->cur_transport_priv, pkt, NULL, 0); if (ret == 0) { rt->cur_transport_priv = NULL; return 0; @@ -1672,13 +1735,13 @@ case RTSP_LOWER_TRANSPORT_UDP_MULTICAST: len = udp_read_packet(s, &rtsp_st, rt->recvbuf, RECVBUF_SIZE, wait_end); if (len > 0 && rtsp_st->transport_priv && rt->transport == RTSP_TRANSPORT_RTP) - rtp_check_and_send_back_rr(rtsp_st->transport_priv, len); + ff_rtp_check_and_send_back_rr(rtsp_st->transport_priv, len); break; } if (len == AVERROR(EAGAIN) && first_queue_st && rt->transport == RTSP_TRANSPORT_RTP) { rtsp_st = first_queue_st; - ret = rtp_parse_packet(rtsp_st->transport_priv, pkt, NULL, 0); + ret = ff_rtp_parse_packet(rtsp_st->transport_priv, pkt, NULL, 0); goto end; } if (len < 0) @@ -1688,7 +1751,7 @@ if (rt->transport == RTSP_TRANSPORT_RDT) { ret = ff_rdt_parse_packet(rtsp_st->transport_priv, pkt, &rt->recvbuf, len); } else { - ret = rtp_parse_packet(rtsp_st->transport_priv, pkt, &rt->recvbuf, len); + ret = ff_rtp_parse_packet(rtsp_st->transport_priv, pkt, &rt->recvbuf, len); if (ret < 0) { /* Either bad packet, or a RTCP packet. Check if the * first_rtcp_ntp_time field was initialized. */ @@ -1792,8 +1855,9 @@ namebuf, sizeof(namebuf), NULL, 0, NI_NUMERICHOST); ff_url_join(url, sizeof(url), "rtp", NULL, namebuf, rtsp_st->sdp_port, - "?localport=%d&ttl=%d", rtsp_st->sdp_port, - rtsp_st->sdp_ttl); + "?localport=%d&ttl=%d&connect=%d", rtsp_st->sdp_port, + rtsp_st->sdp_ttl, + rt->rtsp_flags & RTSP_FLAG_FILTER_SRC ? 1 : 0); if (ffurl_open(&rtsp_st->rtp_handle, url, AVIO_FLAG_READ_WRITE) < 0) { err = AVERROR_INVALIDDATA; goto fail; @@ -1815,6 +1879,13 @@ return 0; } +static const AVClass sdp_demuxer_class = { + .class_name = "SDP demuxer", + .item_name = av_default_item_name, + .option = sdp_options, + .version = LIBAVUTIL_VERSION_INT, +}; + AVInputFormat ff_sdp_demuxer = { .name = "sdp", .long_name = NULL_IF_CONFIG_SMALL("SDP"), @@ -1823,6 +1894,7 @@ .read_header = sdp_read_header, .read_packet = ff_rtsp_fetch_packet, .read_close = sdp_read_close, + .priv_class = &sdp_demuxer_class }; #endif /* CONFIG_SDP_DEMUXER */ @@ -1919,6 +1991,13 @@ return ret; } +static const AVClass rtp_demuxer_class = { + .class_name = "RTP demuxer", + .item_name = av_default_item_name, + .option = rtp_options, + .version = LIBAVUTIL_VERSION_INT, +}; + AVInputFormat ff_rtp_demuxer = { .name = "rtp", .long_name = NULL_IF_CONFIG_SMALL("RTP input format"), @@ -1928,6 +2007,7 @@ .read_packet = ff_rtsp_fetch_packet, .read_close = sdp_read_close, .flags = AVFMT_NOFILE, + .priv_class = &rtp_demuxer_class }; #endif /* CONFIG_RTP_DEMUXER */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rtspdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rtspdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rtspdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rtspdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -22,7 +22,6 @@ #include "libavutil/avstring.h" #include "libavutil/intreadwrite.h" #include "libavutil/mathematics.h" -#include "libavutil/opt.h" #include "avformat.h" #include "internal.h" @@ -388,15 +387,10 @@ return 0; } -static const AVOption options[] = { - { "initial_pause", "Don't start playing the stream immediately", offsetof(RTSPState, initial_pause), FF_OPT_TYPE_INT, {.dbl = 0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM }, - { NULL }, -}; - const AVClass rtsp_demuxer_class = { .class_name = "RTSP demuxer", .item_name = av_default_item_name, - .option = options, + .option = ff_rtsp_options, .version = LIBAVUTIL_VERSION_INT, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rtspenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rtspenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rtspenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rtspenc.c 2011-11-04 12:38:27.000000000 +0000 @@ -33,20 +33,13 @@ #include "libavutil/intreadwrite.h" #include "libavutil/avstring.h" #include "url.h" -#include "libavutil/opt.h" -#include "rtpenc.h" #define SDP_MAX_SIZE 16384 -static const AVOption options[] = { - FF_RTP_FLAG_OPTS(RTSPState, rtp_muxer_flags), - { NULL }, -}; - static const AVClass rtsp_muxer_class = { .class_name = "RTSP muxer", .item_name = av_default_item_name, - .option = options, + .option = ff_rtsp_options, .version = LIBAVUTIL_VERSION_INT, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rtsp.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rtsp.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/rtsp.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/rtsp.h 2011-11-04 12:38:27.000000000 +0000 @@ -29,6 +29,7 @@ #include "httpauth.h" #include "libavutil/log.h" +#include "libavutil/opt.h" /** * Network layer over which RTP/etc packet data will be transported. @@ -37,7 +38,10 @@ RTSP_LOWER_TRANSPORT_UDP = 0, /**< UDP/unicast */ RTSP_LOWER_TRANSPORT_TCP = 1, /**< TCP; interleaved in RTSP */ RTSP_LOWER_TRANSPORT_UDP_MULTICAST = 2, /**< UDP/multicast */ - RTSP_LOWER_TRANSPORT_NB + RTSP_LOWER_TRANSPORT_NB, + RTSP_LOWER_TRANSPORT_HTTP = 8, /**< HTTP tunneled - not a proper + transport mode as such, + only for use via AVOptions */ }; /** @@ -313,10 +317,6 @@ /** Reusable buffer for receiving packets */ uint8_t* recvbuf; - /** Filter incoming UDP packets - receive packets only from the right - * source address and port. */ - int filter_source; - /** * A mask with all requested transport methods */ @@ -346,8 +346,25 @@ * Option flags for the chained RTP muxer. */ int rtp_muxer_flags; + + /** Whether the server accepts the x-Dynamic-Rate header */ + int accept_dynamic_rate; + + /** + * Various option flags for the RTSP muxer/demuxer. + */ + int rtsp_flags; + + /** + * Mask of all requested media types + */ + int media_type_mask; } RTSPState; +#define RTSP_FLAG_FILTER_SRC 0x1 /**< Filter incoming UDP packets - + receive packets only from the right + source address and port. */ + /** * Describes a single stream, as identified by a single m= line block in the * SDP content. In the case of RDT, one RTSPStream can represent multiple @@ -534,4 +551,6 @@ */ void ff_rtsp_undo_setup(AVFormatContext *s); +extern const AVOption ff_rtsp_options[]; + #endif /* AVFORMAT_RTSP_H */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/sapdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/sapdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/sapdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/sapdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -163,11 +163,12 @@ if (sap->sdp_ctx->ctx_flags & AVFMTCTX_NOHEADER) s->ctx_flags |= AVFMTCTX_NOHEADER; for (i = 0; i < sap->sdp_ctx->nb_streams; i++) { - AVStream *st = av_new_stream(s, i); + AVStream *st = avformat_new_stream(s, NULL); if (!st) { ret = AVERROR(ENOMEM); goto fail; } + st->id = i; avcodec_copy_context(st->codec, sap->sdp_ctx->streams[i]->codec); st->time_base = sap->sdp_ctx->streams[i]->time_base; } @@ -211,11 +212,12 @@ if (s->ctx_flags & AVFMTCTX_NOHEADER) { while (sap->sdp_ctx->nb_streams > s->nb_streams) { int i = s->nb_streams; - AVStream *st = av_new_stream(s, i); + AVStream *st = avformat_new_stream(s, NULL); if (!st) { av_free_packet(pkt); return AVERROR(ENOMEM); } + st->id = i; avcodec_copy_context(st->codec, sap->sdp_ctx->streams[i]->codec); st->time_base = sap->sdp_ctx->streams[i]->time_base; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/sdp.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/sdp.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/sdp.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/sdp.c 2011-11-04 12:38:27.000000000 +0000 @@ -252,7 +252,7 @@ return NULL; } - if (ff_split_xiph_headers(c->extradata, c->extradata_size, + if (avpriv_split_xiph_headers(c->extradata, c->extradata_size, first_header_size, header_start, header_len) < 0) { av_log(c, AV_LOG_ERROR, "Extradata corrupt.\n"); @@ -342,7 +342,7 @@ char *config; for (rate_index = 0; rate_index < 16; rate_index++) - if (ff_mpeg4audio_sample_rates[rate_index] == c->sample_rate) + if (avpriv_mpeg4audio_sample_rates[rate_index] == c->sample_rate) break; if (rate_index == 16) { av_log(c, AV_LOG_ERROR, "Unsupported sample rate\n"); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/seek-test.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/seek-test.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/seek-test.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/seek-test.c 2011-11-04 12:38:27.000000000 +0000 @@ -64,10 +64,10 @@ AVFormatContext *ic = NULL; int i, ret, stream_id; int64_t timestamp; - AVFormatParameters params, *ap= ¶ms; - memset(ap, 0, sizeof(params)); - ap->channels=1; - ap->sample_rate= 22050; + AVDictionary *format_opts = NULL; + + av_dict_set(&format_opts, "channels", "1", 0); + av_dict_set(&format_opts, "sample_rate", "22050", 0); /* initialize libavcodec, and register all codecs and formats */ av_register_all(); @@ -80,7 +80,8 @@ filename = argv[1]; - ret = av_open_input_file(&ic, filename, NULL, 0, ap); + ret = avformat_open_input(&ic, filename, NULL, &format_opts); + av_dict_free(&format_opts); if (ret < 0) { fprintf(stderr, "cannot open %s\n", filename); exit(1); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/segafilm.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/segafilm.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/segafilm.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/segafilm.c 2011-11-04 12:38:27.000000000 +0000 @@ -134,7 +134,7 @@ /* initialize the decoder streams */ if (film->video_type) { - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); film->video_stream_index = st->index; @@ -146,7 +146,7 @@ } if (film->audio_type) { - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); film->audio_stream_index = st->index; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/segment.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/segment.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/segment.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/segment.c 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,234 @@ +/* + * Generic Segmenter + * Copyright (c) 2011, Luca Barbato + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/avstring.h" +#include "libavutil/log.h" +#include "libavutil/opt.h" +#include "libavutil/mathematics.h" +#include "libavutil/parseutils.h" +#include "avformat.h" +#include "internal.h" +#include +#include + +typedef struct { + const AVClass *class; /**< Class for private options. */ + int number; + AVFormatContext *avf; + char *format; /**< Set by a private option. */ + char *pattern; /**< Set by a private option. */ + char *path; /**< Set by a private option. */ + float time; /**< Set by a private option. */ + int64_t offset_time; + int64_t recording_time; +} SegmentContext; + +#if CONFIG_SEGMENT_MUXER + +static int segment_header(SegmentContext *s) +{ + AVFormatContext *oc = s->avf; + int err = 0; + + av_strlcpy(oc->filename, s->path, sizeof(oc->filename)); + + av_strlcatf(oc->filename, sizeof(oc->filename), + s->pattern, s->number++); + + if ((err = avio_open(&oc->pb, oc->filename, AVIO_FLAG_WRITE)) < 0) { + return err; + } + + if (!oc->priv_data && oc->oformat->priv_data_size > 0) { + oc->priv_data = av_mallocz(oc->oformat->priv_data_size); + if (!oc->priv_data) { + avio_close(oc->pb); + return AVERROR(ENOMEM); + } + } + + if ((err = oc->oformat->write_header(oc)) < 0) { + avio_close(oc->pb); + av_freep(&oc->priv_data); + } + + return err; +} + +static int segment_trailer(AVFormatContext *oc) +{ + int ret = 0; + + if(oc->oformat->write_trailer) + ret = oc->oformat->write_trailer(oc); + + avio_close(oc->pb); + av_freep(&oc->priv_data); + + return ret; +} + +static int seg_write_header(AVFormatContext *s) +{ + SegmentContext *seg = s->priv_data; + AVFormatContext *oc; + int ret; + + seg->number = 0; + seg->recording_time = seg->time*1000000; + seg->offset_time = 0; + + if (!seg->path) { + char *t; + seg->path = av_strdup(s->filename); + t = strrchr(seg->path, '.'); + if (t) *t = '\0'; + } + + oc = avformat_alloc_context(); + + if (!oc) { + return AVERROR(ENOMEM); + } + + oc->oformat = av_guess_format(seg->format, NULL, NULL); + + if (!oc->oformat) { + avformat_free_context(oc); + return AVERROR_MUXER_NOT_FOUND; + } + + seg->avf = oc; + + oc->streams = s->streams; + oc->nb_streams = s->nb_streams; + + av_strlcpy(oc->filename, seg->path, sizeof(oc->filename)); + + av_strlcatf(oc->filename, sizeof(oc->filename), + seg->pattern, seg->number++); + + if ((ret = avio_open(&oc->pb, oc->filename, AVIO_FLAG_WRITE)) < 0) { + avformat_free_context(oc); + return ret; + } + + if ((ret = avformat_write_header(oc, NULL)) < 0) { + avio_close(oc->pb); + } + + if (ret) + avformat_free_context(oc); + + avio_printf(s->pb, "%s\n", oc->filename); + avio_flush(s->pb); + + return ret; +} + +static int seg_write_packet(AVFormatContext *s, AVPacket *pkt) +{ + SegmentContext *seg = s->priv_data; + AVFormatContext *oc = seg->avf; + AVStream *st = oc->streams[pkt->stream_index]; + int ret; + + if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && + av_compare_ts(pkt->pts, st->time_base, + seg->recording_time*seg->number, + (AVRational){1, 1000000}) >= 0 && + pkt->flags & AV_PKT_FLAG_KEY) { + av_log(s, AV_LOG_INFO, "I'd reset at %d %"PRId64"\n", + pkt->stream_index, pkt->pts); + + ret = segment_trailer(oc); + if (!ret) + ret = segment_header(seg); + + if (ret) { + avformat_free_context(oc); + return ret; + } + avio_printf(s->pb, "%s\n", oc->filename); + avio_flush(s->pb); + } + + ret = oc->oformat->write_packet(oc, pkt); + + return ret; +} + +static int seg_write_trailer(struct AVFormatContext *s) +{ + SegmentContext *seg = s->priv_data; + AVFormatContext *oc = seg->avf; + + return segment_trailer(oc); +} + +#endif /* CONFIG_SEGMENT_MUXER */ + +#define OFFSET(x) offsetof(SegmentContext, x) +#define E AV_OPT_FLAG_ENCODING_PARAM +static const AVOption options[] = { + { "container_format", "container format used for the segments", OFFSET(format), AV_OPT_TYPE_STRING, {.str = "nut"}, 0, 0, E }, + { "segment_time", "segment lenght in seconds", OFFSET(time), AV_OPT_TYPE_FLOAT, {.dbl = 2}, 0, FLT_MAX, E }, + { "segment_pattern", "pattern to use in segment files", OFFSET(pattern),AV_OPT_TYPE_STRING, {.str = "%03d"}, 0, 0, E }, + { "segment_basename", "basename to use in segment files", OFFSET(path ),AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E }, + { NULL }, +}; + +static const AVClass seg_class = { + .class_name = "segment muxer", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + +/* input +#if CONFIG_IMAGE2_DEMUXER +AVInputFormat ff_image2_demuxer = { + .name = "image2", + .long_name = NULL_IF_CONFIG_SMALL("image2 sequence"), + .priv_data_size = sizeof(VideoData), + .read_probe = read_probe, + .read_header = read_header, + .read_packet = read_packet, + .flags = AVFMT_NOFILE, + .priv_class = &img2_class, +}; +#endif +*/ + +/* output */ +#if CONFIG_SEGMENT_MUXER +AVOutputFormat ff_segment_muxer = { + .name = "segment", + .long_name = NULL_IF_CONFIG_SMALL("segment muxer"), + .extensions = "m3u8", + .priv_data_size = sizeof(SegmentContext), + .flags = AVFMT_GLOBALHEADER, + .write_header = seg_write_header, + .write_packet = seg_write_packet, + .write_trailer = seg_write_trailer, + .priv_class = &seg_class, +}; +#endif diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/sierravmd.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/sierravmd.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/sierravmd.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/sierravmd.c 2011-11-04 12:38:27.000000000 +0000 @@ -104,7 +104,7 @@ else vmd->is_indeo3 = 0; /* start up the decoders */ - vst = av_new_stream(s, 0); + vst = avformat_new_stream(s, NULL); if (!vst) return AVERROR(ENOMEM); av_set_pts_info(vst, 33, 1, 10); @@ -125,7 +125,7 @@ /* if sample rate is 0, assume no audio */ vmd->sample_rate = AV_RL16(&vmd->vmd_header[804]); if (vmd->sample_rate) { - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); vmd->audio_stream_index = st->index; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/siff.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/siff.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/siff.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/siff.c 2011-11-04 12:38:27.000000000 +0000 @@ -71,7 +71,7 @@ static int create_audio_stream(AVFormatContext *s, SIFFContext *c) { AVStream *ast; - ast = av_new_stream(s, 0); + ast = avformat_new_stream(s, NULL); if (!ast) return -1; ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; @@ -115,7 +115,7 @@ avio_skip(pb, 16); //zeroes - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return -1; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/smacker.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/smacker.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/smacker.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/smacker.c 2011-11-04 12:38:27.000000000 +0000 @@ -31,11 +31,11 @@ #define SMACKER_FLAG_RING_FRAME 0x01 enum SAudFlags { - SMK_AUD_PACKED = 0x80000000, - SMK_AUD_16BITS = 0x20000000, - SMK_AUD_STEREO = 0x10000000, - SMK_AUD_BINKAUD = 0x08000000, - SMK_AUD_USEDCT = 0x04000000 + SMK_AUD_PACKED = 0x80, + SMK_AUD_16BITS = 0x20, + SMK_AUD_STEREO = 0x10, + SMK_AUD_BINKAUD = 0x08, + SMK_AUD_USEDCT = 0x04 }; typedef struct SmackerContext { @@ -48,6 +48,7 @@ uint32_t audio[7]; uint32_t treesize; uint32_t mmap_size, mclr_size, full_size, type_size; + uint8_t aflags[7]; uint32_t rates[7]; uint32_t pad; /* frame info */ @@ -129,8 +130,10 @@ smk->mclr_size = avio_rl32(pb); smk->full_size = avio_rl32(pb); smk->type_size = avio_rl32(pb); - for(i = 0; i < 7; i++) - smk->rates[i] = avio_rl32(pb); + for(i = 0; i < 7; i++) { + smk->rates[i] = avio_rl24(pb); + smk->aflags[i] = avio_r8(pb); + } smk->pad = avio_rl32(pb); /* setup data */ if(smk->frames > 0xFFFFFF) { @@ -151,7 +154,7 @@ } /* init video codec */ - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return -1; smk->videoindex = st->index; @@ -173,23 +176,23 @@ /* handle possible audio streams */ for(i = 0; i < 7; i++) { smk->indexes[i] = -1; - if(smk->rates[i] & 0xFFFFFF){ - ast[i] = av_new_stream(s, 0); + if (smk->rates[i]) { + ast[i] = avformat_new_stream(s, NULL); smk->indexes[i] = ast[i]->index; ast[i]->codec->codec_type = AVMEDIA_TYPE_AUDIO; - if (smk->rates[i] & SMK_AUD_BINKAUD) { + if (smk->aflags[i] & SMK_AUD_BINKAUD) { ast[i]->codec->codec_id = CODEC_ID_BINKAUDIO_RDFT; - } else if (smk->rates[i] & SMK_AUD_USEDCT) { + } else if (smk->aflags[i] & SMK_AUD_USEDCT) { ast[i]->codec->codec_id = CODEC_ID_BINKAUDIO_DCT; - } else if (smk->rates[i] & SMK_AUD_PACKED){ + } else if (smk->aflags[i] & SMK_AUD_PACKED){ ast[i]->codec->codec_id = CODEC_ID_SMACKAUDIO; ast[i]->codec->codec_tag = MKTAG('S', 'M', 'K', 'A'); } else { ast[i]->codec->codec_id = CODEC_ID_PCM_U8; } - ast[i]->codec->channels = (smk->rates[i] & SMK_AUD_STEREO) ? 2 : 1; - ast[i]->codec->sample_rate = smk->rates[i] & 0xFFFFFF; - ast[i]->codec->bits_per_coded_sample = (smk->rates[i] & SMK_AUD_16BITS) ? 16 : 8; + ast[i]->codec->channels = (smk->aflags[i] & SMK_AUD_STEREO) ? 2 : 1; + ast[i]->codec->sample_rate = smk->rates[i]; + ast[i]->codec->bits_per_coded_sample = (smk->aflags[i] & SMK_AUD_16BITS) ? 16 : 8; if(ast[i]->codec->bits_per_coded_sample == 16 && ast[i]->codec->codec_id == CODEC_ID_PCM_U8) ast[i]->codec->codec_id = CODEC_ID_PCM_S16LE; av_set_pts_info(ast[i], 64, 1, ast[i]->codec->sample_rate diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/sol.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/sol.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/sol.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/sol.c 2011-11-04 12:38:27.000000000 +0000 @@ -110,7 +110,7 @@ else id = 0; /* now we are ready: build format streams */ - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return -1; st->codec->codec_type = AVMEDIA_TYPE_AUDIO; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/soxdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/soxdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/soxdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/soxdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -51,7 +51,7 @@ double sample_rate, sample_rate_frac; AVStream *st; - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/spdifdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/spdifdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/spdifdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/spdifdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -57,7 +57,7 @@ break; case IEC61937_MPEG2_AAC: init_get_bits(&gbc, buf, AAC_ADTS_HEADER_SIZE * 8); - if (ff_aac_parse_header(&gbc, &aac_hdr)) { + if (avpriv_aac_parse_header(&gbc, &aac_hdr)) { if (s) /* be silent during a probe */ av_log(s, AV_LOG_ERROR, "Invalid AAC packet in IEC 61937\n"); return AVERROR_INVALIDDATA; @@ -205,7 +205,7 @@ if (!s->nb_streams) { /* first packet, create a stream */ - AVStream *st = av_new_stream(s, 0); + AVStream *st = avformat_new_stream(s, NULL); if (!st) { av_free_packet(pkt); return AVERROR(ENOMEM); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/spdifenc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/spdifenc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/spdifenc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/spdifenc.c 2011-11-04 12:38:27.000000000 +0000 @@ -86,10 +86,10 @@ } IEC61937Context; static const AVOption options[] = { -{ "spdif_flags", "IEC 61937 encapsulation flags", offsetof(IEC61937Context, spdif_flags), FF_OPT_TYPE_FLAGS, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "spdif_flags" }, -{ "be", "output in big-endian format (for use as s16be)", 0, FF_OPT_TYPE_CONST, {.dbl = SPDIF_FLAG_BIGENDIAN}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "spdif_flags" }, -{ "dtshd_rate", "mux complete DTS frames in HD mode at the specified IEC958 rate (in Hz, default 0=disabled)", offsetof(IEC61937Context, dtshd_rate), FF_OPT_TYPE_INT, {.dbl = 0}, 0, 768000, AV_OPT_FLAG_ENCODING_PARAM }, -{ "dtshd_fallback_time", "min secs to strip HD for after an overflow (-1: till the end, default 60)", offsetof(IEC61937Context, dtshd_fallback), FF_OPT_TYPE_INT, {.dbl = 60}, -1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, +{ "spdif_flags", "IEC 61937 encapsulation flags", offsetof(IEC61937Context, spdif_flags), AV_OPT_TYPE_FLAGS, {.dbl = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "spdif_flags" }, +{ "be", "output in big-endian format (for use as s16be)", 0, AV_OPT_TYPE_CONST, {.dbl = SPDIF_FLAG_BIGENDIAN}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "spdif_flags" }, +{ "dtshd_rate", "mux complete DTS frames in HD mode at the specified IEC958 rate (in Hz, default 0=disabled)", offsetof(IEC61937Context, dtshd_rate), AV_OPT_TYPE_INT, {.dbl = 0}, 0, 768000, AV_OPT_FLAG_ENCODING_PARAM }, +{ "dtshd_fallback_time", "min secs to strip HD for after an overflow (-1: till the end, default 60)", offsetof(IEC61937Context, dtshd_fallback), AV_OPT_TYPE_INT, {.dbl = 60}, -1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM }, { NULL }, }; @@ -220,7 +220,10 @@ } ctx->out_bytes = sizeof(dtshd_start_code) + 2 + pkt_size; - ctx->length_code = ctx->out_bytes; + + /* Align so that (length_code & 0xf) == 0x8. This is reportedly needed + * with some receivers, but the exact requirement is unconfirmed. */ + ctx->length_code = FFALIGN(ctx->out_bytes + 0x8, 0x10) - 0x8; av_fast_malloc(&ctx->hd_buf, &ctx->hd_buf_size, ctx->out_bytes); if (!ctx->hd_buf) @@ -349,7 +352,7 @@ int ret; init_get_bits(&gbc, pkt->data, AAC_ADTS_HEADER_SIZE * 8); - ret = ff_aac_parse_header(&gbc, &hdr); + ret = avpriv_aac_parse_header(&gbc, &hdr); if (ret < 0) { av_log(s, AV_LOG_ERROR, "Wrong AAC file format\n"); return AVERROR_INVALIDDATA; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/srtdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/srtdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/srtdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/srtdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -42,7 +42,7 @@ static int srt_read_header(AVFormatContext *s, AVFormatParameters *ap) { - AVStream *st = av_new_stream(s, 0); + AVStream *st = avformat_new_stream(s, NULL); if (!st) return -1; av_set_pts_info(st, 64, 1, 1000); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/swfdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/swfdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/swfdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/swfdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -106,9 +106,10 @@ avio_rl16(pb); avio_r8(pb); /* Check for FLV1 */ - vst = av_new_stream(s, ch_id); + vst = avformat_new_stream(s, NULL); if (!vst) return -1; + vst->id = ch_id; vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; vst->codec->codec_id = ff_codec_get_id(swf_codec_tags, avio_r8(pb)); av_set_pts_info(vst, 16, 256, swf->frame_rate); @@ -127,9 +128,10 @@ avio_r8(pb); v = avio_r8(pb); swf->samples_per_frame = avio_rl16(pb); - ast = av_new_stream(s, -1); /* -1 to avoid clash with video stream ch_id */ + ast = avformat_new_stream(s, NULL); if (!ast) return -1; + ast->id = -1; /* -1 to avoid clash with video stream ch_id */ ast->codec->channels = 1 + (v&1); ast->codec->codec_type = AVMEDIA_TYPE_AUDIO; ast->codec->codec_id = ff_codec_get_id(swf_audio_codec_tags, (v>>4) & 15); @@ -177,9 +179,10 @@ break; } if (i == s->nb_streams) { - vst = av_new_stream(s, -2); /* -2 to avoid clash with video stream and audio stream */ + vst = avformat_new_stream(s, NULL); if (!vst) return -1; + vst->id = -2; /* -2 to avoid clash with video stream and audio stream */ vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; vst->codec->codec_id = CODEC_ID_MJPEG; av_set_pts_info(vst, 64, 256, swf->frame_rate); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/thp.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/thp.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/thp.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/thp.c 2011-11-04 12:38:27.000000000 +0000 @@ -94,7 +94,7 @@ break; /* Video component. */ - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); @@ -117,7 +117,7 @@ break; /* Audio component. */ - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/tiertexseq.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/tiertexseq.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/tiertexseq.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/tiertexseq.c 2011-11-04 12:38:27.000000000 +0000 @@ -206,7 +206,7 @@ seq->audio_buffer_full = 0; /* initialize the video decoder stream */ - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); @@ -219,7 +219,7 @@ st->codec->height = SEQ_FRAME_H; /* initialize the audio decoder stream */ - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/timecode_v2.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/timecode_v2.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/timecode_v2.c 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/timecode_v2.c 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,53 @@ +/* + * extract pts as timecode v2, as defined by mkvtoolnix + * Copyright (c) 2009 David Conrad + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "avformat.h" + +static int timecode_v2_write_header(AVFormatContext *s) +{ + static const char *header = "# timecode format v2\n"; + put_buffer(s->pb, header, strlen(header)); + av_set_pts_info(s->streams[0], 64, 1, 1000); + return 0; +} + +static int timecode_v2_write_packet(AVFormatContext *s, AVPacket *pkt) +{ + char buf[256]; + if (pkt->stream_index) + av_log(s, AV_LOG_WARNING, "More than one stream unsupported\n"); + snprintf(buf, sizeof(buf), "%" PRId64 "\n", pkt->dts); + put_buffer(s->pb, buf, strlen(buf)); + put_flush_packet(s->pb); + return 0; +} + +AVOutputFormat ff_timecode_v2_muxer = { + "timecode_v2", + NULL_IF_CONFIG_SMALL("timecode format v2"), + NULL, + "", + 0, + CODEC_ID_NONE, + CODEC_ID_RAWVIDEO, + timecode_v2_write_header, + timecode_v2_write_packet, +}; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/timefilter.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/timefilter.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/timefilter.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/timefilter.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,151 +0,0 @@ -/* - * Delay Locked Loop based time filter - * Copyright (c) 2009 Samalyse - * Copyright (c) 2009 Michael Niedermayer - * Author: Olivier Guilyardi - * Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#include "config.h" -#include "avformat.h" -#include "timefilter.h" - -struct TimeFilter { - /// Delay Locked Loop data. These variables refer to mathematical - /// concepts described in: http://www.kokkinizita.net/papers/usingdll.pdf - double cycle_time; - double feedback2_factor; - double feedback3_factor; - double clock_period; - int count; -}; - -TimeFilter * ff_timefilter_new(double clock_period, double feedback2_factor, double feedback3_factor) -{ - TimeFilter *self = av_mallocz(sizeof(TimeFilter)); - self->clock_period = clock_period; - self->feedback2_factor = feedback2_factor; - self->feedback3_factor = feedback3_factor; - return self; -} - -void ff_timefilter_destroy(TimeFilter *self) -{ - av_freep(&self); -} - -void ff_timefilter_reset(TimeFilter *self) -{ - self->count = 0; -} - -double ff_timefilter_update(TimeFilter *self, double system_time, double period) -{ - self->count++; - if (self->count==1) { - /// init loop - self->cycle_time = system_time; - } else { - double loop_error; - self->cycle_time += self->clock_period * period; - /// calculate loop error - loop_error = system_time - self->cycle_time; - - /// update loop - self->cycle_time += FFMAX(self->feedback2_factor, 1.0/(self->count)) * loop_error; - self->clock_period += self->feedback3_factor * loop_error / period; - } - return self->cycle_time; -} - -#ifdef TEST -#include "libavutil/lfg.h" -#define LFG_MAX ((1LL << 32) - 1) - -#undef printf - -int main(void) -{ - AVLFG prng; - double n0,n1; -#define SAMPLES 1000 - double ideal[SAMPLES]; - double samples[SAMPLES]; -#if 1 - for(n0= 0; n0<40; n0=2*n0+1){ - for(n1= 0; n1<10; n1=2*n1+1){ -#else - {{ - n0=7; - n1=1; -#endif - double best_error= 1000000000; - double bestpar0=1; - double bestpar1=0.001; - int better, i; - - av_lfg_init(&prng, 123); - for(i=0; i - * Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVFORMAT_TIMEFILTER_H -#define AVFORMAT_TIMEFILTER_H - -/** - * Opaque type representing a time filter state - * - * The purpose of this filter is to provide a way to compute accurate time - * stamps that can be compared to wall clock time, especially when dealing - * with two clocks: the system clock and a hardware device clock, such as - * a soundcard. - */ -typedef struct TimeFilter TimeFilter; - - -/** - * Create a new Delay Locked Loop time filter - * - * feedback2_factor and feedback3_factor are the factors used for the - * multiplications that are respectively performed in the second and third - * feedback paths of the loop. - * - * Unless you know what you are doing, you should set these as follow: - * - * o = 2 * M_PI * bandwidth * period - * feedback2_factor = sqrt(2 * o) - * feedback3_factor = o * o - * - * Where bandwidth is up to you to choose. Smaller values will filter out more - * of the jitter, but also take a longer time for the loop to settle. A good - * starting point is something between 0.3 and 3 Hz. - * - * @param clock_period period of the hardware clock in seconds - * (for example 1.0/44100) - * - * For more details about these parameters and background concepts please see: - * http://www.kokkinizita.net/papers/usingdll.pdf - */ -TimeFilter * ff_timefilter_new(double clock_period, double feedback2_factor, double feedback3_factor); - -/** - * Update the filter - * - * This function must be called in real time, at each process cycle. - * - * @param period the device cycle duration in clock_periods. For example, at - * 44.1kHz and a buffer size of 512 frames, period = 512 when clock_period - * was 1.0/44100, or 512/44100 if clock_period was 1. - * - * system_time, in seconds, should be the value of the system clock time, - * at (or as close as possible to) the moment the device hardware interrupt - * occured (or any other event the device clock raises at the beginning of a - * cycle). - * - * @return the filtered time, in seconds - */ -double ff_timefilter_update(TimeFilter *self, double system_time, double period); - -/** - * Reset the filter - * - * This function should mainly be called in case of XRUN. - * - * Warning: after calling this, the filter is in an undetermined state until - * the next call to ff_timefilter_update() - */ -void ff_timefilter_reset(TimeFilter *); - -/** - * Free all resources associated with the filter - */ -void ff_timefilter_destroy(TimeFilter *); - -#endif /* AVFORMAT_TIMEFILTER_H */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/tmv.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/tmv.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/tmv.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/tmv.c 2011-11-04 12:38:27.000000000 +0000 @@ -73,10 +73,10 @@ if (avio_rl32(pb) != TMV_TAG) return -1; - if (!(vst = av_new_stream(s, 0))) + if (!(vst = avformat_new_stream(s, NULL))) return AVERROR(ENOMEM); - if (!(ast = av_new_stream(s, 0))) + if (!(ast = avformat_new_stream(s, NULL))) return AVERROR(ENOMEM); ast->codec->sample_rate = avio_rl16(pb); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/tta.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/tta.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/tta.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/tta.c 2011-11-04 12:38:27.000000000 +0000 @@ -77,7 +77,7 @@ return -1; } - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); @@ -107,6 +107,10 @@ return -1; } st->codec->extradata = av_mallocz(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE); + if (!st->codec->extradata) { + st->codec->extradata_size = 0; + return AVERROR(ENOMEM); + } avio_seek(s->pb, start_offset, SEEK_SET); avio_read(s->pb, st->codec->extradata, st->codec->extradata_size); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/tty.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/tty.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/tty.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/tty.c 2011-11-04 12:38:27.000000000 +0000 @@ -76,7 +76,7 @@ { TtyDemuxContext *s = avctx->priv_data; int width = 0, height = 0, ret = 0; - AVStream *st = av_new_stream(avctx, 0); + AVStream *st = avformat_new_stream(avctx, NULL); AVRational framerate; if (!st) { @@ -142,9 +142,9 @@ #define OFFSET(x) offsetof(TtyDemuxContext, x) #define DEC AV_OPT_FLAG_DECODING_PARAM static const AVOption options[] = { - { "chars_per_frame", "", offsetof(TtyDemuxContext, chars_per_frame), FF_OPT_TYPE_INT, {.dbl = 6000}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM}, - { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, - { "framerate", "", OFFSET(framerate), FF_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC }, + { "chars_per_frame", "", offsetof(TtyDemuxContext, chars_per_frame), AV_OPT_TYPE_INT, {.dbl = 6000}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM}, + { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC }, + { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_STRING, {.str = "25"}, 0, 0, DEC }, { NULL }, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/txd.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/txd.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/txd.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/txd.c 2011-11-04 12:38:27.000000000 +0000 @@ -40,7 +40,7 @@ static int txd_read_header(AVFormatContext *s, AVFormatParameters *ap) { AVStream *st; - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_VIDEO; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/utils.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/utils.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/utils.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/utils.c 2011-11-04 12:38:27.000000000 +0000 @@ -38,7 +38,6 @@ #include "url.h" #include #include -#include #include #if CONFIG_NETWORK #include "network.h" @@ -170,7 +169,7 @@ while (*p != '\0' && *p != ',' && q-ext1iformat && !strlen(filename)) + return 0; + if (s->pb) { s->flags |= AVFMT_FLAG_CUSTOM_IO; if (!s->iformat) @@ -756,12 +759,18 @@ av_log(s, AV_LOG_WARNING, "Dropped corrupted packet (stream = %d)\n", pkt->stream_index); + av_free_packet(pkt); continue; } if(!(s->flags & AVFMT_FLAG_KEEP_SIDE_DATA)) av_packet_merge_side_data(pkt); + if(pkt->stream_index >= (unsigned)s->nb_streams){ + av_log(s, AV_LOG_ERROR, "Invalid stream index %d\n", pkt->stream_index); + continue; + } + st= s->streams[pkt->stream_index]; switch(st->codec->codec_type){ @@ -1408,7 +1417,8 @@ av_free_packet(&st->cur_pkt); } st->last_IP_pts = AV_NOPTS_VALUE; - st->cur_dts = AV_NOPTS_VALUE; /* we set the current DTS to an unspecified origin */ + if(st->first_dts == AV_NOPTS_VALUE) st->cur_dts = 0; + else st->cur_dts = AV_NOPTS_VALUE; /* we set the current DTS to an unspecified origin */ st->reference_dts = AV_NOPTS_VALUE; /* fail safe */ st->cur_ptr = NULL; @@ -1421,7 +1431,15 @@ } } -void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp){ +#if FF_API_SEEK_PUBLIC +void av_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp) +{ + return ff_update_cur_dts(s, ref_st, timestamp); +} +#endif + +void ff_update_cur_dts(AVFormatContext *s, AVStream *ref_st, int64_t timestamp) +{ int i; for(i = 0; i < s->nb_streams; i++) { @@ -1541,7 +1559,14 @@ wanted_timestamp, flags); } +#if FF_API_SEEK_PUBLIC int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags){ + return ff_seek_frame_binary(s, stream_index, target_ts, flags); +} +#endif + +int ff_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags) +{ AVInputFormat *avif= s->iformat; int64_t av_uninit(pos_min), av_uninit(pos_max), pos, pos_limit; int64_t ts_min, ts_max, ts; @@ -1588,7 +1613,7 @@ } } - pos= av_gen_search(s, stream_index, target_ts, pos_min, pos_max, pos_limit, ts_min, ts_max, flags, &ts, avif->read_timestamp); + pos= ff_gen_search(s, stream_index, target_ts, pos_min, pos_max, pos_limit, ts_min, ts_max, flags, &ts, avif->read_timestamp); if(pos<0) return -1; @@ -1596,12 +1621,29 @@ if ((ret = avio_seek(s->pb, pos, SEEK_SET)) < 0) return ret; - av_update_cur_dts(s, st, ts); + ff_read_frame_flush(s); + ff_update_cur_dts(s, st, ts); return 0; } -int64_t av_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, int64_t pos_min, int64_t pos_max, int64_t pos_limit, int64_t ts_min, int64_t ts_max, int flags, int64_t *ts_ret, int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t )){ +#if FF_API_SEEK_PUBLIC +int64_t av_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, + int64_t pos_min, int64_t pos_max, int64_t pos_limit, + int64_t ts_min, int64_t ts_max, int flags, int64_t *ts_ret, + int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t )) +{ + return ff_gen_search(s, stream_index, target_ts, pos_min, pos_max, + pos_limit, ts_min, ts_max, flags, ts_ret, + read_timestamp); +} +#endif + +int64_t ff_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, + int64_t pos_min, int64_t pos_max, int64_t pos_limit, + int64_t ts_min, int64_t ts_max, int flags, int64_t *ts_ret, + int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t )) +{ int64_t pos, ts; int64_t start_pos, filesize; int no_change; @@ -1615,6 +1657,11 @@ return -1; } + if(ts_min >= target_ts){ + *ts_ret= ts_min; + return pos_min; + } + if(ts_max == AV_NOPTS_VALUE){ int step= 1024; filesize = avio_size(s->pb); @@ -1640,6 +1687,11 @@ pos_limit= pos_max; } + if(ts_max <= target_ts){ + *ts_ret= ts_max; + return pos_max; + } + if(ts_min > ts_max){ return -1; }else if(ts_min == ts_max){ @@ -1697,12 +1749,14 @@ pos = (flags & AVSEEK_FLAG_BACKWARD) ? pos_min : pos_max; ts = (flags & AVSEEK_FLAG_BACKWARD) ? ts_min : ts_max; +#if 0 pos_min = pos; ts_min = read_timestamp(s, stream_index, &pos_min, INT64_MAX); pos_min++; ts_max = read_timestamp(s, stream_index, &pos_min, INT64_MAX); av_dlog(s, "pos=0x%"PRIx64" %"PRId64"<=%"PRId64"<=%"PRId64"\n", pos, ts_min, target_ts, ts_max); +#endif *ts_ret= ts; return pos; } @@ -1756,7 +1810,7 @@ ie= &st->index_entries[st->nb_index_entries-1]; if ((ret = avio_seek(s->pb, ie->pos, SEEK_SET)) < 0) return ret; - av_update_cur_dts(s, st, ie->timestamp); + ff_update_cur_dts(s, st, ie->timestamp); }else{ if ((ret = avio_seek(s->pb, s->data_offset, SEEK_SET)) < 0) return ret; @@ -1793,7 +1847,7 @@ ie = &st->index_entries[index]; if ((ret = avio_seek(s->pb, ie->pos, SEEK_SET)) < 0) return ret; - av_update_cur_dts(s, st, ie->timestamp); + ff_update_cur_dts(s, st, ie->timestamp); return 0; } @@ -1803,10 +1857,12 @@ int ret; AVStream *st; - ff_read_frame_flush(s); - - if(flags & AVSEEK_FLAG_BYTE) + if (flags & AVSEEK_FLAG_BYTE) { + if (s->iformat->flags & AVFMT_NO_BYTE_SEEK) + return -1; + ff_read_frame_flush(s); return seek_frame_byte(s, stream_index, timestamp, flags); + } if(stream_index < 0){ stream_index= av_find_default_stream_index(s); @@ -1820,19 +1876,23 @@ /* first, we try the format specific seek */ AV_NOWARN_DEPRECATED( - if (s->iformat->read_seek) + if (s->iformat->read_seek) { + ff_read_frame_flush(s); ret = s->iformat->read_seek(s, stream_index, timestamp, flags); - else + } else ret = -1; ) if (ret >= 0) { return 0; } - if(s->iformat->read_timestamp && !(s->iformat->flags & AVFMT_NOBINSEARCH)) - return av_seek_frame_binary(s, stream_index, timestamp, flags); - else if (!(s->iformat->flags & AVFMT_NOGENSEARCH)) + if (s->iformat->read_timestamp && !(s->iformat->flags & AVFMT_NOBINSEARCH)) { + ff_read_frame_flush(s); + return ff_seek_frame_binary(s, stream_index, timestamp, flags); + } else if (!(s->iformat->flags & AVFMT_NOGENSEARCH)) { + ff_read_frame_flush(s); return seek_frame_generic(s, stream_index, timestamp, flags); + } else return -1; } @@ -1842,10 +1902,10 @@ if(min_ts > ts || max_ts < ts) return -1; - ff_read_frame_flush(s); - - if (s->iformat->read_seek2) + if (s->iformat->read_seek2) { + ff_read_frame_flush(s); return s->iformat->read_seek2(s, stream_index, min_ts, ts, max_ts, flags); + } if(s->iformat->read_timestamp){ //try to seek via read_timestamp() @@ -1891,7 +1951,7 @@ static void update_stream_timings(AVFormatContext *ic) { int64_t start_time, start_time1, start_time_text, end_time, end_time1; - int64_t duration, duration1; + int64_t duration, duration1, filesize; int i; AVStream *st; @@ -1907,36 +1967,31 @@ if (start_time1 < start_time_text) start_time_text = start_time1; } else - if (start_time1 < start_time) - start_time = start_time1; + start_time = FFMIN(start_time, start_time1); if (st->duration != AV_NOPTS_VALUE) { end_time1 = start_time1 + av_rescale_q(st->duration, st->time_base, AV_TIME_BASE_Q); - if (end_time1 > end_time) - end_time = end_time1; + end_time = FFMAX(end_time, end_time1); } } if (st->duration != AV_NOPTS_VALUE) { duration1 = av_rescale_q(st->duration, st->time_base, AV_TIME_BASE_Q); - if (duration1 > duration) - duration = duration1; + duration = FFMAX(duration, duration1); } } if (start_time == INT64_MAX || (start_time > start_time_text && start_time - start_time_text < AV_TIME_BASE)) start_time = start_time_text; if (start_time != INT64_MAX) { ic->start_time = start_time; - if (end_time != INT64_MIN) { - if (end_time - start_time > duration) - duration = end_time - start_time; - } + if (end_time != INT64_MIN) + duration = FFMAX(duration, end_time - start_time); } if (duration != INT64_MIN && ic->duration == AV_NOPTS_VALUE) { ic->duration = duration; } - if (ic->file_size > 0 && ic->duration != AV_NOPTS_VALUE) { + if (ic->pb && (filesize = avio_size(ic->pb)) > 0 && ic->duration != AV_NOPTS_VALUE) { /* compute the bitrate */ - ic->bit_rate = (double)ic->file_size * 8.0 * AV_TIME_BASE / + ic->bit_rate = (double)filesize * 8.0 * AV_TIME_BASE / (double)ic->duration; } } @@ -1977,9 +2032,8 @@ /* if duration is already set, we believe it */ if (ic->duration == AV_NOPTS_VALUE && - ic->bit_rate != 0 && - ic->file_size != 0) { - filesize = ic->file_size; + ic->bit_rate != 0) { + filesize = ic->pb ? avio_size(ic->pb) : 0; if (filesize > 0) { for(i = 0; i < ic->nb_streams; i++) { st = ic->streams[i]; @@ -2023,7 +2077,7 @@ /* estimate the end time (duration) */ /* XXX: may need to support wrapping */ - filesize = ic->file_size; + filesize = ic->pb ? avio_size(ic->pb) : 0; end_time = AV_NOPTS_VALUE; do{ offset = filesize - (DURATION_MAX_READ_SIZE<pb); - if (file_size < 0) - file_size = 0; + file_size = FFMAX(0, file_size); } - ic->file_size = file_size; if ((!strcmp(ic->iformat->name, "mpeg") || !strcmp(ic->iformat->name, "mpegts")) && @@ -2133,7 +2185,6 @@ avctx->codec_id == CODEC_ID_MP1 || avctx->codec_id == CODEC_ID_MP2 || avctx->codec_id == CODEC_ID_MP3 || - avctx->codec_id == CODEC_ID_SPEEX || avctx->codec_id == CODEC_ID_CELT)) return 0; break; @@ -2152,7 +2203,7 @@ static int has_decode_delay_been_guessed(AVStream *st) { return st->codec->codec_id != CODEC_ID_H264 || - st->codec_info_nb_frames >= 6 + st->codec->has_b_frames; + st->info->nb_decoded_frames >= 6; } static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **options) @@ -2178,6 +2229,8 @@ avcodec_get_frame_defaults(&picture); ret = avcodec_decode_video2(st->codec, &picture, &got_picture, avpkt); + if (got_picture) + st->info->nb_decoded_frames++; break; case AVMEDIA_TYPE_AUDIO: data_size = FFMAX(avpkt->size, AVCODEC_MAX_AUDIO_FRAME_SIZE); @@ -2214,7 +2267,7 @@ return tags[i].id; } for(i=0; tags[i].id != CODEC_ID_NONE; i++) { - if (ff_toupper4(tag) == ff_toupper4(tags[i].tag)) + if (avpriv_toupper4(tag) == avpriv_toupper4(tags[i].tag)) return tags[i].id; } return CODEC_ID_NONE; @@ -2435,10 +2488,10 @@ } { int64_t last = st->info->last_dts; - int64_t duration= pkt->dts - last; - if(pkt->dts != AV_NOPTS_VALUE && last != AV_NOPTS_VALUE && duration>0){ + if(pkt->dts != AV_NOPTS_VALUE && last != AV_NOPTS_VALUE && pkt->dts > last){ double dts= pkt->dts * av_q2d(st->time_base); + int64_t duration= pkt->dts - last; // if(st->codec->codec_type == AVMEDIA_TYPE_VIDEO) // av_log(NULL, AV_LOG_ERROR, "%f\n", dur); @@ -2752,8 +2805,18 @@ avio_close(pb); } +#if FF_API_NEW_STREAM AVStream *av_new_stream(AVFormatContext *s, int id) { + AVStream *st = avformat_new_stream(s, NULL); + if (st) + st->id = id; + return st; +} +#endif + +AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c) +{ AVStream *st; int i; AVStream **streams; @@ -2773,13 +2836,12 @@ return NULL; } - st->codec = avcodec_alloc_context3(NULL); + st->codec = avcodec_alloc_context3(c); if (s->iformat) { /* no default bitrate if decoding */ st->codec->bit_rate = 0; } st->index = s->nb_streams; - st->id = id; st->start_time = AV_NOPTS_VALUE; st->duration = AV_NOPTS_VALUE; /* we set the current DTS to 0 so that formats without any timestamps @@ -2826,7 +2888,7 @@ return program; } -AVChapter *ff_new_chapter(AVFormatContext *s, int id, AVRational time_base, int64_t start, int64_t end, const char *title) +AVChapter *avpriv_new_chapter(AVFormatContext *s, int id, AVRational time_base, int64_t start, int64_t end, const char *title) { AVChapter *chapter = NULL; int i; @@ -2950,7 +3012,7 @@ for (n = 0; s->oformat->codec_tag[n]; n++) { avctag = s->oformat->codec_tag[n]; while (avctag->id != CODEC_ID_NONE) { - if (ff_toupper4(avctag->tag) == ff_toupper4(st->codec->codec_tag)) { + if (avpriv_toupper4(avctag->tag) == avpriv_toupper4(st->codec->codec_tag)) { id = avctag->id; if (id == st->codec->codec_id) return 1; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/vc1test.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/vc1test.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/vc1test.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/vc1test.c 2011-11-04 12:38:27.000000000 +0000 @@ -54,7 +54,7 @@ return -1; /* init video codec */ - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return -1; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/version.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/version.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/version.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/version.h 2011-11-04 12:38:27.000000000 +0000 @@ -24,7 +24,7 @@ #include "libavutil/avutil.h" #define LIBAVFORMAT_VERSION_MAJOR 53 -#define LIBAVFORMAT_VERSION_MINOR 14 +#define LIBAVFORMAT_VERSION_MINOR 18 #define LIBAVFORMAT_VERSION_MICRO 0 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ @@ -89,5 +89,29 @@ #ifndef FF_API_TIMESTAMP #define FF_API_TIMESTAMP (LIBAVFORMAT_VERSION_MAJOR < 54) #endif +#ifndef FF_API_FILESIZE +#define FF_API_FILESIZE (LIBAVFORMAT_VERSION_MAJOR < 54) +#endif +#ifndef FF_API_MUXRATE +#define FF_API_MUXRATE (LIBAVFORMAT_VERSION_MAJOR < 54) +#endif +#ifndef FF_API_RTSP_URL_OPTIONS +#define FF_API_RTSP_URL_OPTIONS (LIBAVFORMAT_VERSION_MAJOR < 54) +#endif +#ifndef FF_API_NEW_STREAM +#define FF_API_NEW_STREAM (LIBAVFORMAT_VERSION_MAJOR < 54) +#endif +#ifndef FF_API_PRELOAD +#define FF_API_PRELOAD (LIBAVFORMAT_VERSION_MAJOR < 54) +#endif +#ifndef FF_API_STREAM_COPY +#define FF_API_STREAM_COPY (LIBAVFORMAT_VERSION_MAJOR < 54) +#endif +#ifndef FF_API_SEEK_PUBLIC +#define FF_API_SEEK_PUBLIC (LIBAVFORMAT_VERSION_MAJOR < 54) +#endif +#ifndef FF_API_REORDER_PRIVATE +#define FF_API_REORDER_PRIVATE (LIBAVFORMAT_VERSION_MAJOR < 54) +#endif #endif /* AVFORMAT_VERSION_H */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/vocdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/vocdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/vocdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/vocdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -52,7 +52,7 @@ return AVERROR(ENOSYS); } avio_skip(pb, header_size); - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/vqf.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/vqf.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/vqf.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/vqf.c 2011-11-04 12:38:27.000000000 +0000 @@ -64,7 +64,7 @@ static int vqf_read_header(AVFormatContext *s, AVFormatParameters *ap) { VqfContext *c = s->priv_data; - AVStream *st = av_new_stream(s, 0); + AVStream *st = avformat_new_stream(s, NULL); int chunk_tag; int rate_flag = -1; int header_size; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/wav.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/wav.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/wav.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/wav.c 2011-11-04 12:38:27.000000000 +0000 @@ -45,6 +45,13 @@ int last_duration; int w64; int write_bext; + int64_t smv_data_ofs; + int smv_block_size; + int smv_frames_per_jpeg; + int smv_block; + int smv_last_stream; + int smv_eof; + int audio_eof; } WAVContext; #if CONFIG_WAV_MUXER @@ -194,7 +201,7 @@ #define OFFSET(x) offsetof(WAVContext, x) #define ENC AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { - { "write_bext", "Write BEXT chunk.", OFFSET(write_bext), FF_OPT_TYPE_INT, { 0 }, 0, 1, ENC }, + { "write_bext", "Write BEXT chunk.", OFFSET(write_bext), AV_OPT_TYPE_INT, { 0 }, 0, 1, ENC }, { NULL }, }; @@ -273,7 +280,7 @@ int ret; /* parse fmt header */ - *st = av_new_stream(s, 0); + *st = avformat_new_stream(s, NULL); if (!*st) return AVERROR(ENOMEM); @@ -392,6 +399,8 @@ int ret, got_fmt = 0; int64_t next_tag_ofs, data_ofs = -1; + wav->smv_data_ofs = -1; + /* check RIFF header */ tag = avio_rl32(pb); @@ -423,6 +432,7 @@ } for (;;) { + AVStream *vst; size = next_tag(pb, &tag); next_tag_ofs = avio_tell(pb) + size; @@ -468,6 +478,31 @@ if ((ret = wav_parse_bext_tag(s, size)) < 0) return ret; break; + case MKTAG('S','M','V','0'): + // SMV file, a wav file with video appended. + if (size != MKTAG('0','2','0','0')) { + av_log(s, AV_LOG_ERROR, "Unknown SMV version found\n"); + goto break_loop; + } + av_log(s, AV_LOG_DEBUG, "Found SMV data\n"); + vst = av_new_stream(s, 1); + if (!vst) + return AVERROR(ENOMEM); + avio_r8(pb); + vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; + vst->codec->codec_id = CODEC_ID_MJPEG; + vst->codec->width = avio_rl24(pb); + vst->codec->height = avio_rl24(pb); + size = avio_rl24(pb); + wav->smv_data_ofs = avio_tell(pb) + (size - 5) * 3; + avio_rl24(pb); + wav->smv_block_size = avio_rl24(pb); + av_set_pts_info(vst, 32, 1, avio_rl24(pb)); + vst->duration = avio_rl24(pb); + avio_rl24(pb); + avio_rl24(pb); + wav->smv_frames_per_jpeg = avio_rl24(pb); + goto break_loop; } /* seek to next tag unless we know that we'll run into EOF */ @@ -527,6 +562,45 @@ AVStream *st; WAVContext *wav = s->priv_data; + if (wav->smv_data_ofs > 0) { + int64_t audio_dts, video_dts; +smv_retry: + audio_dts = s->streams[0]->cur_dts; + video_dts = s->streams[1]->cur_dts; + if (audio_dts != AV_NOPTS_VALUE && video_dts != AV_NOPTS_VALUE) { + audio_dts = av_rescale_q(audio_dts, s->streams[0]->time_base, AV_TIME_BASE_Q); + video_dts = av_rescale_q(video_dts, s->streams[1]->time_base, AV_TIME_BASE_Q); + wav->smv_last_stream = video_dts >= audio_dts; + } + wav->smv_last_stream = !wav->smv_last_stream; + wav->smv_last_stream |= wav->audio_eof; + wav->smv_last_stream &= !wav->smv_eof; + if (wav->smv_last_stream) { + uint64_t old_pos = avio_tell(s->pb); + uint64_t new_pos = wav->smv_data_ofs + + wav->smv_block * wav->smv_block_size; + if (avio_seek(s->pb, new_pos, SEEK_SET) < 0) { + ret = AVERROR_EOF; + goto smv_out; + } + size = avio_rl24(s->pb); + ret = av_get_packet(s->pb, pkt, size); + if (ret < 0) + goto smv_out; + pkt->pos -= 3; + pkt->pts = wav->smv_block * wav->smv_frames_per_jpeg; + wav->smv_block++; + pkt->stream_index = 1; +smv_out: + avio_seek(s->pb, old_pos, SEEK_SET); + if (ret == AVERROR_EOF) { + wav->smv_eof = 1; + goto smv_retry; + } + return ret; + } + } + st = s->streams[0]; left = wav->data_end - avio_tell(s->pb); @@ -535,8 +609,12 @@ left = find_guid(s->pb, guid_data) - 24; else left = find_tag(s->pb, MKTAG('d', 'a', 't', 'a')); - if (left < 0) + if (left < 0) { + wav->audio_eof = 1; + if (wav->smv_data_ofs > 0 && !wav->smv_eof) + goto smv_retry; return AVERROR_EOF; + } wav->data_end= avio_tell(s->pb) + left; } @@ -558,7 +636,18 @@ static int wav_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) { + WAVContext *wav = s->priv_data; AVStream *st; + wav->smv_eof = 0; + wav->audio_eof = 0; + if (wav->smv_data_ofs > 0) { + int64_t smv_timestamp = timestamp; + if (stream_index == 0) + smv_timestamp = av_rescale_q(timestamp, s->streams[0]->time_base, s->streams[1]->time_base); + else + timestamp = av_rescale_q(smv_timestamp, s->streams[1]->time_base, s->streams[0]->time_base); + wav->smv_block = smv_timestamp / wav->smv_frames_per_jpeg; + } st = s->streams[0]; switch (st->codec->codec_id) { @@ -637,7 +726,7 @@ return -1; } - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/wc3movie.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/wc3movie.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/wc3movie.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/wc3movie.c 2011-11-04 12:38:27.000000000 +0000 @@ -163,7 +163,7 @@ } while (fourcc_tag != BRCH_TAG); /* initialize the decoder streams */ - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); av_set_pts_info(st, 33, 1, WC3_FRAME_FPS); @@ -174,7 +174,7 @@ st->codec->width = wc3->width; st->codec->height = wc3->height; - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); av_set_pts_info(st, 33, 1, WC3_FRAME_FPS); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/westwood.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/westwood.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/westwood.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/westwood.c 2011-11-04 12:38:27.000000000 +0000 @@ -144,7 +144,7 @@ wsaud->audio_bits = (((header[10] & 0x2) >> 1) + 1) * 8; /* initialize the audio decoder stream */ - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); av_set_pts_info(st, 33, 1, wsaud->audio_samplerate); @@ -221,7 +221,7 @@ unsigned int chunk_size; /* initialize the video decoder stream */ - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); av_set_pts_info(st, 33, 1, VQA_FRAMERATE); @@ -247,7 +247,7 @@ /* initialize the audio decoder stream for VQA v1 or nonzero samplerate */ if (AV_RL16(&header[24]) || (AV_RL16(&header[0]) == 1 && AV_RL16(&header[2]) == 1)) { - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); av_set_pts_info(st, 33, 1, VQA_FRAMERATE); @@ -277,10 +277,8 @@ /* there are 0 or more chunks before the FINF chunk; iterate until * FINF has been skipped and the file will be ready to be demuxed */ do { - if (avio_read(pb, scratch, VQA_PREAMBLE_SIZE) != VQA_PREAMBLE_SIZE) { - av_free(st->codec->extradata); + if (avio_read(pb, scratch, VQA_PREAMBLE_SIZE) != VQA_PREAMBLE_SIZE) return AVERROR(EIO); - } chunk_tag = AV_RB32(&scratch[0]); chunk_size = AV_RB32(&scratch[4]); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/wtvdec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/wtvdec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/wtvdec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/wtvdec.c 2011-11-04 12:38:27.000000000 +0000 @@ -414,7 +414,7 @@ if (!filesize) goto done; - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) goto done; av_dict_set(&st->metadata, "title", description, 0); @@ -562,9 +562,10 @@ WtvStream *wst = av_mallocz(sizeof(WtvStream)); if (!wst) return NULL; - st = av_new_stream(s, sid); + st = avformat_new_stream(s, NULL); if (!st) return NULL; + st->id = sid; st->priv_data = wst; } st->codec->codec_type = codec_type; @@ -772,7 +773,7 @@ buf_size = FFMIN(len - consumed, sizeof(buf)); avio_read(pb, buf, buf_size); consumed += buf_size; - ff_parse_mpeg2_descriptor(s, st, 0, &pbuf, buf + buf_size, 0, 0, 0, 0); + ff_parse_mpeg2_descriptor(s, st, 0, &pbuf, buf + buf_size, NULL, 0, 0, NULL); } } else if (!ff_guidcmp(g, EVENTID_AudioTypeSpanningEvent)) { int stream_index = ff_find_stream_index(s, sid); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/wv.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/wv.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/wv.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/wv.c 2011-11-04 12:38:27.000000000 +0000 @@ -220,7 +220,7 @@ } /* now we are ready: build format streams */ - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return -1; st->codec->codec_type = AVMEDIA_TYPE_AUDIO; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/xa.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/xa.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/xa.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/xa.c 2011-11-04 12:38:27.000000000 +0000 @@ -70,7 +70,7 @@ AVStream *st; /*Set up the XA Audio Decoder*/ - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/xmv.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/xmv.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/xmv.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/xmv.c 2011-11-04 12:38:27.000000000 +0000 @@ -147,7 +147,7 @@ /* Video track */ - vst = av_new_stream(s, 0); + vst = avformat_new_stream(s, NULL); if (!vst) return AVERROR(ENOMEM); @@ -202,7 +202,7 @@ av_log(s, AV_LOG_WARNING, "Unsupported 5.1 ADPCM audio stream " "(0x%04X)\n", packet->flags); - ast = av_new_stream(s, audio_track); + ast = avformat_new_stream(s, NULL); if (!ast) return AVERROR(ENOMEM); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/xwma.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/xwma.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/xwma.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/xwma.c 2011-11-04 12:38:27.000000000 +0000 @@ -69,7 +69,7 @@ if (tag != MKTAG('f', 'm', 't', ' ')) return -1; size = avio_rl32(pb); - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/yop.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/yop.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/yop.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/yop.c 2011-11-04 12:38:27.000000000 +0000 @@ -56,8 +56,8 @@ int frame_rate, ret; - audio_stream = av_new_stream(s, 0); - video_stream = av_new_stream(s, 1); + audio_stream = avformat_new_stream(s, NULL); + video_stream = avformat_new_stream(s, NULL); // Extra data that will be passed to the decoder video_stream->codec->extradata_size = 8; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/yuv4mpeg.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/yuv4mpeg.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavformat/yuv4mpeg.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavformat/yuv4mpeg.c 2011-11-04 12:38:27.000000000 +0000 @@ -333,7 +333,7 @@ aspectd = 1; } - st = av_new_stream(s, 0); + st = avformat_new_stream(s, NULL); if(!st) return AVERROR(ENOMEM); st->codec->width = width; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/arm/intmath.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/arm/intmath.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/arm/intmath.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/arm/intmath.h 2011-11-04 12:38:27.000000000 +0000 @@ -106,7 +106,7 @@ "mvnne %1, #1<<31 \n\t" "moveq %0, %Q2 \n\t" "eorne %0, %1, %R2, asr #31 \n\t" - : "=r"(x), "=&r"(y) : "r"(a)); + : "=r"(x), "=&r"(y) : "r"(a):"cc"); return x; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/avstring.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/avstring.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/avstring.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/avstring.c 2011-11-04 12:38:27.000000000 +0000 @@ -51,11 +51,11 @@ char *av_stristr(const char *s1, const char *s2) { if (!*s2) - return s1; + return (char*)(intptr_t)s1; do { if (av_stristart(s1, s2, NULL)) - return s1; + return (char*)(intptr_t)s1; } while (*s1++); return NULL; @@ -160,6 +160,62 @@ return ret; } +char *av_strtok(char *s, const char *delim, char **saveptr) +{ + char *tok; + + if (!s && !(s = *saveptr)) + return NULL; + + /* skip leading delimiters */ + s += strspn(s, delim); + + /* s now points to the first non delimiter char, or to the end of the string */ + if (!*s) { + *saveptr = NULL; + return NULL; + } + tok = s++; + + /* skip non delimiters */ + s += strcspn(s, delim); + if (*s) { + *s = 0; + *saveptr = s+1; + } else { + *saveptr = NULL; + } + + return tok; +} + +#define TOUPPER(c) do { if (c >= 'a' && c <= 'z') c -= 'a' - 'A'; } while (0) + +int av_strcasecmp(const char *a, const char *b) +{ + uint8_t c1, c2; + do { + c1 = *a++; + c2 = *b++; + TOUPPER(c1); + TOUPPER(c2); + } while (c1 && c1 == c2); + return c1 - c2; +} + +int av_strncasecmp(const char *a, const char *b, size_t n) +{ + const char *end = a + n; + uint8_t c1, c2; + do { + c1 = *a++; + c2 = *b++; + TOUPPER(c1); + TOUPPER(c2); + } while (a < end && c1 && c1 == c2); + return c1 - c2; +} + #ifdef TEST #undef printf diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/avstring.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/avstring.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/avstring.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/avstring.h 2011-11-04 12:38:27.000000000 +0000 @@ -141,4 +141,40 @@ */ char *av_get_token(const char **buf, const char *term); +/** + * Split the string into several tokens which can be accessed by + * successive calls to av_strtok(). + * + * A token is defined as a sequence of characters not belonging to the + * set specified in delim. + * + * On the first call to av_strtok(), s should point to the string to + * parse, and the value of saveptr is ignored. In subsequent calls, s + * should be NULL, and saveptr should be unchanged since the previous + * call. + * + * This function is similar to strtok_r() defined in POSIX.1. + * + * @param s the string to parse, may be NULL + * @param delim 0-terminated list of token delimiters, must be non-NULL + * @param saveptr user-provided pointer which points to stored + * information necessary for av_strtok() to continue scanning the same + * string. saveptr is updated to point to the next character after the + * first delimiter found, or to NULL if the string was terminated + * @return the found token, or NULL when no token is found + */ +char *av_strtok(char *s, const char *delim, char **saveptr); + +/** + * Locale independent case-insensitive compare. + * Note: This means only ASCII-range characters are case-insensitive + */ +int av_strcasecmp(const char *a, const char *b); + +/** + * Locale independent case-insensitive compare. + * Note: This means only ASCII-range characters are case-insensitive + */ +int av_strncasecmp(const char *a, const char *b, size_t n); + #endif /* AVUTIL_AVSTRING_H */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/avutil.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/avutil.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/avutil.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/avutil.h 2011-11-04 12:38:27.000000000 +0000 @@ -40,7 +40,7 @@ #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) #define LIBAVUTIL_VERSION_MAJOR 51 -#define LIBAVUTIL_VERSION_MINOR 20 +#define LIBAVUTIL_VERSION_MINOR 23 #define LIBAVUTIL_VERSION_MICRO 0 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/crc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/crc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/crc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/crc.c 2011-11-04 12:38:27.000000000 +0000 @@ -57,7 +57,7 @@ * @return <0 on failure */ int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size){ - int i, j; + unsigned i, j; uint32_t c; if (bits < 8 || bits > 32 || poly >= (1LL<elems[m->count].key = key; + m->elems[m->count].key = (char*)(intptr_t)key; } else m->elems[m->count].key = av_strdup(key ); if (flags & AV_DICT_DONT_STRDUP_VAL) { - m->elems[m->count].value = value; + m->elems[m->count].value = (char*)(intptr_t)value; } else if (oldval && flags & AV_DICT_APPEND) { int len = strlen(oldval) + strlen(value) + 1; if (!(oldval = av_realloc(oldval, len))) diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/eval.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/eval.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/eval.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/eval.c 2011-11-04 12:38:27.000000000 +0000 @@ -44,7 +44,7 @@ int log_offset; void *log_ctx; #define VARS 10 - double var[VARS]; + double *var; } Parser; static const AVClass class = { "Eval", av_default_item_name, NULL, LIBAVUTIL_VERSION_INT, offsetof(Parser,log_offset), offsetof(Parser,log_ctx) }; @@ -72,6 +72,15 @@ ['Y'-'E']= 24, }; +static const struct { + const char *name; + double value; +} constants[] = { + { "E", M_E }, + { "PI", M_PI }, + { "PHI", M_PHI }, +}; + double av_strtod(const char *numstr, char **tail) { double d; @@ -126,7 +135,7 @@ e_mod, e_max, e_min, e_eq, e_gt, e_gte, e_pow, e_mul, e_div, e_add, e_last, e_st, e_while, e_floor, e_ceil, e_trunc, - e_sqrt, e_not, + e_sqrt, e_not, e_random, e_hypot, e_gcd, } type; double value; // is sign in other types union { @@ -136,6 +145,7 @@ double (*func2)(void *, double, double); } a; struct AVExpr *param[2]; + double *var; }; static double eval_expr(Parser *p, AVExpr *e) @@ -154,7 +164,14 @@ case e_ceil : return e->value * ceil (eval_expr(p, e->param[0])); case e_trunc: return e->value * trunc(eval_expr(p, e->param[0])); case e_sqrt: return e->value * sqrt (eval_expr(p, e->param[0])); - case e_not: return e->value * eval_expr(p, e->param[0]) == 0; + case e_not: return e->value * (eval_expr(p, e->param[0]) == 0); + case e_random:{ + int idx= av_clip(eval_expr(p, e->param[0]), 0, VARS-1); + uint64_t r= isnan(p->var[idx]) ? 0 : p->var[idx]; + r= r*1664525+1013904223; + p->var[idx]= r; + return e->value * (r * (1.0/UINT64_MAX)); + } case e_while: { double d = NAN; while (eval_expr(p, e->param[0])) @@ -166,6 +183,7 @@ double d2 = eval_expr(p, e->param[1]); switch (e->type) { case e_mod: return e->value * (d - floor(d/d2)*d2); + case e_gcd: return e->value * av_gcd(d,d2); case e_max: return e->value * (d > d2 ? d : d2); case e_min: return e->value * (d < d2 ? d : d2); case e_eq: return e->value * (d == d2 ? 1.0 : 0.0); @@ -177,6 +195,7 @@ case e_add: return e->value * (d + d2); case e_last:return e->value * d2; case e_st : return e->value * (p->var[av_clip(d, 0, VARS-1)]= d2); + case e_hypot:return e->value * (sqrt(d*d + d2*d2)); } } } @@ -190,6 +209,7 @@ if (!e) return; av_expr_free(e->param[0]); av_expr_free(e->param[1]); + av_freep(&e->var); av_freep(&e); } @@ -222,6 +242,15 @@ return 0; } } + for (i = 0; i < FF_ARRAY_ELEMS(constants); i++) { + if (strmatch(p->s, constants[i].name)) { + p->s += strlen(constants[i].name); + d->type = e_value; + d->value = constants[i].value; + *e = d; + return 0; + } + } p->s= strchr(p->s, '('); if (p->s==NULL) { @@ -292,6 +321,9 @@ else if (strmatch(next, "sqrt" )) d->type = e_sqrt; else if (strmatch(next, "not" )) d->type = e_not; else if (strmatch(next, "pow" )) d->type = e_pow; + else if (strmatch(next, "random")) d->type = e_random; + else if (strmatch(next, "hypot" )) d->type = e_hypot; + else if (strmatch(next, "gcd" )) d->type = e_gcd; else { for (i=0; p->func1_names && p->func1_names[i]; i++) { if (strmatch(next, p->func1_names[i])) { @@ -461,6 +493,7 @@ case e_trunc: case e_sqrt: case e_not: + case e_random: return verify_expr(e->param[0]); default: return verify_expr(e->param[0]) && verify_expr(e->param[1]); } @@ -510,6 +543,7 @@ ret = AVERROR(EINVAL); goto end; } + e->var= av_mallocz(sizeof(double) *VARS); *expr = e; end: av_free(w); @@ -519,6 +553,7 @@ double av_expr_eval(AVExpr *e, const double *const_values, void *opaque) { Parser p = { 0 }; + p.var= e->var; p.const_values = const_values; p.opaque = opaque; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/file.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/file.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/file.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/file.c 2011-11-04 12:38:27.000000000 +0000 @@ -130,6 +130,52 @@ #endif } +int av_tempfile(const char *prefix, char **filename, int log_offset, void *log_ctx) { + FileLogContext file_log_ctx = { &file_log_ctx_class, log_offset, log_ctx }; + int fd=-1; +#if !HAVE_MKSTEMP + void *ptr= tempnam(NULL, prefix); + if(!ptr) + ptr= tempnam(".", prefix); + *filename = av_strdup(ptr); +#undef free + free(ptr); +#else + size_t len = strlen(prefix) + 12; /* room for "/tmp/" and "XXXXXX\0" */ + *filename = av_malloc(len); +#endif + /* -----common section-----*/ + if (*filename == NULL) { + av_log(&file_log_ctx, AV_LOG_ERROR, "ff_tempfile: Cannot allocate file name\n"); + return AVERROR(ENOMEM); + } +#if !HAVE_MKSTEMP +# ifndef O_BINARY +# define O_BINARY 0 +# endif +# ifndef O_EXCL +# define O_EXCL 0 +# endif + fd = open(*filename, O_RDWR | O_BINARY | O_CREAT | O_EXCL, 0600); +#else + snprintf(*filename, len, "/tmp/%sXXXXXX", prefix); + fd = mkstemp(*filename); +#ifdef _WIN32 + if (fd < 0) { + snprintf(*filename, len, "./%sXXXXXX", prefix); + fd = mkstemp(*filename); + } +#endif +#endif + /* -----common section-----*/ + if (fd < 0) { + int err = AVERROR(errno); + av_log(&file_log_ctx, AV_LOG_ERROR, "ff_tempfile: Cannot open temporary file %s\n", *filename); + return err; + } + return fd; /* success */ +} + #ifdef TEST #undef printf diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/file.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/file.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/file.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/file.h 2011-11-04 12:38:27.000000000 +0000 @@ -49,4 +49,13 @@ */ void av_file_unmap(uint8_t *bufptr, size_t size); +/** + * Wrapper to work around the lack of mkstemp() on mingw. + * Also, tries to create file in /tmp first, if possible. + * *prefix can be a character constant; *filename will be allocated internally. + * @return file descriptor of opened file (or -1 on error) + * and opened file name in **filename. + */ +int av_tempfile(const char *prefix, char **filename, int log_offset, void *log_ctx); + #endif /* AVUTIL_FILE_H */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/internal.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/internal.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/internal.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/internal.h 2011-11-04 12:38:27.000000000 +0000 @@ -156,6 +156,10 @@ #define puts please_use_av_log_instead_of_puts #undef perror #define perror please_use_av_log_instead_of_perror +#undef strcasecmp +#define strcasecmp please_use_av_strcasecmp +#undef strncasecmp +#define strncasecmp please_use_av_strncasecmp #define FF_ALLOC_OR_GOTO(ctx, p, size, label)\ {\ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/intfloat_readwrite.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/intfloat_readwrite.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/intfloat_readwrite.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/intfloat_readwrite.c 2011-11-04 12:38:27.000000000 +0000 @@ -30,13 +30,13 @@ #include "intfloat_readwrite.h" double av_int2dbl(int64_t v){ - if(v+v > 0xFFEULL<<52) + if((uint64_t)v+v > 0xFFEULL<<52) return NAN; return ldexp(((v&((1LL<<52)-1)) + (1LL<<52)) * (v>>63|1), (v>>52&0x7FF)-1075); } float av_int2flt(int32_t v){ - if(v+v > 0xFF000000U) + if((uint32_t)v+v > 0xFF000000U) return NAN; return ldexp(((v&0x7FFFFF) + (1<<23)) * (v>>31|1), (v>>23&0xFF)-150); } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/libm.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/libm.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/libm.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/libm.h 2011-11-04 12:38:27.000000000 +0000 @@ -28,6 +28,11 @@ #include "config.h" #include "attributes.h" +#if !HAVE_CBRTF +#undef cbrtf +#define cbrtf(x) powf(x, 1.0/3.0) +#endif /* HAVE_CBRTF */ + #if !HAVE_EXP2 #undef exp2 #define exp2(x) exp((x) * 0.693147180559945) diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/log.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/log.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/log.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/log.c 2011-11-04 12:38:27.000000000 +0000 @@ -52,17 +52,17 @@ #if defined(_WIN32) && !defined(__MINGW32CE__) CONSOLE_SCREEN_BUFFER_INFO con_info; con = GetStdHandle(STD_ERROR_HANDLE); - use_color = (con != INVALID_HANDLE_VALUE) && !getenv("NO_COLOR") && !getenv("FFMPEG_FORCE_NOCOLOR"); + use_color = (con != INVALID_HANDLE_VALUE) && !getenv("NO_COLOR") && !getenv("AV_LOG_FORCE_NOCOLOR"); if (use_color) { GetConsoleScreenBufferInfo(con, &con_info); attr_orig = con_info.wAttributes; background = attr_orig & 0xF0; } #elif HAVE_ISATTY - use_color= !getenv("NO_COLOR") && !getenv("FFMPEG_FORCE_NOCOLOR") && - (getenv("TERM") && isatty(2) || getenv("FFMPEG_FORCE_COLOR")); + use_color= !getenv("NO_COLOR") && !getenv("AV_LOG_FORCE_NOCOLOR") && + (getenv("TERM") && isatty(2) || getenv("AV_LOG_FORCE_COLOR")); #else - use_color= getenv("FFMPEG_FORCE_COLOR") && !getenv("NO_COLOR") && !getenv("FFMPEG_FORCE_NOCOLOR"); + use_color= getenv("AV_LOG_FORCE_COLOR") && !getenv("NO_COLOR") && !getenv("AV_LOG_FORCE_NOCOLOR"); #endif } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/log.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/log.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/log.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/log.h 2011-11-04 12:38:27.000000000 +0000 @@ -30,7 +30,7 @@ * arbitrary struct of which the first field is a pointer to an * AVClass struct (e.g. AVCodecContext, AVFormatContext etc.). */ -typedef struct { +typedef struct AVClass { /** * The name of the class; usually it is the same name as the * context structure type to which the AVClass is associated. @@ -73,11 +73,19 @@ int parent_log_context_offset; /** - * A function for extended searching, e.g. in possible - * children objects. + * Return next AVOptions-enabled child or NULL */ - const struct AVOption* (*opt_find)(void *obj, const char *name, const char *unit, - int opt_flags, int search_flags); + void* (*child_next)(void *obj, void *prev); + + /** + * Return an AVClass corresponding to next potential + * AVOptions-enabled child. + * + * The difference between child_next and this is that + * child_next iterates over _already existing_ objects, while + * child_class_next iterates over _all possible_ children. + */ + const struct AVClass* (*child_class_next)(const struct AVClass *prev); } AVClass; /* av_log API */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/mem.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/mem.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/mem.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/mem.c 2011-11-04 12:38:27.000000000 +0000 @@ -137,7 +137,9 @@ //FIXME this isn't aligned correctly, though it probably isn't needed if(!ptr) return av_malloc(size); diff= ((char*)ptr)[-1]; - return (char*)realloc((char*)ptr - diff, size + diff) + diff; + ptr= realloc((char*)ptr - diff, size + diff); + if(ptr) ptr = (char*)ptr + diff; + return ptr; #else return realloc(ptr, size + !size); #endif diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/opt.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/opt.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/opt.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/opt.c 2011-11-04 12:38:27.000000000 +0000 @@ -46,36 +46,50 @@ } #endif +#if FF_API_OLD_AVOPTIONS const AVOption *av_next_option(void *obj, const AVOption *last) { + return av_opt_next(obj, last); +} +#endif + +const AVOption *av_opt_next(void *obj, const AVOption *last) +{ if (last && last[1].name) return ++last; else if (last || !(*(AVClass**)obj)->option->name) return NULL; else return (*(AVClass**)obj)->option; } -static int av_set_number2(void *obj, const char *name, double num, int den, int64_t intnum, const AVOption **o_out) +static int read_number(const AVOption *o, void *dst, double *num, int *den, int64_t *intnum) { - const AVOption *o = av_opt_find(obj, name, NULL, 0, 0); - void *dst; - if (o_out) - *o_out= o; - if (!o) - return AVERROR_OPTION_NOT_FOUND; + switch (o->type) { + case AV_OPT_TYPE_FLAGS: *intnum = *(unsigned int*)dst;return 0; + case AV_OPT_TYPE_INT: *intnum = *(int *)dst;return 0; + case AV_OPT_TYPE_INT64: *intnum = *(int64_t *)dst;return 0; + case AV_OPT_TYPE_FLOAT: *num = *(float *)dst;return 0; + case AV_OPT_TYPE_DOUBLE: *num = *(double *)dst;return 0; + case AV_OPT_TYPE_RATIONAL: *intnum = ((AVRational*)dst)->num; + *den = ((AVRational*)dst)->den; + return 0; + case AV_OPT_TYPE_CONST: *num = o->default_val.dbl; return 0; + } + return AVERROR(EINVAL); +} +static int write_number(void *obj, const AVOption *o, void *dst, double num, int den, int64_t intnum) +{ if (o->max*den < num*intnum || o->min*den > num*intnum) { - av_log(obj, AV_LOG_ERROR, "Value %lf for parameter '%s' out of range\n", num, name); + av_log(obj, AV_LOG_ERROR, "Value %lf for parameter '%s' out of range\n", num, o->name); return AVERROR(ERANGE); } - dst= ((uint8_t*)obj) + o->offset; - switch (o->type) { - case FF_OPT_TYPE_FLAGS: - case FF_OPT_TYPE_INT: *(int *)dst= llrint(num/den)*intnum; break; - case FF_OPT_TYPE_INT64: *(int64_t *)dst= llrint(num/den)*intnum; break; - case FF_OPT_TYPE_FLOAT: *(float *)dst= num*intnum/den; break; - case FF_OPT_TYPE_DOUBLE:*(double *)dst= num*intnum/den; break; - case FF_OPT_TYPE_RATIONAL: + case AV_OPT_TYPE_FLAGS: + case AV_OPT_TYPE_INT: *(int *)dst= llrint(num/den)*intnum; break; + case AV_OPT_TYPE_INT64: *(int64_t *)dst= llrint(num/den)*intnum; break; + case AV_OPT_TYPE_FLOAT: *(float *)dst= num*intnum/den; break; + case AV_OPT_TYPE_DOUBLE:*(double *)dst= num*intnum/den; break; + case AV_OPT_TYPE_RATIONAL: if ((int)num == num) *(AVRational*)dst= (AVRational){num*intnum, den}; else *(AVRational*)dst= av_d2q(num*intnum/den, 1<<24); break; @@ -85,15 +99,6 @@ return 0; } -static const AVOption *av_set_number(void *obj, const char *name, double num, int den, int64_t intnum) -{ - const AVOption *o = NULL; - if (av_set_number2(obj, name, num, den, intnum, &o) < 0) - return NULL; - else - return o; -} - static const double const_values[] = { M_PI, M_E, @@ -115,113 +120,202 @@ return -1; } -int av_set_string3(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out) +static int set_string_binary(void *obj, const AVOption *o, const char *val, uint8_t **dst) { - int ret; - const AVOption *o = av_opt_find(obj, name, NULL, 0, 0); - if (o_out) - *o_out = o; - if (!o) - return AVERROR_OPTION_NOT_FOUND; - if (!val && o->type != FF_OPT_TYPE_STRING) + int *lendst = (int *)(dst + 1); + uint8_t *bin, *ptr; + int len = strlen(val); + + av_freep(dst); + *lendst = 0; + + if (len & 1) return AVERROR(EINVAL); + len /= 2; - if (o->type == FF_OPT_TYPE_BINARY) { - uint8_t **dst = (uint8_t **)(((uint8_t*)obj) + o->offset); - int *lendst = (int *)(dst + 1); - uint8_t *bin, *ptr; - int len = strlen(val); - av_freep(dst); - *lendst = 0; - if (len & 1) return AVERROR(EINVAL); - len /= 2; - ptr = bin = av_malloc(len); - while (*val) { - int a = hexchar2int(*val++); - int b = hexchar2int(*val++); - if (a < 0 || b < 0) { - av_free(bin); - return AVERROR(EINVAL); - } - *ptr++ = (a << 4) | b; + ptr = bin = av_malloc(len); + while (*val) { + int a = hexchar2int(*val++); + int b = hexchar2int(*val++); + if (a < 0 || b < 0) { + av_free(bin); + return AVERROR(EINVAL); } - *dst = bin; - *lendst = len; - return 0; + *ptr++ = (a << 4) | b; } - if (o->type != FF_OPT_TYPE_STRING) { - int notfirst=0; - for (;;) { - int i; - char buf[256]; - int cmd=0; - double d; - - if (*val == '+' || *val == '-') - cmd= *(val++); - - for (i=0; iunit, 0, 0); - if (o_named && o_named->type == FF_OPT_TYPE_CONST) - d= o_named->default_val.dbl; - else if (!strcmp(buf, "default")) d= o->default_val.dbl; - else if (!strcmp(buf, "max" )) d= o->max; - else if (!strcmp(buf, "min" )) d= o->min; - else if (!strcmp(buf, "none" )) d= 0; - else if (!strcmp(buf, "all" )) d= ~0; - else { - int res = av_expr_parse_and_eval(&d, buf, const_names, const_values, NULL, NULL, NULL, NULL, NULL, 0, obj); - if (res < 0) { - av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\"\n", val); - return res; - } + *dst = bin; + *lendst = len; + + return 0; +} + +static int set_string(void *obj, const AVOption *o, const char *val, uint8_t **dst) +{ + av_freep(dst); + *dst = av_strdup(val); + return 0; +} + +static int set_string_number(void *obj, const AVOption *o, const char *val, void *dst) +{ + int ret = 0, notfirst = 0; + for (;;) { + int i, den = 1; + char buf[256]; + int cmd = 0; + double d, num = 1; + int64_t intnum = 1; + + if (*val == '+' || *val == '-') + cmd = *(val++); + + for (i = 0; i < sizeof(buf) - 1 && val[i] && val[i] != '+' && val[i] != '-'; i++) + buf[i] = val[i]; + buf[i] = 0; + + { + const AVOption *o_named = av_opt_find(obj, buf, o->unit, 0, 0); + if (o_named && o_named->type == AV_OPT_TYPE_CONST) + d = o_named->default_val.dbl; + else if (!strcmp(buf, "default")) d = o->default_val.dbl; + else if (!strcmp(buf, "max" )) d = o->max; + else if (!strcmp(buf, "min" )) d = o->min; + else if (!strcmp(buf, "none" )) d = 0; + else if (!strcmp(buf, "all" )) d = ~0; + else { + int res = av_expr_parse_and_eval(&d, buf, const_names, const_values, NULL, NULL, NULL, NULL, NULL, 0, obj); + if (res < 0) { + av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\"\n", val); + return res; } } - if (o->type == FF_OPT_TYPE_FLAGS) { - if (cmd=='+') d= av_get_int(obj, name, NULL) | (int64_t)d; - else if (cmd=='-') d= av_get_int(obj, name, NULL) &~(int64_t)d; - } else { - if (cmd=='+') d= notfirst*av_get_double(obj, name, NULL) + d; - else if (cmd=='-') d= notfirst*av_get_double(obj, name, NULL) - d; - } - - if ((ret = av_set_number2(obj, name, d, 1, 1, o_out)) < 0) - return ret; - val+= i; - if (!*val) - return 0; - notfirst=1; } - } + if (o->type == AV_OPT_TYPE_FLAGS) { + read_number(o, dst, NULL, NULL, &intnum); + if (cmd == '+') d = intnum | (int64_t)d; + else if (cmd == '-') d = intnum &~(int64_t)d; + } else { + read_number(o, dst, &num, &den, &intnum); + if (cmd == '+') d = notfirst*num*intnum/den + d; + else if (cmd == '-') d = notfirst*num*intnum/den - d; + } - if (alloc) { - av_free(*(void**)(((uint8_t*)obj) + o->offset)); - val= av_strdup(val); + if ((ret = write_number(obj, o, dst, d, 1, 1)) < 0) + return ret; + val += i; + if (!*val) + return 0; + notfirst = 1; } - memcpy(((uint8_t*)obj) + o->offset, &val, sizeof(val)); return 0; } +#if FF_API_OLD_AVOPTIONS +int av_set_string3(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out) +{ + const AVOption *o = av_opt_find(obj, name, NULL, 0, 0); + if (o_out) + *o_out = o; + return av_opt_set(obj, name, val, 0); +} +#endif + +int av_opt_set(void *obj, const char *name, const char *val, int search_flags) +{ + void *dst, *target_obj; + const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj); + if (!o || !target_obj) + return AVERROR_OPTION_NOT_FOUND; + if (!val && o->type != AV_OPT_TYPE_STRING) + return AVERROR(EINVAL); + + dst = ((uint8_t*)target_obj) + o->offset; + switch (o->type) { + case AV_OPT_TYPE_STRING: return set_string(obj, o, val, dst); + case AV_OPT_TYPE_BINARY: return set_string_binary(obj, o, val, dst); + case AV_OPT_TYPE_FLAGS: + case AV_OPT_TYPE_INT: + case AV_OPT_TYPE_INT64: + case AV_OPT_TYPE_FLOAT: + case AV_OPT_TYPE_DOUBLE: + case AV_OPT_TYPE_RATIONAL: return set_string_number(obj, o, val, dst); + } + + av_log(obj, AV_LOG_ERROR, "Invalid option type.\n"); + return AVERROR(EINVAL); +} + +#define OPT_EVAL_NUMBER(name, opttype, vartype)\ + int av_opt_eval_ ## name(void *obj, const AVOption *o, const char *val, vartype *name ## _out)\ + {\ + if (!o || o->type != opttype)\ + return AVERROR(EINVAL);\ + return set_string_number(obj, o, val, name ## _out);\ + } + +OPT_EVAL_NUMBER(flags, AV_OPT_TYPE_FLAGS, int) +OPT_EVAL_NUMBER(int, AV_OPT_TYPE_INT, int) +OPT_EVAL_NUMBER(int64, AV_OPT_TYPE_INT64, int64_t) +OPT_EVAL_NUMBER(float, AV_OPT_TYPE_FLOAT, float) +OPT_EVAL_NUMBER(double, AV_OPT_TYPE_DOUBLE, double) +OPT_EVAL_NUMBER(q, AV_OPT_TYPE_RATIONAL, AVRational) + +static int set_number(void *obj, const char *name, double num, int den, int64_t intnum, + int search_flags) +{ + void *dst, *target_obj; + const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj); + + if (!o || !target_obj) + return AVERROR_OPTION_NOT_FOUND; + + dst = ((uint8_t*)target_obj) + o->offset; + return write_number(obj, o, dst, num, den, intnum); +} + +#if FF_API_OLD_AVOPTIONS const AVOption *av_set_double(void *obj, const char *name, double n) { - return av_set_number(obj, name, n, 1, 1); + const AVOption *o = av_opt_find(obj, name, NULL, 0, 0); + if (set_number(obj, name, n, 1, 1, 0) < 0) + return NULL; + return o; } const AVOption *av_set_q(void *obj, const char *name, AVRational n) { - return av_set_number(obj, name, n.num, n.den, 1); + const AVOption *o = av_opt_find(obj, name, NULL, 0, 0); + if (set_number(obj, name, n.num, n.den, 1, 0) < 0) + return NULL; + return o; } const AVOption *av_set_int(void *obj, const char *name, int64_t n) { - return av_set_number(obj, name, 1, 1, n); + const AVOption *o = av_opt_find(obj, name, NULL, 0, 0); + if (set_number(obj, name, 1, 1, n, 0) < 0) + return NULL; + return o; +} +#endif + +int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags) +{ + return set_number(obj, name, 1, 1, val, search_flags); } +int av_opt_set_double(void *obj, const char *name, double val, int search_flags) +{ + return set_number(obj, name, val, 1, 1, search_flags); +} + +int av_opt_set_q(void *obj, const char *name, AVRational val, int search_flags) +{ + return set_number(obj, name, val.num, val.den, 1, search_flags); +} + +#if FF_API_OLD_AVOPTIONS /** * * @param buf a buffer which is used for returning non string values as strings, can be NULL @@ -235,21 +329,22 @@ int len, i; if (!o) return NULL; - if (o->type != FF_OPT_TYPE_STRING && (!buf || !buf_len)) + if (o->type != AV_OPT_TYPE_STRING && (!buf || !buf_len)) return NULL; dst= ((uint8_t*)obj) + o->offset; if (o_out) *o_out= o; switch (o->type) { - case FF_OPT_TYPE_FLAGS: snprintf(buf, buf_len, "0x%08X",*(int *)dst);break; - case FF_OPT_TYPE_INT: snprintf(buf, buf_len, "%d" , *(int *)dst);break; - case FF_OPT_TYPE_INT64: snprintf(buf, buf_len, "%"PRId64, *(int64_t*)dst);break; - case FF_OPT_TYPE_FLOAT: snprintf(buf, buf_len, "%f" , *(float *)dst);break; - case FF_OPT_TYPE_DOUBLE: snprintf(buf, buf_len, "%f" , *(double *)dst);break; - case FF_OPT_TYPE_RATIONAL: snprintf(buf, buf_len, "%d/%d", ((AVRational*)dst)->num, ((AVRational*)dst)->den);break; - case FF_OPT_TYPE_STRING: return *(void**)dst; - case FF_OPT_TYPE_BINARY: + case AV_OPT_TYPE_FLAGS: snprintf(buf, buf_len, "0x%08X",*(int *)dst);break; + case AV_OPT_TYPE_INT: snprintf(buf, buf_len, "%d" , *(int *)dst);break; + case AV_OPT_TYPE_INT64: snprintf(buf, buf_len, "%"PRId64, *(int64_t*)dst);break; + case AV_OPT_TYPE_FLOAT: snprintf(buf, buf_len, "%f" , *(float *)dst);break; + case AV_OPT_TYPE_DOUBLE: snprintf(buf, buf_len, "%f" , *(double *)dst);break; + case AV_OPT_TYPE_RATIONAL: snprintf(buf, buf_len, "%d/%d", ((AVRational*)dst)->num, ((AVRational*)dst)->den);break; + case AV_OPT_TYPE_CONST: snprintf(buf, buf_len, "%f" , o->default_val.dbl);break; + case AV_OPT_TYPE_STRING: return *(void**)dst; + case AV_OPT_TYPE_BINARY: len = *(int*)(((uint8_t *)dst) + sizeof(uint8_t *)); if (len >= (buf_len + 1)/2) return NULL; bin = *(uint8_t**)dst; @@ -259,41 +354,82 @@ } return buf; } +#endif -static int get_number(void *obj, const char *name, const AVOption **o_out, double *num, int *den, int64_t *intnum) +int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val) { - const AVOption *o = av_opt_find(obj, name, NULL, 0, AV_OPT_SEARCH_CHILDREN); - void *dst; - if (!o || (o->offset<=0 && o->type != FF_OPT_TYPE_CONST)) - goto error; + void *dst, *target_obj; + const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj); + uint8_t *bin, buf[128]; + int len, i, ret; - dst= ((uint8_t*)obj) + o->offset; + if (!o || !target_obj || (o->offset<=0 && o->type != AV_OPT_TYPE_CONST)) + return AVERROR_OPTION_NOT_FOUND; - if (o_out) *o_out= o; + dst = (uint8_t*)target_obj + o->offset; + buf[0] = 0; switch (o->type) { - case FF_OPT_TYPE_FLAGS: *intnum= *(unsigned int*)dst;return 0; - case FF_OPT_TYPE_INT: *intnum= *(int *)dst;return 0; - case FF_OPT_TYPE_INT64: *intnum= *(int64_t*)dst;return 0; - case FF_OPT_TYPE_FLOAT: *num= *(float *)dst;return 0; - case FF_OPT_TYPE_DOUBLE: *num= *(double *)dst;return 0; - case FF_OPT_TYPE_RATIONAL: *intnum= ((AVRational*)dst)->num; - *den = ((AVRational*)dst)->den; - return 0; - case FF_OPT_TYPE_CONST: *intnum= o->default_val.dbl;return 0; + case AV_OPT_TYPE_FLAGS: ret = snprintf(buf, sizeof(buf), "0x%08X", *(int *)dst);break; + case AV_OPT_TYPE_INT: ret = snprintf(buf, sizeof(buf), "%d" , *(int *)dst);break; + case AV_OPT_TYPE_INT64: ret = snprintf(buf, sizeof(buf), "%"PRId64, *(int64_t*)dst);break; + case AV_OPT_TYPE_FLOAT: ret = snprintf(buf, sizeof(buf), "%f" , *(float *)dst);break; + case AV_OPT_TYPE_DOUBLE: ret = snprintf(buf, sizeof(buf), "%f" , *(double *)dst);break; + case AV_OPT_TYPE_RATIONAL: ret = snprintf(buf, sizeof(buf), "%d/%d", ((AVRational*)dst)->num, ((AVRational*)dst)->den);break; + case AV_OPT_TYPE_CONST: ret = snprintf(buf, sizeof(buf), "%f" , o->default_val.dbl);break; + case AV_OPT_TYPE_STRING: + if (*(uint8_t**)dst) + *out_val = av_strdup(*(uint8_t**)dst); + else + *out_val = av_strdup(""); + return 0; + case AV_OPT_TYPE_BINARY: + len = *(int*)(((uint8_t *)dst) + sizeof(uint8_t *)); + if ((uint64_t)len*2 + 1 > INT_MAX) + return AVERROR(EINVAL); + if (!(*out_val = av_malloc(len*2 + 1))) + return AVERROR(ENOMEM); + bin = *(uint8_t**)dst; + for (i = 0; i < len; i++) + snprintf(*out_val + i*2, 3, "%02X", bin[i]); + return 0; + default: + return AVERROR(EINVAL); } + + if (ret >= sizeof(buf)) + return AVERROR(EINVAL); + *out_val = av_strdup(buf); + return 0; +} + +static int get_number(void *obj, const char *name, const AVOption **o_out, double *num, int *den, int64_t *intnum, + int search_flags) +{ + void *dst, *target_obj; + const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj); + if (!o || !target_obj) + goto error; + + dst = ((uint8_t*)target_obj) + o->offset; + + if (o_out) *o_out= o; + + return read_number(o, dst, num, den, intnum); + error: *den=*intnum=0; return -1; } +#if FF_API_OLD_AVOPTIONS double av_get_double(void *obj, const char *name, const AVOption **o_out) { int64_t intnum=1; double num=1; int den=1; - if (get_number(obj, name, o_out, &num, &den, &intnum) < 0) + if (get_number(obj, name, o_out, &num, &den, &intnum, 0) < 0) return NAN; return num*intnum/den; } @@ -304,7 +440,7 @@ double num=1; int den=1; - if (get_number(obj, name, o_out, &num, &den, &intnum) < 0) + if (get_number(obj, name, o_out, &num, &den, &intnum, 0) < 0) return (AVRational){0, 0}; if (num == 1.0 && (int)intnum == intnum) return (AVRational){intnum, den}; @@ -318,19 +454,63 @@ double num=1; int den=1; - if (get_number(obj, name, o_out, &num, &den, &intnum) < 0) + if (get_number(obj, name, o_out, &num, &den, &intnum, 0) < 0) return -1; return num*intnum/den; } +#endif + +int av_opt_get_int(void *obj, const char *name, int search_flags, int64_t *out_val) +{ + int64_t intnum = 1; + double num = 1; + int ret, den = 1; + + if ((ret = get_number(obj, name, NULL, &num, &den, &intnum, search_flags)) < 0) + return ret; + *out_val = num*intnum/den; + return 0; +} + +int av_opt_get_double(void *obj, const char *name, int search_flags, double *out_val) +{ + int64_t intnum = 1; + double num = 1; + int ret, den = 1; + + if ((ret = get_number(obj, name, NULL, &num, &den, &intnum, search_flags)) < 0) + return ret; + *out_val = num*intnum/den; + return 0; +} + +int av_opt_get_q(void *obj, const char *name, int search_flags, AVRational *out_val) +{ + int64_t intnum = 1; + double num = 1; + int ret, den = 1; + + if ((ret = get_number(obj, name, NULL, &num, &den, &intnum, search_flags)) < 0) + return ret; + + if (num == 1.0 && (int)intnum == intnum) + *out_val = (AVRational){intnum, den}; + else + *out_val = av_d2q(num*intnum/den, 1<<24); + return 0; +} int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name) { - const AVOption *field = av_find_opt(obj, field_name, NULL, 0, 0); - const AVOption *flag = av_find_opt(obj, flag_name, NULL, 0, 0); + const AVOption *field = av_opt_find(obj, field_name, NULL, 0, 0); + const AVOption *flag = av_opt_find(obj, flag_name, + field ? field->unit : NULL, 0, 0); + int64_t res; - if (!field || !flag || flag->type != FF_OPT_TYPE_CONST) + if (!field || !flag || flag->type != AV_OPT_TYPE_CONST || + av_opt_get_int(obj, field_name, 0, &res) < 0) return 0; - return av_get_int(obj, field_name, NULL) & (int) flag->default_val.dbl; + return res & (int) flag->default_val.dbl; } static void opt_list(void *obj, void *av_log_obj, const char *unit, @@ -338,7 +518,7 @@ { const AVOption *opt=NULL; - while ((opt= av_next_option(obj, opt))) { + while ((opt = av_opt_next(obj, opt))) { if (!(opt->flags & req_flags) || (opt->flags & rej_flags)) continue; @@ -346,43 +526,43 @@ * Don't print anything but CONST's on level two. * Only print items from the requested unit. */ - if (!unit && opt->type==FF_OPT_TYPE_CONST) + if (!unit && opt->type==AV_OPT_TYPE_CONST) continue; - else if (unit && opt->type!=FF_OPT_TYPE_CONST) + else if (unit && opt->type!=AV_OPT_TYPE_CONST) continue; - else if (unit && opt->type==FF_OPT_TYPE_CONST && strcmp(unit, opt->unit)) + else if (unit && opt->type==AV_OPT_TYPE_CONST && strcmp(unit, opt->unit)) continue; - else if (unit && opt->type == FF_OPT_TYPE_CONST) + else if (unit && opt->type == AV_OPT_TYPE_CONST) av_log(av_log_obj, AV_LOG_INFO, " %-15s ", opt->name); else av_log(av_log_obj, AV_LOG_INFO, "-%-17s ", opt->name); switch (opt->type) { - case FF_OPT_TYPE_FLAGS: + case AV_OPT_TYPE_FLAGS: av_log(av_log_obj, AV_LOG_INFO, "%-7s ", ""); break; - case FF_OPT_TYPE_INT: + case AV_OPT_TYPE_INT: av_log(av_log_obj, AV_LOG_INFO, "%-7s ", ""); break; - case FF_OPT_TYPE_INT64: + case AV_OPT_TYPE_INT64: av_log(av_log_obj, AV_LOG_INFO, "%-7s ", ""); break; - case FF_OPT_TYPE_DOUBLE: + case AV_OPT_TYPE_DOUBLE: av_log(av_log_obj, AV_LOG_INFO, "%-7s ", ""); break; - case FF_OPT_TYPE_FLOAT: + case AV_OPT_TYPE_FLOAT: av_log(av_log_obj, AV_LOG_INFO, "%-7s ", ""); break; - case FF_OPT_TYPE_STRING: + case AV_OPT_TYPE_STRING: av_log(av_log_obj, AV_LOG_INFO, "%-7s ", ""); break; - case FF_OPT_TYPE_RATIONAL: + case AV_OPT_TYPE_RATIONAL: av_log(av_log_obj, AV_LOG_INFO, "%-7s ", ""); break; - case FF_OPT_TYPE_BINARY: + case AV_OPT_TYPE_BINARY: av_log(av_log_obj, AV_LOG_INFO, "%-7s ", ""); break; - case FF_OPT_TYPE_CONST: + case AV_OPT_TYPE_CONST: default: av_log(av_log_obj, AV_LOG_INFO, "%-7s ", ""); break; @@ -396,7 +576,7 @@ if (opt->help) av_log(av_log_obj, AV_LOG_INFO, " %s", opt->help); av_log(av_log_obj, AV_LOG_INFO, "\n"); - if (opt->unit && opt->type != FF_OPT_TYPE_CONST) { + if (opt->unit && opt->type != AV_OPT_TYPE_CONST) { opt_list(obj, av_log_obj, opt->unit, req_flags, rej_flags); } } @@ -424,44 +604,44 @@ { #endif const AVOption *opt = NULL; - while ((opt = av_next_option(s, opt)) != NULL) { + while ((opt = av_opt_next(s, opt)) != NULL) { #if FF_API_OLD_AVOPTIONS if ((opt->flags & mask) != flags) continue; #endif switch (opt->type) { - case FF_OPT_TYPE_CONST: + case AV_OPT_TYPE_CONST: /* Nothing to be done here */ break; - case FF_OPT_TYPE_FLAGS: - case FF_OPT_TYPE_INT: { + case AV_OPT_TYPE_FLAGS: + case AV_OPT_TYPE_INT: { int val; val = opt->default_val.dbl; - av_set_int(s, opt->name, val); + av_opt_set_int(s, opt->name, val, 0); } break; - case FF_OPT_TYPE_INT64: + case AV_OPT_TYPE_INT64: if ((double)(opt->default_val.dbl+0.6) == opt->default_val.dbl) av_log(s, AV_LOG_DEBUG, "loss of precision in default of %s\n", opt->name); - av_set_int(s, opt->name, opt->default_val.dbl); + av_opt_set_int(s, opt->name, opt->default_val.dbl, 0); break; - case FF_OPT_TYPE_DOUBLE: - case FF_OPT_TYPE_FLOAT: { + case AV_OPT_TYPE_DOUBLE: + case AV_OPT_TYPE_FLOAT: { double val; val = opt->default_val.dbl; - av_set_double(s, opt->name, val); + av_opt_set_double(s, opt->name, val, 0); } break; - case FF_OPT_TYPE_RATIONAL: { + case AV_OPT_TYPE_RATIONAL: { AVRational val; val = av_d2q(opt->default_val.dbl, INT_MAX); - av_set_q(s, opt->name, val); + av_opt_set_q(s, opt->name, val, 0); } break; - case FF_OPT_TYPE_STRING: - av_set_string3(s, opt->name, opt->default_val.str, 1, NULL); + case AV_OPT_TYPE_STRING: + av_opt_set(s, opt->name, opt->default_val.str, 0); break; - case FF_OPT_TYPE_BINARY: + case AV_OPT_TYPE_BINARY: /* Cannot set default for binary */ break; default: @@ -484,7 +664,7 @@ * set, or a negative value corresponding to an AVERROR code in case * of error: * AVERROR(EINVAL) if the key/value pair cannot be parsed, - * the error code issued by av_set_string3() if the key/value pair + * the error code issued by av_opt_set() if the key/value pair * cannot be set */ static int parse_key_value_pair(void *ctx, const char **buf, @@ -505,7 +685,7 @@ av_log(ctx, AV_LOG_DEBUG, "Setting value '%s' for key '%s'\n", val, key); - ret = av_set_string3(ctx, key, val, 1, NULL); + ret = av_opt_set(ctx, key, val, 0); if (ret == AVERROR_OPTION_NOT_FOUND) av_log(ctx, AV_LOG_ERROR, "Key '%s' not found.\n", key); @@ -521,6 +701,7 @@ if (!opts) return 0; + while (*opts) { if ((ret = parse_key_value_pair(ctx, &opts, key_val_sep, pairs_sep)) < 0) return ret; @@ -536,8 +717,8 @@ void av_opt_free(void *obj) { const AVOption *o = NULL; - while ((o = av_next_option(obj, o))) - if (o->type == FF_OPT_TYPE_STRING || o->type == FF_OPT_TYPE_BINARY) + while ((o = av_opt_next(obj, o))) + if (o->type == AV_OPT_TYPE_STRING || o->type == AV_OPT_TYPE_BINARY) av_freep((uint8_t *)obj + o->offset); } @@ -548,7 +729,7 @@ int ret = 0; while ((t = av_dict_get(*options, "", t, AV_DICT_IGNORE_SUFFIX))) { - ret = av_set_string3(obj, t->key, t->value, 1, NULL); + ret = av_opt_set(obj, t->key, t->value, 0); if (ret == AVERROR_OPTION_NOT_FOUND) av_dict_set(&tmp, t->key, t->value, 0); else if (ret < 0) { @@ -565,22 +746,60 @@ const AVOption *av_opt_find(void *obj, const char *name, const char *unit, int opt_flags, int search_flags) { - AVClass *c = *(AVClass**)obj; + return av_opt_find2(obj, name, unit, opt_flags, search_flags, NULL); +} + +const AVOption *av_opt_find2(void *obj, const char *name, const char *unit, + int opt_flags, int search_flags, void **target_obj) +{ + const AVClass *c = *(AVClass**)obj; const AVOption *o = NULL; - if (c->opt_find && search_flags & AV_OPT_SEARCH_CHILDREN && - (o = c->opt_find(obj, name, unit, opt_flags, search_flags))) - return o; + if (search_flags & AV_OPT_SEARCH_CHILDREN) { + if (search_flags & AV_OPT_SEARCH_FAKE_OBJ) { + const AVClass *child = NULL; + while (child = av_opt_child_class_next(c, child)) + if (o = av_opt_find2(&child, name, unit, opt_flags, search_flags, NULL)) + return o; + } else { + void *child = NULL; + while (child = av_opt_child_next(obj, child)) + if (o = av_opt_find2(child, name, unit, opt_flags, search_flags, target_obj)) + return o; + } + } - while (o = av_next_option(obj, o)) { + while (o = av_opt_next(obj, o)) { if (!strcmp(o->name, name) && (o->flags & opt_flags) == opt_flags && - ((!unit && o->type != FF_OPT_TYPE_CONST) || - (unit && o->type == FF_OPT_TYPE_CONST && o->unit && !strcmp(o->unit, unit)))) + ((!unit && o->type != AV_OPT_TYPE_CONST) || + (unit && o->type == AV_OPT_TYPE_CONST && o->unit && !strcmp(o->unit, unit)))) { + if (target_obj) { + if (!(search_flags & AV_OPT_SEARCH_FAKE_OBJ)) + *target_obj = obj; + else + *target_obj = NULL; + } return o; + } } return NULL; } +void *av_opt_child_next(void *obj, void *prev) +{ + const AVClass *c = *(AVClass**)obj; + if (c->child_next) + return c->child_next(obj, prev); + return NULL; +} + +const AVClass *av_opt_child_class_next(const AVClass *parent, const AVClass *prev) +{ + if (parent->child_class_next) + return parent->child_class_next(prev); + return NULL; +} + #ifdef TEST #undef printf @@ -602,14 +821,14 @@ #define TEST_FLAG_MU 04 static const AVOption test_options[]= { -{"num", "set num", OFFSET(num), FF_OPT_TYPE_INT, {0}, 0, 100 }, -{"toggle", "set toggle", OFFSET(toggle), FF_OPT_TYPE_INT, {0}, 0, 1 }, -{"rational", "set rational", OFFSET(rational), FF_OPT_TYPE_RATIONAL, {0}, 0, 10 }, -{"string", "set string", OFFSET(string), FF_OPT_TYPE_STRING, {0}, CHAR_MIN, CHAR_MAX }, -{"flags", "set flags", OFFSET(flags), FF_OPT_TYPE_FLAGS, {0}, 0, INT_MAX, 0, "flags" }, -{"cool", "set cool flag ", 0, FF_OPT_TYPE_CONST, {TEST_FLAG_COOL}, INT_MIN, INT_MAX, 0, "flags" }, -{"lame", "set lame flag ", 0, FF_OPT_TYPE_CONST, {TEST_FLAG_LAME}, INT_MIN, INT_MAX, 0, "flags" }, -{"mu", "set mu flag ", 0, FF_OPT_TYPE_CONST, {TEST_FLAG_MU}, INT_MIN, INT_MAX, 0, "flags" }, +{"num", "set num", OFFSET(num), AV_OPT_TYPE_INT, {0}, 0, 100 }, +{"toggle", "set toggle", OFFSET(toggle), AV_OPT_TYPE_INT, {0}, 0, 1 }, +{"rational", "set rational", OFFSET(rational), AV_OPT_TYPE_RATIONAL, {0}, 0, 10 }, +{"string", "set string", OFFSET(string), AV_OPT_TYPE_STRING, {0}, CHAR_MIN, CHAR_MAX }, +{"flags", "set flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {0}, 0, INT_MAX, 0, "flags" }, +{"cool", "set cool flag ", 0, AV_OPT_TYPE_CONST, {TEST_FLAG_COOL}, INT_MIN, INT_MAX, 0, "flags" }, +{"lame", "set lame flag ", 0, AV_OPT_TYPE_CONST, {TEST_FLAG_LAME}, INT_MIN, INT_MAX, 0, "flags" }, +{"mu", "set mu flag ", 0, AV_OPT_TYPE_CONST, {TEST_FLAG_MU}, INT_MIN, INT_MAX, 0, "flags" }, {NULL}, }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/opt.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/opt.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/opt.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/opt.h 2011-11-04 12:38:27.000000000 +0000 @@ -30,9 +30,203 @@ #include "rational.h" #include "avutil.h" #include "dict.h" +#include "log.h" + +/** + * @defgroup avoptions AVOptions + * @{ + * AVOptions provide a generic system to declare options on arbitrary structs + * ("objects"). An option can have a help text, a type and a range of possible + * values. Options may then be enumerated, read and written to. + * + * @section avoptions_implement Implementing AVOptions + * This section describes how to add AVOptions capabilities to a struct. + * + * All AVOptions-related information is stored in an AVClass. Therefore + * the first member of the struct must be a pointer to an AVClass describing it. + * The option field of the AVClass must be set to a NULL-terminated static array + * of AVOptions. Each AVOption must have a non-empty name, a type, a default + * value and for number-type AVOptions also a range of allowed values. It must + * also declare an offset in bytes from the start of the struct, where the field + * associated with this AVOption is located. Other fields in the AVOption struct + * should also be set when applicable, but are not required. + * + * The following example illustrates an AVOptions-enabled struct: + * @code + * typedef struct test_struct { + * AVClass *class; + * int int_opt; + * char *str_opt; + * uint8_t *bin_opt; + * int bin_len; + * } test_struct; + * + * static const AVOption options[] = { + * { "test_int", "This is a test option of int type.", offsetof(test_struct, int_opt), + * AV_OPT_TYPE_INT, { -1 }, INT_MIN, INT_MAX }, + * { "test_str", "This is a test option of string type.", offsetof(test_struct, str_opt), + * AV_OPT_TYPE_STRING }, + * { "test_bin", "This is a test option of binary type.", offsetof(test_struct, bin_opt), + * AV_OPT_TYPE_BINARY }, + * { NULL }, + * }; + * + * static const AVClass test_class = { + * .class_name = "test class", + * .item_name = av_default_item_name, + * .option = options, + * .version = LIBAVUTIL_VERSION_INT, + * }; + * @endcode + * + * Next, when allocating your struct, you must ensure that the AVClass pointer + * is set to the correct value. Then, av_opt_set_defaults() must be called to + * initialize defaults. After that the struct is ready to be used with the + * AVOptions API. + * + * When cleaning up, you may use the av_opt_free() function to automatically + * free all the allocated string and binary options. + * + * Continuing with the above example: + * + * @code + * test_struct *alloc_test_struct(void) + * { + * test_struct *ret = av_malloc(sizeof(*ret)); + * ret->class = &test_class; + * av_opt_set_defaults(ret); + * return ret; + * } + * void free_test_struct(test_struct **foo) + * { + * av_opt_free(*foo); + * av_freep(foo); + * } + * @endcode + * + * @subsection avoptions_implement_nesting Nesting + * It may happen that an AVOptions-enabled struct contains another + * AVOptions-enabled struct as a member (e.g. AVCodecContext in + * libavcodec exports generic options, while its priv_data field exports + * codec-specific options). In such a case, it is possible to set up the + * parent struct to export a child's options. To do that, simply + * implement AVClass.child_next() and AVClass.child_class_next() in the + * parent struct's AVClass. + * Assuming that the test_struct from above now also contains a + * child_struct field: + * + * @code + * typedef struct child_struct { + * AVClass *class; + * int flags_opt; + * } child_struct; + * static const AVOption child_opts[] = { + * { "test_flags", "This is a test option of flags type.", + * offsetof(child_struct, flags_opt), AV_OPT_TYPE_FLAGS, { 0 }, INT_MIN, INT_MAX }, + * { NULL }, + * }; + * static const AVClass child_class = { + * .class_name = "child class", + * .item_name = av_default_item_name, + * .option = child_opts, + * .version = LIBAVUTIL_VERSION_INT, + * }; + * + * void *child_next(void *obj, void *prev) + * { + * test_struct *t = obj; + * if (!prev && t->child_struct) + * return t->child_struct; + * return NULL + * } + * const AVClass child_class_next(const AVClass *prev) + * { + * return prev ? NULL : &child_class; + * } + * @endcode + * Putting child_next() and child_class_next() as defined above into + * test_class will now make child_struct's options accessible through + * test_struct (again, proper setup as described above needs to be done on + * child_struct right after it is created). + * + * From the above example it might not be clear why both child_next() + * and child_class_next() are needed. The distinction is that child_next() + * iterates over actually existing objects, while child_class_next() + * iterates over all possible child classes. E.g. if an AVCodecContext + * was initialized to use a codec which has private options, then its + * child_next() will return AVCodecContext.priv_data and finish + * iterating. OTOH child_class_next() on AVCodecContext.av_class will + * iterate over all available codecs with private options. + * + * @subsection avoptions_implement_named_constants Named constants + * It is possible to create named constants for options. Simply set the unit + * field of the option the constants should apply to to a string and + * create the constants themselves as options of type AV_OPT_TYPE_CONST + * with their unit field set to the same string. + * Their default_val field should contain the value of the named + * constant. + * For example, to add some named constants for the test_flags option + * above, put the following into the child_opts array: + * @code + * { "test_flags", "This is a test option of flags type.", + * offsetof(child_struct, flags_opt), AV_OPT_TYPE_FLAGS, { 0 }, INT_MIN, INT_MAX, "test_unit" }, + * { "flag1", "This is a flag with value 16", 0, AV_OPT_TYPE_CONST, { 16 }, 0, 0, "test_unit" }, + * @endcode + * + * @section avoptions_use Using AVOptions + * This section deals with accessing options in an AVOptions-enabled struct. + * Such structs in Libav are e.g. AVCodecContext in libavcodec or + * AVFormatContext in libavformat. + * + * @subsection avoptions_use_examine Examining AVOptions + * The basic functions for examining options are av_opt_next(), which iterates + * over all options defined for one object, and av_opt_find(), which searches + * for an option with the given name. + * + * The situation is more complicated with nesting. An AVOptions-enabled struct + * may have AVOptions-enabled children. Passing the AV_OPT_SEARCH_CHILDREN flag + * to av_opt_find() will make the function search children recursively. + * + * For enumerating there are basically two cases. The first is when you want to + * get all options that may potentially exist on the struct and its children + * (e.g. when constructing documentation). In that case you should call + * av_opt_child_class_next() recursively on the parent struct's AVClass. The + * second case is when you have an already initialized struct with all its + * children and you want to get all options that can be actually written or read + * from it. In that case you should call av_opt_child_next() recursively (and + * av_opt_next() on each result). + * + * @subsection avoptions_use_get_set Reading and writing AVOptions + * When setting options, you often have a string read directly from the + * user. In such a case, simply passing it to av_opt_set() is enough. For + * non-string type options, av_opt_set() will parse the string according to the + * option type. + * + * Similarly av_opt_get() will read any option type and convert it to a string + * which will be returned. Do not forget that the string is allocated, so you + * have to free it with av_free(). + * + * In some cases it may be more convenient to put all options into an + * AVDictionary and call av_opt_set_dict() on it. A specific case of this + * are the format/codec open functions in lavf/lavc which take a dictionary + * filled with option as a parameter. This allows to set some options + * that cannot be set otherwise, since e.g. the input file format is not known + * before the file is actually opened. + * @} + */ enum AVOptionType{ - FF_OPT_TYPE_FLAGS, + AV_OPT_TYPE_FLAGS, + AV_OPT_TYPE_INT, + AV_OPT_TYPE_INT64, + AV_OPT_TYPE_DOUBLE, + AV_OPT_TYPE_FLOAT, + AV_OPT_TYPE_STRING, + AV_OPT_TYPE_RATIONAL, + AV_OPT_TYPE_BINARY, ///< offset must point to a pointer immediately followed by an int for the length + AV_OPT_TYPE_CONST = 128, +#if FF_API_OLD_AVOPTIONS + FF_OPT_TYPE_FLAGS = 0, FF_OPT_TYPE_INT, FF_OPT_TYPE_INT64, FF_OPT_TYPE_DOUBLE, @@ -41,6 +235,7 @@ FF_OPT_TYPE_RATIONAL, FF_OPT_TYPE_BINARY, ///< offset must point to a pointer immediately followed by an int for the length FF_OPT_TYPE_CONST=128, +#endif }; /** @@ -111,6 +306,7 @@ const AVOption *av_find_opt(void *obj, const char *name, const char *unit, int mask, int flags); #endif +#if FF_API_OLD_AVOPTIONS /** * Set the field of obj with the given name to value. * @@ -129,25 +325,27 @@ * similarly, '-' unsets a flag. * @param[out] o_out if non-NULL put here a pointer to the AVOption * found - * @param alloc when 1 then the old value will be av_freed() and the - * new av_strduped() - * when 0 then no av_free() nor av_strdup() will be used + * @param alloc this parameter is currently ignored * @return 0 if the value has been set, or an AVERROR code in case of * error: * AVERROR_OPTION_NOT_FOUND if no matching option exists * AVERROR(ERANGE) if the value is out of range * AVERROR(EINVAL) if the value is not valid + * @deprecated use av_opt_set() */ +attribute_deprecated int av_set_string3(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out); -const AVOption *av_set_double(void *obj, const char *name, double n); -const AVOption *av_set_q(void *obj, const char *name, AVRational n); -const AVOption *av_set_int(void *obj, const char *name, int64_t n); +attribute_deprecated const AVOption *av_set_double(void *obj, const char *name, double n); +attribute_deprecated const AVOption *av_set_q(void *obj, const char *name, AVRational n); +attribute_deprecated const AVOption *av_set_int(void *obj, const char *name, int64_t n); + double av_get_double(void *obj, const char *name, const AVOption **o_out); AVRational av_get_q(void *obj, const char *name, const AVOption **o_out); int64_t av_get_int(void *obj, const char *name, const AVOption **o_out); -const char *av_get_string(void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len); -const AVOption *av_next_option(void *obj, const AVOption *last); +attribute_deprecated const char *av_get_string(void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len); +attribute_deprecated const AVOption *av_next_option(void *obj, const AVOption *last); +#endif /** * Show the obj options. @@ -223,6 +421,30 @@ */ int av_opt_set_dict(void *obj, struct AVDictionary **options); +/** + * @defgroup opt_eval_funcs Evaluating option strings + * @{ + * This group of functions can be used to evaluate option strings + * and get numbers out of them. They do the same thing as av_opt_set(), + * except the result is written into the caller-supplied pointer. + * + * @param obj a struct whose first element is a pointer to AVClass. + * @param o an option for which the string is to be evaluated. + * @param val string to be evaluated. + * @param *_out value of the string will be written here. + * + * @return 0 on success, a negative number on failure. + */ +int av_opt_eval_flags (void *obj, const AVOption *o, const char *val, int *flags_out); +int av_opt_eval_int (void *obj, const AVOption *o, const char *val, int *int_out); +int av_opt_eval_int64 (void *obj, const AVOption *o, const char *val, int64_t *int64_out); +int av_opt_eval_float (void *obj, const AVOption *o, const char *val, float *float_out); +int av_opt_eval_double(void *obj, const AVOption *o, const char *val, double *double_out); +int av_opt_eval_q (void *obj, const AVOption *o, const char *val, AVRational *q_out); +/** + * @} + */ + #define AV_OPT_SEARCH_CHILDREN 0x0001 /**< Search in possible children of the given object first. */ /** @@ -258,4 +480,112 @@ const AVOption *av_opt_find(void *obj, const char *name, const char *unit, int opt_flags, int search_flags); +/** + * Look for an option in an object. Consider only options which + * have all the specified flags set. + * + * @param[in] obj A pointer to a struct whose first element is a + * pointer to an AVClass. + * Alternatively a double pointer to an AVClass, if + * AV_OPT_SEARCH_FAKE_OBJ search flag is set. + * @param[in] name The name of the option to look for. + * @param[in] unit When searching for named constants, name of the unit + * it belongs to. + * @param opt_flags Find only options with all the specified flags set (AV_OPT_FLAG). + * @param search_flags A combination of AV_OPT_SEARCH_*. + * @param[out] target_obj if non-NULL, an object to which the option belongs will be + * written here. It may be different from obj if AV_OPT_SEARCH_CHILDREN is present + * in search_flags. This parameter is ignored if search_flags contain + * AV_OPT_SEARCH_FAKE_OBJ. + * + * @return A pointer to the option found, or NULL if no option + * was found. + */ +const AVOption *av_opt_find2(void *obj, const char *name, const char *unit, + int opt_flags, int search_flags, void **target_obj); + +/** + * Iterate over all AVOptions belonging to obj. + * + * @param obj an AVOptions-enabled struct or a double pointer to an + * AVClass describing it. + * @param prev result of the previous call to av_opt_next() on this object + * or NULL + * @return next AVOption or NULL + */ +const AVOption *av_opt_next(void *obj, const AVOption *prev); + +/** + * Iterate over AVOptions-enabled children of obj. + * + * @param prev result of a previous call to this function or NULL + * @return next AVOptions-enabled child or NULL + */ +void *av_opt_child_next(void *obj, void *prev); + +/** + * Iterate over potential AVOptions-enabled children of parent. + * + * @param prev result of a previous call to this function or NULL + * @return AVClass corresponding to next potential child or NULL + */ +const AVClass *av_opt_child_class_next(const AVClass *parent, const AVClass *prev); + +/** + * @defgroup opt_set_funcs Option setting functions + * @{ + * Those functions set the field of obj with the given name to value. + * + * @param[in] obj A struct whose first element is a pointer to an AVClass. + * @param[in] name the name of the field to set + * @param[in] val The value to set. In case of av_opt_set() if the field is not + * of a string type, then the given string is parsed. + * SI postfixes and some named scalars are supported. + * If the field is of a numeric type, it has to be a numeric or named + * scalar. Behavior with more than one scalar and +- infix operators + * is undefined. + * If the field is of a flags type, it has to be a sequence of numeric + * scalars or named flags separated by '+' or '-'. Prefixing a flag + * with '+' causes it to be set without affecting the other flags; + * similarly, '-' unsets a flag. + * @param search_flags flags passed to av_opt_find2. I.e. if AV_OPT_SEARCH_CHILDREN + * is passed here, then the option may be set on a child of obj. + * + * @return 0 if the value has been set, or an AVERROR code in case of + * error: + * AVERROR_OPTION_NOT_FOUND if no matching option exists + * AVERROR(ERANGE) if the value is out of range + * AVERROR(EINVAL) if the value is not valid + */ +int av_opt_set (void *obj, const char *name, const char *val, int search_flags); +int av_opt_set_int (void *obj, const char *name, int64_t val, int search_flags); +int av_opt_set_double(void *obj, const char *name, double val, int search_flags); +int av_opt_set_q (void *obj, const char *name, AVRational val, int search_flags); +/** + * @} + */ + +/** + * @defgroup opt_get_funcs Option getting functions + * @{ + * Those functions get a value of the option with the given name from an object. + * + * @param[in] obj a struct whose first element is a pointer to an AVClass. + * @param[in] name name of the option to get. + * @param[in] search_flags flags passed to av_opt_find2. I.e. if AV_OPT_SEARCH_CHILDREN + * is passed here, then the option may be found in a child of obj. + * @param[out] out_val value of the option will be written here + * @return 0 on success, a negative error code otherwise + */ +/** + * @note the returned string will av_malloc()ed and must be av_free()ed by the caller + */ +int av_opt_get (void *obj, const char *name, int search_flags, uint8_t **out_val); +int av_opt_get_int (void *obj, const char *name, int search_flags, int64_t *out_val); +int av_opt_get_double(void *obj, const char *name, int search_flags, double *out_val); +int av_opt_get_q (void *obj, const char *name, int search_flags, AVRational *out_val); +/** + * @} + */ + #endif /* AVUTIL_OPT_H */ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/parseutils.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/parseutils.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/parseutils.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/parseutils.c 2011-11-04 12:38:27.000000000 +0000 @@ -21,7 +21,6 @@ * misc parsing utilities */ -#include #include #include @@ -97,7 +96,7 @@ { int i; int n = FF_ARRAY_ELEMS(video_size_abbrs); - char *p; + const char *p; int width = 0, height = 0; for (i = 0; i < n; i++) { @@ -109,10 +108,10 @@ } if (i == n) { p = str; - width = strtol(p, &p, 10); + width = strtol(p, (void*)&p, 10); if (*p) p++; - height = strtol(p, &p, 10); + height = strtol(p, (void*)&p, 10); } if (width <= 0 || height <= 0) return AVERROR(EINVAL); @@ -294,7 +293,7 @@ static int color_table_compare(const void *lhs, const void *rhs) { - return strcasecmp(lhs, ((const ColorEntry *)rhs)->name); + return av_strcasecmp(lhs, ((const ColorEntry *)rhs)->name); } #define ALPHA_SEP '@' @@ -320,7 +319,7 @@ len = strlen(color_string2); rgba_color[3] = 255; - if (!strcasecmp(color_string2, "random") || !strcasecmp(color_string2, "bikeshed")) { + if (!av_strcasecmp(color_string2, "random") || !av_strcasecmp(color_string2, "bikeshed")) { int rgba = av_get_random_seed(); rgba_color[0] = rgba >> 24; rgba_color[1] = rgba >> 16; @@ -411,9 +410,7 @@ * function call, or NULL in case the function fails to match all of * the fmt string and therefore an error occurred */ -static -const char *small_strptime(const char *p, const char *fmt, - struct tm *dt) +static const char *small_strptime(const char *p, const char *fmt, struct tm *dt) { int c, val; @@ -527,7 +524,7 @@ p = timestr; q = NULL; if (!duration) { - if (!strncasecmp(timestr, "now", len)) { + if (!av_strncasecmp(timestr, "now", len)) { *timeval = (int64_t) now * 1000000; return 0; } @@ -573,7 +570,7 @@ q = small_strptime(p, time_fmt[0], &dt); if (!q) { /* parse timestr as S+ */ - dt.tm_sec = strtol(p, (char **)&q, 10); + dt.tm_sec = strtol(p, (void *)&q, 10); if (q == p) { /* the parsing didn't succeed */ *timeval = INT64_MIN; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/pixdesc.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/pixdesc.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/pixdesc.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/pixdesc.c 2011-11-04 12:38:27.000000000 +0000 @@ -859,6 +859,29 @@ }, .flags = PIX_FMT_BE, }, + [PIX_FMT_YUV422P9LE] = { + .name = "yuv422p9le", + .nb_components= 3, + .log2_chroma_w= 1, + .log2_chroma_h= 0, + .comp = { + {0,1,1,0,8}, /* Y */ + {1,1,1,0,8}, /* U */ + {2,1,1,0,8}, /* V */ + }, + }, + [PIX_FMT_YUV422P9BE] = { + .name = "yuv422p9be", + .nb_components= 3, + .log2_chroma_w= 1, + .log2_chroma_h= 0, + .comp = { + {0,1,1,0,8}, /* Y */ + {1,1,1,0,8}, /* U */ + {2,1,1,0,8}, /* V */ + }, + .flags = PIX_FMT_BE, + }, [PIX_FMT_YUV422P10LE] = { .name = "yuv422p10le", .nb_components= 3, @@ -980,6 +1003,12 @@ .log2_chroma_h = 1, .flags = PIX_FMT_HWACCEL, }, + [PIX_FMT_VDA_VLD] = { + .name = "vda_vld", + .log2_chroma_w = 1, + .log2_chroma_h = 1, + .flags = PIX_FMT_HWACCEL, + }, [PIX_FMT_GRAY8A] = { .name = "gray8a", .nb_components= 2, @@ -988,6 +1017,15 @@ {0,1,2,0,7}, /* A */ }, }, + [PIX_FMT_GBR24P] = { + .name = "gbr24p", + .nb_components= 3, + .comp = { + {1,0,1,0,7}, /* B */ + {0,0,1,0,7}, /* G */ + {2,0,1,0,7}, /* R */ + }, + }, }; static enum PixelFormat get_pix_fmt_internal(const char *name) diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/pixfmt.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/pixfmt.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/pixfmt.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/pixfmt.h 2011-11-04 12:38:27.000000000 +0000 @@ -149,11 +149,17 @@ PIX_FMT_YUV444P9LE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian PIX_FMT_YUV444P10BE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian PIX_FMT_YUV444P10LE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian + PIX_FMT_YUV422P9BE, ///< planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian + PIX_FMT_YUV422P9LE, ///< planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian PIX_FMT_RGBA64BE, ///< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian PIX_FMT_RGBA64LE, ///< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian PIX_FMT_BGRA64BE, ///< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian PIX_FMT_BGRA64LE, ///< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian + PIX_FMT_GBR24P, ///< planar GBR, 24bpp, 8G, 8B, 8R. + + PIX_FMT_VDA_VLD, ///< HW decoding through VDA. + PIX_FMT_NB, ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions }; @@ -181,6 +187,7 @@ #define PIX_FMT_BGR444 PIX_FMT_NE(BGR444BE, BGR444LE) #define PIX_FMT_YUV420P9 PIX_FMT_NE(YUV420P9BE , YUV420P9LE) +#define PIX_FMT_YUV422P9 PIX_FMT_NE(YUV422P9BE , YUV422P9LE) #define PIX_FMT_YUV444P9 PIX_FMT_NE(YUV444P9BE , YUV444P9LE) #define PIX_FMT_YUV420P10 PIX_FMT_NE(YUV420P10BE, YUV420P10LE) #define PIX_FMT_YUV422P10 PIX_FMT_NE(YUV422P10BE, YUV422P10LE) diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/x86/x86util.asm ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/x86/x86util.asm --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libavutil/x86/x86util.asm 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libavutil/x86/x86util.asm 2011-11-04 12:38:27.000000000 +0000 @@ -536,6 +536,18 @@ %endif %endmacro +%macro SPLATD_MMX 1 + punpckldq %1, %1 +%endmacro + +%macro SPLATD_SSE 1 + shufps %1, %1, 0 +%endmacro + +%macro SPLATD_SSE2 1 + pshufd %1, %1, 0 +%endmacro + %macro CLIPW 3 ;(dst, min, max) pmaxsw %1, %2 pminsw %1, %3 diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libpostproc/postprocess_template.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libpostproc/postprocess_template.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libpostproc/postprocess_template.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libpostproc/postprocess_template.c 2011-11-04 12:38:27.000000000 +0000 @@ -3588,7 +3588,7 @@ /* for(x=0; x>15) #define SAMPLE int16_t +#define COEFF int #define RENAME(x) x ## _s16 #include "rematrix_template.c" @@ -194,7 +197,7 @@ int ch_in=0; for(j=0; j<64; j++){ s->matrix[out_i][in_i]= matrix[i][j]; - s->matrix16[out_i][in_i]= lrintf(matrix[i][j] * 32768); + s->matrix32[out_i][in_i]= lrintf(matrix[i][j] * 32768); if(matrix[i][j]){ s->matrix_ch[out_i][++ch_in]= in_i; sum += fabs(matrix[i][j]); @@ -207,28 +210,40 @@ if(s->out_ch_layout & (1ULL<rematrix_volume < 0) + maxcoef = -s->rematrix_volume; + if(( s->out_sample_fmt < AV_SAMPLE_FMT_FLT || s->int_sample_fmt < AV_SAMPLE_FMT_FLT) && maxcoef > 1.0){ for(i=0; imatrix[i][j] /= maxcoef; - s->matrix16[i][j]= lrintf(s->matrix[i][j] * 32768); + s->matrix32[i][j]= lrintf(s->matrix[i][j] * 32768); } } - for(i=0; iout_ch_layout); i++){ - for(j=0; jin_ch_layout); j++){ - av_log(NULL, AV_LOG_DEBUG, "%f ", s->matrix[i][j]); + + if(s->rematrix_volume > 0){ + for(i=0; imatrix[i][j] *= s->rematrix_volume; + s->matrix32[i][j]= lrintf(s->matrix[i][j] * 32768); } - av_log(NULL, AV_LOG_DEBUG, "\n"); + } + + for(i=0; iout_ch_layout); i++){ + for(j=0; jin_ch_layout); j++){ + av_log(NULL, AV_LOG_DEBUG, "%f ", s->matrix[i][j]); } + av_log(NULL, AV_LOG_DEBUG, "\n"); + } return 0; } int swr_rematrix(SwrContext *s, AudioData *out, AudioData *in, int len, int mustcopy){ int out_i, in_i, i, j; -av_assert0(out->ch_count == av_get_channel_layout_nb_channels(s->out_ch_layout)); -av_assert0(in ->ch_count == av_get_channel_layout_nb_channels(s-> in_ch_layout)); + av_assert0(out->ch_count == av_get_channel_layout_nb_channels(s->out_ch_layout)); + av_assert0(in ->ch_count == av_get_channel_layout_nb_channels(s-> in_ch_layout)); for(out_i=0; out_ich_count; out_i++){ switch(s->matrix_ch[out_i][0]){ @@ -236,21 +251,21 @@ in_i= s->matrix_ch[out_i][1]; if(mustcopy || s->matrix[out_i][in_i]!=1.0){ if(s->int_sample_fmt == AV_SAMPLE_FMT_FLT){ - copy_float(out->ch[out_i], in->ch[in_i], s->matrix[out_i][in_i], len); + copy_float((float *)out->ch[out_i], (const float *)in->ch[in_i], s->matrix [out_i][in_i], len); }else - copy_s16 (out->ch[out_i], in->ch[in_i], s->matrix16[out_i][in_i], len); + copy_s16 ((int16_t*)out->ch[out_i], (const int16_t*)in->ch[in_i], s->matrix32[out_i][in_i], len); }else{ out->ch[out_i]= in->ch[in_i]; } break; case 2: if(s->int_sample_fmt == AV_SAMPLE_FMT_FLT){ - sum2_float(out->ch[out_i], in->ch[ s->matrix_ch[out_i][1] ], in->ch[ s->matrix_ch[out_i][2] ], + sum2_float((float *)out->ch[out_i], (const float *)in->ch[ s->matrix_ch[out_i][1] ], (const float *)in->ch[ s->matrix_ch[out_i][2] ], s->matrix[out_i][ s->matrix_ch[out_i][1] ], s->matrix[out_i][ s->matrix_ch[out_i][2] ], len); }else{ - sum2_s16 (out->ch[out_i], in->ch[ s->matrix_ch[out_i][1] ], in->ch[ s->matrix_ch[out_i][2] ], - s->matrix16[out_i][ s->matrix_ch[out_i][1] ], s->matrix16[out_i][ s->matrix_ch[out_i][2] ], + sum2_s16 ((int16_t*)out->ch[out_i], (const int16_t*)in->ch[ s->matrix_ch[out_i][1] ], (const int16_t*)in->ch[ s->matrix_ch[out_i][2] ], + s->matrix32[out_i][ s->matrix_ch[out_i][1] ], s->matrix32[out_i][ s->matrix_ch[out_i][2] ], len); } break; @@ -269,7 +284,7 @@ int v=0; for(j=0; jmatrix_ch[out_i][0]; j++){ in_i= s->matrix_ch[out_i][1+j]; - v+= ((int16_t*)in->ch[in_i])[i] * s->matrix16[out_i][in_i]; + v+= ((int16_t*)in->ch[in_i])[i] * s->matrix32[out_i][in_i]; } ((int16_t*)out->ch[out_i])[i]= (v + 16384)>>15; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libswresample/rematrix_template.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libswresample/rematrix_template.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libswresample/rematrix_template.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libswresample/rematrix_template.c 2011-11-04 12:38:27.000000000 +0000 @@ -19,14 +19,14 @@ */ -static void RENAME(sum2)(SAMPLE *out, const SAMPLE *in1, const SAMPLE *in2, SAMPLE coeff1, SAMPLE coeff2, int len){ +static void RENAME(sum2)(SAMPLE *out, const SAMPLE *in1, const SAMPLE *in2, COEFF coeff1, COEFF coeff2, int len){ int i; for(i=0; iphase_shift!=phase_shift || c->linear!=linear || c->factor != factor - || c->filter_length!=FFMAX((int)ceil(filter_size/factor), 1)){ - c= av_mallocz(sizeof(AVResampleContext)); - if (!c) - return NULL; - - c->phase_shift= phase_shift; - c->phase_mask= phase_count-1; - c->linear= linear; - c->factor= factor; - - c->filter_length= FFMAX((int)ceil(filter_size/factor), 1); - c->filter_bank= av_mallocz(c->filter_length*(phase_count+1)*sizeof(FELEM)); - if (!c->filter_bank) - goto error; - if (build_filter(c->filter_bank, factor, c->filter_length, phase_count, 1<filter_bank[c->filter_length*phase_count+1], c->filter_bank, (c->filter_length-1)*sizeof(FELEM)); - c->filter_bank[c->filter_length*phase_count]= c->filter_bank[c->filter_length - 1]; + if (!c || c->phase_shift != phase_shift || c->linear!=linear || c->factor != factor + || c->filter_length != FFMAX((int)ceil(filter_size/factor), 1)) { + c = av_mallocz(sizeof(AVResampleContext)); + if (!c) + return NULL; + + c->phase_shift = phase_shift; + c->phase_mask = phase_count - 1; + c->linear = linear; + c->factor = factor; + c->filter_length = FFMAX((int)ceil(filter_size/factor), 1); + c->filter_bank = av_mallocz(c->filter_length*(phase_count+1)*sizeof(FELEM)); + if (!c->filter_bank) + goto error; + if (build_filter(c->filter_bank, factor, c->filter_length, phase_count, 1<filter_bank[c->filter_length*phase_count+1], c->filter_bank, (c->filter_length-1)*sizeof(FELEM)); + c->filter_bank[c->filter_length*phase_count]= c->filter_bank[c->filter_length - 1]; } c->compensation_distance= 0; - c->src_incr= out_rate; - c->ideal_dst_incr= c->dst_incr= in_rate * phase_count; + if(!av_reduce(&c->src_incr, &c->dst_incr, out_rate, in_rate * (int64_t)phase_count, INT32_MAX/2)) + goto error; + c->ideal_dst_incr= c->dst_incr; + c->index= -phase_count*((c->filter_length-1)/2); c->frac= 0; @@ -251,7 +252,7 @@ c->dst_incr = c->ideal_dst_incr - c->ideal_dst_incr * (int64_t)sample_delta / compensation_distance; } -int swr_resample(AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx){ +int swr_resample(AVResampleContext *c, short *dst, const short *src, int *consumed, int src_size, int dst_size, int update_ctx){ int dst_index, i; int index= c->index; int frac= c->frac; @@ -259,7 +260,7 @@ int dst_incr= c->dst_incr / c->src_incr; int compensation_distance= c->compensation_distance; - if(compensation_distance == 0 && c->filter_length == 1 && c->phase_shift==0){ + if(compensation_distance == 0 && c->filter_length == 1 && c->phase_shift==0){ int64_t index2= ((int64_t)index)<<32; int64_t incr= (1LL<<32) * c->dst_incr / c->src_incr; dst_size= FFMIN(dst_size, (src_size-1-index) * (int64_t)c->src_incr / c->dst_incr); @@ -268,55 +269,54 @@ dst[dst_index] = src[index2>>32]; index2 += incr; } - frac += dst_index * dst_incr_frac; index += dst_index * dst_incr; - index += frac / c->src_incr; - frac %= c->src_incr; - }else{ - for(dst_index=0; dst_index < dst_size; dst_index++){ - FELEM *filter= c->filter_bank + c->filter_length*(index & c->phase_mask); - int sample_index= index >> c->phase_shift; - FELEM2 val=0; - - if(sample_index < 0){ - for(i=0; ifilter_length; i++) - val += src[FFABS(sample_index + i) % src_size] * filter[i]; - }else if(sample_index + c->filter_length > src_size){ - break; - }else if(c->linear){ - FELEM2 v2=0; - for(i=0; ifilter_length; i++){ - val += src[sample_index + i] * (FELEM2)filter[i]; - v2 += src[sample_index + i] * (FELEM2)filter[i + c->filter_length]; - } - val+=(v2-val)*(FELEML)frac / c->src_incr; - }else{ - for(i=0; ifilter_length; i++){ - val += src[sample_index + i] * (FELEM2)filter[i]; + index += (frac + dst_index * (int64_t)dst_incr_frac) / c->src_incr; + frac = (frac + dst_index * (int64_t)dst_incr_frac) % c->src_incr; + }else{ + for(dst_index=0; dst_index < dst_size; dst_index++){ + FELEM *filter= c->filter_bank + c->filter_length*(index & c->phase_mask); + int sample_index= index >> c->phase_shift; + FELEM2 val=0; + + if(sample_index < 0){ + for(i=0; ifilter_length; i++) + val += src[FFABS(sample_index + i) % src_size] * filter[i]; + }else if(sample_index + c->filter_length > src_size){ + break; + }else if(c->linear){ + FELEM2 v2=0; + for(i=0; ifilter_length; i++){ + val += src[sample_index + i] * (FELEM2)filter[i]; + v2 += src[sample_index + i] * (FELEM2)filter[i + c->filter_length]; + } + val+=(v2-val)*(FELEML)frac / c->src_incr; + }else{ + for(i=0; ifilter_length; i++){ + val += src[sample_index + i] * (FELEM2)filter[i]; + } } - } #ifdef CONFIG_RESAMPLE_AUDIOPHILE_KIDDY_MODE - dst[dst_index] = av_clip_int16(lrintf(val)); + dst[dst_index] = av_clip_int16(lrintf(val)); #else - val = (val + (1<<(FILTER_SHIFT-1)))>>FILTER_SHIFT; - dst[dst_index] = (unsigned)(val + 32768) > 65535 ? (val>>31) ^ 32767 : val; + val = (val + (1<<(FILTER_SHIFT-1)))>>FILTER_SHIFT; + dst[dst_index] = (unsigned)(val + 32768) > 65535 ? (val>>31) ^ 32767 : val; #endif - frac += dst_incr_frac; - index += dst_incr; - if(frac >= c->src_incr){ - frac -= c->src_incr; - index++; - } + frac += dst_incr_frac; + index += dst_incr; + if(frac >= c->src_incr){ + frac -= c->src_incr; + index++; + } - if(dst_index + 1 == compensation_distance){ - compensation_distance= 0; - dst_incr_frac= c->ideal_dst_incr % c->src_incr; - dst_incr= c->ideal_dst_incr / c->src_incr; + if(dst_index + 1 == compensation_distance){ + compensation_distance= 0; + dst_incr_frac= c->ideal_dst_incr % c->src_incr; + dst_incr= c->ideal_dst_incr / c->src_incr; + } } } - } *consumed= FFMAX(index, 0) >> c->phase_shift; if(index>=0) index &= c->phase_mask; @@ -345,7 +345,7 @@ int i, ret= -1; for(i=0; ich_count; i++){ - ret= swr_resample(c, dst->ch[i], src->ch[i], consumed, src_size, dst_size, i+1==dst->ch_count); + ret= swr_resample(c, (short*)dst->ch[i], (const short*)src->ch[i], consumed, src_size, dst_size, i+1==dst->ch_count); } return ret; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libswresample/swresample.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libswresample/swresample.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libswresample/swresample.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libswresample/swresample.c 2011-11-04 12:38:27.000000000 +0000 @@ -36,21 +36,22 @@ //TODO split options array out? #define OFFSET(x) offsetof(SwrContext,x) static const AVOption options[]={ -{"ich", "input channel count", OFFSET( in.ch_count ), FF_OPT_TYPE_INT, {.dbl=2}, 1, SWR_CH_MAX, 0}, -{"och", "output channel count", OFFSET(out.ch_count ), FF_OPT_TYPE_INT, {.dbl=2}, 1, SWR_CH_MAX, 0}, -{"isr", "input sample rate" , OFFSET( in_sample_rate), FF_OPT_TYPE_INT, {.dbl=48000}, 1, INT_MAX, 0}, -{"osr", "output sample rate" , OFFSET(out_sample_rate), FF_OPT_TYPE_INT, {.dbl=48000}, 1, INT_MAX, 0}, -//{"ip" , "input planar" , OFFSET( in.planar ), FF_OPT_TYPE_INT, {.dbl=0}, 0, 1, 0}, -//{"op" , "output planar" , OFFSET(out.planar ), FF_OPT_TYPE_INT, {.dbl=0}, 0, 1, 0}, -{"isf", "input sample format", OFFSET( in_sample_fmt ), FF_OPT_TYPE_INT, {.dbl=AV_SAMPLE_FMT_S16}, 0, AV_SAMPLE_FMT_NB-1+256, 0}, -{"osf", "output sample format", OFFSET(out_sample_fmt ), FF_OPT_TYPE_INT, {.dbl=AV_SAMPLE_FMT_S16}, 0, AV_SAMPLE_FMT_NB-1+256, 0}, -{"tsf", "internal sample format", OFFSET(int_sample_fmt ), FF_OPT_TYPE_INT, {.dbl=AV_SAMPLE_FMT_NONE}, -1, AV_SAMPLE_FMT_FLT, 0}, -{"icl", "input channel layout" , OFFSET( in_ch_layout), FF_OPT_TYPE_INT64, {.dbl=0}, 0, INT64_MAX, 0, "channel_layout"}, -{"ocl", "output channel layout", OFFSET(out_ch_layout), FF_OPT_TYPE_INT64, {.dbl=0}, 0, INT64_MAX, 0, "channel_layout"}, -{"clev", "center mix level" , OFFSET(clev) , FF_OPT_TYPE_FLOAT, {.dbl=C_30DB}, 0, 4, 0}, -{"slev", "sourround mix level" , OFFSET(slev) , FF_OPT_TYPE_FLOAT, {.dbl=C_30DB}, 0, 4, 0}, -{"flags", NULL , OFFSET(flags) , FF_OPT_TYPE_FLAGS, {.dbl=0}, 0, UINT_MAX, 0, "flags"}, -{"res", "force resampling", 0, FF_OPT_TYPE_CONST, {.dbl=SWR_FLAG_RESAMPLE}, INT_MIN, INT_MAX, 0, "flags"}, +{"ich", "input channel count", OFFSET( in.ch_count ), AV_OPT_TYPE_INT, {.dbl=2}, 1, SWR_CH_MAX, 0}, +{"och", "output channel count", OFFSET(out.ch_count ), AV_OPT_TYPE_INT, {.dbl=2}, 1, SWR_CH_MAX, 0}, +{"isr", "input sample rate" , OFFSET( in_sample_rate), AV_OPT_TYPE_INT, {.dbl=48000}, 1, INT_MAX, 0}, +{"osr", "output sample rate" , OFFSET(out_sample_rate), AV_OPT_TYPE_INT, {.dbl=48000}, 1, INT_MAX, 0}, +//{"ip" , "input planar" , OFFSET( in.planar ), AV_OPT_TYPE_INT, {.dbl=0}, 0, 1, 0}, +//{"op" , "output planar" , OFFSET(out.planar ), AV_OPT_TYPE_INT, {.dbl=0}, 0, 1, 0}, +{"isf", "input sample format", OFFSET( in_sample_fmt ), AV_OPT_TYPE_INT, {.dbl=AV_SAMPLE_FMT_S16}, 0, AV_SAMPLE_FMT_NB-1+256, 0}, +{"osf", "output sample format", OFFSET(out_sample_fmt ), AV_OPT_TYPE_INT, {.dbl=AV_SAMPLE_FMT_S16}, 0, AV_SAMPLE_FMT_NB-1+256, 0}, +{"tsf", "internal sample format", OFFSET(int_sample_fmt ), AV_OPT_TYPE_INT, {.dbl=AV_SAMPLE_FMT_NONE}, -1, AV_SAMPLE_FMT_FLT, 0}, +{"icl", "input channel layout" , OFFSET( in_ch_layout), AV_OPT_TYPE_INT64, {.dbl=0}, 0, INT64_MAX, 0, "channel_layout"}, +{"ocl", "output channel layout", OFFSET(out_ch_layout), AV_OPT_TYPE_INT64, {.dbl=0}, 0, INT64_MAX, 0, "channel_layout"}, +{"clev", "center mix level" , OFFSET(clev) , AV_OPT_TYPE_FLOAT, {.dbl=C_30DB}, 0, 4, 0}, +{"slev", "sourround mix level" , OFFSET(slev) , AV_OPT_TYPE_FLOAT, {.dbl=C_30DB}, 0, 4, 0}, +{"rmvol", "rematrix volume" , OFFSET(rematrix_volume), AV_OPT_TYPE_FLOAT, {.dbl=1.0}, -1000, 1000, 0}, +{"flags", NULL , OFFSET(flags) , AV_OPT_TYPE_FLAGS, {.dbl=0}, 0, UINT_MAX, 0, "flags"}, +{"res", "force resampling", 0, AV_OPT_TYPE_CONST, {.dbl=SWR_FLAG_RESAMPLE}, INT_MIN, INT_MAX, 0, "flags"}, {0} }; @@ -166,7 +167,7 @@ return -1; } - if(s-> in.ch_count && s->in.ch_count != av_get_channel_layout_nb_channels(s-> in_ch_layout)){ + if(s-> in.ch_count && s-> in_ch_layout && s->in.ch_count != av_get_channel_layout_nb_channels(s-> in_ch_layout)){ av_log(s, AV_LOG_WARNING, "Input channel layout has a different number of channels than there actually is, ignoring layout\n"); s-> in_ch_layout= 0; } @@ -176,7 +177,7 @@ if(!s->out_ch_layout) s->out_ch_layout= av_get_default_channel_layout(s->out.ch_count); - s->rematrix= s->out_ch_layout !=s->in_ch_layout; + s->rematrix= s->out_ch_layout !=s->in_ch_layout || s->rematrix_volume!=1.0; #define RSC 1 //FIXME finetune if(!s-> in.ch_count) @@ -279,7 +280,7 @@ int swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_count, const uint8_t *in_arg [SWR_CH_MAX], int in_count){ AudioData *postin, *midbuf, *preout; - int ret, i/*, in_max*/; + int ret/*, in_max*/; AudioData * in= &s->in; AudioData *out= &s->out; AudioData preout_tmp, midbuf_tmp; @@ -290,7 +291,7 @@ out_count = in_count; } - fill_audiodata(in , in_arg); + fill_audiodata(in , (void*)in_arg); fill_audiodata(out, out_arg); if(s->full_convert){ diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libswresample/swresample_internal.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libswresample/swresample_internal.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libswresample/swresample_internal.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libswresample/swresample_internal.h 2011-11-04 12:38:27.000000000 +0000 @@ -33,7 +33,7 @@ } AudioData; typedef struct SwrContext { //FIXME find unused fields - AVClass *av_class; + const AVClass *av_class; int log_level_offset; void *log_ctx; enum AVSampleFormat in_sample_fmt; @@ -44,7 +44,7 @@ int in_sample_rate; int out_sample_rate; int flags; - float slev, clev; + float slev, clev, rematrix_volume; //below are private int int_bps; @@ -62,7 +62,7 @@ struct AVResampleContext *resample; float matrix[SWR_CH_MAX][SWR_CH_MAX]; - int16_t matrix16[SWR_CH_MAX][SWR_CH_MAX]; + int32_t matrix32[SWR_CH_MAX][SWR_CH_MAX]; uint8_t matrix_ch[SWR_CH_MAX][SWR_CH_MAX+1]; //TODO callbacks for asm optims @@ -72,7 +72,7 @@ void swr_resample_free(struct AVResampleContext **c); int swr_multiple_resample(struct AVResampleContext *c, AudioData *dst, int dst_size, AudioData *src, int src_size, int *consumed); void swr_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance); -int swr_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx); +int swr_resample(struct AVResampleContext *c, short *dst, const short *src, int *consumed, int src_size, int dst_size, int update_ctx); int swr_rematrix_init(SwrContext *s); int swr_rematrix(SwrContext *s, AudioData *out, AudioData *in, int len, int mustcopy); diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libswscale/options.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libswscale/options.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libswscale/options.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libswscale/options.c 2011-11-04 12:38:27.000000000 +0000 @@ -34,34 +34,34 @@ #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { - { "sws_flags", "scaler/cpu flags", OFFSET(flags), FF_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, 0, UINT_MAX, VE, "sws_flags" }, - { "fast_bilinear", "fast bilinear", 0, FF_OPT_TYPE_CONST, {.dbl = SWS_FAST_BILINEAR }, INT_MIN, INT_MAX, VE, "sws_flags" }, - { "bilinear", "bilinear", 0, FF_OPT_TYPE_CONST, {.dbl = SWS_BILINEAR }, INT_MIN, INT_MAX, VE, "sws_flags" }, - { "bicubic", "bicubic", 0, FF_OPT_TYPE_CONST, {.dbl = SWS_BICUBIC }, INT_MIN, INT_MAX, VE, "sws_flags" }, - { "experimental", "experimental", 0, FF_OPT_TYPE_CONST, {.dbl = SWS_X }, INT_MIN, INT_MAX, VE, "sws_flags" }, - { "neighbor", "nearest neighbor", 0, FF_OPT_TYPE_CONST, {.dbl = SWS_POINT }, INT_MIN, INT_MAX, VE, "sws_flags" }, - { "area", "averaging area", 0, FF_OPT_TYPE_CONST, {.dbl = SWS_AREA }, INT_MIN, INT_MAX, VE, "sws_flags" }, - { "bicublin", "luma bicubic, chroma bilinear", 0, FF_OPT_TYPE_CONST, {.dbl = SWS_BICUBLIN }, INT_MIN, INT_MAX, VE, "sws_flags" }, - { "gauss", "gaussian", 0, FF_OPT_TYPE_CONST, {.dbl = SWS_GAUSS }, INT_MIN, INT_MAX, VE, "sws_flags" }, - { "sinc", "sinc", 0, FF_OPT_TYPE_CONST, {.dbl = SWS_SINC }, INT_MIN, INT_MAX, VE, "sws_flags" }, - { "lanczos", "lanczos", 0, FF_OPT_TYPE_CONST, {.dbl = SWS_LANCZOS }, INT_MIN, INT_MAX, VE, "sws_flags" }, - { "spline", "natural bicubic spline", 0, FF_OPT_TYPE_CONST, {.dbl = SWS_SPLINE }, INT_MIN, INT_MAX, VE, "sws_flags" }, - { "print_info", "print info", 0, FF_OPT_TYPE_CONST, {.dbl = SWS_PRINT_INFO }, INT_MIN, INT_MAX, VE, "sws_flags" }, - { "accurate_rnd", "accurate rounding", 0, FF_OPT_TYPE_CONST, {.dbl = SWS_ACCURATE_RND }, INT_MIN, INT_MAX, VE, "sws_flags" }, - { "full_chroma_int", "full chroma interpolation", 0 , FF_OPT_TYPE_CONST, {.dbl = SWS_FULL_CHR_H_INT }, INT_MIN, INT_MAX, VE, "sws_flags" }, - { "full_chroma_inp", "full chroma input", 0 , FF_OPT_TYPE_CONST, {.dbl = SWS_FULL_CHR_H_INP }, INT_MIN, INT_MAX, VE, "sws_flags" }, - { "bitexact", "", 0 , FF_OPT_TYPE_CONST, {.dbl = SWS_BITEXACT }, INT_MIN, INT_MAX, VE, "sws_flags" }, + { "sws_flags", "scaler/cpu flags", OFFSET(flags), AV_OPT_TYPE_FLAGS, {.dbl = DEFAULT }, 0, UINT_MAX, VE, "sws_flags" }, + { "fast_bilinear", "fast bilinear", 0, AV_OPT_TYPE_CONST, {.dbl = SWS_FAST_BILINEAR }, INT_MIN, INT_MAX, VE, "sws_flags" }, + { "bilinear", "bilinear", 0, AV_OPT_TYPE_CONST, {.dbl = SWS_BILINEAR }, INT_MIN, INT_MAX, VE, "sws_flags" }, + { "bicubic", "bicubic", 0, AV_OPT_TYPE_CONST, {.dbl = SWS_BICUBIC }, INT_MIN, INT_MAX, VE, "sws_flags" }, + { "experimental", "experimental", 0, AV_OPT_TYPE_CONST, {.dbl = SWS_X }, INT_MIN, INT_MAX, VE, "sws_flags" }, + { "neighbor", "nearest neighbor", 0, AV_OPT_TYPE_CONST, {.dbl = SWS_POINT }, INT_MIN, INT_MAX, VE, "sws_flags" }, + { "area", "averaging area", 0, AV_OPT_TYPE_CONST, {.dbl = SWS_AREA }, INT_MIN, INT_MAX, VE, "sws_flags" }, + { "bicublin", "luma bicubic, chroma bilinear", 0, AV_OPT_TYPE_CONST, {.dbl = SWS_BICUBLIN }, INT_MIN, INT_MAX, VE, "sws_flags" }, + { "gauss", "gaussian", 0, AV_OPT_TYPE_CONST, {.dbl = SWS_GAUSS }, INT_MIN, INT_MAX, VE, "sws_flags" }, + { "sinc", "sinc", 0, AV_OPT_TYPE_CONST, {.dbl = SWS_SINC }, INT_MIN, INT_MAX, VE, "sws_flags" }, + { "lanczos", "lanczos", 0, AV_OPT_TYPE_CONST, {.dbl = SWS_LANCZOS }, INT_MIN, INT_MAX, VE, "sws_flags" }, + { "spline", "natural bicubic spline", 0, AV_OPT_TYPE_CONST, {.dbl = SWS_SPLINE }, INT_MIN, INT_MAX, VE, "sws_flags" }, + { "print_info", "print info", 0, AV_OPT_TYPE_CONST, {.dbl = SWS_PRINT_INFO }, INT_MIN, INT_MAX, VE, "sws_flags" }, + { "accurate_rnd", "accurate rounding", 0, AV_OPT_TYPE_CONST, {.dbl = SWS_ACCURATE_RND }, INT_MIN, INT_MAX, VE, "sws_flags" }, + { "full_chroma_int", "full chroma interpolation", 0 , AV_OPT_TYPE_CONST, {.dbl = SWS_FULL_CHR_H_INT }, INT_MIN, INT_MAX, VE, "sws_flags" }, + { "full_chroma_inp", "full chroma input", 0 , AV_OPT_TYPE_CONST, {.dbl = SWS_FULL_CHR_H_INP }, INT_MIN, INT_MAX, VE, "sws_flags" }, + { "bitexact", "", 0 , AV_OPT_TYPE_CONST, {.dbl = SWS_BITEXACT }, INT_MIN, INT_MAX, VE, "sws_flags" }, - { "srcw", "source width" , OFFSET(srcW), FF_OPT_TYPE_INT, {.dbl = 16 }, 1, INT_MAX, VE }, - { "srch", "source height" , OFFSET(srcH), FF_OPT_TYPE_INT, {.dbl = 16 }, 1, INT_MAX, VE }, - { "dstw", "destination width" , OFFSET(dstW), FF_OPT_TYPE_INT, {.dbl = 16 }, 1, INT_MAX, VE }, - { "dsth", "destination height", OFFSET(dstH), FF_OPT_TYPE_INT, {.dbl = 16 }, 1, INT_MAX, VE }, - { "src_format", "source format" , OFFSET(srcFormat), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, PIX_FMT_NB-1, VE }, - { "dst_format", "destination format", OFFSET(dstFormat), FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, PIX_FMT_NB-1, VE }, - { "src_range" , "source range" , OFFSET(srcRange) , FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, 1, VE }, - { "dst_range" , "destination range" , OFFSET(dstRange) , FF_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, 1, VE }, - { "param0" , "scaler param 0" , OFFSET(param[0]) , FF_OPT_TYPE_DOUBLE, {.dbl = SWS_PARAM_DEFAULT}, INT_MIN, INT_MAX, VE }, - { "param1" , "scaler param 1" , OFFSET(param[1]) , FF_OPT_TYPE_DOUBLE, {.dbl = SWS_PARAM_DEFAULT}, INT_MIN, INT_MAX, VE }, + { "srcw", "source width" , OFFSET(srcW), AV_OPT_TYPE_INT, {.dbl = 16 }, 1, INT_MAX, VE }, + { "srch", "source height" , OFFSET(srcH), AV_OPT_TYPE_INT, {.dbl = 16 }, 1, INT_MAX, VE }, + { "dstw", "destination width" , OFFSET(dstW), AV_OPT_TYPE_INT, {.dbl = 16 }, 1, INT_MAX, VE }, + { "dsth", "destination height", OFFSET(dstH), AV_OPT_TYPE_INT, {.dbl = 16 }, 1, INT_MAX, VE }, + { "src_format", "source format" , OFFSET(srcFormat), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, PIX_FMT_NB-1, VE }, + { "dst_format", "destination format", OFFSET(dstFormat), AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, PIX_FMT_NB-1, VE }, + { "src_range" , "source range" , OFFSET(srcRange) , AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, 1, VE }, + { "dst_range" , "destination range" , OFFSET(dstRange) , AV_OPT_TYPE_INT, {.dbl = DEFAULT }, 0, 1, VE }, + { "param0" , "scaler param 0" , OFFSET(param[0]) , AV_OPT_TYPE_DOUBLE, {.dbl = SWS_PARAM_DEFAULT}, INT_MIN, INT_MAX, VE }, + { "param1" , "scaler param 1" , OFFSET(param[1]) , AV_OPT_TYPE_DOUBLE, {.dbl = SWS_PARAM_DEFAULT}, INT_MIN, INT_MAX, VE }, { NULL } }; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libswscale/ppc/swscale_altivec.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libswscale/ppc/swscale_altivec.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libswscale/ppc/swscale_altivec.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libswscale/ppc/swscale_altivec.c 2011-11-04 12:38:27.000000000 +0000 @@ -94,34 +94,29 @@ //FIXME remove the usage of scratch buffers. static void -yuv2yuvX_altivec_real(SwsContext *c, - const int16_t *lumFilter, const int16_t **lumSrc, - int lumFilterSize, const int16_t *chrFilter, - const int16_t **chrUSrc, const int16_t **chrVSrc, - int chrFilterSize, const int16_t **alpSrc, - uint8_t *dest[4], int dstW, int chrDstW) +yuv2planeX_altivec(const int16_t *filter, int filterSize, + const int16_t **src, uint8_t *dest, int dstW, + const uint8_t *dither, int offset) { - uint8_t *yDest = dest[0], *uDest = dest[1], *vDest = dest[2]; - const uint8_t *lumDither = c->lumDither8, *chrDither = c->chrDither8; register int i, j; { DECLARE_ALIGNED(16, int, val)[dstW]; for (i=0; ialpPixBuf) { - c->yuv2yuvX = yuv2yuvX_altivec_real; + c->yuv2planeX = yuv2planeX_altivec; } /* The following list of supported dstFormat values should diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libswscale/swscale.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libswscale/swscale.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libswscale/swscale.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libswscale/swscale.c 2011-11-04 12:38:27.000000000 +0000 @@ -290,80 +290,54 @@ { 3, 5, 7, 9, 11, 12, 14, 15, 15, 15, 15, 15, 15, 15, 16,65535,}, }; -static av_always_inline void -yuv2yuvX16_c_template(const int16_t *lumFilter, const int32_t **lumSrc, - int lumFilterSize, const int16_t *chrFilter, - const int32_t **chrUSrc, const int32_t **chrVSrc, - int chrFilterSize, const int32_t **alpSrc, - uint16_t *dest[4], int dstW, int chrDstW, - int big_endian, int output_bits) -{ - //FIXME Optimize (just quickly written not optimized..) - int i; - int dword= output_bits == 16; - uint16_t *yDest = dest[0], *uDest = dest[1], *vDest = dest[2], - *aDest = CONFIG_SWSCALE_ALPHA ? dest[3] : NULL; - int shift = 11 + 4*dword + 16 - output_bits - 1; - -#define output_pixel(pos, val) \ +#define output_pixel(pos, val, bias, signedness) \ if (big_endian) { \ - AV_WB16(pos, av_clip_uint16(val >> shift)); \ + AV_WB16(pos, bias + av_clip_ ## signedness ## 16(val >> shift)); \ } else { \ - AV_WL16(pos, av_clip_uint16(val >> shift)); \ + AV_WL16(pos, bias + av_clip_ ## signedness ## 16(val >> shift)); \ } - for (i = 0; i < dstW; i++) { - int val = 1 << (26-output_bits + 4*dword - 1); - int j; - for (j = 0; j < lumFilterSize; j++) - val += ((dword ? lumSrc[j][i] : ((int16_t**)lumSrc)[j][i]) * lumFilter[j])>>1; +static av_always_inline void +yuv2plane1_16_c_template(const int32_t *src, uint16_t *dest, int dstW, + int big_endian, int output_bits) +{ + int i; + int shift = 3; + av_assert0(output_bits == 16); - output_pixel(&yDest[i], val); + for (i = 0; i < dstW; i++) { + int val = src[i] + (1 << (shift - 1)); + output_pixel(&dest[i], val, 0, uint); } +} - if (uDest) { - for (i = 0; i < chrDstW; i++) { - int u = 1 << (26-output_bits + 4*dword - 1); - int v = 1 << (26-output_bits + 4*dword - 1); - int j; - - for (j = 0; j < chrFilterSize; j++) { - u += ((dword ? chrUSrc[j][i] : ((int16_t**)chrUSrc)[j][i]) * chrFilter[j]) >> 1; - v += ((dword ? chrVSrc[j][i] : ((int16_t**)chrVSrc)[j][i]) * chrFilter[j]) >> 1; - } - - output_pixel(&uDest[i], u); - output_pixel(&vDest[i], v); - } - } +static av_always_inline void +yuv2planeX_16_c_template(const int16_t *filter, int filterSize, + const int32_t **src, uint16_t *dest, int dstW, + int big_endian, int output_bits) +{ + int i; + int shift = 15; + av_assert0(output_bits == 16); - if (CONFIG_SWSCALE_ALPHA && aDest) { - for (i = 0; i < dstW; i++) { - int val = 1 << (26-output_bits + 4*dword - 1); - int j; + for (i = 0; i < dstW; i++) { + int val = 1 << (shift - 1); + int j; - for (j = 0; j < lumFilterSize; j++) - val += ((dword ? alpSrc[j][i] : ((int16_t**)alpSrc)[j][i]) * lumFilter[j]) >> 1; + /* range of val is [0,0x7FFFFFFF], so 31 bits, but with lanczos/spline + * filters (or anything with negative coeffs, the range can be slightly + * wider in both directions. To account for this overflow, we subtract + * a constant so it always fits in the signed range (assuming a + * reasonable filterSize), and re-add that at the end. */ + val -= 0x40000000; + for (j = 0; j < filterSize; j++) + val += src[j][i] * filter[j]; - output_pixel(&aDest[i], val); - } + output_pixel(&dest[i], val, 0x8000, int); } -#undef output_pixel } -static av_always_inline void -yuv2yuvX10_c_template(const int16_t *lumFilter, const int16_t **lumSrc, - int lumFilterSize, const int16_t *chrFilter, - const int16_t **chrUSrc, const int16_t **chrVSrc, - int chrFilterSize, const int16_t **alpSrc, - uint16_t *dest[4], int dstW, int chrDstW, - int big_endian, int output_bits) -{ - //FIXME Optimize (just quickly written not optimized..) - int i; - uint16_t *yDest = dest[0], *uDest = dest[1], *vDest = dest[2], - *aDest = CONFIG_SWSCALE_ALPHA ? dest[3] : NULL; - int shift = 11 + 16 - output_bits; +#undef output_pixel #define output_pixel(pos, val) \ if (big_endian) { \ @@ -371,171 +345,96 @@ } else { \ AV_WL16(pos, av_clip_uintp2(val >> shift, output_bits)); \ } - for (i = 0; i < dstW; i++) { - int val = 1 << (26-output_bits); - int j; - for (j = 0; j < lumFilterSize; j++) - val += lumSrc[j][i] * lumFilter[j]; +static av_always_inline void +yuv2plane1_10_c_template(const int16_t *src, uint16_t *dest, int dstW, + int big_endian, int output_bits) +{ + int i; + int shift = 15 - output_bits; - output_pixel(&yDest[i], val); + for (i = 0; i < dstW; i++) { + int val = src[i] + (1 << (shift - 1)); + output_pixel(&dest[i], val); } +} - if (uDest) { - for (i = 0; i < chrDstW; i++) { - int u = 1 << (26-output_bits); - int v = 1 << (26-output_bits); - int j; - - for (j = 0; j < chrFilterSize; j++) { - u += chrUSrc[j][i] * chrFilter[j]; - v += chrVSrc[j][i] * chrFilter[j]; - } - - output_pixel(&uDest[i], u); - output_pixel(&vDest[i], v); - } - } +static av_always_inline void +yuv2planeX_10_c_template(const int16_t *filter, int filterSize, + const int16_t **src, uint16_t *dest, int dstW, + int big_endian, int output_bits) +{ + int i; + int shift = 11 + 16 - output_bits; - if (CONFIG_SWSCALE_ALPHA && aDest) { - for (i = 0; i < dstW; i++) { - int val = 1 << (26-output_bits); - int j; + for (i = 0; i < dstW; i++) { + int val = 1 << (shift - 1); + int j; - for (j = 0; j < lumFilterSize; j++) - val += alpSrc[j][i] * lumFilter[j]; + for (j = 0; j < filterSize; j++) + val += src[j][i] * filter[j]; - output_pixel(&aDest[i], val); - } + output_pixel(&dest[i], val); } -#undef output_pixel } -#define yuv2NBPS(bits, BE_LE, is_be, yuv2yuvX_template_fn, typeX_t) \ -static void yuv2yuvX ## bits ## BE_LE ## _c(SwsContext *c, const int16_t *lumFilter, \ - const int16_t **_lumSrc, int lumFilterSize, \ - const int16_t *chrFilter, const int16_t **_chrUSrc, \ - const int16_t **_chrVSrc, \ - int chrFilterSize, const int16_t **_alpSrc, \ - uint8_t *_dest[4], int dstW, int chrDstW) \ +#undef output_pixel + +#define yuv2NBPS(bits, BE_LE, is_be, template_size, typeX_t) \ +static void yuv2plane1_ ## bits ## BE_LE ## _c(const int16_t *src, \ + uint8_t *dest, int dstW, \ + const uint8_t *dither, int offset)\ { \ - const typeX_t **lumSrc = (const typeX_t **) _lumSrc, \ - **chrUSrc = (const typeX_t **) _chrUSrc, \ - **chrVSrc = (const typeX_t **) _chrVSrc, \ - **alpSrc = (const typeX_t **) _alpSrc; \ - yuv2yuvX_template_fn(lumFilter, lumSrc, lumFilterSize, \ - chrFilter, chrUSrc, chrVSrc, chrFilterSize, \ - alpSrc, (uint16_t **) _dest, \ - dstW, chrDstW, is_be, bits); \ -} -yuv2NBPS( 9, BE, 1, yuv2yuvX10_c_template, int16_t); -yuv2NBPS( 9, LE, 0, yuv2yuvX10_c_template, int16_t); -yuv2NBPS(10, BE, 1, yuv2yuvX10_c_template, int16_t); -yuv2NBPS(10, LE, 0, yuv2yuvX10_c_template, int16_t); -yuv2NBPS(16, BE, 1, yuv2yuvX16_c_template, int32_t); -yuv2NBPS(16, LE, 0, yuv2yuvX16_c_template, int32_t); - -static void yuv2yuvX_c(SwsContext *c, const int16_t *lumFilter, - const int16_t **lumSrc, int lumFilterSize, - const int16_t *chrFilter, const int16_t **chrUSrc, - const int16_t **chrVSrc, - int chrFilterSize, const int16_t **alpSrc, - uint8_t *dest[4], int dstW, int chrDstW) + yuv2plane1_ ## template_size ## _c_template((const typeX_t *) src, \ + (uint16_t *) dest, dstW, is_be, bits); \ +}\ +static void yuv2planeX_ ## bits ## BE_LE ## _c(const int16_t *filter, int filterSize, \ + const int16_t **src, uint8_t *dest, int dstW, \ + const uint8_t *dither, int offset)\ +{ \ + yuv2planeX_## template_size ## _c_template(filter, \ + filterSize, (const typeX_t **) src, \ + (uint16_t *) dest, dstW, is_be, bits); \ +} +yuv2NBPS( 9, BE, 1, 10, int16_t); +yuv2NBPS( 9, LE, 0, 10, int16_t); +yuv2NBPS(10, BE, 1, 10, int16_t); +yuv2NBPS(10, LE, 0, 10, int16_t); +yuv2NBPS(16, BE, 1, 16, int32_t); +yuv2NBPS(16, LE, 0, 16, int32_t); + +static void yuv2planeX_8_c(const int16_t *filter, int filterSize, + const int16_t **src, uint8_t *dest, int dstW, + const uint8_t *dither, int offset) { - uint8_t *yDest = dest[0], *uDest = dest[1], *vDest = dest[2], - *aDest = CONFIG_SWSCALE_ALPHA ? dest[3] : NULL; int i; - const uint8_t *lumDither = c->lumDither8, *chrDither = c->chrDither8; - - //FIXME Optimize (just quickly written not optimized..) for (i=0; i>19); + dest[i]= av_clip_uint8(val>>19); } - - if (uDest) - for (i=0; i>19); - vDest[i]= av_clip_uint8(v>>19); - } - - if (CONFIG_SWSCALE_ALPHA && aDest) - for (i=0; i>19); - } } -static void yuv2yuv1_c(SwsContext *c, const int16_t *lumSrc, - const int16_t *chrUSrc, const int16_t *chrVSrc, - const int16_t *alpSrc, - uint8_t *dest[4], int dstW, int chrDstW) +static void yuv2plane1_8_c(const int16_t *src, uint8_t *dest, int dstW, + const uint8_t *dither, int offset) { - uint8_t *yDest = dest[0], *uDest = dest[1], *vDest = dest[2], - *aDest = CONFIG_SWSCALE_ALPHA ? dest[3] : NULL; int i; - const uint8_t *lumDither = c->lumDither8, *chrDither = c->chrDither8; - for (i=0; i> 7; - yDest[i]= av_clip_uint8(val); + int val = (src[i] + dither[(i + offset) & 7]) >> 7; + dest[i]= av_clip_uint8(val); } - - if (uDest) - for (i=0; i> 7; - int v = (chrVSrc[i] + chrDither[(i + 3) & 7]) >> 7; - uDest[i]= av_clip_uint8(u); - vDest[i]= av_clip_uint8(v); - } - - if (CONFIG_SWSCALE_ALPHA && aDest) - for (i=0; i> 7; - aDest[i]= av_clip_uint8(val); - } } -static void yuv2nv12X_c(SwsContext *c, const int16_t *lumFilter, - const int16_t **lumSrc, int lumFilterSize, - const int16_t *chrFilter, const int16_t **chrUSrc, - const int16_t **chrVSrc, int chrFilterSize, - const int16_t **alpSrc, uint8_t *dest[4], - int dstW, int chrDstW) +static void yuv2nv12cX_c(SwsContext *c, const int16_t *chrFilter, int chrFilterSize, + const int16_t **chrUSrc, const int16_t **chrVSrc, + uint8_t *dest, int chrDstW) { - uint8_t *yDest = dest[0], *uDest = dest[1]; enum PixelFormat dstFormat = c->dstFormat; - const uint8_t *lumDither = c->lumDither8, *chrDither = c->chrDither8; - - //FIXME Optimize (just quickly written not optimized..) + const uint8_t *chrDither = c->chrDither8; int i; - for (i=0; i>19); - } - - if (!uDest) - return; if (dstFormat == PIX_FMT_NV12) for (i=0; i>19); - uDest[2*i+1]= av_clip_uint8(v>>19); + dest[2*i]= av_clip_uint8(u>>19); + dest[2*i+1]= av_clip_uint8(v>>19); } else for (i=0; i>19); - uDest[2*i+1]= av_clip_uint8(u>>19); + dest[2*i]= av_clip_uint8(v>>19); + dest[2*i+1]= av_clip_uint8(u>>19); } } @@ -1610,7 +1509,7 @@ #undef input_pixel #define rgb48funcs(pattern, BE_LE, origin) \ -static void pattern ## 48 ## BE_LE ## ToY_c(uint8_t *_dst, const uint8_t *_src, \ +static void pattern ## 48 ## BE_LE ## ToY_c(uint8_t *_dst, const uint8_t *_src, const uint8_t *unused0, const uint8_t *unused1,\ int width, uint32_t *unused) \ { \ const uint16_t *src = (const uint16_t *) _src; \ @@ -1619,7 +1518,7 @@ } \ \ static void pattern ## 48 ## BE_LE ## ToUV_c(uint8_t *_dstU, uint8_t *_dstV, \ - const uint8_t *_src1, const uint8_t *_src2, \ + const uint8_t *unused0, const uint8_t *_src1, const uint8_t *_src2, \ int width, uint32_t *unused) \ { \ const uint16_t *src1 = (const uint16_t *) _src1, \ @@ -1629,7 +1528,7 @@ } \ \ static void pattern ## 48 ## BE_LE ## ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, \ - const uint8_t *_src1, const uint8_t *_src2, \ + const uint8_t *unused0, const uint8_t *_src1, const uint8_t *_src2, \ int width, uint32_t *unused) \ { \ const uint16_t *src1 = (const uint16_t *) _src1, \ @@ -1730,7 +1629,7 @@ #define rgb16_32_wrapper(fmt, name, shr, shg, shb, shp, maskr, \ maskg, maskb, rsh, gsh, bsh, S) \ -static void name ## ToY_c(uint8_t *dst, const uint8_t *src, \ +static void name ## ToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, \ int width, uint32_t *unused) \ { \ rgb16_32ToY_c_template((int16_t*)dst, src, width, fmt, \ @@ -1739,7 +1638,7 @@ } \ \ static void name ## ToUV_c(uint8_t *dstU, uint8_t *dstV, \ - const uint8_t *src, const uint8_t *dummy, \ + const uint8_t *unused0, const uint8_t *src, const uint8_t *dummy, \ int width, uint32_t *unused) \ { \ rgb16_32ToUV_c_template((int16_t*)dstU, (int16_t*)dstV, src, width, fmt, \ @@ -1748,7 +1647,7 @@ } \ \ static void name ## ToUV_half_c(uint8_t *dstU, uint8_t *dstV, \ - const uint8_t *src, const uint8_t *dummy, \ + const uint8_t *unused0, const uint8_t *src, const uint8_t *dummy, \ int width, uint32_t *unused) \ { \ rgb16_32ToUV_half_c_template((int16_t*)dstU, (int16_t*)dstV, src, width, fmt, \ @@ -1769,7 +1668,50 @@ rgb16_32_wrapper(PIX_FMT_RGB565BE, rgb16be, 0, 0, 0, 0, 0xF800, 0x07E0, 0x001F, 0, 5, 11, RGB2YUV_SHIFT+8); rgb16_32_wrapper(PIX_FMT_RGB555BE, rgb15be, 0, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, 0, 5, 10, RGB2YUV_SHIFT+7); -static void abgrToA_c(int16_t *dst, const uint8_t *src, int width, uint32_t *unused) +static void gbr24pToY_c(uint16_t *dst, const uint8_t *gsrc, const uint8_t *bsrc, const uint8_t *rsrc, + int width, uint32_t *unused) +{ + int i; + for (i = 0; i < width; i++) { + unsigned int g = gsrc[i]; + unsigned int b = bsrc[i]; + unsigned int r = rsrc[i]; + + dst[i] = (RY*r + GY*g + BY*b + (0x801<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6); + } +} + +static void gbr24pToUV_c(uint16_t *dstU, uint16_t *dstV, + const uint8_t *gsrc, const uint8_t *bsrc, const uint8_t *rsrc, + int width, enum PixelFormat origin) +{ + int i; + for (i = 0; i < width; i++) { + unsigned int g = gsrc[i]; + unsigned int b = bsrc[i]; + unsigned int r = rsrc[i]; + + dstU[i] = (RU*r + GU*g + BU*b + (0x4001<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6); + dstV[i] = (RV*r + GV*g + BV*b + (0x4001<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6); + } +} + +static void gbr24pToUV_half_c(uint16_t *dstU, uint16_t *dstV, + const uint8_t *gsrc, const uint8_t *bsrc, const uint8_t *rsrc, + int width, enum PixelFormat origin) +{ + int i; + for (i = 0; i < width; i++) { + unsigned int g = gsrc[2*i] + gsrc[2*i+1]; + unsigned int b = bsrc[2*i] + bsrc[2*i+1]; + unsigned int r = rsrc[2*i] + rsrc[2*i+1]; + + dstU[i] = (RU*r + GU*g + BU*b + (0x4001<<(RGB2YUV_SHIFT-6))) >> (RGB2YUV_SHIFT-6+1); + dstV[i] = (RV*r + GV*g + BV*b + (0x4001<<(RGB2YUV_SHIFT-6))) >> (RGB2YUV_SHIFT-6+1); + } +} + +static void abgrToA_c(int16_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused) { int i; for (i=0; ialpToYV12 : c->lumToYV12; + void (*toYV12)(uint8_t *, const uint8_t *, const uint8_t *, const uint8_t *, int, uint32_t *) = isAlpha ? c->alpToYV12 : c->lumToYV12; void (*convertRange)(int16_t *, int) = isAlpha ? NULL : c->lumConvertRange; if (toYV12) { - toYV12(formatConvBuffer, src, srcW, pal); + toYV12(formatConvBuffer, src, src2, src3, srcW, pal); src= formatConvBuffer; } @@ -2241,14 +2184,14 @@ } static av_always_inline void hcscale(SwsContext *c, int16_t *dst1, int16_t *dst2, int dstWidth, - const uint8_t *src1, const uint8_t *src2, + const uint8_t *src0, const uint8_t *src1, const uint8_t *src2, int srcW, int xInc, const int16_t *hChrFilter, const int16_t *hChrFilterPos, int hChrFilterSize, uint8_t *formatConvBuffer, uint32_t *pal) { if (c->chrToYV12) { uint8_t *buf2 = formatConvBuffer + FFALIGN(srcW*2+78, 16); - c->chrToYV12(formatConvBuffer, buf2, src1, src2, srcW, pal); + c->chrToYV12(formatConvBuffer, buf2, src0, src1, src2, srcW, pal); src1= formatConvBuffer; src2= buf2; } @@ -2266,26 +2209,31 @@ static av_always_inline void find_c_packed_planar_out_funcs(SwsContext *c, - yuv2planar1_fn *yuv2yuv1, yuv2planarX_fn *yuv2yuvX, + yuv2planar1_fn *yuv2plane1, yuv2planarX_fn *yuv2planeX, + yuv2interleavedX_fn *yuv2nv12cX, yuv2packed1_fn *yuv2packed1, yuv2packed2_fn *yuv2packed2, yuv2packedX_fn *yuv2packedX) { enum PixelFormat dstFormat = c->dstFormat; - if (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21) { - *yuv2yuvX = yuv2nv12X_c; - } else if (is16BPS(dstFormat)) { - *yuv2yuvX = isBE(dstFormat) ? yuv2yuvX16BE_c : yuv2yuvX16LE_c; + if (is16BPS(dstFormat)) { + *yuv2planeX = isBE(dstFormat) ? yuv2planeX_16BE_c : yuv2planeX_16LE_c; + *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_16BE_c : yuv2plane1_16LE_c; } else if (is9_OR_10BPS(dstFormat)) { if (av_pix_fmt_descriptors[dstFormat].comp[0].depth_minus1 == 8) { - *yuv2yuvX = isBE(dstFormat) ? yuv2yuvX9BE_c : yuv2yuvX9LE_c; + *yuv2planeX = isBE(dstFormat) ? yuv2planeX_9BE_c : yuv2planeX_9LE_c; + *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_9BE_c : yuv2plane1_9LE_c; } else { - *yuv2yuvX = isBE(dstFormat) ? yuv2yuvX10BE_c : yuv2yuvX10LE_c; + *yuv2planeX = isBE(dstFormat) ? yuv2planeX_10BE_c : yuv2planeX_10LE_c; + *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_10BE_c : yuv2plane1_10LE_c; } } else { - *yuv2yuv1 = yuv2yuv1_c; - *yuv2yuvX = yuv2yuvX_c; + *yuv2plane1 = yuv2plane1_8_c; + *yuv2planeX = yuv2planeX_8_c; + if (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21) + *yuv2nv12cX = yuv2nv12cX_c; } + if(c->flags & SWS_FULL_CHR_H_INT) { switch (dstFormat) { case PIX_FMT_RGBA: @@ -2525,8 +2473,6 @@ int16_t *vChrFilterPos= c->vChrFilterPos; int16_t *hLumFilterPos= c->hLumFilterPos; int16_t *hChrFilterPos= c->hChrFilterPos; - int16_t *vLumFilter= c->vLumFilter; - int16_t *vChrFilter= c->vChrFilter; int16_t *hLumFilter= c->hLumFilter; int16_t *hChrFilter= c->hChrFilter; int32_t *lumMmxFilter= c->lumMmxFilter; @@ -2547,10 +2493,11 @@ const int chrSrcSliceH= -((-srcSliceH) >> c->chrSrcVSubSample); int lastDstY; uint32_t *pal=c->pal_yuv; - int should_dither= isNBPS(c->srcFormat) || is16BPS(c->srcFormat); - yuv2planar1_fn yuv2yuv1 = c->yuv2yuv1; - yuv2planarX_fn yuv2yuvX = c->yuv2yuvX; + + yuv2planar1_fn yuv2plane1 = c->yuv2plane1; + yuv2planarX_fn yuv2planeX = c->yuv2planeX; + yuv2interleavedX_fn yuv2nv12cX = c->yuv2nv12cX; yuv2packed1_fn yuv2packed1 = c->yuv2packed1; yuv2packed2_fn yuv2packed2 = c->yuv2packed2; yuv2packedX_fn yuv2packedX = c->yuv2packedX; @@ -2583,7 +2530,7 @@ DEBUG_BUFFERS("vLumFilterSize: %d vLumBufSize: %d vChrFilterSize: %d vChrBufSize: %d\n", vLumFilterSize, vLumBufSize, vChrFilterSize, vChrBufSize); - if (dstStride[0]%8 !=0 || dstStride[1]%8 !=0 || dstStride[2]%8 !=0 || dstStride[3]%8 != 0) { + if (dstStride[0]%16 !=0 || dstStride[1]%16 !=0 || dstStride[2]%16 !=0 || dstStride[3]%16 != 0) { static int warnedAlready=0; //FIXME move this into the context perhaps if (flags & SWS_PRINT_INFO && !warnedAlready) { av_log(c, AV_LOG_WARNING, "Warning: dstStride is not aligned!\n" @@ -2592,6 +2539,18 @@ } } + if ((int)dst[0]%16 || (int)dst[1]%16 || (int)dst[2]%16 || (int)src[0]%16 || (int)src[1]%16 || (int)src[2]%16 + || dstStride[0]%16 || dstStride[1]%16 || dstStride[2]%16 || dstStride[3]%16 + || srcStride[0]%16 || srcStride[1]%16 || srcStride[2]%16 || srcStride[3]%16 + ) { + static int warnedAlready=0; + int cpu_flags = av_get_cpu_flags(); + if (HAVE_MMX2 && (cpu_flags & AV_CPU_FLAG_SSE2) && !warnedAlready){ + av_log(c, AV_LOG_WARNING, "Warning: data is not aligned! This can lead to a speedloss\n"); + warnedAlready=1; + } + } + /* Note the user might start scaling the picture in the middle so this will not get executed. This is not really intended but works currently, so people might do it. */ @@ -2616,6 +2575,7 @@ dst[2] + dstStride[2] * chrDstY, (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? dst[3] + dstStride[3] * dstY : NULL, }; + int use_mmx_vfilter= c->use_mmx_vfilter; const int firstLumSrcY= vLumFilterPos[dstY]; //First line needed as input const int firstLumSrcY2= vLumFilterPos[FFMIN(dstY | ((1<chrDstVSubSample) - 1), dstH-1)]; @@ -2650,17 +2610,19 @@ //Do horizontal scaling while(lastInLumBuf < lastLumSrcY) { const uint8_t *src1= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0]; - const uint8_t *src2= src[3]+(lastInLumBuf + 1 - srcSliceY)*srcStride[3]; + const uint8_t *src2= src[1]+(lastInLumBuf + 1 - srcSliceY)*srcStride[1]; + const uint8_t *src3= src[2]+(lastInLumBuf + 1 - srcSliceY)*srcStride[2]; + const uint8_t *src4= src[3]+(lastInLumBuf + 1 - srcSliceY)*srcStride[3]; lumBufIndex++; assert(lumBufIndex < 2*vLumBufSize); assert(lastInLumBuf + 1 - srcSliceY < srcSliceH); assert(lastInLumBuf + 1 - srcSliceY >= 0); - hyscale(c, lumPixBuf[ lumBufIndex ], dstW, src1, srcW, lumXInc, + hyscale(c, lumPixBuf[ lumBufIndex ], dstW, src1, src2, src3, srcW, lumXInc, hLumFilter, hLumFilterPos, hLumFilterSize, formatConvBuffer, pal, 0); if (CONFIG_SWSCALE_ALPHA && alpPixBuf) - hyscale(c, alpPixBuf[ lumBufIndex ], dstW, src2, srcW, + hyscale(c, alpPixBuf[ lumBufIndex ], dstW, src4, NULL, NULL, srcW, lumXInc, hLumFilter, hLumFilterPos, hLumFilterSize, formatConvBuffer, pal, 1); @@ -2669,6 +2631,7 @@ lumBufIndex, lastInLumBuf); } while(lastInChrBuf < lastChrSrcY) { + const uint8_t *src0= src[0]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[0]; const uint8_t *src1= src[1]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[1]; const uint8_t *src2= src[2]+(lastInChrBuf + 1 - chrSrcSliceY)*srcStride[2]; chrBufIndex++; @@ -2679,7 +2642,7 @@ if (c->needs_hcscale) hcscale(c, chrUPixBuf[chrBufIndex], chrVPixBuf[chrBufIndex], - chrDstW, src1, src2, chrSrcW, chrXInc, + chrDstW, src0, src1, src2, chrSrcW, chrXInc, hChrFilter, hChrFilterPos, hChrFilterSize, formatConvBuffer, pal); lastInChrBuf++; @@ -2701,9 +2664,9 @@ } if (dstY >= dstH-2) { // hmm looks like we can't use MMX here without overwriting this array's tail - find_c_packed_planar_out_funcs(c, &yuv2yuv1, &yuv2yuvX, - &yuv2packed1, &yuv2packed2, - &yuv2packedX); + find_c_packed_planar_out_funcs(c, &yuv2plane1, &yuv2planeX, &yuv2nv12cX, + &yuv2packed1, &yuv2packed2, &yuv2packedX); + use_mmx_vfilter= 0; } { @@ -2711,21 +2674,60 @@ const int16_t **chrUSrcPtr= (const int16_t **) chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; const int16_t **chrVSrcPtr= (const int16_t **) chrVPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **) alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL; + int16_t *vLumFilter= c->vLumFilter; + int16_t *vChrFilter= c->vChrFilter; if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { //YV12 like const int chrSkipMask= (1<chrDstVSubSample)-1; - if ((dstY&chrSkipMask) || isGray(dstFormat)) - dest[1] = dest[2] = NULL; //FIXME split functions in lumi / chromi - if (c->yuv2yuv1 && vLumFilterSize == 1 && vChrFilterSize == 1) { // unscaled YV12 - const int16_t *alpBuf= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? alpSrcPtr[0] : NULL; - yuv2yuv1(c, lumSrcPtr[0], chrUSrcPtr[0], chrVSrcPtr[0], alpBuf, - dest, dstW, chrDstW); - } else { //General YV12 - yuv2yuvX(c, vLumFilter + dstY * vLumFilterSize, - lumSrcPtr, vLumFilterSize, - vChrFilter + chrDstY * vChrFilterSize, - chrUSrcPtr, chrVSrcPtr, vChrFilterSize, - alpSrcPtr, dest, dstW, chrDstW); + + vLumFilter += dstY * vLumFilterSize; + vChrFilter += chrDstY * vChrFilterSize; + + av_assert0(use_mmx_vfilter != ( + yuv2planeX == yuv2planeX_10BE_c + || yuv2planeX == yuv2planeX_10LE_c + || yuv2planeX == yuv2planeX_9BE_c + || yuv2planeX == yuv2planeX_9LE_c + || yuv2planeX == yuv2planeX_16BE_c + || yuv2planeX == yuv2planeX_16LE_c + || yuv2planeX == yuv2planeX_8_c) || !ARCH_X86); + + if(use_mmx_vfilter){ + vLumFilter= c->lumMmxFilter; + vChrFilter= c->chrMmxFilter; + } + + if (vLumFilterSize == 1) { + yuv2plane1(lumSrcPtr[0], dest[0], dstW, c->lumDither8, 0); + } else { + yuv2planeX(vLumFilter, vLumFilterSize, + lumSrcPtr, dest[0], dstW, c->lumDither8, 0); + } + + if (!((dstY&chrSkipMask) || isGray(dstFormat))) { + if (yuv2nv12cX) { + yuv2nv12cX(c, vChrFilter, vChrFilterSize, chrUSrcPtr, chrVSrcPtr, dest[1], chrDstW); + } else if (vChrFilterSize == 1) { + yuv2plane1(chrUSrcPtr[0], dest[1], chrDstW, c->chrDither8, 0); + yuv2plane1(chrVSrcPtr[0], dest[2], chrDstW, c->chrDither8, 3); + } else { + yuv2planeX(vChrFilter, vChrFilterSize, + chrUSrcPtr, dest[1], chrDstW, c->chrDither8, 0); + yuv2planeX(vChrFilter, vChrFilterSize, + chrVSrcPtr, dest[2], chrDstW, c->chrDither8, use_mmx_vfilter ? (c->uv_offx2 >> 1) : 3); + } + } + + if (CONFIG_SWSCALE_ALPHA && alpPixBuf){ + if(use_mmx_vfilter){ + vLumFilter= c->alpMmxFilter; + } + if (vLumFilterSize == 1) { + yuv2plane1(alpSrcPtr[0], dest[3], dstW, c->lumDither8, 0); + } else { + yuv2planeX(vLumFilter, vLumFilterSize, + alpSrcPtr, dest[3], dstW, c->lumDither8, 0); + } } } else { assert(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2); @@ -2779,8 +2781,8 @@ { enum PixelFormat srcFormat = c->srcFormat; - find_c_packed_planar_out_funcs(c, &c->yuv2yuv1, &c->yuv2yuvX, - &c->yuv2packed1, &c->yuv2packed2, + find_c_packed_planar_out_funcs(c, &c->yuv2plane1, &c->yuv2planeX, + &c->yuv2nv12cX, &c->yuv2packed1, &c->yuv2packed2, &c->yuv2packedX); c->chrToYV12 = NULL; @@ -2796,6 +2798,7 @@ case PIX_FMT_RGB4_BYTE: c->chrToYV12 = palToUV_c; break; #if HAVE_BIGENDIAN case PIX_FMT_YUV444P9LE: + case PIX_FMT_YUV422P9LE: case PIX_FMT_YUV420P9LE: case PIX_FMT_YUV422P10LE: case PIX_FMT_YUV420P10LE: @@ -2805,6 +2808,7 @@ case PIX_FMT_YUV444P16LE: c->chrToYV12 = bswap16UV_c; break; #else case PIX_FMT_YUV444P9BE: + case PIX_FMT_YUV422P9BE: case PIX_FMT_YUV420P9BE: case PIX_FMT_YUV444P10BE: case PIX_FMT_YUV422P10BE: @@ -2834,6 +2838,7 @@ case PIX_FMT_RGB565BE: c->chrToYV12 = rgb16beToUV_half_c; break; case PIX_FMT_RGB555LE: c->chrToYV12 = rgb15leToUV_half_c; break; case PIX_FMT_RGB555BE: c->chrToYV12 = rgb15beToUV_half_c; break; + case PIX_FMT_GBR24P : c->chrToYV12 = gbr24pToUV_half_c; break; } } else { switch(srcFormat) { @@ -2855,6 +2860,7 @@ case PIX_FMT_RGB565BE: c->chrToYV12 = rgb16beToUV_c; break; case PIX_FMT_RGB555LE: c->chrToYV12 = rgb15leToUV_c; break; case PIX_FMT_RGB555BE: c->chrToYV12 = rgb15beToUV_c; break; + case PIX_FMT_GBR24P : c->chrToYV12 = gbr24pToUV_c; break; } } @@ -2863,6 +2869,7 @@ switch (srcFormat) { #if HAVE_BIGENDIAN case PIX_FMT_YUV444P9LE: + case PIX_FMT_YUV422P9LE: case PIX_FMT_YUV420P9LE: case PIX_FMT_YUV422P10LE: case PIX_FMT_YUV420P10LE: @@ -2873,6 +2880,7 @@ case PIX_FMT_GRAY16LE: c->lumToYV12 = bswap16Y_c; break; #else case PIX_FMT_YUV444P9BE: + case PIX_FMT_YUV422P9BE: case PIX_FMT_YUV420P9BE: case PIX_FMT_YUV444P10BE: case PIX_FMT_YUV422P10BE: @@ -2910,6 +2918,7 @@ case PIX_FMT_RGB48LE: c->lumToYV12 = rgb48LEToY_c; break; case PIX_FMT_BGR48BE: c->lumToYV12 = bgr48BEToY_c; break; case PIX_FMT_BGR48LE: c->lumToYV12 = bgr48LEToY_c; break; + case PIX_FMT_GBR24P : c->lumToYV12 = gbr24pToY_c ; break; } if (c->alpPixBuf) { switch (srcFormat) { diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libswscale/swscale_internal.h ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libswscale/swscale_internal.h --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libswscale/swscale_internal.h 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libswscale/swscale_internal.h 2011-11-04 12:38:27.000000000 +0000 @@ -61,56 +61,58 @@ int srcStride[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]); + /** - * Write one line of horizontally scaled Y/U/V/A to planar output + * Write one line of horizontally scaled data to planar output * without any additional vertical scaling (or point-scaling). * - * @param c SWS scaling context - * @param lumSrc scaled luma (Y) source data, 15bit for 8-10bit output, - * 19-bit for 16bit output (in int32_t) - * @param chrUSrc scaled chroma (U) source data, 15bit for 8-10bit output, - * 19-bit for 16bit output (in int32_t) - * @param chrVSrc scaled chroma (V) source data, 15bit for 8-10bit output, + * @param src scaled source data, 15bit for 8-10bit output, * 19-bit for 16bit output (in int32_t) - * @param alpSrc scaled alpha (A) source data, 15bit for 8-10bit output, - * 19-bit for 16bit output (in int32_t) - * @param dest pointer to the 4 output planes (Y/U/V/A). For >8bit + * @param dest pointer to the output plane. For >8bit * output, this is in uint16_t - * @param dstW width of dest[0], dest[3], lumSrc and alpSrc in pixels - * @param chrDstW width of dest[1], dest[2], chrUSrc and chrVSrc + * @param dstW width of destination in pixels + * @param dither ordered dither array of type int16_t and size 8 + * @param offset Dither offset */ -typedef void (*yuv2planar1_fn) (struct SwsContext *c, - const int16_t *lumSrc, const int16_t *chrUSrc, - const int16_t *chrVSrc, const int16_t *alpSrc, - uint8_t *dest[4], int dstW, int chrDstW); +typedef void (*yuv2planar1_fn) (const int16_t *src, uint8_t *dest, int dstW, + const uint8_t *dither, int offset); + /** - * Write one line of horizontally scaled Y/U/V/A to planar output + * Write one line of horizontally scaled data to planar output * with multi-point vertical scaling between input pixels. * - * @param c SWS scaling context - * @param lumFilter vertical luma/alpha scaling coefficients, 12bit [0,4096] - * @param lumSrc scaled luma (Y) source data, 15bit for 8-10bit output, + * @param filter vertical luma/alpha scaling coefficients, 12bit [0,4096] + * @param src scaled luma (Y) or alpha (A) source data, 15bit for 8-10bit output, * 19-bit for 16bit output (in int32_t) - * @param lumFilterSize number of vertical luma/alpha input lines to scale + * @param filterSize number of vertical input lines to scale + * @param dest pointer to output plane. For >8bit + * output, this is in uint16_t + * @param dstW width of destination pixels + * @param offset Dither offset + */ +typedef void (*yuv2planarX_fn) (const int16_t *filter, int filterSize, + const int16_t **src, uint8_t *dest, int dstW, + const uint8_t *dither, int offset); + +/** + * Write one line of horizontally scaled chroma to interleaved output + * with multi-point vertical scaling between input pixels. + * + * @param c SWS scaling context * @param chrFilter vertical chroma scaling coefficients, 12bit [0,4096] * @param chrUSrc scaled chroma (U) source data, 15bit for 8-10bit output, * 19-bit for 16bit output (in int32_t) * @param chrVSrc scaled chroma (V) source data, 15bit for 8-10bit output, * 19-bit for 16bit output (in int32_t) * @param chrFilterSize number of vertical chroma input lines to scale - * @param alpSrc scaled alpha (A) source data, 15bit for 8-10bit output, - * 19-bit for 16bit output (in int32_t) - * @param dest pointer to the 4 output planes (Y/U/V/A). For >8bit + * @param dest pointer to the output plane. For >8bit * output, this is in uint16_t - * @param dstW width of dest[0], dest[3], lumSrc and alpSrc in pixels - * @param chrDstW width of dest[1], dest[2], chrUSrc and chrVSrc + * @param dstW width of chroma planes */ -typedef void (*yuv2planarX_fn) (struct SwsContext *c, const int16_t *lumFilter, - const int16_t **lumSrc, int lumFilterSize, - const int16_t *chrFilter, const int16_t **chrUSrc, - const int16_t **chrVSrc, int chrFilterSize, - const int16_t **alpSrc, uint8_t *dest[4], - int dstW, int chrDstW); +typedef void (*yuv2interleavedX_fn) (struct SwsContext *c, const int16_t *chrFilter, int chrFilterSize, + const int16_t **chrUSrc, const int16_t **chrVSrc, + uint8_t *dest, int dstW); + /** * Write one line of horizontally scaled Y/U/V/A to packed-pixel YUV/RGB * output without any additional vertical scaling (or point-scaling). Note @@ -410,20 +412,22 @@ #if HAVE_VIS DECLARE_ALIGNED(8, uint64_t, sparc_coeffs)[10]; #endif + int use_mmx_vfilter; /* function pointers for swScale() */ - yuv2planar1_fn yuv2yuv1; - yuv2planarX_fn yuv2yuvX; + yuv2planar1_fn yuv2plane1; + yuv2planarX_fn yuv2planeX; + yuv2interleavedX_fn yuv2nv12cX; yuv2packed1_fn yuv2packed1; yuv2packed2_fn yuv2packed2; yuv2packedX_fn yuv2packedX; - void (*lumToYV12)(uint8_t *dst, const uint8_t *src, + void (*lumToYV12)(uint8_t *dst, const uint8_t *src, const uint8_t *src2, const uint8_t *src3, int width, uint32_t *pal); ///< Unscaled conversion of luma plane to YV12 for horizontal scaler. - void (*alpToYV12)(uint8_t *dst, const uint8_t *src, + void (*alpToYV12)(uint8_t *dst, const uint8_t *src, const uint8_t *src2, const uint8_t *src3, int width, uint32_t *pal); ///< Unscaled conversion of alpha plane to YV12 for horizontal scaler. void (*chrToYV12)(uint8_t *dstU, uint8_t *dstV, - const uint8_t *src1, const uint8_t *src2, + const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, int width, uint32_t *pal); ///< Unscaled conversion of chroma planes to YV12 for horizontal scaler. /** * Scale one horizontal line of input data using a bilinear filter @@ -547,6 +551,8 @@ #define isNBPS(x) ( \ (x)==PIX_FMT_YUV420P9LE \ || (x)==PIX_FMT_YUV420P9BE \ + || (x)==PIX_FMT_YUV422P9LE \ + || (x)==PIX_FMT_YUV422P9BE \ || (x)==PIX_FMT_YUV444P9BE \ || (x)==PIX_FMT_YUV444P9LE \ || (x)==PIX_FMT_YUV422P10BE \ @@ -574,6 +580,7 @@ #define isPlanarYUV(x) ( \ isPlanar8YUV(x) \ || (x)==PIX_FMT_YUV420P9LE \ + || (x)==PIX_FMT_YUV422P9LE \ || (x)==PIX_FMT_YUV444P9LE \ || (x)==PIX_FMT_YUV420P10LE \ || (x)==PIX_FMT_YUV422P10LE \ @@ -583,6 +590,7 @@ || (x)==PIX_FMT_YUV422P16LE \ || (x)==PIX_FMT_YUV444P16LE \ || (x)==PIX_FMT_YUV420P9BE \ + || (x)==PIX_FMT_YUV422P9BE \ || (x)==PIX_FMT_YUV444P9BE \ || (x)==PIX_FMT_YUV420P10BE \ || (x)==PIX_FMT_YUV422P10BE \ @@ -592,6 +600,12 @@ || (x)==PIX_FMT_YUV422P16BE \ || (x)==PIX_FMT_YUV444P16BE \ ) + +#define isPlanar(x) ( \ + isPlanarYUV(x) \ + || (x)==PIX_FMT_GBR24P \ + ) + #define isYUV(x) ( \ (x)==PIX_FMT_UYVY422 \ || (x)==PIX_FMT_YUYV422 \ @@ -668,6 +682,7 @@ #define isAnyRGB(x) ( \ isRGBinInt(x) \ || isBGRinInt(x) \ + || (x)==PIX_FMT_GBR24P \ ) #define isALPHA(x) ( \ (x)==PIX_FMT_BGRA64BE \ @@ -687,7 +702,8 @@ || (x)==PIX_FMT_YUYV422 \ || (x)==PIX_FMT_UYVY422 \ || (x)==PIX_FMT_Y400A \ - || isAnyRGB(x) \ + || isRGBinInt(x) \ + || isBGRinInt(x) \ ) #define usePal(x) ((av_pix_fmt_descriptors[x].flags & PIX_FMT_PAL) || (x) == PIX_FMT_GRAY8A) diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libswscale/swscale-test.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libswscale/swscale-test.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libswscale/swscale-test.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libswscale/swscale-test.c 2011-11-04 12:38:27.000000000 +0000 @@ -104,6 +104,7 @@ av_image_fill_linesizes(srcStride, srcFormat, srcW); for (p = 0; p < 4; p++) { + srcStride[p] = FFALIGN(srcStride[p], 16); if (srcStride[p]) src[p] = av_mallocz(srcStride[p]*srcH+16); if (srcStride[p] && !src[p]) { @@ -139,6 +140,7 @@ * allocated with av_malloc). */ /* An extra 16 bytes is being allocated because some scalers may write * out of bounds. */ + dstStride[i] = FFALIGN(dstStride[i], 16); if (dstStride[i]) dst[i]= av_mallocz(dstStride[i]*dstH+16); if (dstStride[i] && !dst[i]) { @@ -178,6 +180,7 @@ ssdA = r->ssdA; } else { for (i=0; i<4; i++) { + refStride[i] = FFALIGN(refStride[i], 16); if (refStride[i]) out[i]= av_mallocz(refStride[i]*h); if (refStride[i] && !out[i]) { diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libswscale/swscale_unscaled.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libswscale/swscale_unscaled.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libswscale/swscale_unscaled.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libswscale/swscale_unscaled.c 2011-11-04 12:38:27.000000000 +0000 @@ -672,7 +672,7 @@ { if(!isALPHA(format)) src[3]=NULL; - if(!isPlanarYUV(format)) { + if(!isPlanar(format)) { src[3]=src[2]=NULL; if (!usePal(format)) @@ -798,7 +798,7 @@ int dstStride2[4]= {dstStride[0], dstStride[1], dstStride[2], dstStride[3]}; reset_ptr(src2, c->srcFormat); - reset_ptr((const uint8_t**)dst2, c->dstFormat); + reset_ptr((void*)dst2, c->dstFormat); /* reset slice direction at end of frame */ if (srcSliceY + srcSliceH == c->srcH) diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libswscale/utils.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libswscale/utils.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libswscale/utils.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libswscale/utils.c 2011-11-04 12:38:27.000000000 +0000 @@ -136,12 +136,15 @@ [PIX_FMT_YUV420P9LE] = { 1 , 1 }, [PIX_FMT_YUV420P10BE] = { 1 , 1 }, [PIX_FMT_YUV420P10LE] = { 1 , 1 }, + [PIX_FMT_YUV422P9BE] = { 1 , 1 }, + [PIX_FMT_YUV422P9LE] = { 1 , 1 }, [PIX_FMT_YUV422P10BE] = { 1 , 1 }, [PIX_FMT_YUV422P10LE] = { 1 , 1 }, [PIX_FMT_YUV444P9BE] = { 1 , 1 }, [PIX_FMT_YUV444P9LE] = { 1 , 1 }, [PIX_FMT_YUV444P10BE] = { 1 , 1 }, [PIX_FMT_YUV444P10LE] = { 1 , 1 }, + [PIX_FMT_GBR24P] = { 1 , 0 }, }; int sws_isSupportedInput(enum PixelFormat pix_fmt) @@ -279,15 +282,18 @@ if (flags & SWS_BICUBIC) { int64_t B= (param[0] != SWS_PARAM_DEFAULT ? param[0] : 0) * (1<<24); int64_t C= (param[1] != SWS_PARAM_DEFAULT ? param[1] : 0.6) * (1<<24); - int64_t dd = ( d*d)>>30; - int64_t ddd= (dd*d)>>30; - if (d < 1LL<<30) - coeff = (12*(1<<24)-9*B-6*C)*ddd + (-18*(1<<24)+12*B+6*C)*dd + (6*(1<<24)-2*B)*(1<<30); - else if (d < 1LL<<31) - coeff = (-B-6*C)*ddd + (6*B+30*C)*dd + (-12*B-48*C)*d + (8*B+24*C)*(1<<30); - else - coeff=0.0; + if (d >= 1LL<<31) { + coeff = 0.0; + } else { + int64_t dd = (d * d) >> 30; + int64_t ddd = (dd * d) >> 30; + + if (d < 1LL<<30) + coeff = (12*(1<<24)-9*B-6*C)*ddd + (-18*(1<<24)+12*B+6*C)*dd + (6*(1<<24)-2*B)*(1<<30); + else + coeff = (-B-6*C)*ddd + (6*B+30*C)*dd + (-12*B-48*C)*d + (8*B+24*C)*(1<<30); + } coeff *= fone>>(30+24); } /* else if (flags & SWS_X) { diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libswscale/x86/scale.asm ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libswscale/x86/scale.asm --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libswscale/x86/scale.asm 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libswscale/x86/scale.asm 2011-11-04 12:38:27.000000000 +0000 @@ -1,6 +1,7 @@ ;****************************************************************************** -;* x86-optimized horizontal line scaling functions +;* x86-optimized horizontal/vertical line scaling functions ;* Copyright (c) 2011 Ronald S. Bultje +;* Kieran Kunhya ;* ;* This file is part of Libav. ;* @@ -28,6 +29,11 @@ max_19bit_flt: times 4 dd 524287.0 minshort: times 8 dw 0x8000 unicoeff: times 4 dd 0x20000000 +yuv2yuvX_16_start: times 4 dd 0x4000 - 0x40000000 +yuv2yuvX_10_start: times 4 dd 0x10000 +yuv2yuvX_9_start: times 4 dd 0x20000 +yuv2yuvX_10_upper: times 8 dw 0x3ff +yuv2yuvX_9_upper: times 8 dw 0x1ff SECTION .text @@ -369,7 +375,7 @@ cvtps2dq m0, m0 %endif ; mmx/sse2/ssse3/sse4 %ifnidn %3, X - movu [r1+r2*(4>>r2shr)], m0 + mova [r1+r2*(4>>r2shr)], m0 %else ; %3 == X movq [r1+r2*4], m0 %endif ; %3 ==/!= X @@ -429,3 +435,233 @@ SCALE_FUNCS2 sse2, 6, 7, 8 SCALE_FUNCS2 ssse3, 6, 6, 8 SCALE_FUNCS2 sse4, 6, 6, 8 + +;----------------------------------------------------------------------------- +; vertical line scaling +; +; void yuv2plane1__(const int16_t *src, uint8_t *dst, int dstW, +; const uint8_t *dither, int offset) +; and +; void yuv2planeX__(const int16_t *filter, int filterSize, +; const int16_t **src, uint8_t *dst, int dstW, +; const uint8_t *dither, int offset) +; +; Scale one or $filterSize lines of source data to generate one line of output +; data. The input is 15-bit in int16_t if $output_size is [8,10] and 19-bit in +; int32_t if $output_size is 16. $filter is 12-bits. $filterSize is a multiple +; of 2. $offset is either 0 or 3. $dither holds 8 values. +;----------------------------------------------------------------------------- + +%macro yuv2planeX_fn 4 + +%ifdef ARCH_X86_32 +%define cntr_reg r1 +%define movsx mov +%else +%define cntr_reg r11 +%define movsx movsxd +%endif + +cglobal yuv2planeX_%2_%1, %4, 7, %3 +%if %2 == 8 || %2 == 9 || %2 == 10 + pxor m6, m6 +%endif ; %2 == 8/9/10 + +%if %2 == 8 +%ifdef ARCH_X86_32 +%assign pad 0x2c - (stack_offset & 15) + SUB rsp, pad +%define m_dith m7 +%else ; x86-64 +%define m_dith m9 +%endif ; x86-32 + + ; create registers holding dither + movq m_dith, [r5] ; dither + test r6d, r6d + jz .no_rot +%if mmsize == 16 + punpcklqdq m_dith, m_dith +%endif ; mmsize == 16 + PALIGNR m_dith, m_dith, 3, m0 +.no_rot: +%if mmsize == 16 + punpcklbw m_dith, m6 +%ifdef ARCH_X86_64 + punpcklwd m8, m_dith, m6 + pslld m8, 12 +%else ; x86-32 + punpcklwd m5, m_dith, m6 + pslld m5, 12 +%endif ; x86-32/64 + punpckhwd m_dith, m6 + pslld m_dith, 12 +%ifdef ARCH_X86_32 + mova [rsp+ 0], m5 + mova [rsp+16], m_dith +%endif +%else ; mmsize == 8 + punpcklbw m5, m_dith, m6 + punpckhbw m_dith, m6 + punpcklwd m4, m5, m6 + punpckhwd m5, m6 + punpcklwd m3, m_dith, m6 + punpckhwd m_dith, m6 + pslld m4, 12 + pslld m5, 12 + pslld m3, 12 + pslld m_dith, 12 + mova [rsp+ 0], m4 + mova [rsp+ 8], m5 + mova [rsp+16], m3 + mova [rsp+24], m_dith +%endif ; mmsize == 8/16 +%endif ; %2 == 8 + + xor r5, r5 + +.pixelloop: +%assign %%i 0 + ; the rep here is for the 8bit output mmx case, where dither covers + ; 8 pixels but we can only handle 2 pixels per register, and thus 4 + ; pixels per iteration. In order to not have to keep track of where + ; we are w.r.t. dithering, we unroll the mmx/8bit loop x2. +%if %2 == 8 +%rep 16/mmsize +%endif ; %2 == 8 + +%if %2 == 8 +%ifdef ARCH_X86_32 + mova m2, [rsp+mmsize*(0+%%i)] + mova m1, [rsp+mmsize*(1+%%i)] +%else ; x86-64 + mova m2, m8 + mova m1, m_dith +%endif ; x86-32/64 +%else ; %2 == 9/10/16 + mova m1, [yuv2yuvX_%2_start] + mova m2, m1 +%endif ; %2 == 8/9/10/16 + movsx cntr_reg, r1m +.filterloop_ %+ %%i: + ; input pixels + mov r6, [r2+gprsize*cntr_reg-2*gprsize] +%if %2 == 16 + mova m3, [r6+r5*4] + mova m5, [r6+r5*4+mmsize] +%else ; %2 == 8/9/10 + mova m3, [r6+r5*2] +%endif ; %2 == 8/9/10/16 + mov r6, [r2+gprsize*cntr_reg-gprsize] +%if %2 == 16 + mova m4, [r6+r5*4] + mova m6, [r6+r5*4+mmsize] +%else ; %2 == 8/9/10 + mova m4, [r6+r5*2] +%endif ; %2 == 8/9/10/16 + + ; coefficients + movd m0, [r0+2*cntr_reg-4]; coeff[0], coeff[1] +%if %2 == 16 + pshuflw m7, m0, 0 ; coeff[0] + pshuflw m0, m0, 0x55 ; coeff[1] + pmovsxwd m7, m7 ; word -> dword + pmovsxwd m0, m0 ; word -> dword + + pmulld m3, m7 + pmulld m5, m7 + pmulld m4, m0 + pmulld m6, m0 + + paddd m2, m3 + paddd m1, m5 + paddd m2, m4 + paddd m1, m6 +%else ; %2 == 10/9/8 + punpcklwd m5, m3, m4 + punpckhwd m3, m4 + SPLATD m0, m0 + + pmaddwd m5, m0 + pmaddwd m3, m0 + + paddd m2, m5 + paddd m1, m3 +%endif ; %2 == 8/9/10/16 + + sub cntr_reg, 2 + jg .filterloop_ %+ %%i + +%if %2 == 16 + psrad m2, 31 - %2 + psrad m1, 31 - %2 +%else ; %2 == 10/9/8 + psrad m2, 27 - %2 + psrad m1, 27 - %2 +%endif ; %2 == 8/9/10/16 + +%if %2 == 8 + packssdw m2, m1 + packuswb m2, m2 + movh [r3+r5*1], m2 +%else ; %2 == 9/10/16 +%if %2 == 16 + packssdw m2, m1 + paddw m2, [minshort] +%else ; %2 == 9/10 +%ifidn %1, sse4 + packusdw m2, m1 +%elifidn %1, avx + packusdw m2, m1 +%else ; mmx2/sse2 + packssdw m2, m1 + pmaxsw m2, m6 +%endif ; mmx2/sse2/sse4/avx + pminsw m2, [yuv2yuvX_%2_upper] +%endif ; %2 == 9/10/16 + mova [r3+r5*2], m2 +%endif ; %2 == 8/9/10/16 + + add r5, mmsize/2 + sub r4d, mmsize/2 +%if %2 == 8 +%assign %%i %%i+2 +%endrep +%endif ; %2 == 8 + jg .pixelloop + +%if %2 == 8 +%ifdef ARCH_X86_32 + ADD rsp, pad + RET +%else ; x86-64 + REP_RET +%endif ; x86-32/64 +%else ; %2 == 9/10/16 + REP_RET +%endif ; %2 == 8/9/10/16 +%endmacro + +%define PALIGNR PALIGNR_MMX +%ifdef ARCH_X86_32 +INIT_MMX +yuv2planeX_fn mmx, 8, 0, 7 +yuv2planeX_fn mmx2, 9, 0, 5 +yuv2planeX_fn mmx2, 10, 0, 5 +%endif + +INIT_XMM +yuv2planeX_fn sse2, 8, 10, 7 +yuv2planeX_fn sse2, 9, 7, 5 +yuv2planeX_fn sse2, 10, 7, 5 + +%define PALIGNR PALIGNR_SSSE3 +yuv2planeX_fn sse4, 8, 10, 7 +yuv2planeX_fn sse4, 9, 7, 5 +yuv2planeX_fn sse4, 10, 7, 5 +yuv2planeX_fn sse4, 16, 8, 5 + +INIT_AVX +yuv2planeX_fn avx, 8, 10, 7 +yuv2planeX_fn avx, 9, 7, 5 +yuv2planeX_fn avx, 10, 7, 5 diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libswscale/x86/swscale_mmx.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libswscale/x86/swscale_mmx.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libswscale/x86/swscale_mmx.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libswscale/x86/swscale_mmx.c 2011-11-04 12:38:27.000000000 +0000 @@ -176,6 +176,65 @@ } } +static void yuv2yuvX_sse3(const int16_t *filter, int filterSize, + const int16_t **src, uint8_t *dest, int dstW, + const uint8_t *dither, int offset) +{ + if(((int)dest) & 15){ + return yuv2yuvX_MMX2(filter, filterSize, src, dest, dstW, dither, offset); + } + if (offset) { + __asm__ volatile("movq (%0), %%xmm3\n\t" + "movdqa %%xmm3, %%xmm4\n\t" + "psrlq $24, %%xmm3\n\t" + "psllq $40, %%xmm4\n\t" + "por %%xmm4, %%xmm3\n\t" + :: "r"(dither) + ); + } else { + __asm__ volatile("movq (%0), %%xmm3\n\t" + :: "r"(dither) + ); + } + __asm__ volatile( + "pxor %%xmm0, %%xmm0\n\t" + "punpcklbw %%xmm0, %%xmm3\n\t" + "psraw $4, %%xmm3\n\t" + "movdqa %%xmm3, %%xmm4\n\t" + "movdqa %%xmm3, %%xmm7\n\t" + "movl %3, %%ecx\n\t" + "mov %0, %%"REG_d" \n\t"\ + "mov (%%"REG_d"), %%"REG_S" \n\t"\ + ".p2align 4 \n\t" /* FIXME Unroll? */\ + "1: \n\t"\ + "movddup 8(%%"REG_d"), %%xmm0 \n\t" /* filterCoeff */\ + "movdqa (%%"REG_S", %%"REG_c", 2), %%xmm2 \n\t" /* srcData */\ + "movdqa 16(%%"REG_S", %%"REG_c", 2), %%xmm5 \n\t" /* srcData */\ + "add $16, %%"REG_d" \n\t"\ + "mov (%%"REG_d"), %%"REG_S" \n\t"\ + "test %%"REG_S", %%"REG_S" \n\t"\ + "pmulhw %%xmm0, %%xmm2 \n\t"\ + "pmulhw %%xmm0, %%xmm5 \n\t"\ + "paddw %%xmm2, %%xmm3 \n\t"\ + "paddw %%xmm5, %%xmm4 \n\t"\ + " jnz 1b \n\t"\ + "psraw $3, %%xmm3 \n\t"\ + "psraw $3, %%xmm4 \n\t"\ + "packuswb %%xmm4, %%xmm3 \n\t" + "movntdq %%xmm3, (%1, %%"REG_c")\n\t" + "add $16, %%"REG_c" \n\t"\ + "cmp %2, %%"REG_c" \n\t"\ + "movdqa %%xmm7, %%xmm3\n\t" + "movdqa %%xmm7, %%xmm4\n\t" + "mov %0, %%"REG_d" \n\t"\ + "mov (%%"REG_d"), %%"REG_S" \n\t"\ + "jb 1b \n\t"\ + :: "g" (filter), + "r" (dest-offset), "g" ((x86_reg)(dstW+offset)), "m" (offset) + : "%"REG_d, "%"REG_S, "%"REG_c + ); +} + #define SCALE_FUNC(filter_n, from_bpc, to_bpc, opt) \ extern void ff_hscale ## from_bpc ## to ## to_bpc ## _ ## filter_n ## _ ## opt( \ SwsContext *c, int16_t *data, \ @@ -213,6 +272,23 @@ SCALE_FUNCS_SSE(ssse3); SCALE_FUNCS_SSE(sse4); +#define VSCALEX_FUNC(size, opt) \ +extern void ff_yuv2planeX_ ## size ## _ ## opt(const int16_t *filter, int filterSize, \ + const int16_t **src, uint8_t *dest, int dstW, \ + const uint8_t *dither, int offset) +#define VSCALEX_FUNCS(opt1, opt2) \ + VSCALEX_FUNC(8, opt1); \ + VSCALEX_FUNC(9, opt2); \ + VSCALEX_FUNC(10, opt2) + +#if ARCH_X86_32 +VSCALEX_FUNCS(mmx, mmx2); +#endif +VSCALEX_FUNCS(sse2, sse2); +VSCALEX_FUNCS(sse4, sse4); +VSCALEX_FUNC(16, sse4); +VSCALEX_FUNCS(avx, avx); + void ff_sws_init_swScale_mmx(SwsContext *c) { int cpu_flags = av_get_cpu_flags(); @@ -222,6 +298,10 @@ #if HAVE_MMX2 if (cpu_flags & AV_CPU_FLAG_MMX2) sws_init_swScale_MMX2(c); + if (cpu_flags & AV_CPU_FLAG_SSE3){ + if(c->use_mmx_vfilter && !(c->flags & SWS_ACCURATE_RND)) + c->yuv2planeX = yuv2yuvX_sse3; + } #endif #if HAVE_YASM @@ -249,10 +329,18 @@ case 8: ASSIGN_SCALE_FUNC2(hscalefn, 8, opt1, opt2); break; \ default: ASSIGN_SCALE_FUNC2(hscalefn, X, opt1, opt2); break; \ } +#define ASSIGN_VSCALEX_FUNC(vscalefn, opt1, opt2, opt2chk, do_16_case) \ +switch(c->dstBpc){ \ + case 16: /*do_16_case;*/ break; \ + case 10: if (!isBE(c->dstFormat) && opt2chk) /*vscalefn = ff_yuv2planeX_10_ ## opt2;*/ break; \ + case 9: if (!isBE(c->dstFormat) && opt2chk) /*vscalefn = ff_yuv2planeX_9_ ## opt2;*/ break; \ + default: /*vscalefn = ff_yuv2planeX_8_ ## opt1;*/ break; \ + } #if ARCH_X86_32 if (cpu_flags & AV_CPU_FLAG_MMX) { ASSIGN_MMX_SCALE_FUNC(c->hyScale, c->hLumFilterSize, mmx, mmx); ASSIGN_MMX_SCALE_FUNC(c->hcScale, c->hChrFilterSize, mmx, mmx); + ASSIGN_VSCALEX_FUNC(c->yuv2planeX, mmx, mmx2, cpu_flags & AV_CPU_FLAG_MMX2,); } #endif #define ASSIGN_SSE_SCALE_FUNC(hscalefn, filtersize, opt1, opt2) \ @@ -266,6 +354,7 @@ if (cpu_flags & AV_CPU_FLAG_SSE2) { ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, sse2, sse2); ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, sse2, sse2); + ASSIGN_VSCALEX_FUNC(c->yuv2planeX, sse2, sse2, 1,); } if (cpu_flags & AV_CPU_FLAG_SSSE3) { ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, ssse3, ssse3); @@ -275,6 +364,12 @@ /* Xto15 don't need special sse4 functions */ ASSIGN_SSE_SCALE_FUNC(c->hyScale, c->hLumFilterSize, sse4, ssse3); ASSIGN_SSE_SCALE_FUNC(c->hcScale, c->hChrFilterSize, sse4, ssse3); + ASSIGN_VSCALEX_FUNC(c->yuv2planeX, sse4, sse4, 1, + if (!isBE(c->dstFormat)) c->yuv2planeX = ff_yuv2planeX_16_sse4); + } + + if (cpu_flags & AV_CPU_FLAG_AVX) { + ASSIGN_VSCALEX_FUNC(c->yuv2planeX, avx, avx, 1,); } #endif } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libswscale/x86/swscale_template.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libswscale/x86/swscale_template.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libswscale/x86/swscale_template.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libswscale/x86/swscale_template.c 2011-11-04 12:38:27.000000000 +0000 @@ -20,6 +20,7 @@ #undef REAL_MOVNTQ #undef MOVNTQ +#undef MOVNTQ2 #undef PREFETCH #if COMPILE_TEMPLATE_MMX2 @@ -30,49 +31,16 @@ #if COMPILE_TEMPLATE_MMX2 #define REAL_MOVNTQ(a,b) "movntq " #a ", " #b " \n\t" +#define MOVNTQ2 "movntq " #else #define REAL_MOVNTQ(a,b) "movq " #a ", " #b " \n\t" +#define MOVNTQ2 "movq " #endif #define MOVNTQ(a,b) REAL_MOVNTQ(a,b) -#define YSCALEYUV2YV12X(offset, dest, end, pos) \ - __asm__ volatile(\ - "movq "DITHER16"+0(%0), %%mm3 \n\t"\ - "movq "DITHER16"+8(%0), %%mm4 \n\t"\ - "lea " offset "(%0), %%"REG_d" \n\t"\ - "mov (%%"REG_d"), %%"REG_S" \n\t"\ - ".p2align 4 \n\t" /* FIXME Unroll? */\ - "1: \n\t"\ - "movq 8(%%"REG_d"), %%mm0 \n\t" /* filterCoeff */\ - "movq (%%"REG_S", %3, 2), %%mm2 \n\t" /* srcData */\ - "movq 8(%%"REG_S", %3, 2), %%mm5 \n\t" /* srcData */\ - "add $16, %%"REG_d" \n\t"\ - "mov (%%"REG_d"), %%"REG_S" \n\t"\ - "test %%"REG_S", %%"REG_S" \n\t"\ - "pmulhw %%mm0, %%mm2 \n\t"\ - "pmulhw %%mm0, %%mm5 \n\t"\ - "paddw %%mm2, %%mm3 \n\t"\ - "paddw %%mm5, %%mm4 \n\t"\ - " jnz 1b \n\t"\ - "psraw $3, %%mm3 \n\t"\ - "psraw $3, %%mm4 \n\t"\ - "packuswb %%mm4, %%mm3 \n\t"\ - MOVNTQ(%%mm3, (%1, %3))\ - "add $8, %3 \n\t"\ - "cmp %2, %3 \n\t"\ - "movq "DITHER16"+0(%0), %%mm3 \n\t"\ - "movq "DITHER16"+8(%0), %%mm4 \n\t"\ - "lea " offset "(%0), %%"REG_d" \n\t"\ - "mov (%%"REG_d"), %%"REG_S" \n\t"\ - "jb 1b \n\t"\ - :: "r" (&c->redDither),\ - "r" (dest), "g" ((x86_reg)(end)), "r"((x86_reg)(pos))\ - : "%"REG_d, "%"REG_S\ - ); - #if !COMPILE_TEMPLATE_MMX2 static av_always_inline void -dither_8to16(SwsContext *c, const uint8_t *srcDither, int rot) +dither_8to16(const uint8_t *srcDither, int rot) { if (rot) { __asm__ volatile("pxor %%mm0, %%mm0\n\t" @@ -84,11 +52,7 @@ "movq %%mm3, %%mm4\n\t" "punpcklbw %%mm0, %%mm3\n\t" "punpckhbw %%mm0, %%mm4\n\t" - "psraw $4, %%mm3\n\t" - "psraw $4, %%mm4\n\t" - "movq %%mm3, "DITHER16"+0(%1)\n\t" - "movq %%mm4, "DITHER16"+8(%1)\n\t" - :: "r"(srcDither), "r"(&c->redDither) + :: "r"(srcDither) ); } else { __asm__ volatile("pxor %%mm0, %%mm0\n\t" @@ -96,253 +60,76 @@ "movq %%mm3, %%mm4\n\t" "punpcklbw %%mm0, %%mm3\n\t" "punpckhbw %%mm0, %%mm4\n\t" - "psraw $4, %%mm3\n\t" - "psraw $4, %%mm4\n\t" - "movq %%mm3, "DITHER16"+0(%1)\n\t" - "movq %%mm4, "DITHER16"+8(%1)\n\t" - :: "r"(srcDither), "r"(&c->redDither) + :: "r"(srcDither) ); } } #endif -static void RENAME(yuv2yuvX)(SwsContext *c, const int16_t *lumFilter, - const int16_t **lumSrc, int lumFilterSize, - const int16_t *chrFilter, const int16_t **chrUSrc, - const int16_t **chrVSrc, - int chrFilterSize, const int16_t **alpSrc, - uint8_t *dest[4], int dstW, int chrDstW) -{ - uint8_t *yDest = dest[0], *uDest = dest[1], *vDest = dest[2], - *aDest = CONFIG_SWSCALE_ALPHA ? dest[3] : NULL; - const uint8_t *lumDither = c->lumDither8, *chrDither = c->chrDither8; - - if (uDest) { - x86_reg uv_off = c->uv_offx2 >> 1; - dither_8to16(c, chrDither, 0); - YSCALEYUV2YV12X(CHR_MMX_FILTER_OFFSET, uDest, chrDstW, 0) - dither_8to16(c, chrDither, 1); - YSCALEYUV2YV12X(CHR_MMX_FILTER_OFFSET, vDest - uv_off, chrDstW + uv_off, uv_off) - } - dither_8to16(c, lumDither, 0); - if (CONFIG_SWSCALE_ALPHA && aDest) { - YSCALEYUV2YV12X(ALP_MMX_FILTER_OFFSET, aDest, dstW, 0) - } - - YSCALEYUV2YV12X(LUM_MMX_FILTER_OFFSET, yDest, dstW, 0) -} - -#define YSCALEYUV2YV12X_ACCURATE(offset, dest, end, pos) \ +static void RENAME(yuv2yuvX)(const int16_t *filter, int filterSize, + const int16_t **src, uint8_t *dest, int dstW, + const uint8_t *dither, int offset) +{ + dither_8to16(dither, offset); __asm__ volatile(\ - "lea " offset "(%0), %%"REG_d" \n\t"\ - "movq "DITHER32"+0(%0), %%mm4 \n\t"\ - "movq "DITHER32"+8(%0), %%mm5 \n\t"\ - "movq "DITHER32"+16(%0), %%mm6 \n\t"\ - "movq "DITHER32"+24(%0), %%mm7 \n\t"\ + "psraw $4, %%mm3\n\t" + "psraw $4, %%mm4\n\t" + "movq %%mm3, %%mm6\n\t" + "movq %%mm4, %%mm7\n\t" + "movl %3, %%ecx\n\t" + "mov %0, %%"REG_d" \n\t"\ "mov (%%"REG_d"), %%"REG_S" \n\t"\ - ".p2align 4 \n\t"\ + ".p2align 4 \n\t" /* FIXME Unroll? */\ "1: \n\t"\ - "movq (%%"REG_S", %3, 2), %%mm0 \n\t" /* srcData */\ - "movq 8(%%"REG_S", %3, 2), %%mm2 \n\t" /* srcData */\ - "mov "STR(APCK_PTR2)"(%%"REG_d"), %%"REG_S" \n\t"\ - "movq (%%"REG_S", %3, 2), %%mm1 \n\t" /* srcData */\ - "movq %%mm0, %%mm3 \n\t"\ - "punpcklwd %%mm1, %%mm0 \n\t"\ - "punpckhwd %%mm1, %%mm3 \n\t"\ - "movq "STR(APCK_COEF)"(%%"REG_d"), %%mm1 \n\t" /* filterCoeff */\ - "pmaddwd %%mm1, %%mm0 \n\t"\ - "pmaddwd %%mm1, %%mm3 \n\t"\ - "paddd %%mm0, %%mm4 \n\t"\ - "paddd %%mm3, %%mm5 \n\t"\ - "movq 8(%%"REG_S", %3, 2), %%mm3 \n\t" /* srcData */\ - "mov "STR(APCK_SIZE)"(%%"REG_d"), %%"REG_S" \n\t"\ - "add $"STR(APCK_SIZE)", %%"REG_d" \n\t"\ + "movq 8(%%"REG_d"), %%mm0 \n\t" /* filterCoeff */\ + "movq (%%"REG_S", %%"REG_c", 2), %%mm2 \n\t" /* srcData */\ + "movq 8(%%"REG_S", %%"REG_c", 2), %%mm5 \n\t" /* srcData */\ + "add $16, %%"REG_d" \n\t"\ + "mov (%%"REG_d"), %%"REG_S" \n\t"\ "test %%"REG_S", %%"REG_S" \n\t"\ - "movq %%mm2, %%mm0 \n\t"\ - "punpcklwd %%mm3, %%mm2 \n\t"\ - "punpckhwd %%mm3, %%mm0 \n\t"\ - "pmaddwd %%mm1, %%mm2 \n\t"\ - "pmaddwd %%mm1, %%mm0 \n\t"\ - "paddd %%mm2, %%mm6 \n\t"\ - "paddd %%mm0, %%mm7 \n\t"\ + "pmulhw %%mm0, %%mm2 \n\t"\ + "pmulhw %%mm0, %%mm5 \n\t"\ + "paddw %%mm2, %%mm3 \n\t"\ + "paddw %%mm5, %%mm4 \n\t"\ " jnz 1b \n\t"\ - "psrad $19, %%mm4 \n\t"\ - "psrad $19, %%mm5 \n\t"\ - "psrad $19, %%mm6 \n\t"\ - "psrad $19, %%mm7 \n\t"\ - "packssdw %%mm5, %%mm4 \n\t"\ - "packssdw %%mm7, %%mm6 \n\t"\ - "packuswb %%mm6, %%mm4 \n\t"\ - MOVNTQ(%%mm4, (%1, %3))\ - "add $8, %3 \n\t"\ - "cmp %2, %3 \n\t"\ - "lea " offset "(%0), %%"REG_d" \n\t"\ - "movq "DITHER32"+0(%0), %%mm4 \n\t"\ - "movq "DITHER32"+8(%0), %%mm5 \n\t"\ - "movq "DITHER32"+16(%0), %%mm6 \n\t"\ - "movq "DITHER32"+24(%0), %%mm7 \n\t"\ + "psraw $3, %%mm3 \n\t"\ + "psraw $3, %%mm4 \n\t"\ + "packuswb %%mm4, %%mm3 \n\t" + MOVNTQ2 " %%mm3, (%1, %%"REG_c")\n\t" + "add $8, %%"REG_c" \n\t"\ + "cmp %2, %%"REG_c" \n\t"\ + "movq %%mm6, %%mm3\n\t" + "movq %%mm7, %%mm4\n\t" + "mov %0, %%"REG_d" \n\t"\ "mov (%%"REG_d"), %%"REG_S" \n\t"\ "jb 1b \n\t"\ - :: "r" (&c->redDither),\ - "r" (dest), "g" ((x86_reg)(end)), "r"((x86_reg)(pos))\ - : "%"REG_a, "%"REG_d, "%"REG_S\ + :: "g" (filter), + "r" (dest-offset), "g" ((x86_reg)(dstW+offset)), "m" (offset) + : "%"REG_d, "%"REG_S, "%"REG_c ); - -#if !COMPILE_TEMPLATE_MMX2 -static av_always_inline void -dither_8to32(SwsContext *c, const uint8_t *srcDither, int rot) -{ - if (rot) { - __asm__ volatile("pxor %%mm0, %%mm0\n\t" - "movq (%0), %%mm4\n\t" - "movq %%mm4, %%mm5\n\t" - "psrlq $24, %%mm4\n\t" - "psllq $40, %%mm5\n\t" - "por %%mm5, %%mm4\n\t" - "movq %%mm4, %%mm6\n\t" - "punpcklbw %%mm0, %%mm4\n\t" - "punpckhbw %%mm0, %%mm6\n\t" - "movq %%mm4, %%mm5\n\t" - "movq %%mm6, %%mm7\n\t" - "punpcklwd %%mm0, %%mm4\n\t" - "punpckhwd %%mm0, %%mm5\n\t" - "punpcklwd %%mm0, %%mm6\n\t" - "punpckhwd %%mm0, %%mm7\n\t" - "pslld $12, %%mm4\n\t" - "pslld $12, %%mm5\n\t" - "pslld $12, %%mm6\n\t" - "pslld $12, %%mm7\n\t" - "movq %%mm4, "DITHER32"+0(%1)\n\t" - "movq %%mm5, "DITHER32"+8(%1)\n\t" - "movq %%mm6, "DITHER32"+16(%1)\n\t" - "movq %%mm7, "DITHER32"+24(%1)\n\t" - :: "r"(srcDither), "r"(&c->redDither) - ); - } else { - __asm__ volatile("pxor %%mm0, %%mm0\n\t" - "movq (%0), %%mm4\n\t" - "movq %%mm4, %%mm6\n\t" - "punpcklbw %%mm0, %%mm4\n\t" - "punpckhbw %%mm0, %%mm6\n\t" - "movq %%mm4, %%mm5\n\t" - "movq %%mm6, %%mm7\n\t" - "punpcklwd %%mm0, %%mm4\n\t" - "punpckhwd %%mm0, %%mm5\n\t" - "punpcklwd %%mm0, %%mm6\n\t" - "punpckhwd %%mm0, %%mm7\n\t" - "pslld $12, %%mm4\n\t" - "pslld $12, %%mm5\n\t" - "pslld $12, %%mm6\n\t" - "pslld $12, %%mm7\n\t" - "movq %%mm4, "DITHER32"+0(%1)\n\t" - "movq %%mm5, "DITHER32"+8(%1)\n\t" - "movq %%mm6, "DITHER32"+16(%1)\n\t" - "movq %%mm7, "DITHER32"+24(%1)\n\t" - :: "r"(srcDither), "r"(&c->redDither) - ); - } } -#endif -static void RENAME(yuv2yuvX_ar)(SwsContext *c, const int16_t *lumFilter, - const int16_t **lumSrc, int lumFilterSize, - const int16_t *chrFilter, const int16_t **chrUSrc, - const int16_t **chrVSrc, - int chrFilterSize, const int16_t **alpSrc, - uint8_t *dest[4], int dstW, int chrDstW) +static void RENAME(yuv2yuv1_ar)(const int16_t *src, uint8_t *dst, int dstW, const uint8_t *dither, int offset) { - uint8_t *yDest = dest[0], *uDest = dest[1], *vDest = dest[2], - *aDest = CONFIG_SWSCALE_ALPHA ? dest[3] : NULL; - const uint8_t *lumDither = c->lumDither8, *chrDither = c->chrDither8; - - if (uDest) { - x86_reg uv_off = c->uv_offx2 >> 1; - dither_8to32(c, chrDither, 0); - YSCALEYUV2YV12X_ACCURATE(CHR_MMX_FILTER_OFFSET, uDest, chrDstW, 0) - dither_8to32(c, chrDither, 1); - YSCALEYUV2YV12X_ACCURATE(CHR_MMX_FILTER_OFFSET, vDest - uv_off, chrDstW + uv_off, uv_off) - } - dither_8to32(c, lumDither, 0); - if (CONFIG_SWSCALE_ALPHA && aDest) { - YSCALEYUV2YV12X_ACCURATE(ALP_MMX_FILTER_OFFSET, aDest, dstW, 0) - } - - YSCALEYUV2YV12X_ACCURATE(LUM_MMX_FILTER_OFFSET, yDest, dstW, 0) -} - -static void RENAME(yuv2yuv1)(SwsContext *c, const int16_t *lumSrc, - const int16_t *chrUSrc, const int16_t *chrVSrc, - const int16_t *alpSrc, - uint8_t *dst[4], int dstW, int chrDstW) -{ - int p= 4; - const int16_t *src[4]= { - lumSrc + dstW, chrUSrc + chrDstW, - chrVSrc + chrDstW, alpSrc + dstW - }; - x86_reg counter[4]= { dstW, chrDstW, chrDstW, dstW }; - - while (p--) { - if (dst[p]) { - __asm__ volatile( - "mov %2, %%"REG_a" \n\t" - ".p2align 4 \n\t" /* FIXME Unroll? */ - "1: \n\t" - "movq (%0, %%"REG_a", 2), %%mm0 \n\t" - "movq 8(%0, %%"REG_a", 2), %%mm1 \n\t" - "psraw $7, %%mm0 \n\t" - "psraw $7, %%mm1 \n\t" - "packuswb %%mm1, %%mm0 \n\t" - MOVNTQ(%%mm0, (%1, %%REGa)) - "add $8, %%"REG_a" \n\t" - "jnc 1b \n\t" - :: "r" (src[p]), "r" (dst[p] + counter[p]), - "g" (-counter[p]) - : "%"REG_a - ); - } - } -} - -static void RENAME(yuv2yuv1_ar)(SwsContext *c, const int16_t *lumSrc, - const int16_t *chrUSrc, const int16_t *chrVSrc, - const int16_t *alpSrc, - uint8_t *dst[4], int dstW, int chrDstW) -{ - int p= 4; - const int16_t *src[4]= { - lumSrc + dstW, chrUSrc + chrDstW, - chrVSrc + chrDstW, alpSrc + dstW - }; - x86_reg counter[4]= { dstW, chrDstW, chrDstW, dstW }; - const uint8_t *lumDither = c->lumDither8, *chrDither = c->chrDither8; - - while (p--) { - if (dst[p]) { - int i; - for(i=0; i<8; i++) c->dither16[i] = (p == 2 || p == 3) ? lumDither[i] : chrDither[i]; - __asm__ volatile( - "mov %2, %%"REG_a" \n\t" - "movq "DITHER16"+0(%3), %%mm6 \n\t" - "movq "DITHER16"+8(%3), %%mm7 \n\t" - ".p2align 4 \n\t" /* FIXME Unroll? */ - "1: \n\t" - "movq (%0, %%"REG_a", 2), %%mm0 \n\t" - "movq 8(%0, %%"REG_a", 2), %%mm1 \n\t" - "paddsw %%mm6, %%mm0 \n\t" - "paddsw %%mm7, %%mm1 \n\t" - "psraw $7, %%mm0 \n\t" - "psraw $7, %%mm1 \n\t" - "packuswb %%mm1, %%mm0 \n\t" - MOVNTQ(%%mm0, (%1, %%REGa)) - "add $8, %%"REG_a" \n\t" - "jnc 1b \n\t" - :: "r" (src[p]), "r" (dst[p] + counter[p]), - "g" (-counter[p]), "r"(&c->redDither) - : "%"REG_a - ); - } - } + dither_8to16(dither, offset); + __asm__ volatile( + "mov %2, %%"REG_a" \n\t" + ".p2align 4 \n\t" /* FIXME Unroll? */ + "1: \n\t" + "movq (%0, %%"REG_a", 2), %%mm0 \n\t" + "movq 8(%0, %%"REG_a", 2), %%mm1 \n\t" + "paddsw %%mm3, %%mm0 \n\t" + "paddsw %%mm4, %%mm1 \n\t" + "psraw $7, %%mm0 \n\t" + "psraw $7, %%mm1 \n\t" + "packuswb %%mm1, %%mm0 \n\t" + MOVNTQ(%%mm0, (%1, %%REGa)) + "add $8, %%"REG_a" \n\t" + "jnc 1b \n\t" + :: "r" (src + dstW), "r" (dst + dstW), + "g" ((x86_reg)-dstW) + : "%"REG_a + ); } #define YSCALEYUV2PACKEDX_UV \ @@ -1674,7 +1461,7 @@ #if !COMPILE_TEMPLATE_MMX2 //FIXME yuy2* can read up to 7 samples too much -static void RENAME(yuy2ToY)(uint8_t *dst, const uint8_t *src, +static void RENAME(yuy2ToY)(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused) { __asm__ volatile( @@ -1695,7 +1482,7 @@ } static void RENAME(yuy2ToUV)(uint8_t *dstU, uint8_t *dstV, - const uint8_t *src1, const uint8_t *src2, + const uint8_t *unused1, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *unused) { __asm__ volatile( @@ -1724,7 +1511,7 @@ /* This is almost identical to the previous, end exists only because * yuy2ToY/UV)(dst, src+1, ...) would have 100% unaligned accesses. */ -static void RENAME(uyvyToY)(uint8_t *dst, const uint8_t *src, +static void RENAME(uyvyToY)(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused) { __asm__ volatile( @@ -1744,7 +1531,7 @@ } static void RENAME(uyvyToUV)(uint8_t *dstU, uint8_t *dstV, - const uint8_t *src1, const uint8_t *src2, + const uint8_t *unused1, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *unused) { __asm__ volatile( @@ -1798,14 +1585,14 @@ } static void RENAME(nv12ToUV)(uint8_t *dstU, uint8_t *dstV, - const uint8_t *src1, const uint8_t *src2, + const uint8_t *unused1, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *unused) { RENAME(nvXXtoUV)(dstU, dstV, src1, width); } static void RENAME(nv21ToUV)(uint8_t *dstU, uint8_t *dstV, - const uint8_t *src1, const uint8_t *src2, + const uint8_t *unused1, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *unused) { RENAME(nvXXtoUV)(dstV, dstU, src1, width); @@ -1865,13 +1652,13 @@ ); } -static void RENAME(bgr24ToY)(int16_t *dst, const uint8_t *src, +static void RENAME(bgr24ToY)(int16_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused) { RENAME(bgr24ToY_mmx)(dst, src, width, PIX_FMT_BGR24); } -static void RENAME(rgb24ToY)(int16_t *dst, const uint8_t *src, +static void RENAME(rgb24ToY)(int16_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2, int width, uint32_t *unused) { RENAME(bgr24ToY_mmx)(dst, src, width, PIX_FMT_RGB24); @@ -1936,7 +1723,7 @@ } static void RENAME(bgr24ToUV)(int16_t *dstU, int16_t *dstV, - const uint8_t *src1, const uint8_t *src2, + const uint8_t *unused1, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *unused) { RENAME(bgr24ToUV_mmx)(dstU, dstV, src1, width, PIX_FMT_BGR24); @@ -1944,7 +1731,7 @@ } static void RENAME(rgb24ToUV)(int16_t *dstU, int16_t *dstV, - const uint8_t *src1, const uint8_t *src2, + const uint8_t *unused1, const uint8_t *src1, const uint8_t *src2, int width, uint32_t *unused) { assert(src1==src2); @@ -2091,12 +1878,12 @@ { enum PixelFormat srcFormat = c->srcFormat, dstFormat = c->dstFormat; - + c->use_mmx_vfilter= 0; if (!is16BPS(dstFormat) && !is9_OR_10BPS(dstFormat) && dstFormat != PIX_FMT_NV12 && dstFormat != PIX_FMT_NV21 && !(c->flags & SWS_BITEXACT)) { + c->yuv2plane1 = RENAME(yuv2yuv1_ar ); if (c->flags & SWS_ACCURATE_RND) { - c->yuv2yuv1 = RENAME(yuv2yuv1_ar ); - c->yuv2yuvX = RENAME(yuv2yuvX_ar ); + //c->yuv2yuv1 = RENAME(yuv2yuv1_ar ); if (!(c->flags & SWS_FULL_CHR_H_INT)) { switch (c->dstFormat) { case PIX_FMT_RGB32: c->yuv2packedX = RENAME(yuv2rgb32_X_ar); break; @@ -2109,8 +1896,9 @@ } } else { int should_dither= isNBPS(c->srcFormat) || is16BPS(c->srcFormat); - c->yuv2yuv1 = should_dither ? RENAME(yuv2yuv1_ar ) : RENAME(yuv2yuv1 ); - c->yuv2yuvX = RENAME(yuv2yuvX ); + //c->yuv2plane1 = should_dither ? RENAME(yuv2yuv1_ar ) : RENAME(yuv2yuv1 ); + c->use_mmx_vfilter= 1; + c->yuv2planeX = RENAME(yuv2yuvX ); if (!(c->flags & SWS_FULL_CHR_H_INT)) { switch (c->dstFormat) { case PIX_FMT_RGB32: c->yuv2packedX = RENAME(yuv2rgb32_X); break; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libswscale/yuv2rgb.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libswscale/yuv2rgb.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/libswscale/yuv2rgb.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/libswscale/yuv2rgb.c 2011-11-04 12:38:27.000000000 +0000 @@ -790,8 +790,8 @@ y_table32 = c->yuvTable; yb = -(384<<16) - oy; for (i = 0; i < 1024; i++) { - uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16); - y_table32[i ] = (yval << rbase) + (needAlpha ? 0 : (255 << abase)); + unsigned yval = av_clip_uint8((yb + 0x8000) >> 16); + y_table32[i ] = (yval << rbase) + (needAlpha ? 0 : (255u << abase)); y_table32[i+1024] = yval << gbase; y_table32[i+2048] = yval << bbase; yb += cy; diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/MAINTAINERS ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/MAINTAINERS --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/MAINTAINERS 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/MAINTAINERS 2011-11-04 12:38:26.000000000 +0000 @@ -40,11 +40,11 @@ documentation Mike Melanson website Robert Swain build system (configure,Makefiles) Diego Biurrun, Mans Rullgard -project server Diego Biurrun, Mans Rullgard -mailinglists Michael Niedermayer, Baptiste Coudurier +project server Árpád Gereöffy, Michael Niedermayer, Reimar Döffinger +mailinglists Michael Niedermayer, Baptiste Coudurier, Lou Logan presets Robert Swain metadata subsystem Aurelien Jacobs -release management Diego Biurrun, Reinhard Tartler +release management Michael Niedermayer libavutil @@ -235,7 +235,9 @@ Hardware acceleration: crystalhd.c Philip Langdale dxva2* Laurent Aimar + libstagefright.cpp Mohamed Naufal vaapi* Gwenole Beauchesne + vda* Sebastien Zwickert vdpau* Carl Eugen Hoyos diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/Makefile ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/Makefile --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/Makefile 2011-10-07 14:04:25.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/Makefile 2011-11-04 12:38:26.000000000 +0000 @@ -38,7 +38,7 @@ FFLIBS := avutil -DATA_FILES := $(wildcard $(SRC_PATH)/ffpresets/*.ffpreset) +DATA_FILES := $(wildcard $(SRC_PATH)/presets/*.ffpreset) SKIPHEADERS = cmdutils_common_opts.h diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/presets/libvpx-1080p50_60.ffpreset ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/presets/libvpx-1080p50_60.ffpreset --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/presets/libvpx-1080p50_60.ffpreset 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/presets/libvpx-1080p50_60.ffpreset 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,17 @@ +g=120 +lag-in-frames=25 +deadline=good +cpu-used=0 +vprofile=1 +qmax=51 +qmin=11 +slices=4 +b=2M + +#ignored unless using -pass 2 +maxrate=24M +minrate=100k +auto-alt-ref=1 +arnr-maxframes=7 +arnr-strength=5 +arnr-type=centered diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/presets/libvpx-1080p.ffpreset ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/presets/libvpx-1080p.ffpreset --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/presets/libvpx-1080p.ffpreset 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/presets/libvpx-1080p.ffpreset 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,17 @@ +g=120 +lag-in-frames=16 +deadline=good +cpu-used=0 +vprofile=1 +qmax=51 +qmin=11 +slices=4 +b=2M + +#ignored unless using -pass 2 +maxrate=24M +minrate=100k +auto-alt-ref=1 +arnr-maxframes=7 +arnr-strength=5 +arnr-type=centered diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/presets/libvpx-360p.ffpreset ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/presets/libvpx-360p.ffpreset --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/presets/libvpx-360p.ffpreset 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/presets/libvpx-360p.ffpreset 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,16 @@ +g=120 +lag-in-frames=16 +deadline=good +cpu-used=0 +vprofile=0 +qmax=63 +qmin=0 +b=768k + +#ignored unless using -pass 2 +maxrate=1.5M +minrate=40k +auto-alt-ref=1 +arnr-maxframes=7 +arnr-strength=5 +arnr-type=centered diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/presets/libvpx-720p50_60.ffpreset ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/presets/libvpx-720p50_60.ffpreset --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/presets/libvpx-720p50_60.ffpreset 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/presets/libvpx-720p50_60.ffpreset 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,17 @@ +g=120 +lag-in-frames=25 +deadline=good +cpu-used=0 +vprofile=0 +qmax=51 +qmin=11 +slices=4 +b=2M + +#ignored unless using -pass 2 +maxrate=24M +minrate=100k +auto-alt-ref=1 +arnr-maxframes=7 +arnr-strength=5 +arnr-type=centered diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/presets/libvpx-720p.ffpreset ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/presets/libvpx-720p.ffpreset --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/presets/libvpx-720p.ffpreset 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/presets/libvpx-720p.ffpreset 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,17 @@ +g=120 +lag-in-frames=16 +deadline=good +cpu-used=0 +vprofile=0 +qmax=51 +qmin=11 +slices=4 +b=2M + +#ignored unless using -pass 2 +maxrate=24M +minrate=100k +auto-alt-ref=1 +arnr-maxframes=7 +arnr-strength=5 +arnr-type=centered diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/presets/libx264-ipod320.ffpreset ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/presets/libx264-ipod320.ffpreset --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/presets/libx264-ipod320.ffpreset 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/presets/libx264-ipod320.ffpreset 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,4 @@ +vprofile=baseline +level=13 +maxrate=768000 +bufsize=3000000 diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/presets/libx264-ipod640.ffpreset ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/presets/libx264-ipod640.ffpreset --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/presets/libx264-ipod640.ffpreset 1970-01-01 00:00:00.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/presets/libx264-ipod640.ffpreset 2011-11-04 12:38:27.000000000 +0000 @@ -0,0 +1,4 @@ +vprofile=baseline +level=30 +maxrate=10000000 +bufsize=10000000 diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/subdir.mak ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/subdir.mak --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/subdir.mak 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/subdir.mak 2011-11-04 12:38:27.000000000 +0000 @@ -20,7 +20,7 @@ $(YASMDEP) $(YASMFLAGS) -I $( $(@:.o=.d) $(YASM) $(YASMFLAGS) -I $( + +#include "libavformat/avformat.h" +#include "libavcodec/avcodec.h" +#include "libavutil/log.h" +#include "libavutil/opt.h" + +static void print_usage(void) +{ + fprintf(stderr, "Usage: enum_options type\n" + "type: format codec\n"); + exit(1); +} + +static void print_option(const AVClass *class, const AVOption *o) +{ + printf("@item -%s @var{", o->name); + switch (o->type) { + case FF_OPT_TYPE_BINARY: printf("hexadecimal string"); break; + case FF_OPT_TYPE_STRING: printf("string"); break; + case FF_OPT_TYPE_INT: + case FF_OPT_TYPE_INT64: printf("integer"); break; + case FF_OPT_TYPE_FLOAT: + case FF_OPT_TYPE_DOUBLE: printf("float"); break; + case FF_OPT_TYPE_RATIONAL: printf("rational number"); break; + case FF_OPT_TYPE_FLAGS: printf("flags"); break; + default: printf("value"); break; + } + printf("} (@emph{"); + + if (o->flags & AV_OPT_FLAG_ENCODING_PARAM) { + printf("input"); + if (o->flags & AV_OPT_FLAG_ENCODING_PARAM) + printf("/"); + } + if (o->flags & AV_OPT_FLAG_ENCODING_PARAM) + printf("output"); + + printf("})\n"); + if (o->help) + printf("%s\n", o->help); + + if (o->unit) { + const AVOption *u = NULL; + printf("\nPossible values:\n@table @samp\n"); + + while ((u = av_next_option(&class, u))) + if (u->type == FF_OPT_TYPE_CONST && u->unit && !strcmp(u->unit, o->unit)) + printf("@item %s\n%s\n", u->name, u->help ? u->help : ""); + printf("@end table\n"); + } +} + +static void show_opts(const AVClass *class) +{ + const AVOption *o = NULL; + + printf("@table @option\n"); + while ((o = av_next_option(&class, o))) + if (o->type != FF_OPT_TYPE_CONST) + print_option(class, o); + printf("@end table\n"); +} + +static void show_format_opts(void) +{ + AVInputFormat *iformat = NULL; + AVOutputFormat *oformat = NULL; + + printf("@section Generic format AVOptions\n"); + show_opts(avformat_get_class()); + + printf("@section Format-specific AVOptions\n"); + while ((iformat = av_iformat_next(iformat))) { + if (!iformat->priv_class) + continue; + printf("@subsection %s AVOptions\n", iformat->priv_class->class_name); + show_opts(iformat->priv_class); + } + while ((oformat = av_oformat_next(oformat))) { + if (!oformat->priv_class) + continue; + printf("@subsection %s AVOptions\n", oformat->priv_class->class_name); + show_opts(oformat->priv_class); + } +} + +static void show_codec_opts(void) +{ + AVCodec *c = NULL; + + printf("@section Generic codec AVOptions\n"); + show_opts(avcodec_get_class()); + + printf("@section Codec-specific AVOptions\n"); + while ((c = av_codec_next(c))) { + if (!c->priv_class) + continue; + printf("@subsection %s AVOptions\n", c->priv_class->class_name); + show_opts(c->priv_class); + } +} + +int main(int argc, char **argv) +{ + if (argc < 2) + print_usage(); + + av_register_all(); + + if (!strcmp(argv[1], "format")) + show_format_opts(); + else if (!strcmp(argv[1], "codec")) + show_codec_opts(); + else + print_usage(); + + return 0; +} diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/tools/pktdumper.c ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/tools/pktdumper.c --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/ffmpeg/tools/pktdumper.c 2011-10-07 14:04:26.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/ffmpeg/tools/pktdumper.c 2011-11-04 12:38:27.000000000 +0000 @@ -44,7 +44,7 @@ { char fntemplate[PATH_MAX]; char pktfilename[PATH_MAX]; - AVFormatContext *fctx; + AVFormatContext *fctx = NULL; AVPacket pkt; int64_t pktnum = 0; int64_t maxpkts = 0; @@ -83,9 +83,9 @@ // register all file formats av_register_all(); - err = av_open_input_file(&fctx, argv[1], NULL, 0, NULL); + err = avformat_open_input(&fctx, argv[1], NULL, NULL); if (err < 0) { - fprintf(stderr, "av_open_input_file: error %d\n", err); + fprintf(stderr, "cannot open input: error %d\n", err); return 1; } diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/SConstruct ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/SConstruct --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/SConstruct 2011-10-07 14:01:07.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/SConstruct 2011-11-04 12:34:39.000000000 +0000 @@ -5,14 +5,13 @@ import SCons -def svnversion(): +def version(): f = os.popen("./version.sh") version = f.read().strip() f.close() return version -pkg_version="0.28" -pkg_version +="+svn" + svnversion() +pkg_version=version() pkg_name="ffmpeg2theora" diff -Nru ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/version.sh ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/version.sh --- ffmpeg2theora-0.28~ppa2+503+30387+3~oneiric1/version.sh 2011-10-07 14:01:07.000000000 +0000 +++ ffmpeg2theora-0.28~ppa2+506+30862+3~oneiric1/version.sh 2011-11-04 12:34:39.000000000 +0000 @@ -1,2 +1,11 @@ +#!/bin/bash cd `dirname $0` -svnversion +version='0.28' +test -e .svn && svnversion=`which svnversion` +echo -n $version +if [ "x$svnversion" != "x" ]; then + echo -n "+svn" + svnversion +else + echo +fi