Re: [FFmpeg-devel] [PATCH 1/2] lavf/avienc: Add support for palette side data packets

2016-02-28 Thread Mats Peterson

On 02/28/2016 11:31 AM, Mats Peterson wrote:


Speaking of something else, with these patches it should be possible for
MPlayer to deliver the palette in a side data packet to the FFmpeg AVI
and QuickTime muxers. I suppose that's part of the reason why you want
palette side data handling to be implemented in the muxers, Reimar.



Plus the fact that it's needed when doing stream copy, with FFmpeg's 
current way of using palette side data packets on the demuxer side.


Mats

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


Re: [FFmpeg-devel] [PATCH 1/2] lavf/avienc: Add support for palette side data packets

2016-02-28 Thread Mats Peterson

On 02/28/2016 11:31 AM, Mats Peterson wrote:

On 02/28/2016 11:25 AM, Mats Peterson wrote:

On 02/28/2016 11:24 AM, Reimar Döffinger wrote:

Why is the packet data in AVI packets sometimes zero bytes when using
stream copy, Michael? There certainly must be some reason for it?


AVI is fixed frame rate. If you have for example variable frame rate
input empty packets will be used to get the right timing.
I'm not sure that is truly the cause in your case, but it is at least
one possible reason.
___


Yeah, that sounds like a possible reason alright. It only happens for
AVI, not Quicktime, so...

Mats

___



Speaking of something else, with these patches it should be possible for
MPlayer to deliver the palette in a side data packet to the FFmpeg AVI
and QuickTime muxers. I suppose that's part of the reason why you want
palette side data handling to be implemented in the muxers, Reimar.

Mats



or MEncoder, rather.


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


Re: [FFmpeg-devel] [PATCH 1/2] lavf/avienc: Add support for palette side data packets

2016-02-28 Thread Mats Peterson

On 02/28/2016 11:25 AM, Mats Peterson wrote:

On 02/28/2016 11:24 AM, Reimar Döffinger wrote:

Why is the packet data in AVI packets sometimes zero bytes when using
stream copy, Michael? There certainly must be some reason for it?


AVI is fixed frame rate. If you have for example variable frame rate
input empty packets will be used to get the right timing.
I'm not sure that is truly the cause in your case, but it is at least
one possible reason.
___


Yeah, that sounds like a possible reason alright. It only happens for
AVI, not Quicktime, so...

Mats

___



Speaking of something else, with these patches it should be possible for 
MPlayer to deliver the palette in a side data packet to the FFmpeg AVI 
and QuickTime muxers. I suppose that's part of the reason why you want 
palette side data handling to be implemented in the muxers, Reimar.


Mats

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


Re: [FFmpeg-devel] [PATCH 1/2] lavf/avienc: Add support for palette side data packets

2016-02-28 Thread Reimar Döffinger


On 28.02.2016, at 03:10, Mats Peterson  wrote:

> On 02/28/2016 03:00 AM, Mats Peterson wrote:
>> 
>> 
>> 
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>> 
> 
> Why is the packet data in AVI packets sometimes zero bytes when using stream 
> copy, Michael? There certainly must be some reason for it?

AVI is fixed frame rate. If you have for example variable frame rate input 
empty packets will be used to get the right timing.
I'm not sure that is truly the cause in your case, but it is at least one 
possible reason.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] lavf/avienc: Add support for palette side data packets

2016-02-27 Thread Mats Peterson

On 02/28/2016 03:00 AM, Mats Peterson wrote:




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



Why is the packet data in AVI packets sometimes zero bytes when using 
stream copy, Michael? There certainly must be some reason for it?


Mats

--
Mats Peterson
http://matsp888.no-ip.org/~mats/
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/2] lavf/avienc: Add support for palette side data packets

2016-02-27 Thread Mats Peterson


--
Mats Peterson
http://matsp888.no-ip.org/~mats/
>From 40adfd0b3be94dfaf88187ee9f71bd85ad858f9d Mon Sep 17 00:00:00 2001
From: Mats Peterson 
Date: Sun, 28 Feb 2016 02:58:36 +0100
Subject: [PATCH 1/2] lavf/avienc: Add support for palette side data packets

---
 libavformat/avienc.c |   49 +++--
 1 file changed, 27 insertions(+), 22 deletions(-)

diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index ca505f4..10c4413 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -668,39 +668,44 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
 if ((ret = write_skip_frames(s, stream_index, pkt->dts)) < 0)
 return ret;
 
-if (enc->codec_id == AV_CODEC_ID_RAWVIDEO && enc->codec_tag == 0) {
+if (enc->codec_id == AV_CODEC_ID_RAWVIDEO && enc->codec_tag == 0 && size) {
 int64_t bpc = enc->bits_per_coded_sample != 15 ? enc->bits_per_coded_sample : 16;
 int expected_stride = ((enc->width * bpc + 31) >> 5)*4;
-
+const uint8_t *pal = NULL;
+int pal_size = 1 << enc->bits_per_coded_sample;
+int i;
 ret = ff_reshuffle_raw_rgb(s, , enc, expected_stride);
 if (ret < 0)
 return ret;
-if (ret) {
-if (ret == CONTAINS_PAL) {
-int pc_tag, i;
-int pal_size = 1 << enc->bits_per_coded_sample;
-if (!avist->hdr_pal_done) {
-int64_t cur_offset = avio_tell(pb);
-avio_seek(pb, avist->pal_offset, SEEK_SET);
+pal = (uint8_t *)av_packet_get_side_data(pkt, AV_PKT_DATA_PALETTE, NULL);
+if (!pal && ret == CONTAINS_PAL)
+pal = data + size - AVPALETTE_SIZE;
+if (pal) {
+int pc_tag;
+if (!avist->hdr_pal_done) {
+int64_t cur_offset = avio_tell(pb);
+if (avio_seek(pb, avist->pal_offset, SEEK_SET) >= 0) {
 for (i = 0; i < pal_size; i++) {
-uint32_t v = AV_RL32(data + size - 4*pal_size + 4*i);
+uint32_t v = AV_RL32(pal + 4*i);
 avio_wl32(pb, v & 0xff);
 }
 avio_seek(pb, cur_offset, SEEK_SET);
-avist->hdr_pal_done++;
-}
-avi_stream2fourcc(tag, stream_index, enc->codec_type);
-tag[2] = 'p'; tag[3] = 'c';
-pc_tag = ff_start_tag(pb, tag);
-avio_w8(pb, 0);
-avio_w8(pb, pal_size & 0xFF);
-avio_wl16(pb, 0); // reserved
-for (i = 0; i < pal_size; i++) {
-uint32_t v = AV_RL32(data + size - 4*pal_size + 4*i);
-avio_wb32(pb, v<<8);
 }
-ff_end_tag(pb, pc_tag);
+avist->hdr_pal_done++;
 }
+avi_stream2fourcc(tag, stream_index, enc->codec_type);
+tag[2] = 'p'; tag[3] = 'c';
+pc_tag = ff_start_tag(pb, tag);
+avio_w8(pb, 0);
+avio_w8(pb, pal_size & 0xFF);
+avio_wl16(pb, 0); // reserved
+for (i = 0; i < pal_size; i++) {
+uint32_t v = AV_RL32(pal + 4*i);
+avio_wb32(pb, v<<8);
+}
+ff_end_tag(pb, pc_tag);
+}
+if (ret) {
 ret = avi_write_packet_internal(s, pkt);
 av_packet_free();
 return ret;
-- 
1.7.10.4

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