Re: [FFmpeg-devel] [PATCH 1/6] lavf/movenc: add sdtp (sample dependency) box

2017-12-02 Thread Michael Niedermayer
On Sun, Nov 19, 2017 at 12:46:30PM -0800, John Stebbins wrote:
> The sdtp is required by the AppleTV 4K in order to play 2160p60 video.
> ---
>  libavcodec/avcodec.h |  6 ++
>  libavformat/isom.h   |  5 +
>  libavformat/movenc.c | 30 ++
>  libavformat/movenc.h |  2 ++
>  4 files changed, 43 insertions(+)

will apply

thanks

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If you drop bombs on a foreign country and kill a hundred thousand
innocent people, expect your government to call the consequence
"unprovoked inhuman terrorist attacks" and use it to justify dropping
more bombs and killing more people. The technology changed, the idea is old.


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/6] lavf/movenc: add sdtp (sample dependency) box

2017-11-20 Thread John Stebbins

On 11/19/2017 02:29 PM, Carl Eugen Hoyos wrote:
> 2017-11-19 23:25 GMT+01:00 John Stebbins :
>> On 11/19/2017 02:12 PM, Carl Eugen Hoyos wrote:
>>> 2017-11-19 21:46 GMT+01:00 John Stebbins :
 The sdtp is required by the AppleTV 4K in order to play 2160p60 video.
 +/**
 + * Flag is used to indicate packets that contain frames that can
 + * be discarded by the decoder.  I.e. Non-reference frames.
 + */
 +#define AV_PKT_FLAG_DISPOSABLE 0x0010
>>> What sets this flag?
>> Encoders when encoding, demuxer when remuxing.
>> The subsequent patches set this flag for x264, x265, and mp4 demux.
> So does this patch alone work wrt the description: Does AppleTV play
> 4k with this patch alone?
>
>

The commit message simply states that the atom is a requirement.  It doesn't 
say whether there are additional
requirements.  Are you saying you would like the commit message amended, or 
that the comment in the code needs to say
who must set the flag, or both?  Please be to the point.

-- 
John  GnuPG fingerprint: D0EC B3DB C372 D1F1 0B01  83F0 49F1 D7B2 60D4 D0F7




signature.asc
Description: OpenPGP digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/6] lavf/movenc: add sdtp (sample dependency) box

2017-11-19 Thread Carl Eugen Hoyos
2017-11-19 23:25 GMT+01:00 John Stebbins :
> On 11/19/2017 02:12 PM, Carl Eugen Hoyos wrote:
>> 2017-11-19 21:46 GMT+01:00 John Stebbins :
>>> The sdtp is required by the AppleTV 4K in order to play 2160p60 video.
>>> +/**
>>> + * Flag is used to indicate packets that contain frames that can
>>> + * be discarded by the decoder.  I.e. Non-reference frames.
>>> + */
>>> +#define AV_PKT_FLAG_DISPOSABLE 0x0010
>> What sets this flag?
>
> Encoders when encoding, demuxer when remuxing.

> The subsequent patches set this flag for x264, x265, and mp4 demux.

So does this patch alone work wrt the description: Does AppleTV play
4k with this patch alone?

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


Re: [FFmpeg-devel] [PATCH 1/6] lavf/movenc: add sdtp (sample dependency) box

2017-11-19 Thread John Stebbins
On 11/19/2017 02:12 PM, Carl Eugen Hoyos wrote:
> 2017-11-19 21:46 GMT+01:00 John Stebbins :
>> The sdtp is required by the AppleTV 4K in order to play 2160p60 video.
>> +/**
>> + * Flag is used to indicate packets that contain frames that can
>> + * be discarded by the decoder.  I.e. Non-reference frames.
>> + */
>> +#define AV_PKT_FLAG_DISPOSABLE 0x0010
> What sets this flag?
>
>

Encoders when encoding, demuxer when remuxing.  The subsequent patches set this 
flag for x264, x265, and mp4 demux.

-- 
John  GnuPG fingerprint: D0EC B3DB C372 D1F1 0B01  83F0 49F1 D7B2 60D4 D0F7




signature.asc
Description: OpenPGP digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/6] lavf/movenc: add sdtp (sample dependency) box

2017-11-19 Thread Carl Eugen Hoyos
2017-11-19 21:46 GMT+01:00 John Stebbins :
> The sdtp is required by the AppleTV 4K in order to play 2160p60 video.

> +/**
> + * Flag is used to indicate packets that contain frames that can
> + * be discarded by the decoder.  I.e. Non-reference frames.
> + */
> +#define AV_PKT_FLAG_DISPOSABLE 0x0010

What sets this flag?

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


[FFmpeg-devel] [PATCH 1/6] lavf/movenc: add sdtp (sample dependency) box

2017-11-19 Thread John Stebbins
The sdtp is required by the AppleTV 4K in order to play 2160p60 video.
---
 libavcodec/avcodec.h |  6 ++
 libavformat/isom.h   |  5 +
 libavformat/movenc.c | 30 ++
 libavformat/movenc.h |  2 ++
 4 files changed, 43 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 442b558d4b..4f4bebc586 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1443,6 +1443,12 @@ typedef struct AVPacket {
  * outside the packet may be followed.
  */
 #define AV_PKT_FLAG_TRUSTED   0x0008
+/**
+ * Flag is used to indicate packets that contain frames that can
+ * be discarded by the decoder.  I.e. Non-reference frames.
+ */
+#define AV_PKT_FLAG_DISPOSABLE 0x0010
+
 
 enum AVSideDataParamChangeFlags {
 AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT  = 0x0001,
diff --git a/libavformat/isom.h b/libavformat/isom.h
index ff08f5d090..65676fb0f5 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -318,6 +318,11 @@ void ff_mp4_parse_es_descr(AVIOContext *pb, int *es_id);
 #define MOV_TKHD_FLAG_IN_PREVIEW0x0004
 #define MOV_TKHD_FLAG_IN_POSTER 0x0008
 
+#define MOV_SAMPLE_DEPENDENCY_UNKNOWN 0x0
+#define MOV_SAMPLE_DEPENDENCY_YES 0x1
+#define MOV_SAMPLE_DEPENDENCY_NO  0x2
+
+
 #define TAG_IS_AVCI(tag)\
 ((tag) == MKTAG('a', 'i', '5', 'p') ||  \
  (tag) == MKTAG('a', 'i', '5', 'q') ||  \
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 01ae467fa1..c9ff65d43d 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -252,6 +252,30 @@ static int mov_write_stss_tag(AVIOContext *pb, MOVTrack 
*track, uint32_t flag)
 return update_size(pb, pos);
 }
 
+/* Sample dependency atom */
+static int mov_write_sdtp_tag(AVIOContext *pb, MOVTrack *track)
+{
+int i;
+uint8_t leading, dependent, reference, redundancy;
+int64_t pos = avio_tell(pb);
+avio_wb32(pb, 0); // size
+ffio_wfourcc(pb, "sdtp");
+avio_wb32(pb, 0); // version & flags
+for (i = 0; i < track->entry; i++) {
+dependent = MOV_SAMPLE_DEPENDENCY_YES;
+leading = reference = redundancy = MOV_SAMPLE_DEPENDENCY_UNKNOWN;
+if (track->cluster[i].flags & MOV_DISPOSABLE_SAMPLE) {
+reference = MOV_SAMPLE_DEPENDENCY_NO;
+}
+if (track->cluster[i].flags & MOV_SYNC_SAMPLE) {
+dependent = MOV_SAMPLE_DEPENDENCY_NO;
+}
+avio_w8(pb, (leading << 6)   | (dependent << 4) |
+(reference << 2) | redundancy);
+}
+return update_size(pb, pos);
+}
+
 static int mov_write_amr_tag(AVIOContext *pb, MOVTrack *track)
 {
 avio_wb32(pb, 0x11); /* size */
@@ -2320,6 +2344,8 @@ static int mov_write_stbl_tag(AVFormatContext *s, 
AVIOContext *pb, MOVMuxContext
  track->par->codec_tag == MKTAG('r','t','p',' ')) &&
 track->has_keyframes && track->has_keyframes < track->entry)
 mov_write_stss_tag(pb, track, MOV_SYNC_SAMPLE);
+if (track->par->codec_type == AVMEDIA_TYPE_VIDEO && track->has_disposable)
+mov_write_sdtp_tag(pb, track);
 if (track->mode == MODE_MOV && track->flags & MOV_TRACK_STPS)
 mov_write_stss_tag(pb, track, MOV_PARTIAL_SYNC_SAMPLE);
 if (track->par->codec_type == AVMEDIA_TYPE_VIDEO &&
@@ -5283,6 +5309,10 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 if (trk->cluster[trk->entry].flags & MOV_SYNC_SAMPLE)
 trk->has_keyframes++;
 }
+if (pkt->flags & AV_PKT_FLAG_DISPOSABLE) {
+trk->cluster[trk->entry].flags |= MOV_DISPOSABLE_SAMPLE;
+trk->has_disposable++;
+}
 trk->entry++;
 trk->sample_count += samples_in_chunk;
 mov->mdat_size+= size;
diff --git a/libavformat/movenc.h b/libavformat/movenc.h
index cc2a155d79..c4e966b7fb 100644
--- a/libavformat/movenc.h
+++ b/libavformat/movenc.h
@@ -53,6 +53,7 @@ typedef struct MOVIentry {
 int  cts;
 #define MOV_SYNC_SAMPLE 0x0001
 #define MOV_PARTIAL_SYNC_SAMPLE 0x0002
+#define MOV_DISPOSABLE_SAMPLE   0x0004
 uint32_t flags;
 } MOVIentry;
 
@@ -89,6 +90,7 @@ typedef struct MOVTrack {
 longsample_size;
 longchunkCount;
 int has_keyframes;
+int has_disposable;
 #define MOV_TRACK_CTTS 0x0001
 #define MOV_TRACK_STPS 0x0002
 #define MOV_TRACK_ENABLED  0x0004
-- 
2.13.6

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