From: Benjamin Larsson <benja...@southpole.se>

---
 libavcodec/asv1.c        |    6 ++++--
 libavcodec/avcodec.h     |    4 ++++
 libavcodec/dnxhddec.c    |    2 +-
 libavcodec/dv.c          |    4 ++--
 libavcodec/huffyuv.c     |    5 +++--
 libavcodec/libopenjpeg.c |    2 +-
 libavcodec/ljpegenc.c    |    1 +
 libavcodec/mjpegbdec.c   |    2 +-
 libavcodec/mjpegdec.c    |    2 +-
 libavcodec/proresdec.c   |    2 +-
 libavcodec/rawdec.c      |    1 +
 libavcodec/rawenc.c      |    1 +
 libavcodec/vcr1.c        |    3 ++-
 libavformat/utils.c      |   29 ++---------------------------
 14 files changed, 25 insertions(+), 39 deletions(-)

diff --git a/libavcodec/asv1.c b/libavcodec/asv1.c
index 97c5e68..924a5ad 100644
--- a/libavcodec/asv1.c
+++ b/libavcodec/asv1.c
@@ -610,7 +610,7 @@ AVCodec ff_asv1_decoder = {
     .init           = decode_init,
     .close          = decode_end,
     .decode         = decode_frame,
-    .capabilities   = CODEC_CAP_DR1,
+    .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_INTRA_ONLY,
     .long_name= NULL_IF_CONFIG_SMALL("ASUS V1"),
 };
 
@@ -622,7 +622,7 @@ AVCodec ff_asv2_decoder = {
     .init           = decode_init,
     .close          = decode_end,
     .decode         = decode_frame,
-    .capabilities   = CODEC_CAP_DR1,
+    .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_INTRA_ONLY,
     .long_name= NULL_IF_CONFIG_SMALL("ASUS V2"),
 };
 
@@ -635,6 +635,7 @@ AVCodec ff_asv1_encoder = {
     .init           = encode_init,
     .encode         = encode_frame,
     //encode_end,
+    .capabilities   = CODEC_CAP_INTRA_ONLY,
     .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
     .long_name= NULL_IF_CONFIG_SMALL("ASUS V1"),
 };
@@ -649,6 +650,7 @@ AVCodec ff_asv2_encoder = {
     .init           = encode_init,
     .encode         = encode_frame,
     //encode_end,
+    .capabilities   = CODEC_CAP_INTRA_ONLY,
     .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
     .long_name= NULL_IF_CONFIG_SMALL("ASUS V2"),
 };
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index a7defa0..df3c87e 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -710,6 +710,10 @@ typedef struct RcOverride{
  * Codec supports slice-based (or partition-based) multithreading.
  */
 #define CODEC_CAP_SLICE_THREADS    0x2000
+/**
+ * Codec is intra only, used to mark packets when some containers miss that 
info
+ */
+#define CODEC_CAP_INTRA_ONLY       0x4000
 
 //The following defines may change, don't expect compatibility if you use them.
 #define MB_TYPE_INTRA4x4   0x0001
diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c
index 7198a2f..ae5e558 100644
--- a/libavcodec/dnxhddec.c
+++ b/libavcodec/dnxhddec.c
@@ -399,6 +399,6 @@ AVCodec ff_dnxhd_decoder = {
     .init           = dnxhd_decode_init,
     .close          = dnxhd_decode_close,
     .decode         = dnxhd_decode_frame,
-    .capabilities   = CODEC_CAP_DR1,
+    .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_INTRA_ONLY,
     .long_name = NULL_IF_CONFIG_SMALL("VC3/DNxHD"),
 };
diff --git a/libavcodec/dv.c b/libavcodec/dv.c
index 9762422..bfefbc2 100644
--- a/libavcodec/dv.c
+++ b/libavcodec/dv.c
@@ -1285,7 +1285,7 @@ AVCodec ff_dvvideo_encoder = {
     .priv_data_size = sizeof(DVVideoContext),
     .init           = dvvideo_init_encoder,
     .encode         = dvvideo_encode_frame,
-    .capabilities = CODEC_CAP_SLICE_THREADS,
+    .capabilities = CODEC_CAP_SLICE_THREADS | CODEC_CAP_INTRA_ONLY,
     .pix_fmts  = (const enum PixelFormat[]) {PIX_FMT_YUV411P, PIX_FMT_YUV422P, 
PIX_FMT_YUV420P, PIX_FMT_NONE},
     .long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"),
 };
@@ -1300,7 +1300,7 @@ AVCodec ff_dvvideo_decoder = {
     .init           = dvvideo_init,
     .close          = dvvideo_close,
     .decode         = dvvideo_decode_frame,
-    .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_SLICE_THREADS,
+    .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_SLICE_THREADS | 
CODEC_CAP_INTRA_ONLY,
     .max_lowres = 3,
     .long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"),
 };
diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c
index 865bc6a..341ce0e 100644
--- a/libavcodec/huffyuv.c
+++ b/libavcodec/huffyuv.c
@@ -1442,7 +1442,7 @@ AVCodec ff_huffyuv_decoder = {
     .init           = decode_init,
     .close          = decode_end,
     .decode         = decode_frame,
-    .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | 
CODEC_CAP_FRAME_THREADS,
+    .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | 
CODEC_CAP_FRAME_THREADS | CODEC_CAP_INTRA_ONLY,
     .init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy),
     .long_name = NULL_IF_CONFIG_SMALL("Huffyuv / HuffYUV"),
 };
@@ -1457,7 +1457,7 @@ AVCodec ff_ffvhuff_decoder = {
     .init           = decode_init,
     .close          = decode_end,
     .decode         = decode_frame,
-    .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | 
CODEC_CAP_FRAME_THREADS,
+    .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_DRAW_HORIZ_BAND | 
CODEC_CAP_FRAME_THREADS | CODEC_CAP_INTRA_ONLY,
     .init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy),
     .long_name = NULL_IF_CONFIG_SMALL("Huffyuv FFmpeg variant"),
 };
@@ -1486,6 +1486,7 @@ AVCodec ff_ffvhuff_encoder = {
     .init           = encode_init,
     .encode         = encode_frame,
     .close          = encode_end,
+    .capabilities   = CODEC_CAP_INTRA_ONLY,
     .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV422P, 
PIX_FMT_RGB32, PIX_FMT_NONE},
     .long_name = NULL_IF_CONFIG_SMALL("Huffyuv FFmpeg variant"),
 };
diff --git a/libavcodec/libopenjpeg.c b/libavcodec/libopenjpeg.c
index 6e9e8fc..6b41eed 100644
--- a/libavcodec/libopenjpeg.c
+++ b/libavcodec/libopenjpeg.c
@@ -193,7 +193,7 @@ AVCodec ff_libopenjpeg_decoder = {
     NULL,
     libopenjpeg_decode_close,
     libopenjpeg_decode_frame,
-    CODEC_CAP_DR1,
+    .capabilities = CODEC_CAP_DR1 | CODEC_CAP_INTRA_ONLY,
     .max_lowres = 5,
     .long_name = NULL_IF_CONFIG_SMALL("OpenJPEG based JPEG 2000 decoder"),
 } ;
diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c
index 56a60c9..42e250d 100644
--- a/libavcodec/ljpegenc.c
+++ b/libavcodec/ljpegenc.c
@@ -194,5 +194,6 @@ AVCodec ff_ljpeg_encoder = { //FIXME avoid MPV_* lossless 
JPEG should not need t
     MPV_encode_init,
     encode_picture_lossless,
     MPV_encode_end,
+    .capabilities   = CODEC_CAP_INTRA_ONLY,
     .long_name = NULL_IF_CONFIG_SMALL("Lossless JPEG"),
 };
diff --git a/libavcodec/mjpegbdec.c b/libavcodec/mjpegbdec.c
index a9f94f1..4968736 100644
--- a/libavcodec/mjpegbdec.c
+++ b/libavcodec/mjpegbdec.c
@@ -157,7 +157,7 @@ AVCodec ff_mjpegb_decoder = {
     .init           = ff_mjpeg_decode_init,
     .close          = ff_mjpeg_decode_end,
     .decode         = mjpegb_decode_frame,
-    .capabilities   = CODEC_CAP_DR1,
+    .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_INTRA_ONLY,
     .max_lowres = 3,
     .long_name = NULL_IF_CONFIG_SMALL("Apple MJPEG-B"),
 };
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 168cc0b..0d044ac 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -1624,7 +1624,7 @@ AVCodec ff_mjpeg_decoder = {
     .init           = ff_mjpeg_decode_init,
     .close          = ff_mjpeg_decode_end,
     .decode         = ff_mjpeg_decode_frame,
-    .capabilities   = CODEC_CAP_DR1,
+    .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_INTRA_ONLY,
     .max_lowres = 3,
     .long_name = NULL_IF_CONFIG_SMALL("MJPEG (Motion JPEG)"),
     .priv_class     = &mjpegdec_class,
diff --git a/libavcodec/proresdec.c b/libavcodec/proresdec.c
index 759c10b..e82f67f 100644
--- a/libavcodec/proresdec.c
+++ b/libavcodec/proresdec.c
@@ -726,6 +726,6 @@ AVCodec ff_prores_decoder = {
     .init           = decode_init,
     .close          = decode_close,
     .decode         = decode_frame,
-    .capabilities   = CODEC_CAP_DR1,
+    .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_INTRA_ONLY,
     .long_name      = NULL_IF_CONFIG_SMALL("Apple ProRes (iCodec Pro)")
 };
diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c
index 9989a36..aaaa569 100644
--- a/libavcodec/rawdec.c
+++ b/libavcodec/rawdec.c
@@ -209,5 +209,6 @@ AVCodec ff_rawvideo_decoder = {
     .init           = raw_init_decoder,
     .close          = raw_close_decoder,
     .decode         = raw_decode,
+    .capabilities   = CODEC_CAP_INTRA_ONLY,
     .long_name = NULL_IF_CONFIG_SMALL("raw video"),
 };
diff --git a/libavcodec/rawenc.c b/libavcodec/rawenc.c
index 6640db0..73e9a35 100644
--- a/libavcodec/rawenc.c
+++ b/libavcodec/rawenc.c
@@ -62,5 +62,6 @@ AVCodec ff_rawvideo_encoder = {
     .priv_data_size = sizeof(AVFrame),
     .init           = raw_init_encoder,
     .encode         = raw_encode,
+    .capabilities   = CODEC_CAP_INTRA_ONLY,
     .long_name = NULL_IF_CONFIG_SMALL("raw video"),
 };
diff --git a/libavcodec/vcr1.c b/libavcodec/vcr1.c
index f745089..5be240e 100644
--- a/libavcodec/vcr1.c
+++ b/libavcodec/vcr1.c
@@ -184,7 +184,7 @@ AVCodec ff_vcr1_decoder = {
     .init           = decode_init,
     .close          = decode_end,
     .decode         = decode_frame,
-    .capabilities   = CODEC_CAP_DR1,
+    .capabilities   = CODEC_CAP_DR1 | CODEC_CAP_INTRA_ONLY,
     .long_name = NULL_IF_CONFIG_SMALL("ATI VCR1"),
 };
 
@@ -196,6 +196,7 @@ AVCodec ff_vcr1_encoder = {
     .priv_data_size = sizeof(VCR1Context),
     .init           = encode_init,
     .encode         = encode_frame,
+    .capabilities   = CODEC_CAP_INTRA_ONLY,
     .long_name = NULL_IF_CONFIG_SMALL("ATI VCR1"),
 };
 #endif
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 17b342e..4a372c0 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -844,31 +844,6 @@ static void compute_frame_duration(int *pnum, int *pden, 
AVStream *st,
     }
 }
 
-static int is_intra_only(AVCodecContext *enc){
-    if(enc->codec_type == AVMEDIA_TYPE_AUDIO){
-        return 1;
-    }else if(enc->codec_type == AVMEDIA_TYPE_VIDEO){
-        switch(enc->codec_id){
-        case CODEC_ID_MJPEG:
-        case CODEC_ID_MJPEGB:
-        case CODEC_ID_LJPEG:
-        case CODEC_ID_PRORES:
-        case CODEC_ID_RAWVIDEO:
-        case CODEC_ID_DVVIDEO:
-        case CODEC_ID_HUFFYUV:
-        case CODEC_ID_FFVHUFF:
-        case CODEC_ID_ASV1:
-        case CODEC_ID_ASV2:
-        case CODEC_ID_VCR1:
-        case CODEC_ID_DNXHD:
-        case CODEC_ID_JPEG2000:
-            return 1;
-        default: break;
-        }
-    }
-    return 0;
-}
-
 static void update_initial_timestamps(AVFormatContext *s, int stream_index,
                                       int64_t dts, int64_t pts)
 {
@@ -1083,8 +1058,8 @@ static void compute_pkt_fields(AVFormatContext *s, 
AVStream *st,
 //    av_log(NULL, AV_LOG_ERROR, "OUTdelayed:%d/%d pts:%"PRId64", 
dts:%"PRId64" cur_dts:%"PRId64"\n", presentation_delayed, delay, pkt->pts, 
pkt->dts, st->cur_dts);
 
     /* update flags */
-    if(is_intra_only(st->codec))
-        pkt->flags |= AV_PKT_FLAG_KEY;
+    if (st->codec->codec->capabilities & CODEC_CAP_INTRA_ONLY)
+        pkt->flags |= AV_PKT_FLAG_KEY;  /* If the codec is an intra codec 
always set the keyframe flag */
     else if (pc) {
         pkt->flags = 0;
         /* keyframe computation */
-- 
1.7.1

_______________________________________________
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to