History

Merge remote branch 'qatar/master'

* qatar/master: avio: add more documentation for AVIOContext. Parse sprite data for WMVP and WVP2, and decode sprites for the latter Replace outdated info on the FAQ Redefine sameq pad: fix example explanation gradfun: add notice from the MPlayer manual eval: add support for trunc, ceil, and floor functions documentation: add setdar and setsar description to filters.texi avio: document some members of AVIOContext. avio: document avio_close(). avio: cosmetics, vertically align comments. avio: cosmetics, group the reading functions. avio: cosmetics, merge all the FF_API_OLD_AVIO blocks. avio: cosmetics, move AVIOContext to start of the file. avio: update file header. os: fix OpenBSD/PowerPC compilation pixfmt: add PIX_FMT_BGR48LE and PIX_FMT_BGR48BE oggdec: fix demuxing chained audio streams fix typo Conflicts: doc/filters.texi libavformat/avio.h libavutil/pixfmt.h

Michael Niedermayer committed 15 years ago

Commit ab8cfd42 parents 2e92a34 d1c5fdf10 files · +315 −164Browse files

Showing the changes to libavcodec (4 of 10 files). Show all

Unified · Split

4 files
  1. libavcodec/vc1.c +0 −3
  2. libavcodec/vc1.h +6 −0
  3. libavcodec/vc1dec.c +124 −3
  4. libavcodec/version.h +1 −1
libavcodec/vc1.c+0−3
@@ -605,9 +605,6 @@ int vc1_parse_frame_header(VC1Context *v, GetBitContext* gb) · 604 unmodified lines
605605 {
606606 int pqindex, lowquant, status;
607607
608− if(v->res_sprite) {
609− skip_bits(gb, 2); //not yet deciphered
610− }
611608 if(v->finterpflag) v->interpfrm = get_bits1(gb);
612609 skip_bits(gb, 2); //framecnt unused
613610 v->rangeredfrm = 0;
libavcodec/vc1.h+6−0
@@ -306,6 +306,12 @@ typedef struct VC1Context{ · 305 unmodified lines
306306 uint8_t range_mapuv;
307307 //@}
308308
309+ /** Frame decoding info for sprite modes */
310+ //@{
311+ int new_sprite;
312+ int two_sprites;
313+ //@}
314+
309315 int p_frame_skipped;
310316 int bi_type;
311317 int x8_type;
libavcodec/vc1dec.c+124−3
@@ -3097,6 +3097,116 @@ static void vc1_decode_blocks(VC1Context *v, int mby_start, int mby_end) · 3096 unmodified lines
30973097 }
30983098 }
30993099
3100+static inline float get_float_val(GetBitContext* gb)
3101+{
3102+ return (float)get_bits_long(gb, 30) / (1<<15) - (1<<14);
3103+}
3104+
3105+static void vc1_sprite_parse_transform(VC1Context *v, GetBitContext* gb, float c[7])
3106+{
3107+ c[1] = c[3] = 0.0f;
3108+
3109+ switch (get_bits(gb, 2)) {
3110+ case 0:
3111+ c[0] = 1.0f;
3112+ c[2] = get_float_val(gb);
3113+ c[4] = 1.0f;
3114+ break;
3115+ case 1:
3116+ c[0] = c[4] = get_float_val(gb);
3117+ c[2] = get_float_val(gb);
3118+ break;
3119+ case 2:
3120+ c[0] = get_float_val(gb);
3121+ c[2] = get_float_val(gb);
3122+ c[4] = get_float_val(gb);
3123+ break;
3124+ case 3:
3125+ av_log_ask_for_sample(v->s.avctx, NULL);
3126+ c[0] = get_float_val(gb);
3127+ c[1] = get_float_val(gb);
3128+ c[2] = get_float_val(gb);
3129+ c[3] = get_float_val(gb);
3130+ c[4] = get_float_val(gb);
3131+ break;
3132+ }
3133+ c[5] = get_float_val(gb);
3134+ if (get_bits1(gb))
3135+ c[6] = get_float_val(gb);
3136+ else
3137+ c[6] = 1.0f;
3138+}
3139+
3140+static void vc1_parse_sprites(VC1Context *v, GetBitContext* gb)
3141+{
3142+ int effect_type, effect_flag, effect_pcount1, effect_pcount2, i;
3143+ float effect_params1[14], effect_params2[10];
3144+
3145+ float coefs[2][7];
3146+ vc1_sprite_parse_transform(v, gb, coefs[0]);
3147+ av_log(v->s.avctx, AV_LOG_DEBUG, "S1:");
3148+ for (i = 0; i < 7; i++)
3149+ av_log(v->s.avctx, AV_LOG_DEBUG, " %.3f", coefs[0][i]);
3150+ av_log(v->s.avctx, AV_LOG_DEBUG, "\n");
3151+
3152+ if (v->two_sprites) {
3153+ vc1_sprite_parse_transform(v, gb, coefs[1]);
3154+ av_log(v->s.avctx, AV_LOG_DEBUG, "S2:");
3155+ for (i = 0; i < 7; i++)
3156+ av_log(v->s.avctx, AV_LOG_DEBUG, " %.3f", coefs[1][i]);
3157+ av_log(v->s.avctx, AV_LOG_DEBUG, "\n");
3158+ }
3159+ skip_bits(gb, 2);
3160+ if (effect_type = get_bits_long(gb, 30)){
3161+ switch (effect_pcount1 = get_bits(gb, 4)) {
3162+ case 2:
3163+ effect_params1[0] = get_float_val(gb);
3164+ effect_params1[1] = get_float_val(gb);
3165+ break;
3166+ case 7:
3167+ vc1_sprite_parse_transform(v, gb, effect_params1);
3168+ break;
3169+ case 14:
3170+ vc1_sprite_parse_transform(v, gb, effect_params1);
3171+ vc1_sprite_parse_transform(v, gb, &effect_params1[7]);
3172+ break;
3173+ default:
3174+ av_log_ask_for_sample(v->s.avctx, NULL);
3175+ return;
3176+ }
3177+ if (effect_type != 13 || effect_params1[0] != coefs[0][6]) {
3178+ // effect 13 is simple alpha blending and matches the opacity above
3179+ av_log(v->s.avctx, AV_LOG_DEBUG, "Effect: %d; params: ", effect_type);
3180+ for (i = 0; i < effect_pcount1; i++)
3181+ av_log(v->s.avctx, AV_LOG_DEBUG, " %.3f", effect_params1[i]);
3182+ av_log(v->s.avctx, AV_LOG_DEBUG, "\n");
3183+ }
3184+
3185+ effect_pcount2 = get_bits(gb, 16);
3186+ if (effect_pcount2 > 10) {
3187+ av_log(v->s.avctx, AV_LOG_ERROR, "Too many effect parameters\n");
3188+ return;
3189+ } else if (effect_pcount2) {
3190+ i = 0;
3191+ av_log(v->s.avctx, AV_LOG_DEBUG, "Effect params 2: ");
3192+ while (i < effect_pcount2){
3193+ effect_params2[i] = get_float_val(gb);
3194+ av_log(v->s.avctx, AV_LOG_DEBUG, " %.3f", effect_params2[i]);
3195+ i++;
3196+ }
3197+ av_log(v->s.avctx, AV_LOG_DEBUG, "\n");
3198+ }
3199+ }
3200+ if (effect_flag = get_bits1(gb))
3201+ av_log(v->s.avctx, AV_LOG_DEBUG, "Effect flag set\n");
3202+
3203+ if (get_bits_count(gb) >= gb->size_in_bits +
3204+ (v->s.avctx->codec_id == CODEC_ID_WMV3 ? 64 : 0))
3205+ av_log(v->s.avctx, AV_LOG_ERROR, "Buffer overrun\n");
3206+ if (get_bits_count(gb) < gb->size_in_bits - 8)
3207+ av_log(v->s.avctx, AV_LOG_WARNING, "Buffer not fully read\n");
3208+}
3209+
31003210 /** Initialize a VC1/WMV3 decoder
31013211 * @todo TODO: Handle VC-1 IDUs (Transport level?)
31023212 * @todo TODO: Decypher remaining bits in extra_data
@@ -3160,7 +3270,7 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx) · 57 unmodified lines
31603270 {
31613271 av_log(avctx, AV_LOG_INFO, "Read %i bits in overflow\n", -count);
31623272 }
3163− } else { // VC1/WVC1
3273+ } else { // VC1/WVC1/WVP2
31643274 const uint8_t *start = avctx->extradata;
31653275 uint8_t *end = avctx->extradata + avctx->extradata_size;
31663276 const uint8_t *next;
@@ -3204,6 +3314,7 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx) · 37 unmodified lines
32043314 av_log(avctx, AV_LOG_ERROR, "Incomplete extradata\n");
32053315 return -1;
32063316 }
3317+ v->res_sprite = (avctx->codec_tag == MKTAG('W','V','P','2'));
32073318 }
32083319 avctx->profile = v->profile;
32093320 if (v->profile == PROFILE_ADVANCED)
@@ -3359,6 +3470,14 @@ static int vc1_decode_frame(AVCodecContext *avctx, · 149 unmodified lines
33593470 init_get_bits(&s->gb, buf2, buf_size2*8);
33603471 } else
33613472 init_get_bits(&s->gb, buf, buf_size*8);
3473+
3474+ if (v->res_sprite) {
3475+ v->new_sprite = !get_bits1(&s->gb);
3476+ v->two_sprites = get_bits1(&s->gb);
3477+ if (!v->new_sprite)
3478+ goto end;
3479+ }
3480+
33623481 // do parse frame header
33633482 if(v->profile < PROFILE_ADVANCED) {
33643483 if(vc1_parse_frame_header(v, &s->gb) == -1) {
@@ -3370,8 +3489,8 @@ static int vc1_decode_frame(AVCodecContext *avctx, · 5 unmodified lines
33703489 }
33713490 }
33723491
3373− if(v->res_sprite && (s->pict_type!=FF_I_TYPE)){
3374− goto err;
3492+ if (v->res_sprite && s->pict_type!=FF_I_TYPE) {
3493+ av_log(v->s.avctx, AV_LOG_WARNING, "Sprite decoder: expected I-frame\n");
33753494 }
33763495
33773496 s->current_picture_ptr->repeat_pict = 0;
@@ -3464,6 +3583,8 @@ assert(s->current_picture.pict_type == s->pict_type); · 86 unmodified lines
34643583 }
34653584
34663585 end:
3586+ if (v->res_sprite)
3587+ vc1_parse_sprites(v, &s->gb);
34673588 av_free(buf2);
34683589 for (i = 0; i < n_slices; i++)
34693590 av_free(slices[i].buf);
libavcodec/version.h+1−1
@@ -22,7 +22,7 @@ · 21 unmodified lines
2222
2323 #define LIBAVCODEC_VERSION_MAJOR 52
2424 #define LIBAVCODEC_VERSION_MINOR 117
25−#define LIBAVCODEC_VERSION_MICRO 0
25+#define LIBAVCODEC_VERSION_MICRO 1
2626
2727 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
2828 LIBAVCODEC_VERSION_MINOR, \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t