Commit ab8cfd45 authored by Michael Niedermayer's avatar Michael Niedermayer

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
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 2e92a34c d1c5fdf8
......@@ -12,6 +12,9 @@ libavutil: 2009-03-08
API changes, most recent first:
2011-04-10 - lavu 50.40.0 - pixfmt.h
Add PIX_FMT_BGR48LE and PIX_FMT_BGR48BE pixel formats
2011-04-08 - lavf 52.106.0 - avformat.h
Minor avformat.h cleanup:
a9bf9d8 deprecate av_guess_image2_codec
......
......@@ -605,9 +605,6 @@ int vc1_parse_frame_header(VC1Context *v, GetBitContext* gb)
{
int pqindex, lowquant, status;
if(v->res_sprite) {
skip_bits(gb, 2); //not yet deciphered
}
if(v->finterpflag) v->interpfrm = get_bits1(gb);
skip_bits(gb, 2); //framecnt unused
v->rangeredfrm = 0;
......
......@@ -306,6 +306,12 @@ typedef struct VC1Context{
uint8_t range_mapuv;
//@}
/** Frame decoding info for sprite modes */
//@{
int new_sprite;
int two_sprites;
//@}
int p_frame_skipped;
int bi_type;
int x8_type;
......
......@@ -3097,6 +3097,116 @@ static void vc1_decode_blocks(VC1Context *v, int mby_start, int mby_end)
}
}
static inline float get_float_val(GetBitContext* gb)
{
return (float)get_bits_long(gb, 30) / (1<<15) - (1<<14);
}
static void vc1_sprite_parse_transform(VC1Context *v, GetBitContext* gb, float c[7])
{
c[1] = c[3] = 0.0f;
switch (get_bits(gb, 2)) {
case 0:
c[0] = 1.0f;
c[2] = get_float_val(gb);
c[4] = 1.0f;
break;
case 1:
c[0] = c[4] = get_float_val(gb);
c[2] = get_float_val(gb);
break;
case 2:
c[0] = get_float_val(gb);
c[2] = get_float_val(gb);
c[4] = get_float_val(gb);
break;
case 3:
av_log_ask_for_sample(v->s.avctx, NULL);
c[0] = get_float_val(gb);
c[1] = get_float_val(gb);
c[2] = get_float_val(gb);
c[3] = get_float_val(gb);
c[4] = get_float_val(gb);
break;
}
c[5] = get_float_val(gb);
if (get_bits1(gb))
c[6] = get_float_val(gb);
else
c[6] = 1.0f;
}
static void vc1_parse_sprites(VC1Context *v, GetBitContext* gb)
{
int effect_type, effect_flag, effect_pcount1, effect_pcount2, i;
float effect_params1[14], effect_params2[10];
float coefs[2][7];
vc1_sprite_parse_transform(v, gb, coefs[0]);
av_log(v->s.avctx, AV_LOG_DEBUG, "S1:");
for (i = 0; i < 7; i++)
av_log(v->s.avctx, AV_LOG_DEBUG, " %.3f", coefs[0][i]);
av_log(v->s.avctx, AV_LOG_DEBUG, "\n");
if (v->two_sprites) {
vc1_sprite_parse_transform(v, gb, coefs[1]);
av_log(v->s.avctx, AV_LOG_DEBUG, "S2:");
for (i = 0; i < 7; i++)
av_log(v->s.avctx, AV_LOG_DEBUG, " %.3f", coefs[1][i]);
av_log(v->s.avctx, AV_LOG_DEBUG, "\n");
}
skip_bits(gb, 2);
if (effect_type = get_bits_long(gb, 30)){
switch (effect_pcount1 = get_bits(gb, 4)) {
case 2:
effect_params1[0] = get_float_val(gb);
effect_params1[1] = get_float_val(gb);
break;
case 7:
vc1_sprite_parse_transform(v, gb, effect_params1);
break;
case 14:
vc1_sprite_parse_transform(v, gb, effect_params1);
vc1_sprite_parse_transform(v, gb, &effect_params1[7]);
break;
default:
av_log_ask_for_sample(v->s.avctx, NULL);
return;
}
if (effect_type != 13 || effect_params1[0] != coefs[0][6]) {
// effect 13 is simple alpha blending and matches the opacity above
av_log(v->s.avctx, AV_LOG_DEBUG, "Effect: %d; params: ", effect_type);
for (i = 0; i < effect_pcount1; i++)
av_log(v->s.avctx, AV_LOG_DEBUG, " %.3f", effect_params1[i]);
av_log(v->s.avctx, AV_LOG_DEBUG, "\n");
}
effect_pcount2 = get_bits(gb, 16);
if (effect_pcount2 > 10) {
av_log(v->s.avctx, AV_LOG_ERROR, "Too many effect parameters\n");
return;
} else if (effect_pcount2) {
i = 0;
av_log(v->s.avctx, AV_LOG_DEBUG, "Effect params 2: ");
while (i < effect_pcount2){
effect_params2[i] = get_float_val(gb);
av_log(v->s.avctx, AV_LOG_DEBUG, " %.3f", effect_params2[i]);
i++;
}
av_log(v->s.avctx, AV_LOG_DEBUG, "\n");
}
}
if (effect_flag = get_bits1(gb))
av_log(v->s.avctx, AV_LOG_DEBUG, "Effect flag set\n");
if (get_bits_count(gb) >= gb->size_in_bits +
(v->s.avctx->codec_id == CODEC_ID_WMV3 ? 64 : 0))
av_log(v->s.avctx, AV_LOG_ERROR, "Buffer overrun\n");
if (get_bits_count(gb) < gb->size_in_bits - 8)
av_log(v->s.avctx, AV_LOG_WARNING, "Buffer not fully read\n");
}
/** Initialize a VC1/WMV3 decoder
* @todo TODO: Handle VC-1 IDUs (Transport level?)
* @todo TODO: Decypher remaining bits in extra_data
......@@ -3160,7 +3270,7 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx)
{
av_log(avctx, AV_LOG_INFO, "Read %i bits in overflow\n", -count);
}
} else { // VC1/WVC1
} else { // VC1/WVC1/WVP2
const uint8_t *start = avctx->extradata;
uint8_t *end = avctx->extradata + avctx->extradata_size;
const uint8_t *next;
......@@ -3204,6 +3314,7 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx)
av_log(avctx, AV_LOG_ERROR, "Incomplete extradata\n");
return -1;
}
v->res_sprite = (avctx->codec_tag == MKTAG('W','V','P','2'));
}
avctx->profile = v->profile;
if (v->profile == PROFILE_ADVANCED)
......@@ -3359,6 +3470,14 @@ static int vc1_decode_frame(AVCodecContext *avctx,
init_get_bits(&s->gb, buf2, buf_size2*8);
} else
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);
if (!v->new_sprite)
goto end;
}
// do parse frame header
if(v->profile < PROFILE_ADVANCED) {
if(vc1_parse_frame_header(v, &s->gb) == -1) {
......@@ -3370,8 +3489,8 @@ static int vc1_decode_frame(AVCodecContext *avctx,
}
}
if(v->res_sprite && (s->pict_type!=FF_I_TYPE)){
goto err;
if (v->res_sprite && s->pict_type!=FF_I_TYPE) {
av_log(v->s.avctx, AV_LOG_WARNING, "Sprite decoder: expected I-frame\n");
}
s->current_picture_ptr->repeat_pict = 0;
......@@ -3464,6 +3583,8 @@ assert(s->current_picture.pict_type == s->pict_type);
}
end:
if (v->res_sprite)
vc1_parse_sprites(v, &s->gb);
av_free(buf2);
for (i = 0; i < n_slices; i++)
av_free(slices[i].buf);
......
......@@ -22,7 +22,7 @@
#define LIBAVCODEC_VERSION_MAJOR 52
#define LIBAVCODEC_VERSION_MINOR 117
#define LIBAVCODEC_VERSION_MICRO 0
#define LIBAVCODEC_VERSION_MICRO 1
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
......
This diff is collapsed.
......@@ -164,6 +164,7 @@ ogg_new_stream (AVFormatContext * s, uint32_t serial)
os->bufsize = DECODER_BUFFER_SIZE;
os->buf = av_malloc(os->bufsize);
os->header = -1;
os->page_begin = 1;
st = av_new_stream (s, idx);
if (!st)
......@@ -241,12 +242,27 @@ ogg_read_page (AVFormatContext * s, int *str)
idx = ogg_find_stream (ogg, serial);
if (idx < 0){
for (i = 0; i < ogg->nstreams; i++) {
if (!ogg->streams[i].page_begin) {
int n;
for (n = 0; n < ogg->nstreams; n++) {
av_free(ogg->streams[n].buf);
av_free(ogg->streams[n].private);
}
ogg->curidx = -1;
ogg->nstreams = 0;
break;
}
}
idx = ogg_new_stream (s, serial);
if (idx < 0)
return -1;
}
os = ogg->streams + idx;
if (!(flags & OGG_FLAG_BOS))
os->page_begin = 0;
os->page_pos = avio_tell(bc) - 27;
if(os->psize > 0)
......
......@@ -75,6 +75,7 @@ struct ogg_stream {
int incomplete; ///< whether we're expecting a continuation in the next page
int page_end; ///< current packet is the last one completed in the page
int keyframe_seek;
int page_begin; ///< set to 1 if the stream only received a begin-of-stream packet, otherwise 0
void *private;
};
......
......@@ -232,6 +232,7 @@ const AVCodecTag ff_codec_bmp_tags[] = {
{ CODEC_ID_WMV3, MKTAG('W', 'M', 'V', 'P') },
{ CODEC_ID_VC1, MKTAG('W', 'V', 'C', '1') },
{ CODEC_ID_VC1, MKTAG('W', 'M', 'V', 'A') },
{ CODEC_ID_VC1, MKTAG('W', 'V', 'P', '2') },
{ CODEC_ID_LOCO, MKTAG('L', 'O', 'C', 'O') },
{ CODEC_ID_WNV1, MKTAG('W', 'N', 'V', '1') },
{ CODEC_ID_AASC, MKTAG('A', 'A', 'S', 'C') },
......
......@@ -20,6 +20,7 @@
#undef _POSIX_C_SOURCE
#include <sys/sysctl.h>
#elif defined(__OpenBSD__)
#undef _POSIX_C_SOURCE
#include <sys/param.h>
#include <sys/sysctl.h>
#include <machine/cpu.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment