From 1eef08f98cc2f216ecc44041ad727aaa7fa2c705 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Mon, 5 Dec 2011 12:35:06 +0200 Subject: [PATCH 01/12] rtmp: Use nb_invokes for all invoke commands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 704af3e29c3ddbc22ac5c8f40e5a0f860d53ac4c broke publishing of rtmp streams, at least publishing to Wowza servers. This changes all invoke commands to use nb_invokes. Signed-off-by: Martin Storsjö --- libavformat/rtmpproto.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index 54213b1dd0..69acd864dc 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -75,6 +75,7 @@ typedef struct RTMPContext { uint8_t flv_header[11]; ///< partial incoming flv packet header int flv_header_bytes; ///< number of initialized bytes in flv_header int nb_invokes; ///< keeps track of invoke messages + int create_stream_invoke; ///< invoke id for the create stream command } RTMPContext; #define PLAYER_KEY_OPEN_PART_LEN 30 ///< length of partial key used for first client digest signing @@ -115,7 +116,7 @@ static void gen_connect(URLContext *s, RTMPContext *rt, const char *proto, ff_url_join(tcurl, sizeof(tcurl), proto, NULL, host, port, "/%s", rt->app); ff_amf_write_string(&p, "connect"); - ff_amf_write_number(&p, 1.0); + ff_amf_write_number(&p, ++rt->nb_invokes); ff_amf_write_object_start(&p); ff_amf_write_field_name(&p, "app"); ff_amf_write_string(&p, rt->app); @@ -237,6 +238,7 @@ static void gen_create_stream(URLContext *s, RTMPContext *rt) ff_amf_write_string(&p, "createStream"); ff_amf_write_number(&p, ++rt->nb_invokes); ff_amf_write_null(&p); + rt->create_stream_invoke = rt->nb_invokes; ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]); ff_rtmp_packet_destroy(&pkt); @@ -257,7 +259,7 @@ static void gen_delete_stream(URLContext *s, RTMPContext *rt) p = pkt.data; ff_amf_write_string(&p, "deleteStream"); - ff_amf_write_number(&p, 0.0); + ff_amf_write_number(&p, ++rt->nb_invokes); ff_amf_write_null(&p); ff_amf_write_number(&p, rt->main_channel_id); @@ -281,7 +283,7 @@ static void gen_play(URLContext *s, RTMPContext *rt) p = pkt.data; ff_amf_write_string(&p, "play"); - ff_amf_write_number(&p, 0.0); + ff_amf_write_number(&p, ++rt->nb_invokes); ff_amf_write_null(&p); ff_amf_write_string(&p, rt->playpath); @@ -315,7 +317,7 @@ static void gen_publish(URLContext *s, RTMPContext *rt) p = pkt.data; ff_amf_write_string(&p, "publish"); - ff_amf_write_number(&p, 0.0); + ff_amf_write_number(&p, ++rt->nb_invokes); ff_amf_write_null(&p); ff_amf_write_string(&p, rt->playpath); ff_amf_write_string(&p, "live"); @@ -614,7 +616,7 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt) * releaseStream and FCPublish calls */ if (!pkt->data[10]) { int pkt_id = (int) av_int2dbl(AV_RB64(pkt->data + 11)); - if (pkt_id == 4) + if (pkt_id == rt->create_stream_invoke) rt->state = STATE_CONNECTING; } if (rt->state != STATE_CONNECTING) From 73585620b8a1d170133c8e41e557d4ec5f648888 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Sun, 4 Dec 2011 21:13:56 +0100 Subject: [PATCH 02/12] drawtext: introduce explicit draw/hide variable Signed-off-by: Luca Barbato --- libavfilter/vf_drawtext.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index b7ba89c944..cd4386a483 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -116,6 +116,8 @@ typedef struct { char *x_expr, *y_expr; AVExpr *x_pexpr, *y_pexpr; ///< parsed expressions for x and y double var_values[VAR_VARS_NB]; + char *d_expr; + AVExpr *d_pexpr; int draw; ///< set to zero to prevent drawing } DrawTextContext; @@ -135,6 +137,7 @@ static const AVOption drawtext_options[]= { {"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 }, +{"draw", "if false do not draw", OFFSET(d_expr), AV_OPT_TYPE_STRING, {.str="1"}, CHAR_MIN, CHAR_MAX }, /* 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" }, @@ -560,6 +563,8 @@ static int config_input(AVFilterLink *inlink) if ((ret = av_expr_parse(&dtext->x_pexpr, dtext->x_expr, var_names, NULL, NULL, NULL, NULL, 0, ctx)) < 0 || (ret = av_expr_parse(&dtext->y_pexpr, dtext->y_expr, var_names, + NULL, NULL, NULL, NULL, 0, ctx)) < 0 || + (ret = av_expr_parse(&dtext->d_pexpr, dtext->d_expr, var_names, NULL, NULL, NULL, NULL, 0, ctx)) < 0) return AVERROR(EINVAL); @@ -777,10 +782,11 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) { AVFilterContext *ctx = inlink->dst; DrawTextContext *dtext = ctx->priv; + int fail = 0; if (dtext_prepare_text(ctx) < 0) { av_log(ctx, AV_LOG_ERROR, "Can't draw text\n"); - dtext->draw = 0; + fail = 1; } dtext->var_values[VAR_T] = inpicref->pts == AV_NOPTS_VALUE ? @@ -792,6 +798,9 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) dtext->var_values[VAR_X] = av_expr_eval(dtext->x_pexpr, dtext->var_values, NULL); + dtext->draw = fail ? 0 : + av_expr_eval(dtext->d_pexpr, dtext->var_values, NULL); + normalize_double(&dtext->x, dtext->var_values[VAR_X]); normalize_double(&dtext->y, dtext->var_values[VAR_Y]); From f5edfc9e92d1340cd50385081e563da226940e4e Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Mon, 5 Dec 2011 00:56:21 +0100 Subject: [PATCH 03/12] drawtext: introduce rand(min, max) Signed-off-by: Luca Barbato --- libavfilter/vf_drawtext.c | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index cd4386a483..87c8d8f8ac 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -34,9 +34,11 @@ #include "libavutil/eval.h" #include "libavutil/opt.h" #include "libavutil/mathematics.h" +#include "libavutil/random_seed.h" #include "libavutil/parseutils.h" #include "libavutil/pixdesc.h" #include "libavutil/tree.h" +#include "libavutil/lfg.h" #include "avfilter.h" #include "drawutils.h" @@ -62,6 +64,22 @@ static const char *var_names[] = { NULL }; +static const char *fun2_names[] = { + "rand", +}; + +static double drand(void *opaque, double min, double max) +{ + return val = min + (max-min) / UINT_MAX * av_lfg_get(opaque); +} + +typedef double (*eval_func2)(void *, double a, double b); + +static const eval_func2 fun2[] = { + drand, + NULL +}; + enum var_name { VAR_E, VAR_PHI, @@ -119,6 +137,7 @@ typedef struct { char *d_expr; AVExpr *d_pexpr; int draw; ///< set to zero to prevent drawing + AVLFG prng; ///< random } DrawTextContext; #define OFFSET(x) offsetof(DrawTextContext, x) @@ -559,13 +578,14 @@ static int config_input(AVFilterLink *inlink) dtext->var_values[VAR_N] = 0; dtext->var_values[VAR_T] = NAN; + av_lfg_init(&dtext->prng, av_get_random_seed()); if ((ret = av_expr_parse(&dtext->x_pexpr, dtext->x_expr, var_names, - NULL, NULL, NULL, NULL, 0, ctx)) < 0 || + NULL, NULL, fun2_names, fun2, 0, ctx)) < 0 || (ret = av_expr_parse(&dtext->y_pexpr, dtext->y_expr, var_names, - NULL, NULL, NULL, NULL, 0, ctx)) < 0 || + NULL, NULL, fun2_names, fun2, 0, ctx)) < 0 || (ret = av_expr_parse(&dtext->d_pexpr, dtext->d_expr, var_names, - NULL, NULL, NULL, NULL, 0, ctx)) < 0) + NULL, NULL, fun2_names, fun2, 0, ctx)) < 0) return AVERROR(EINVAL); if ((ret = @@ -792,14 +812,14 @@ static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref) dtext->var_values[VAR_T] = inpicref->pts == AV_NOPTS_VALUE ? NAN : inpicref->pts * av_q2d(inlink->time_base); dtext->var_values[VAR_X] = - av_expr_eval(dtext->x_pexpr, dtext->var_values, NULL); + av_expr_eval(dtext->x_pexpr, dtext->var_values, &dtext->prng); dtext->var_values[VAR_Y] = - av_expr_eval(dtext->y_pexpr, dtext->var_values, NULL); + av_expr_eval(dtext->y_pexpr, dtext->var_values, &dtext->prng); dtext->var_values[VAR_X] = - av_expr_eval(dtext->x_pexpr, dtext->var_values, NULL); + av_expr_eval(dtext->x_pexpr, dtext->var_values, &dtext->prng); dtext->draw = fail ? 0 : - av_expr_eval(dtext->d_pexpr, dtext->var_values, NULL); + av_expr_eval(dtext->d_pexpr, dtext->var_values, &dtext->prng); normalize_double(&dtext->x, dtext->var_values[VAR_X]); normalize_double(&dtext->y, dtext->var_values[VAR_Y]); From fc9489f6adb9d3e790e6e5ebe984eaee0c733b09 Mon Sep 17 00:00:00 2001 From: "Paul B. Mahol" Date: Tue, 6 Dec 2011 17:45:37 +0000 Subject: [PATCH 04/12] cljr: simplify CLJRContext There is no need to have delta, offset and gb in CLJRContext. Signed-off-by: Janne Grunau --- libavcodec/cljr.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/libavcodec/cljr.c b/libavcodec/cljr.c index 2bfe03580b..e8d818aa78 100644 --- a/libavcodec/cljr.c +++ b/libavcodec/cljr.c @@ -35,9 +35,6 @@ typedef struct CLJRContext{ AVCodecContext *avctx; AVFrame picture; - int delta[16]; - int offset[4]; - GetBitContext gb; } CLJRContext; static int decode_frame(AVCodecContext *avctx, @@ -47,6 +44,7 @@ static int decode_frame(AVCodecContext *avctx, const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; CLJRContext * const a = avctx->priv_data; + GetBitContext gb; AVFrame *picture = data; AVFrame * const p= (AVFrame*)&a->picture; int x, y; @@ -67,20 +65,20 @@ static int decode_frame(AVCodecContext *avctx, p->pict_type= AV_PICTURE_TYPE_I; p->key_frame= 1; - init_get_bits(&a->gb, buf, buf_size * 8); + init_get_bits(&gb, buf, buf_size * 8); for(y=0; yheight; y++){ uint8_t *luma= &a->picture.data[0][ y*a->picture.linesize[0] ]; uint8_t *cb= &a->picture.data[1][ y*a->picture.linesize[1] ]; uint8_t *cr= &a->picture.data[2][ y*a->picture.linesize[2] ]; for(x=0; xwidth; x+=4){ - luma[3] = get_bits(&a->gb, 5) << 3; - luma[2] = get_bits(&a->gb, 5) << 3; - luma[1] = get_bits(&a->gb, 5) << 3; - luma[0] = get_bits(&a->gb, 5) << 3; + luma[3] = get_bits(&gb, 5) << 3; + luma[2] = get_bits(&gb, 5) << 3; + luma[1] = get_bits(&gb, 5) << 3; + luma[0] = get_bits(&gb, 5) << 3; luma+= 4; - *(cb++) = get_bits(&a->gb, 6) << 2; - *(cr++) = get_bits(&a->gb, 6) << 2; + *(cb++) = get_bits(&gb, 6) << 2; + *(cr++) = get_bits(&gb, 6) << 2; } } From ee41963f19eb6303b1582601dfccb1753866ab63 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 7 Dec 2011 13:48:58 +0100 Subject: [PATCH 05/12] cosmetics: drop some completely pointless parentheses --- libavcodec/atrac3.c | 11 +++++++---- libavcodec/mpegvideo.c | 7 ++++--- libavcodec/mpegvideo_common.h | 2 +- libavcodec/msrledec.c | 4 ++-- libavcodec/vc1dec.c | 2 +- libavdevice/libdc1394.c | 4 ++-- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c index bdd03402da..744ef17a06 100644 --- a/libavcodec/atrac3.c +++ b/libavcodec/atrac3.c @@ -708,9 +708,10 @@ static int decodeChannelSoundUnit (ATRAC3Context *q, GetBitContext *gb, channel_ memset(pSnd->IMDCT_buf, 0, 512 * sizeof(float)); /* gain compensation and overlapping */ - gainCompensateAndOverlap (pSnd->IMDCT_buf, &(pSnd->prevFrame[band*256]), &(pOut[band*256]), - &((pSnd->gainBlock[1 - (pSnd->gcBlkSwitch)]).gBlock[band]), - &((pSnd->gainBlock[pSnd->gcBlkSwitch]).gBlock[band])); + gainCompensateAndOverlap(pSnd->IMDCT_buf, &pSnd->prevFrame[band * 256], + &pOut[band * 256], + &pSnd->gainBlock[1 - pSnd->gcBlkSwitch].gBlock[band], + &pSnd->gainBlock[ pSnd->gcBlkSwitch].gBlock[band]); } /* Swap the gain control buffers for the next frame. */ @@ -795,7 +796,9 @@ static int decodeFrame(ATRAC3Context *q, const uint8_t* databuf, for (i=0 ; ichannels ; i++) { /* 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); + 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], out_samples[i], i, q->codingMode); if (result != 0) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 78fae1026d..f2651c8ac1 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -885,7 +885,7 @@ av_cold int MPV_common_init(MpegEncContext *s) s->parse_context.state = -1; if ((s->avctx->debug & (FF_DEBUG_VIS_QP | FF_DEBUG_VIS_MB_TYPE)) || - (s->avctx->debug_mv)) { + s->avctx->debug_mv) { s->visualization_buffer[0] = av_malloc((s->mb_width * 16 + 2 * EDGE_WIDTH) * s->mb_height * 16 + 2 * EDGE_WIDTH); s->visualization_buffer[1] = av_malloc((s->mb_width * 16 + @@ -1564,7 +1564,8 @@ void ff_print_debug_info(MpegEncContext *s, AVFrame *pict){ } } - if((s->avctx->debug&(FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE)) || (s->avctx->debug_mv)){ + if ((s->avctx->debug & (FF_DEBUG_VIS_QP | FF_DEBUG_VIS_MB_TYPE)) || + s->avctx->debug_mv) { const int shift= 1 + s->quarter_sample; int mb_y; uint8_t *ptr; @@ -1589,7 +1590,7 @@ void ff_print_debug_info(MpegEncContext *s, AVFrame *pict){ int mb_x; for(mb_x=0; mb_xmb_width; mb_x++){ const int mb_index= mb_x + mb_y*s->mb_stride; - if((s->avctx->debug_mv) && pict->motion_val){ + if (s->avctx->debug_mv && pict->motion_val) { int type; for(type=0; type<3; type++){ int direction = 0; diff --git a/libavcodec/mpegvideo_common.h b/libavcodec/mpegvideo_common.h index 96155d0f9a..b5b0d23c16 100644 --- a/libavcodec/mpegvideo_common.h +++ b/libavcodec/mpegvideo_common.h @@ -585,7 +585,7 @@ static inline void chroma_4mv_motion(MpegEncContext *s, if (src_y == (s->height >> 1)) dxy &= ~2; - offset = (src_y * (s->uvlinesize)) + src_x; + offset = src_y * s->uvlinesize + src_x; ptr = ref_picture[1] + offset; if(s->flags&CODEC_FLAG_EMU_EDGE){ if( (unsigned)src_x > (s->h_edge_pos>>1) - (dxy &1) - 8 diff --git a/libavcodec/msrledec.c b/libavcodec/msrledec.c index 46cd50dcbc..5e33a59280 100644 --- a/libavcodec/msrledec.c +++ b/libavcodec/msrledec.c @@ -138,8 +138,8 @@ static int msrle_decode_8_16_24_32(AVCodecContext *avctx, AVPicture *pic, int de uint32_t av_uninit(pix32); unsigned int width= FFABS(pic->linesize[0]) / (depth >> 3); - output = pic->data[0] + (avctx->height - 1) * pic->linesize[0]; - output_end = pic->data[0] + (avctx->height) * pic->linesize[0]; + output = pic->data[0] + (avctx->height - 1) * pic->linesize[0]; + output_end = pic->data[0] + avctx->height * pic->linesize[0]; while(src < data + srcsize) { p1 = *src++; if(p1 == 0) { //Escape code diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index b5b8c29bda..7c9e906505 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -236,7 +236,7 @@ static void vc1_put_signed_blocks_clamped(VC1Context *v) 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; + 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, diff --git a/libavdevice/libdc1394.c b/libavdevice/libdc1394.c index 71f08b137d..ac4bb093d4 100644 --- a/libavdevice/libdc1394.c +++ b/libavdevice/libdc1394.c @@ -371,8 +371,8 @@ static int dc1394_v2_read_packet(AVFormatContext *c, AVPacket *pkt) res = dc1394_capture_dequeue(dc1394->camera, DC1394_CAPTURE_POLICY_WAIT, &dc1394->frame); if (res == DC1394_SUCCESS) { - dc1394->packet.data = (uint8_t *)(dc1394->frame->image); - dc1394->packet.pts = (dc1394->current_frame * 1000000) / (dc1394->frame_rate); + dc1394->packet.data = (uint8_t *) dc1394->frame->image; + dc1394->packet.pts = dc1394->current_frame * 1000000 / dc1394->frame_rate; res = dc1394->frame->image_bytes; } else { av_log(c, AV_LOG_ERROR, "DMA capture failed\n"); From ff159e7816796c52fda7bcf6d87066a14784ee36 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 7 Dec 2011 13:43:36 +0100 Subject: [PATCH 06/12] doxygen: Replace '\' by '@' in Doxygen markup tags. --- libavcodec/ppc/h264_altivec.c | 4 ++-- libavcodec/ppc/util_altivec.h | 2 +- libavcodec/tableprint.h | 4 ++-- libavutil/lzo.h | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libavcodec/ppc/h264_altivec.c b/libavcodec/ppc/h264_altivec.c index 3163a37d3b..c8baee456e 100644 --- a/libavcodec/ppc/h264_altivec.c +++ b/libavcodec/ppc/h264_altivec.c @@ -616,8 +616,8 @@ static inline void write16x4(uint8_t *dst, int dst_stride, *(dst_int+15*int_dst_stride) = *(src_int + 15); } -/** \brief performs a 6x16 transpose of data in src, and stores it to dst - \todo FIXME: see if we can't spare some vec_lvsl() by them factorizing +/** @brief performs a 6x16 transpose of data in src, and stores it to dst + @todo FIXME: see if we can't spare some vec_lvsl() by them factorizing out of unaligned_load() */ #define readAndTranspose16x6(src, src_stride, r8, r9, r10, r11, r12, r13) {\ register vec_u8 r0 = unaligned_load(0, src); \ diff --git a/libavcodec/ppc/util_altivec.h b/libavcodec/ppc/util_altivec.h index e68e5b593d..19ea9626db 100644 --- a/libavcodec/ppc/util_altivec.h +++ b/libavcodec/ppc/util_altivec.h @@ -94,7 +94,7 @@ do { \ } while (0) -/** \brief loads unaligned vector \a *src with offset \a offset +/** @brief loads unaligned vector @a *src with offset @a offset and returns it */ static inline vector unsigned char unaligned_load(int offset, uint8_t *src) { diff --git a/libavcodec/tableprint.h b/libavcodec/tableprint.h index 6f46a7cc8a..81bb9afdcb 100644 --- a/libavcodec/tableprint.h +++ b/libavcodec/tableprint.h @@ -58,7 +58,7 @@ void write_##type##_2d_array(const void *arg, int len, int len2)\ /** * @name Predefined functions for printing tables * - * \{ + * @{ */ void write_int8_t_array (const int8_t *, int); void write_uint8_t_array (const uint8_t *, int); @@ -69,7 +69,7 @@ void write_int8_t_2d_array (const void *, int, int); void write_uint8_t_2d_array (const void *, int, int); void write_uint32_t_2d_array(const void *, int, int); void write_float_2d_array (const void *, int, int); -/** \} */ // end of printfuncs group +/** @} */ // end of printfuncs group #define WRITE_ARRAY(prefix, type, name) \ do { \ diff --git a/libavutil/lzo.h b/libavutil/lzo.h index d2c3466239..1b774a53bc 100644 --- a/libavutil/lzo.h +++ b/libavutil/lzo.h @@ -32,7 +32,7 @@ #include /** @name Error flags returned by av_lzo1x_decode - * \{ */ + * @{ */ /// end of the input buffer reached before decoding finished #define AV_LZO_INPUT_DEPLETED 1 /// decoded data did not fit into output buffer @@ -41,7 +41,7 @@ #define AV_LZO_INVALID_BACKPTR 4 /// a non-specific error in the compressed bitstream #define AV_LZO_ERROR 8 -/** \} */ +/** @} */ #define AV_LZO_INPUT_PADDING 8 #define AV_LZO_OUTPUT_PADDING 12 From c7e8187d9d60a61a05f5788e502ec2baf02c7e10 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 7 Dec 2011 11:30:07 +0100 Subject: [PATCH 07/12] avformat/utils: Drop unused goto label. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit libavformat/utils.c:2165:2: warning: label ‘fail’ defined but not used --- libavformat/utils.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index ea075e7286..1df042f0fe 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2162,7 +2162,6 @@ static int try_decode_frame(AVStream *st, AVPacket *avpkt, AVDictionary **option pkt.size -= ret; } } - fail: return ret; } From 7efea2a05196baf61f54ddf53b1e1f53f92ea738 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C3=ABl=20Carr=C3=A9?= Date: Wed, 7 Dec 2011 10:23:52 -0500 Subject: [PATCH 08/12] dxva2.h: include d3d9.h to define LPDIRECT3DSURFACE9 Signed-off-by: Luca Barbato --- libavcodec/dxva2.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/dxva2.h b/libavcodec/dxva2.h index 53a00fff17..374ae039ac 100644 --- a/libavcodec/dxva2.h +++ b/libavcodec/dxva2.h @@ -25,6 +25,7 @@ #include +#include #include #define FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG 1 ///< Work around for DXVA2 and old UVD/UVD+ ATI video cards From d8538f06e6c046680a0237ca5d3eeee43c2682e4 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 5 Dec 2011 13:18:27 +0100 Subject: [PATCH 09/12] doc: add editor configuration section with Vim and Emacs settings based on a patch by Victor Vasiliev, vasilvv gmail com --- doc/developer.texi | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/doc/developer.texi b/doc/developer.texi index c9cf7bde98..dd31e3725b 100644 --- a/doc/developer.texi +++ b/doc/developer.texi @@ -207,6 +207,31 @@ Casts should be used only when necessary. Unneeded parentheses should also be avoided if they don't make the code easier to understand. @end itemize +@subsection Editor configuration +In order to configure Vim to follow Libav formatting conventions, paste +the following snippet into your @file{.vimrc}: +@example +" indentation rules for libav: 4 spaces, no tabs +set expandtab +set shiftwidth=4 +set softtabstop=4 +" allow tabs in Makefiles +autocmd FileType make set noexpandtab shiftwidth=8 softtabstop=8 +" Trailing whitespace and tabs are forbidden, so highlight them. +highlight ForbiddenWhitespace ctermbg=red guibg=red +match ForbiddenWhitespace /\s\+$\|\t/ +" Do not highlight spaces at the end of line while typing on that line. +autocmd InsertEnter * match ForbiddenWhitespace /\t\|\s\+\%#\@@ Date: Tue, 6 Dec 2011 20:42:55 -0800 Subject: [PATCH 10/12] w32thread: port fixes to pthread_cond_broadcast() from x264. --- libavcodec/w32pthreads.h | 54 ++++++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/libavcodec/w32pthreads.h b/libavcodec/w32pthreads.h index c015b87a42..2d1470c5ee 100644 --- a/libavcodec/w32pthreads.h +++ b/libavcodec/w32pthreads.h @@ -115,9 +115,12 @@ static inline int pthread_mutex_unlock(pthread_mutex_t *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_broadcast; pthread_mutex_t mtx_waiter_count; volatile int waiter_count; HANDLE semaphore; + HANDLE waiters_done; + int is_broadcast; } win32_cond_t; static void pthread_cond_init(pthread_cond_t *cond, const void *unused_attr) @@ -136,8 +139,12 @@ static void pthread_cond_init(pthread_cond_t *cond, const void *unused_attr) win32_cond->semaphore = CreateSemaphore(NULL, 0, 0x7fffffff, NULL); if (!win32_cond->semaphore) return; + win32_cond->waiters_done = CreateEvent(NULL, FALSE, FALSE, NULL); + if (!win32_cond->waiters_done) + return; pthread_mutex_init(&win32_cond->mtx_waiter_count, NULL); + pthread_mutex_init(&win32_cond->mtx_broadcast, NULL); } static void pthread_cond_destroy(pthread_cond_t *cond) @@ -149,7 +156,9 @@ static void pthread_cond_destroy(pthread_cond_t *cond) /* non native condition variables */ CloseHandle(win32_cond->semaphore); + CloseHandle(win32_cond->waiters_done); pthread_mutex_destroy(&win32_cond->mtx_waiter_count); + pthread_mutex_destroy(&win32_cond->mtx_broadcast); av_freep(&win32_cond); cond->ptr = NULL; } @@ -157,41 +166,70 @@ static void pthread_cond_destroy(pthread_cond_t *cond) static void pthread_cond_broadcast(pthread_cond_t *cond) { win32_cond_t *win32_cond = cond->ptr; + int have_waiter; + if (cond_broadcast) { cond_broadcast(cond); return; } /* non native condition variables */ + pthread_mutex_lock(&win32_cond->mtx_broadcast); pthread_mutex_lock(&win32_cond->mtx_waiter_count); + have_waiter = 0; + if (win32_cond->waiter_count) { - ReleaseSemaphore(win32_cond->semaphore, win32_cond->waiter_count, NULL); - win32_cond->waiter_count = 0; + win32_cond->is_broadcast = 1; + have_waiter = 1; } - pthread_mutex_unlock(&win32_cond->mtx_waiter_count); + + if (have_waiter) { + ReleaseSemaphore(win32_cond->semaphore, win32_cond->waiter_count, NULL); + pthread_mutex_unlock(&win32_cond->mtx_waiter_count); + WaitForSingleObject(win32_cond->waiters_done, INFINITE); + win32_cond->is_broadcast = 0; + } else + pthread_mutex_unlock(&win32_cond->mtx_waiter_count); + pthread_mutex_unlock(&win32_cond->mtx_broadcast); } static void pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) { win32_cond_t *win32_cond = cond->ptr; + int last_waiter; if (cond_wait) { cond_wait(cond, mutex, INFINITE); return; } /* non native condition variables */ + pthread_mutex_lock(&win32_cond->mtx_broadcast); + pthread_mutex_unlock(&win32_cond->mtx_broadcast); + pthread_mutex_lock(&win32_cond->mtx_waiter_count); win32_cond->waiter_count++; pthread_mutex_unlock(&win32_cond->mtx_waiter_count); + // unlock the external mutex pthread_mutex_unlock(mutex); WaitForSingleObject(win32_cond->semaphore, INFINITE); - pthread_mutex_lock(mutex); + + pthread_mutex_lock(&win32_cond->mtx_waiter_count); + win32_cond->waiter_count--; + last_waiter = !win32_cond->waiter_count && win32_cond->is_broadcast; + pthread_mutex_unlock(&win32_cond->mtx_waiter_count); + + if (last_waiter) + SetEvent(win32_cond->waiters_done); + + // lock the external mutex + return pthread_mutex_lock(mutex); } static void pthread_cond_signal(pthread_cond_t *cond) { win32_cond_t *win32_cond = cond->ptr; + int have_waiter; if (cond_signal) { cond_signal(cond); return; @@ -199,11 +237,11 @@ static void pthread_cond_signal(pthread_cond_t *cond) /* 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--; - } + have_waiter = win32_cond->waiter_count; pthread_mutex_unlock(&win32_cond->mtx_waiter_count); + + if (have_waiter) + ReleaseSemaphore(win32_cond->semaphore, 1, NULL); } static void w32thread_init(void) From bc057f7592b346fdfc05fcb41357947889776ef3 Mon Sep 17 00:00:00 2001 From: Hendrik Leppkes Date: Sun, 4 Dec 2011 23:15:51 +0100 Subject: [PATCH 11/12] pcm-mpeg: implement new audio decoding api Signed-off-by: Justin Ruggles --- libavcodec/pcm-mpeg.c | 52 +++++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/libavcodec/pcm-mpeg.c b/libavcodec/pcm-mpeg.c index de0c302f77..9ab6fc3ff0 100644 --- a/libavcodec/pcm-mpeg.c +++ b/libavcodec/pcm-mpeg.c @@ -119,17 +119,30 @@ static int pcm_bluray_parse_header(AVCodecContext *avctx, return 0; } -static int pcm_bluray_decode_frame(AVCodecContext *avctx, - void *data, - int *data_size, - AVPacket *avpkt) +typedef struct PCMBRDecode { + AVFrame frame; +} PCMBRDecode; + +static av_cold int pcm_bluray_decode_init(AVCodecContext * avctx) +{ + PCMBRDecode *s = avctx->priv_data; + + avcodec_get_frame_defaults(&s->frame); + avctx->coded_frame = &s->frame; + + return 0; +} + +static int pcm_bluray_decode_frame(AVCodecContext *avctx, void *data, + int *got_frame_ptr, AVPacket *avpkt) { const uint8_t *src = avpkt->data; int buf_size = avpkt->size; + PCMBRDecode *s = avctx->priv_data; int num_source_channels, channel, retval; - int sample_size, samples, output_size; - int16_t *dst16 = data; - int32_t *dst32 = data; + int sample_size, samples; + int16_t *dst16; + int32_t *dst32; if (buf_size < 4) { av_log(avctx, AV_LOG_ERROR, "PCM packet too small\n"); @@ -146,15 +159,14 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx, sample_size = (num_source_channels * avctx->bits_per_coded_sample) >> 3; samples = buf_size / sample_size; - output_size = samples * avctx->channels * - (avctx->sample_fmt == AV_SAMPLE_FMT_S32 ? 4 : 2); - if (output_size > *data_size) { - av_log(avctx, AV_LOG_ERROR, - "Insufficient output buffer space (%d bytes, needed %d bytes)\n", - *data_size, output_size); - return -1; + /* get output buffer */ + s->frame.nb_samples = samples; + if ((retval = avctx->get_buffer(avctx, &s->frame)) < 0) { + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); + return retval; } - *data_size = output_size; + dst16 = (int16_t *)s->frame.data[0]; + dst32 = (int32_t *)s->frame.data[0]; if (samples) { switch (avctx->channel_layout) { @@ -165,7 +177,7 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx, samples *= num_source_channels; if (AV_SAMPLE_FMT_S16 == avctx->sample_fmt) { #if HAVE_BIGENDIAN - memcpy(dst16, src, output_size); + memcpy(dst16, src, buf_size); #else do { *dst16++ = bytestream_get_be16(&src); @@ -289,10 +301,13 @@ static int pcm_bluray_decode_frame(AVCodecContext *avctx, } } + *got_frame_ptr = 1; + *(AVFrame *)data = s->frame; + retval = src - avpkt->data; if (avctx->debug & FF_DEBUG_BITSTREAM) av_dlog(avctx, "pcm_bluray_decode_frame: decoded %d -> %d bytes\n", - retval, *data_size); + retval, buf_size); return retval; } @@ -300,7 +315,10 @@ AVCodec ff_pcm_bluray_decoder = { .name = "pcm_bluray", .type = AVMEDIA_TYPE_AUDIO, .id = CODEC_ID_PCM_BLURAY, + .priv_data_size = sizeof(PCMBRDecode), + .init = pcm_bluray_decode_init, .decode = pcm_bluray_decode_frame, + .capabilities = CODEC_CAP_DR1, .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("PCM signed 16|20|24-bit big-endian for Blu-ray media"), From 78212cefe14a2086dc1ea3778b76623b949e5d0c Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Wed, 7 Dec 2011 20:30:55 +0100 Subject: [PATCH 12/12] drawtext: remove typo It slipped through the last two iterations. --- libavfilter/vf_drawtext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index 87c8d8f8ac..060c3a4a0e 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -70,7 +70,7 @@ static const char *fun2_names[] = { static double drand(void *opaque, double min, double max) { - return val = min + (max-min) / UINT_MAX * av_lfg_get(opaque); + return min + (max-min) / UINT_MAX * av_lfg_get(opaque); } typedef double (*eval_func2)(void *, double a, double b);