[FFmpeg-cvslog] RTMP: fix FD leak in rtmp_open()

2014-09-30 Thread Alexander Drozdov
ffmpeg | branch: master | Alexander Drozdov  | Fri Sep 26 
09:45:08 2014 +1100| [08ccc474b73a3acef5e56060c8174d4e82ace20d] | committer: 
Michael Niedermayer

RTMP: fix FD leak in rtmp_open()

If we setup AVIO interrupt callback and it will be returns 1 on socket
timeouts and we try to connect to non-existing streams on some servers
(like nginx-rtmp) we got FD leak.

Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=08ccc474b73a3acef5e56060c8174d4e82ace20d
---

 libavformat/rtmpproto.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index 3cde966..6122548 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -2670,7 +2670,7 @@ reconnect:
 // audio or video packet arrives.
 while (!rt->has_audio && !rt->has_video && !rt->received_metadata) {
 if ((ret = get_packet(s, 0)) < 0)
-   return ret;
+   goto fail;
 }
 
 // Either after we have read the metadata or (if there is none) the

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avcodec/h264_mp4toannexb_bsf: add a case when only SPS/ PPS is in the stream.

2014-09-30 Thread Benoit Fouet
ffmpeg | branch: master | Benoit Fouet  | Mon Sep 29 
15:18:50 2014 +0200| [1cf4d2e9be17e4bf1d1831c746e175aca339fa07] | committer: 
Michael Niedermayer

avcodec/h264_mp4toannexb_bsf: add a case when only SPS/PPS is in the stream.

When only SPS or PPS is present in the stream, copy the missing one from
AVCC before insertion to the output stream.

Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1cf4d2e9be17e4bf1d1831c746e175aca339fa07
---

 libavcodec/h264_mp4toannexb_bsf.c |   57 +++--
 1 file changed, 48 insertions(+), 9 deletions(-)

diff --git a/libavcodec/h264_mp4toannexb_bsf.c 
b/libavcodec/h264_mp4toannexb_bsf.c
index 739ff95..3ec4170 100644
--- a/libavcodec/h264_mp4toannexb_bsf.c
+++ b/libavcodec/h264_mp4toannexb_bsf.c
@@ -26,9 +26,12 @@
 #include "avcodec.h"
 
 typedef struct H264BSFContext {
+int32_t  sps_offset;
+int32_t  pps_offset;
 uint8_t  length_size;
 uint8_t  new_idr;
-uint8_t  idr_sps_pps_seen;
+uint8_t  idr_sps_seen;
+uint8_t  idr_pps_seen;
 int  extradata_parsed;
 } H264BSFContext;
 
@@ -60,7 +63,7 @@ static int alloc_and_copy(uint8_t **poutbuf, int 
*poutbuf_size,
 return 0;
 }
 
-static int h264_extradata_to_annexb(AVCodecContext *avctx, const int padding)
+static int h264_extradata_to_annexb(H264BSFContext *ctx, AVCodecContext 
*avctx, const int padding)
 {
 uint16_t unit_size;
 uint64_t total_size = 0;
@@ -70,11 +73,14 @@ static int h264_extradata_to_annexb(AVCodecContext *avctx, 
const int padding)
 static const uint8_t nalu_header[4] = { 0, 0, 0, 1 };
 int length_size = (*extradata++ & 0x3) + 1; // retrieve length coded size
 
+ctx->sps_offset = ctx->pps_offset = -1;
+
 /* retrieve sps and pps unit(s) */
 unit_nb = *extradata++ & 0x1f; /* number of sps unit(s) */
 if (!unit_nb) {
 goto pps;
 } else {
+ctx->sps_offset = 0;
 sps_seen = 1;
 }
 
@@ -103,8 +109,10 @@ static int h264_extradata_to_annexb(AVCodecContext *avctx, 
const int padding)
 pps:
 if (!unit_nb && !sps_done++) {
 unit_nb = *extradata++; /* number of pps unit(s) */
-if (unit_nb)
+if (unit_nb) {
+ctx->pps_offset = (extradata - 1) - (avctx->extradata + 4);
 pps_seen = 1;
+}
 }
 }
 
@@ -151,12 +159,13 @@ static int 
h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc,
 
 /* retrieve sps and pps NAL units from extradata */
 if (!ctx->extradata_parsed) {
-ret = h264_extradata_to_annexb(avctx, FF_INPUT_BUFFER_PADDING_SIZE);
+ret = h264_extradata_to_annexb(ctx, avctx, 
FF_INPUT_BUFFER_PADDING_SIZE);
 if (ret < 0)
 return ret;
 ctx->length_size  = ret;
 ctx->new_idr  = 1;
-ctx->idr_sps_pps_seen = 0;
+ctx->idr_sps_seen = 0;
+ctx->idr_pps_seen = 0;
 ctx->extradata_parsed = 1;
 }
 
@@ -176,8 +185,25 @@ static int 
h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc,
 if (buf + nal_size > buf_end || nal_size < 0)
 goto fail;
 
-if (unit_type == 7 || unit_type == 8)
-ctx->idr_sps_pps_seen = 1;
+if (unit_type == 7)
+ctx->idr_sps_seen = 1;
+else if (unit_type == 8) {
+ctx->idr_pps_seen = 1;
+/* if SPS has not been seen yet, prepend the AVCC one to PPS */
+if (!ctx->idr_sps_seen) {
+if (ctx->sps_offset == -1)
+av_log(avctx, AV_LOG_WARNING, "SPS not present in the 
stream, nor in AVCC, stream may be unreadable\n");
+else {
+if ((ret = alloc_and_copy(poutbuf, poutbuf_size,
+ avctx->extradata + ctx->sps_offset,
+ ctx->pps_offset != -1 ? 
ctx->pps_offset : avctx->extradata_size - ctx->sps_offset,
+ buf, nal_size)) < 0)
+goto fail;
+ctx->idr_sps_seen = 1;
+goto next_nal;
+}
+}
+}
 
 /* if this is a new IDR picture following an IDR picture, reset the 
idr flag.
  * Just check first_mb_in_slice to be 0 as this is the simplest 
solution.
@@ -186,22 +212,35 @@ static int 
h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc,
 ctx->new_idr = 1;
 
 /* prepend only to the first type 5 NAL unit of an IDR picture, if no 
sps/pps are already present */
-if (ctx->new_idr && unit_type == 5 && !ctx->idr_sps_pps_seen) {
+if (ctx->new_idr && unit_type == 5 && !ctx->idr_sps_seen && 
!ctx->idr_pps_seen) {
 if ((ret=alloc_and_copy(poutbuf, poutbuf_size,
avctx->extradata, avctx->extradata_size,
buf, nal_size)) < 0)
  

[FFmpeg-cvslog] avcodec/h264_mp4toannexb_bsf: use the given padding in h264_extradata_to_annexb().

2014-09-30 Thread Benoit Fouet
ffmpeg | branch: master | Benoit Fouet  | Tue Sep 30 
13:06:30 2014 +0200| [d5ddcb5f8e7b14974fabd5e95e6420c6e9b12991] | committer: 
Michael Niedermayer

avcodec/h264_mp4toannexb_bsf: use the given padding in 
h264_extradata_to_annexb().

Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d5ddcb5f8e7b14974fabd5e95e6420c6e9b12991
---

 libavcodec/h264_mp4toannexb_bsf.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/h264_mp4toannexb_bsf.c 
b/libavcodec/h264_mp4toannexb_bsf.c
index 3ec4170..be42304 100644
--- a/libavcodec/h264_mp4toannexb_bsf.c
+++ b/libavcodec/h264_mp4toannexb_bsf.c
@@ -117,7 +117,7 @@ pps:
 }
 
 if (out)
-memset(out + total_size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
+memset(out + total_size, 0, padding);
 
 if (!sps_seen)
 av_log(avctx, AV_LOG_WARNING,

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] Kill timed SRT

2014-09-30 Thread Clément Bœsch
ffmpeg | branch: master | Clément Bœsch  | Sun Sep 14 20:30:27 
2014 +0200| [55180b3299c61e5e3d16f1e9ea58dba8b787cc8e] | committer: Clément 
Bœsch

Kill timed SRT

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=55180b3299c61e5e3d16f1e9ea58dba8b787cc8e
---

 libavcodec/srtdec.c   |   33 +++--
 libavcodec/srtenc.c   |   45 -
 libavcodec/version.h  |2 +-
 libavformat/matroska.c|1 -
 libavformat/matroskaenc.c |   45 +
 libavformat/srtenc.c  |   11 ---
 libavformat/version.h |2 +-
 7 files changed, 14 insertions(+), 125 deletions(-)

diff --git a/libavcodec/srtdec.c b/libavcodec/srtdec.c
index 794a25a..cc17486 100644
--- a/libavcodec/srtdec.c
+++ b/libavcodec/srtdec.c
@@ -193,28 +193,6 @@ static const char *srt_to_ass(AVCodecContext *avctx, char 
*out, char *out_end,
 return in;
 }
 
-static const char *read_ts(const char *buf, int *ts_start, int *ts_end,
-   int *x1, int *y1, int *x2, int *y2)
-{
-int i, hs, ms, ss, he, me, se;
-
-for (i=0; i<2; i++) {
-/* try to read timestamps in either the first or second line */
-int c = sscanf(buf, "%d:%2d:%2d%*1[,.]%3d --> %d:%2d:%2d%*1[,.]%3d"
-   "%*[ ]X1:%u X2:%u Y1:%u Y2:%u",
-   &hs, &ms, &ss, ts_start, &he, &me, &se, ts_end,
-   x1, x2, y1, y2);
-buf += strcspn(buf, "\n");
-buf += !!*buf;
-if (c >= 8) {
-*ts_start = 100*(ss + 60*(ms + 60*hs)) + *ts_start/10;
-*ts_end   = 100*(se + 60*(me + 60*he)) + *ts_end  /10;
-return buf;
-}
-}
-return NULL;
-}
-
 static int srt_decode_frame(AVCodecContext *avctx,
 void *data, int *got_sub_ptr, AVPacket *avpkt)
 {
@@ -237,11 +215,7 @@ static int srt_decode_frame(AVCodecContext *avctx,
 return avpkt->size;
 
 while (ptr < end && *ptr) {
-if (avctx->codec->id == AV_CODEC_ID_SRT) {
-ptr = read_ts(ptr, &ts_start, &ts_end, &x1, &y1, &x2, &y2);
-if (!ptr)
-break;
-} else {
+// TODO: reindent
 // Do final divide-by-10 outside rescale to force rounding down.
 ts_start = av_rescale_q(avpkt->pts,
 avctx->time_base,
@@ -249,7 +223,6 @@ static int srt_decode_frame(AVCodecContext *avctx,
 ts_end   = av_rescale_q(avpkt->pts + avpkt->duration,
 avctx->time_base,
 (AVRational){1,100});
-}
 ptr = srt_to_ass(avctx, buffer, buffer+sizeof(buffer), ptr,
  x1, y1, x2, y2);
 ret = ff_ass_add_rect(sub, buffer, ts_start, ts_end-ts_start, 0);
@@ -265,9 +238,9 @@ static int srt_decode_frame(AVCodecContext *avctx,
 /* deprecated decoder */
 AVCodec ff_srt_decoder = {
 .name = "srt",
-.long_name= NULL_IF_CONFIG_SMALL("SubRip subtitle with embedded 
timing"),
+.long_name= NULL_IF_CONFIG_SMALL("SubRip subtitle"),
 .type = AVMEDIA_TYPE_SUBTITLE,
-.id   = AV_CODEC_ID_SRT,
+.id   = AV_CODEC_ID_SUBRIP,
 .init = ff_ass_subtitle_header_default,
 .decode   = srt_decode_frame,
 };
diff --git a/libavcodec/srtenc.c b/libavcodec/srtenc.c
index 89c26dc..3287970 100644
--- a/libavcodec/srtenc.c
+++ b/libavcodec/srtenc.c
@@ -33,8 +33,6 @@ typedef struct {
 AVCodecContext *avctx;
 ASSSplitContext *ass_ctx;
 AVBPrint buffer;
-unsigned timestamp_end;
-int count;
 char stack[SRT_STACK_SIZE];
 int stack_ptr;
 int alignment_applied;
@@ -201,35 +199,13 @@ static void srt_cancel_overrides_cb(void *priv, const 
char *style)
 static void srt_move_cb(void *priv, int x1, int y1, int x2, int y2,
 int t1, int t2)
 {
-SRTContext *s = priv;
-
-if (s->avctx->codec->id == AV_CODEC_ID_SRT) {
-char buffer[32];
-int len = snprintf(buffer, sizeof(buffer),
-   "  X1:%03u X2:%03u Y1:%03u Y2:%03u", x1, x2, y1, y2);
-unsigned char *dummy;
-unsigned room;
-
-av_bprint_get_buffer(&s->buffer, len, &dummy, &room);
-if (room >= len) {
-memmove(s->buffer.str + s->timestamp_end + len,
-s->buffer.str + s->timestamp_end,
-s->buffer.len - s->timestamp_end + 1);
-memcpy(s->buffer.str + s->timestamp_end, buffer, len);
-}
-/* Increment even if av_bprint_get_buffer() did not return enough room:
-   the bprint structure will be treated as truncated. */
-s->buffer.len += len;
-}
+// TODO: add a AV_PKT_DATA_SUBTITLE_POSITION side data when a new subtitles
+// encoding API passing the AVPacket is available.
 }
 
 static void srt_end_cb(void *priv)
 {
-SRTContext *s = priv;
-
 srt_stack_push_pop(priv,

[FFmpeg-cvslog] avcodec/srtdec: use AVBPrint API

2014-09-30 Thread Clément Bœsch
ffmpeg | branch: master | Clément Bœsch  | Sun Sep 28 11:57:46 
2014 +0200| [0eb4a428122b74d3ddfa9c48015bf73be433a2cf] | committer: Clément 
Bœsch

avcodec/srtdec: use AVBPrint API

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0eb4a428122b74d3ddfa9c48015bf73be433a2cf
---

 libavcodec/srtdec.c |   78 +++
 1 file changed, 35 insertions(+), 43 deletions(-)

diff --git a/libavcodec/srtdec.c b/libavcodec/srtdec.c
index cc17486..d9cc16a 100644
--- a/libavcodec/srtdec.c
+++ b/libavcodec/srtdec.c
@@ -47,8 +47,14 @@ typedef struct {
 char param[PARAM_NUMBER][128];
 } SrtStack;
 
-static const char *srt_to_ass(AVCodecContext *avctx, char *out, char *out_end,
-  const char *in, int x1, int y1, int x2, int y2)
+static void rstrip_spaces_buf(AVBPrint *buf)
+{
+while (buf->len > 0 && buf->str[buf->len - 1] == ' ')
+buf->str[--buf->len] = 0;
+}
+
+static void srt_to_ass(AVCodecContext *avctx, AVBPrint *dst,
+   const char *in, int x1, int y1, int x2, int y2)
 {
 char *param, buffer[128], tmp[128];
 int len, tag_close, sptr = 1, line_start = 1, an = 0, end = 0;
@@ -61,14 +67,12 @@ static const char *srt_to_ass(AVCodecContext *avctx, char 
*out, char *out_end,
 
 if (x1 >= 0 && y1 >= 0) {
 if (x2 >= 0 && y2 >= 0 && (x2 != x1 || y2 != y1))
-snprintf(out, out_end-out,
-"{\\an1}{\\move(%d,%d,%d,%d)}", x1, y1, x2, y2);
+av_bprintf(dst, "{\\an1}{\\move(%d,%d,%d,%d)}", x1, y1, x2, y2);
 else
-snprintf(out, out_end-out, "{\\an1}{\\pos(%d,%d)}", x1, y1);
-out += strlen(out);
+av_bprintf(dst, "{\\an1}{\\pos(%d,%d)}", x1, y1);
 }
 
-for (; out < out_end && !end && *in; in++) {
+for (; !end && *in; in++) {
 switch (*in) {
 case '\r':
 break;
@@ -77,15 +81,13 @@ static const char *srt_to_ass(AVCodecContext *avctx, char 
*out, char *out_end,
 end = 1;
 break;
 }
-while (out[-1] == ' ')
-out--;
-snprintf(out, out_end-out, "\\N");
-if(out= 0 
&& len > 0)) {
 in += len - 1;
 } else
-*out++ = *in;
+av_bprint_chars(dst, *in, 1);
 break;
 case '<':
 tag_close = in[1] == '/';
@@ -115,9 +117,7 @@ static const char *srt_to_ass(AVCodecContext *avctx, char 
*out, char *out_end,
 if (stack[sptr-1].param[i][0])
 for (j=sptr-2; j>=0; j--)
 if (stack[j].param[i][0]) {
-snprintf(out, out_end-out,
-"%s", 
stack[j].param[i]);
-if(out", buffer);
@@ -169,7 +164,7 @@ static const char *srt_to_ass(AVCodecContext *avctx, char 
*out, char *out_end,
 sptr--;
 } else if (unknown && !strstr(in, tmp)) {
 in -= len + tag_close;
-*out++ = *in;
+av_bprint_chars(dst, *in, 1);
 } else
 av_strlcpy(stack[sptr++].tag, buffer,
sizeof(stack[0].tag));
@@ -177,30 +172,26 @@ static const char *srt_to_ass(AVCodecContext *avctx, char 
*out, char *out_end,
 }
 }
 default:
-*out++ = *in;
+av_bprint_chars(dst, *in, 1);
 break;
 }
 if (*in != ' ' && *in != '\r' && *in != '\n')
 line_start = 0;
 }
 
-out = FFMIN(out, out_end-3);
-while (!strncmp(out-2, "\\N", 2))
-out -= 2;
-while (out[-1] == ' ')
-out--;
-snprintf(out, out_end-out, "\r\n");
-return in;
+while (dst->len >= 2 && !strncmp(&dst->str[dst->len - 2], "\\N", 2))
+dst->len -= 2;
+dst->str[dst->len] = 0;
+rstrip_spaces_buf(dst);
+av_bprintf(dst, "\r\n");
 }
 
 static int srt_decode_frame(AVCodecContext *avctx,
 void *data, int *got_sub_ptr, AVPacket *avpkt)
 {
 AVSubtitle *sub = data;
+AVBPrint buffer;
 int ts_start, ts_end, x1 = -1, y1 = -1, x2 = -1, y2 = -1;
-char buffer[2048];
-const char *ptr = avpkt->data;
-const char *end = avpkt->data + avpkt->size;
 int size, ret;
 const uint8_t *p = av_packet_get_side_data(avpkt, 
AV_PKT_DATA_SUBTITLE_POSITION, &size);
 
@@ -214,7 +205,8 @@ static int srt_decode_frame(AVCodecContext *avctx,
 if (avpkt->size <= 0)
 return avpkt->size;
 
-while (ptr < end && *ptr) {
+av_bprint_init(&buffer, 0, AV_BPRINT_SIZE_UNLIMITED);
+
 // TODO: reindent
 // Do final divide-by-10 outside rescale to force rounding down.
 ts_sta

[FFmpeg-cvslog] avcodec/bitstream_filter: Use av_bitstream_filter_next() instead of direct access in av_bitstream_filter_init()

2014-09-30 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Tue Sep 30 
18:00:00 2014 +0200| [cda5d89defaf65eccd890488675dc3d6e7484d27] | committer: 
Michael Niedermayer

avcodec/bitstream_filter: Use av_bitstream_filter_next() instead of direct 
access in av_bitstream_filter_init()

Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cda5d89defaf65eccd890488675dc3d6e7484d27
---

 libavcodec/bitstream_filter.c |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavcodec/bitstream_filter.c b/libavcodec/bitstream_filter.c
index 751b90d..3275326 100644
--- a/libavcodec/bitstream_filter.c
+++ b/libavcodec/bitstream_filter.c
@@ -43,9 +43,9 @@ void av_register_bitstream_filter(AVBitStreamFilter *bsf)
 
 AVBitStreamFilterContext *av_bitstream_filter_init(const char *name)
 {
-AVBitStreamFilter *bsf = first_bitstream_filter;
+AVBitStreamFilter *bsf = NULL;
 
-while (bsf) {
+while (bsf = av_bitstream_filter_next(bsf)) {
 if (!strcmp(name, bsf->name)) {
 AVBitStreamFilterContext *bsfc =
 av_mallocz(sizeof(AVBitStreamFilterContext));
@@ -54,7 +54,6 @@ AVBitStreamFilterContext *av_bitstream_filter_init(const char 
*name)
 bsf->priv_data_size ? av_mallocz(bsf->priv_data_size) : NULL;
 return bsfc;
 }
-bsf = bsf->next;
 }
 return NULL;
 }

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avformat/flvenc: When using "-c:d copy", don' t require a codec for passing the AMF metadata through from input to output.

2014-09-30 Thread Jeffrey Wescott
ffmpeg | branch: master | Jeffrey Wescott  | Mon Sep 
29 21:06:38 2014 -0700| [07de0db74b56a5cb45039b58b6ff43ea5ffb90bc] | committer: 
Michael Niedermayer

avformat/flvenc: When using "-c:d copy", don't require a codec for passing the 
AMF metadata through from input to output.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=07de0db74b56a5cb45039b58b6ff43ea5ffb90bc
---

 libavformat/flvenc.c |   32 +++-
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index febc5e5..1534667 100644
--- a/libavformat/flvenc.c
+++ b/libavformat/flvenc.c
@@ -248,7 +248,7 @@ static int flv_write_header(AVFormatContext *s)
"16-bit big-endian audio in flv is valid but most 
likely unplayable (hardware dependent); use s16le\n");
 break;
 case AVMEDIA_TYPE_DATA:
-if (enc->codec_id != AV_CODEC_ID_TEXT) {
+if (enc->codec_id != AV_CODEC_ID_TEXT && enc->codec_id != 
AV_CODEC_ID_NONE) {
 av_log(s, AV_LOG_ERROR, "Data codec '%s' for stream %d is not 
compatible with FLV\n",
avcodec_get_name(enc->codec_id), i);
 return AVERROR_INVALIDDATA;
@@ -556,18 +556,24 @@ static int flv_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 if (enc->codec_type == AVMEDIA_TYPE_DATA) {
 int data_size;
 int64_t metadata_size_pos = avio_tell(pb);
-avio_w8(pb, AMF_DATA_TYPE_STRING);
-put_amf_string(pb, "onTextData");
-avio_w8(pb, AMF_DATA_TYPE_MIXEDARRAY);
-avio_wb32(pb, 2);
-put_amf_string(pb, "type");
-avio_w8(pb, AMF_DATA_TYPE_STRING);
-put_amf_string(pb, "Text");
-put_amf_string(pb, "text");
-avio_w8(pb, AMF_DATA_TYPE_STRING);
-put_amf_string(pb, pkt->data);
-put_amf_string(pb, "");
-avio_w8(pb, AMF_END_OF_OBJECT);
+if (enc->codec_type == AV_CODEC_ID_TEXT) {
+// legacy FFmpeg magic?
+avio_w8(pb, AMF_DATA_TYPE_STRING);
+put_amf_string(pb, "onTextData");
+avio_w8(pb, AMF_DATA_TYPE_MIXEDARRAY);
+avio_wb32(pb, 2);
+put_amf_string(pb, "type");
+avio_w8(pb, AMF_DATA_TYPE_STRING);
+put_amf_string(pb, "Text");
+put_amf_string(pb, "text");
+avio_w8(pb, AMF_DATA_TYPE_STRING);
+put_amf_string(pb, pkt->data);
+put_amf_string(pb, "");
+avio_w8(pb, AMF_END_OF_OBJECT);
+} else {
+// just pass the metadata through
+avio_write(pb, data ? data : pkt->data, size);
+}
 /* write total size of tag */
 data_size = avio_tell(pb) - metadata_size_pos;
 avio_seek(pb, metadata_size_pos - 10, SEEK_SET);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avformat/aviobuf: fix avio_flush() for read streams

2014-09-30 Thread wm4
ffmpeg | branch: master | wm4  | Tue Sep 30 18:46:48 
2014 +0200| [c8422f04a3256a9abc01588f1b4aa95f5aadc891] | committer: Michael 
Niedermayer

avformat/aviobuf: fix avio_flush() for read streams

avio_flush() did nothing useful for read streams. Fix it to behave as
expected, and discard the currently read buffer properly.

Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c8422f04a3256a9abc01588f1b4aa95f5aadc891
---

 libavformat/avio.h|8 ++--
 libavformat/aviobuf.c |4 +++-
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/libavformat/avio.h b/libavformat/avio.h
index 2210c01..86f754e 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -289,10 +289,14 @@ int url_feof(AVIOContext *s);
 int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3);
 
 /**
- * Force flushing of buffered data to the output s.
+ * Force flushing of buffered data.
  *
- * Force the buffered data to be immediately written to the output,
+ * For write streams, force the buffered data to be immediately written to the 
output,
  * without to wait to fill the internal buffer.
+ *
+ * For read streams, discard all currently buffered data, and advance the
+ * reported file position to that of the underlying stream. This does not
+ * read new data, and does not perform any seeks.
  */
 void avio_flush(AVIOContext *s);
 
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 9795ba4..f01ed88 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -139,7 +139,7 @@ static void writeout(AVIOContext *s, const uint8_t *data, 
int len)
 
 static void flush_buffer(AVIOContext *s)
 {
-if (s->buf_ptr > s->buffer) {
+if (s->write_flag && s->buf_ptr > s->buffer) {
 writeout(s, s->buffer, s->buf_ptr - s->buffer);
 if (s->update_checksum) {
 s->checksum = s->update_checksum(s->checksum, s->checksum_ptr,
@@ -148,6 +148,8 @@ static void flush_buffer(AVIOContext *s)
 }
 }
 s->buf_ptr = s->buffer;
+if (!s->write_flag)
+s->buf_end = s->buffer;
 }
 
 void avio_w8(AVIOContext *s, int b)

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avcodec/utils: Force mutex to NULL after destruction.

2014-09-30 Thread Manfred Georg
ffmpeg | branch: master | Manfred Georg  | Tue Sep 30 
15:20:42 2014 -0700| [79551d2c7a772ea971e94f0b8dc03d1e897e8d86] | committer: 
Michael Niedermayer

avcodec/utils: Force mutex to NULL after destruction.

A badly behaving user provided mutex manager (such as that in OpenCV) may not 
reset the mutex to NULL on destruction.  This can cause a problem for a later 
mutex manager (which may assert that the mutex is NULL before creating).

Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=79551d2c7a772ea971e94f0b8dc03d1e897e8d86
---

 libavcodec/utils.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 9eb2b5b..778bdc6 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -3461,6 +3461,8 @@ int av_lockmgr_register(int (*cb)(void **mutex, enum 
AVLockOp op))
 return -1;
 if (lockmgr_cb(&avformat_mutex, AV_LOCK_DESTROY))
 return -1;
+codec_mutex = NULL;
+avformat_mutex = NULL;
 }
 
 lockmgr_cb = cb;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog