[libav-commits] hevc: implement pic_output_flag handling

2014-07-11 Thread Gildas Cocherel
Module: libav
Branch: master
Commit: 458e7c94830d1522997e33a0b5e87bd709e8a349

Author:Gildas Cocherel gildas.coche...@laposte.net
Committer: Anton Khirnov an...@khirnov.net
Date:  Fri Jul  4 11:21:56 2014 -0400

hevc: implement pic_output_flag handling

Sample-Id: OPFLAG_B_Qualcomm_1.bit, OPFLAG_C_Qualcomm_1.bit
Signed-off-by: Vittorio Giovara vittorio.giov...@gmail.com
Signed-off-by: Anton Khirnov an...@khirnov.net

---

 libavcodec/hevc.c  |2 ++
 libavcodec/hevc_refs.c |6 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
index d801a47..d9c9c71 100644
--- a/libavcodec/hevc.c
+++ b/libavcodec/hevc.c
@@ -546,6 +546,8 @@ static int hls_slice_header(HEVCContext *s)
 return AVERROR_INVALIDDATA;
 }
 
+// when flag is not present, picture is inferred to be output
+sh-pic_output_flag = 1;
 if (s-pps-output_flag_present_flag)
 sh-pic_output_flag = get_bits1(gb);
 
diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
index 2fbe9e7..c924227 100644
--- a/libavcodec/hevc_refs.c
+++ b/libavcodec/hevc_refs.c
@@ -143,8 +143,12 @@ int ff_hevc_set_new_ref(HEVCContext *s, AVFrame **frame, 
int poc)
 *frame = ref-frame;
 s-ref = ref;
 
+if (s-sh.pic_output_flag)
+ref-flags = HEVC_FRAME_FLAG_OUTPUT | HEVC_FRAME_FLAG_SHORT_REF;
+else
+ref-flags = HEVC_FRAME_FLAG_SHORT_REF;
+
 ref-poc  = poc;
-ref-flags= HEVC_FRAME_FLAG_OUTPUT | HEVC_FRAME_FLAG_SHORT_REF;
 ref-sequence = s-seq_decode;
 ref-window   = s-sps-output_window;
 

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits


[libav-commits] hevc: remove unused array min_cb_addr_zs

2014-06-26 Thread Gildas Cocherel
Module: libav
Branch: master
Commit: a0e1c3517a656dd32293f054a339e0ac73328138

Author:Gildas Cocherel gildas.coche...@laposte.net
Committer: Anton Khirnov an...@khirnov.net
Date:  Wed Jun 25 21:08:12 2014 +0200

hevc: remove unused array min_cb_addr_zs

Signed-off-by: Anton Khirnov an...@khirnov.net

---

 libavcodec/hevc.h|1 -
 libavcodec/hevc_ps.c |   19 +--
 2 files changed, 1 insertion(+), 19 deletions(-)

diff --git a/libavcodec/hevc.h b/libavcodec/hevc.h
index 959cd58..4b8bcf8 100644
--- a/libavcodec/hevc.h
+++ b/libavcodec/hevc.h
@@ -523,7 +523,6 @@ typedef struct HEVCPPS {
 int *ctb_addr_ts_to_rs; /// CtbAddrTSToRS
 int *tile_id;   /// TileId
 int *tile_pos_rs;   /// TilePosRS
-int *min_cb_addr_zs;/// MinCbAddrZS
 int *min_tb_addr_zs;/// MinTbAddrZS
 } HEVCPPS;
 
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 65f41b2..4d1d027 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -980,7 +980,6 @@ static void hevc_pps_free(void *opaque, uint8_t *data)
 av_freep(pps-ctb_addr_ts_to_rs);
 av_freep(pps-tile_pos_rs);
 av_freep(pps-tile_id);
-av_freep(pps-min_cb_addr_zs);
 av_freep(pps-min_tb_addr_zs);
 
 av_freep(pps);
@@ -1235,10 +1234,9 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
 pps-ctb_addr_rs_to_ts = av_malloc_array(pic_area_in_ctbs,
sizeof(*pps-ctb_addr_rs_to_ts));
 pps-ctb_addr_ts_to_rs = av_malloc_array(pic_area_in_ctbs,
sizeof(*pps-ctb_addr_ts_to_rs));
 pps-tile_id   = av_malloc_array(pic_area_in_ctbs,
sizeof(*pps-tile_id));
-pps-min_cb_addr_zs= av_malloc_array(pic_area_in_min_cbs, 
sizeof(*pps-min_cb_addr_zs));
 pps-min_tb_addr_zs= av_malloc_array(pic_area_in_min_tbs, 
sizeof(*pps-min_tb_addr_zs));
 if (!pps-ctb_addr_rs_to_ts || !pps-ctb_addr_ts_to_rs ||
-!pps-tile_id || !pps-min_cb_addr_zs || !pps-min_tb_addr_zs) {
+!pps-tile_id || !pps-min_tb_addr_zs) {
 ret = AVERROR(ENOMEM);
 goto err;
 }
@@ -1292,21 +1290,6 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
 for (i = 0; i  pps-num_tile_columns; i++)
 pps-tile_pos_rs[j * pps-num_tile_columns + i] = pps-row_bd[j] * 
sps-ctb_width + pps-col_bd[i];
 
-for (y = 0; y  sps-min_cb_height; y++) {
-for (x = 0; x  sps-min_cb_width; x++) {
-int tb_x= x  sps-log2_diff_max_min_coding_block_size;
-int tb_y= y  sps-log2_diff_max_min_coding_block_size;
-int ctb_addr_rs = sps-ctb_width * tb_y + tb_x;
-int val = pps-ctb_addr_rs_to_ts[ctb_addr_rs] 
-  (sps-log2_diff_max_min_coding_block_size * 2);
-for (i = 0; i  sps-log2_diff_max_min_coding_block_size; i++) {
-int m = 1  i;
-val += (m  x ? m * m : 0) + (m  y ? 2 * m * m : 0);
-}
-pps-min_cb_addr_zs[y * sps-min_cb_width + x] = val;
-}
-}
-
 log2_diff_ctb_min_tb_size = sps-log2_ctb_size - sps-log2_min_tb_size;
 for (y = 0; y  sps-min_tb_height; y++) {
 for (x = 0; x  sps-min_tb_width; x++) {

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits


[libav-commits] hevc: store profile and level in AVCodecContext

2013-12-20 Thread Gildas Cocherel
Module: libav
Branch: master
Commit: 321cb8b048c7a8c0d2950f9278f36d912a886fa0

Author:Gildas Cocherel gildas.coche...@laposte.net
Committer: Anton Khirnov an...@khirnov.net
Date:  Sat Dec 14 15:50:28 2013 +0100

hevc: store profile and level in AVCodecContext

Signed-off-by: Anton Khirnov an...@khirnov.net

---

 libavcodec/hevc.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
index 530abdc..784e58b 100644
--- a/libavcodec/hevc.c
+++ b/libavcodec/hevc.c
@@ -495,6 +495,9 @@ static int hls_slice_header(HEVCContext *s)
 s-max_ra = INT_MAX;
 }
 
+s-avctx-profile = s-sps-ptl.general_ptl.profile_idc;
+s-avctx-level   = s-sps-ptl.general_ptl.level_idc;
+
 sh-dependent_slice_segment_flag = 0;
 if (!sh-first_slice_in_pic_flag) {
 int slice_address_length;

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits


[libav-commits] lavc: add HEVC profiles names

2013-12-20 Thread Gildas Cocherel
Module: libav
Branch: master
Commit: 2a41826bea3833895dc06939831b7f35ca1f597e

Author:Gildas Cocherel gildas.coche...@laposte.net
Committer: Anton Khirnov an...@khirnov.net
Date:  Thu Dec 19 00:30:24 2013 +0100

lavc: add HEVC profiles names

Signed-off-by: Anton Khirnov an...@khirnov.net

---

 doc/APIchanges   |3 +++
 libavcodec/avcodec.h |5 +
 libavcodec/hevc.c|9 +
 libavcodec/version.h |2 +-
 4 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 944d214..60e16d8 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil: 2013-12-xx
 
 API changes, most recent first:
 
+2013-12-xx - xxx - lavc 55.30.0 - avcodec.h
+  Add HEVC profiles
+
 2013-12-xx - xxx - lavc 55.28.1 - avcodec.h
   av_frame_alloc(), av_frame_unref() and av_frame_free() now can and should be
   used instead of avcodec_alloc_frame(), avcodec_get_frame_defaults() and
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 0e6ac05..9531c85 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2662,6 +2662,11 @@ typedef struct AVCodecContext {
 #define FF_PROFILE_JPEG2000_DCINEMA_2K  3
 #define FF_PROFILE_JPEG2000_DCINEMA_4K  4
 
+
+#define FF_PROFILE_HEVC_MAIN1
+#define FF_PROFILE_HEVC_MAIN_10 2
+#define FF_PROFILE_HEVC_MAIN_STILL_PICTURE  3
+
 /**
  * level
  * - encoding: Set by user.
diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
index 4af5aee..530abdc 100644
--- a/libavcodec/hevc.c
+++ b/libavcodec/hevc.c
@@ -3170,6 +3170,14 @@ static void hevc_decode_flush(AVCodecContext *avctx)
 
 #define OFFSET(x) offsetof(HEVCContext, x)
 #define PAR (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
+
+static const AVProfile profiles[] = {
+{ FF_PROFILE_HEVC_MAIN, Main},
+{ FF_PROFILE_HEVC_MAIN_10,  Main 10 },
+{ FF_PROFILE_HEVC_MAIN_STILL_PICTURE,   Main Still Picture  },
+{ FF_PROFILE_UNKNOWN },
+};
+
 static const AVOption options[] = {
 { apply_defdispwin, Apply default display window from VUI, 
OFFSET(apply_defdispwin),
 AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, PAR },
@@ -3198,4 +3206,5 @@ AVCodec ff_hevc_decoder = {
 .init_thread_copy  = hevc_init_thread_copy,
 .capabilities  = CODEC_CAP_DR1 | CODEC_CAP_DELAY |
  CODEC_CAP_FRAME_THREADS,
+.profiles  = NULL_IF_CONFIG_SMALL(profiles),
 };
diff --git a/libavcodec/version.h b/libavcodec/version.h
index c5a777b..25c22df 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -27,7 +27,7 @@
  */
 
 #define LIBAVCODEC_VERSION_MAJOR 55
-#define LIBAVCODEC_VERSION_MINOR 29
+#define LIBAVCODEC_VERSION_MINOR 30
 #define LIBAVCODEC_VERSION_MICRO  0
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits


[libav-commits] hevc_ps: fix indentation

2013-12-20 Thread Gildas Cocherel
Module: libav
Branch: master
Commit: 259cddb137988a25607f091c2414158ff81ca7d6

Author:Gildas Cocherel gildas.coche...@laposte.net
Committer: Anton Khirnov an...@khirnov.net
Date:  Fri Dec 20 19:39:10 2013 +0100

hevc_ps: fix indentation

Signed-off-by: Anton Khirnov an...@khirnov.net

---

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

diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 5dde0cd..b940c9b 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -320,7 +320,7 @@ int ff_hevc_decode_nal_vps(HEVCContext *s)
 AVBufferRef *vps_buf = av_buffer_allocz(sizeof(*vps));
 
 if (!vps_buf)
-  return AVERROR(ENOMEM);
+return AVERROR(ENOMEM);
 vps = (HEVCVPS*)vps_buf-data;
 
 av_log(s-avctx, AV_LOG_DEBUG, Decoding VPS\n);

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits


[libav-commits] hevc: refactor Profile Tier Level

2013-12-20 Thread Gildas Cocherel
Module: libav
Branch: master
Commit: 2d18aaa14bc2233b0647d2c5abb72e0bc828c2a8

Author:Gildas Cocherel gildas.coche...@laposte.net
Committer: Anton Khirnov an...@khirnov.net
Date:  Thu Dec 19 00:36:45 2013 +0100

hevc: refactor Profile Tier Level

Also store a few PTL flags which were skipped before

Signed-off-by: Anton Khirnov an...@khirnov.net

---

 libavcodec/hevc.h|   25 +++-
 libavcodec/hevc_ps.c |   63 +-
 2 files changed, 45 insertions(+), 43 deletions(-)

diff --git a/libavcodec/hevc.h b/libavcodec/hevc.h
index bd6f50f..f2a8dfa 100644
--- a/libavcodec/hevc.h
+++ b/libavcodec/hevc.h
@@ -328,21 +328,24 @@ typedef struct VUI {
 int log2_max_mv_length_vertical;
 } VUI;
 
+typedef struct PTLCommon {
+uint8_t profile_space;
+uint8_t tier_flag;
+uint8_t profile_idc;
+uint8_t profile_compatibility_flag[32];
+uint8_t level_idc;
+uint8_t progressive_source_flag;
+uint8_t interlaced_source_flag;
+uint8_t non_packed_constraint_flag;
+uint8_t frame_only_constraint_flag;
+} PTLCommon;
+
 typedef struct PTL {
-int general_profile_space;
-uint8_t general_tier_flag;
-int general_profile_idc;
-int general_profile_compatibility_flag[32];
-int general_level_idc;
+PTLCommon general_ptl;
+PTLCommon sub_layer_ptl[MAX_SUB_LAYERS];
 
 uint8_t sub_layer_profile_present_flag[MAX_SUB_LAYERS];
 uint8_t sub_layer_level_present_flag[MAX_SUB_LAYERS];
-
-int sub_layer_profile_space[MAX_SUB_LAYERS];
-uint8_t sub_layer_tier_flag[MAX_SUB_LAYERS];
-int sub_layer_profile_idc[MAX_SUB_LAYERS];
-uint8_t sub_layer_profile_compatibility_flags[MAX_SUB_LAYERS][32];
-int sub_layer_level_idc[MAX_SUB_LAYERS];
 } PTL;
 
 typedef struct HEVCVPS {
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 5f33005..5dde0cd 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -192,51 +192,47 @@ int ff_hevc_decode_short_term_rps(HEVCContext *s, 
ShortTermRPS *rps,
 return 0;
 }
 
-static void decode_profile_tier_level(HEVCLocalContext *lc, PTL *ptl,
- int max_num_sub_layers)
+
+static void decode_profile_tier_level(HEVCContext *s, PTLCommon *ptl)
 {
-int i, j;
-GetBitContext *gb = lc-gb;
+int i;
+GetBitContext *gb = s-HEVClc.gb;
+
+ptl-profile_space = get_bits(gb, 2);
+ptl-tier_flag = get_bits1(gb);
+ptl-profile_idc   = get_bits(gb, 5);
 
-ptl-general_profile_space = get_bits(gb, 2);
-ptl-general_tier_flag = get_bits1(gb);
-ptl-general_profile_idc   = get_bits(gb, 5);
 for (i = 0; i  32; i++)
-ptl-general_profile_compatibility_flag[i] = get_bits1(gb);
-skip_bits1(gb); // general_progressive_source_flag
-skip_bits1(gb); // general_interlaced_source_flag
-skip_bits1(gb); // general_non_packed_constraint_flag
-skip_bits1(gb); // general_frame_only_constraint_flag
+ptl-profile_compatibility_flag[i] = get_bits1(gb);
+ptl-progressive_source_flag= get_bits1(gb);
+ptl-interlaced_source_flag = get_bits1(gb);
+ptl-non_packed_constraint_flag = get_bits1(gb);
+ptl-frame_only_constraint_flag = get_bits1(gb);
+
 skip_bits(gb, 16); // XXX_reserved_zero_44bits[0..15]
 skip_bits(gb, 16); // XXX_reserved_zero_44bits[16..31]
 skip_bits(gb, 12); // XXX_reserved_zero_44bits[32..43]
+}
+
+static void parse_ptl(HEVCContext *s, PTL *ptl, int max_num_sub_layers)
+{
+int i;
+GetBitContext *gb = s-HEVClc.gb;
+decode_profile_tier_level(s, ptl-general_ptl);
+ptl-general_ptl.level_idc = get_bits(gb, 8);
 
-ptl-general_level_idc = get_bits(gb, 8);
 for (i = 0; i  max_num_sub_layers - 1; i++) {
 ptl-sub_layer_profile_present_flag[i] = get_bits1(gb);
 ptl-sub_layer_level_present_flag[i]   = get_bits1(gb);
 }
 if (max_num_sub_layers - 1  0)
 for (i = max_num_sub_layers - 1; i  8; i++)
-skip_bits(gb, 2);  // reserved_zero_2bits[i]
+skip_bits(gb, 2); // reserved_zero_2bits[i]
 for (i = 0; i  max_num_sub_layers - 1; i++) {
-if (ptl-sub_layer_profile_present_flag[i]) {
-ptl-sub_layer_profile_space[i] = get_bits(gb, 2);
-ptl-sub_layer_tier_flag[i] = get_bits(gb, 1);
-ptl-sub_layer_profile_idc[i]   = get_bits(gb, 5);
-for (j = 0; j  32; j++)
-ptl-sub_layer_profile_compatibility_flags[i][j] = 
get_bits1(gb);
-skip_bits1(gb); // sub_layer_progressive_source_flag
-skip_bits1(gb); // sub_layer_interlaced_source_flag
-skip_bits1(gb); // sub_layer_non_packed_constraint_flag
-skip_bits1(gb); // sub_layer_frame_only_constraint_flag
-
-skip_bits(gb, 16); // sub_layer_reserved_zero_44bits[0..15]
-skip_bits(gb, 16); // sub_layer_reserved_zero_44bits[16..31]
-skip_bits(gb, 12); // sub_layer_reserved_zero_44bits[32..43

[libav-commits] hevc: store the VPS list as an AVBufferRef, just like the others *PS

2013-12-11 Thread Gildas Cocherel
Module: libav
Branch: master
Commit: 33452aede6acab78f726cd1924824585f00765cc

Author:Gildas Cocherel gildas.coche...@laposte.net
Committer: Anton Khirnov an...@khirnov.net
Date:  Tue Dec 10 15:42:28 2013 +0100

hevc: store the VPS list as an AVBufferRef, just like the others *PS

Signed-off-by: Anton Khirnov an...@khirnov.net

---

 libavcodec/hevc.c|   13 +++--
 libavcodec/hevc.h|2 +-
 libavcodec/hevc_ps.c |   15 ---
 3 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
index b7e7757..d969f5e 100644
--- a/libavcodec/hevc.c
+++ b/libavcodec/hevc.c
@@ -431,7 +431,7 @@ static int set_sps(HEVCContext *s, const HEVCSPS *sps)
 }
 
 s-sps = sps;
-s-vps = s-vps_list[s-sps-vps_id];
+s-vps = (HEVCVPS*) s-vps_list[s-sps-vps_id]-data;
 return 0;
 
 fail:
@@ -2924,7 +2924,7 @@ static av_cold int hevc_decode_free(AVCodecContext *avctx)
 }
 
 for (i = 0; i  FF_ARRAY_ELEMS(s-vps_list); i++)
-av_freep(s-vps_list[i]);
+av_buffer_unref(s-vps_list[i]);
 for (i = 0; i  FF_ARRAY_ELEMS(s-sps_list); i++)
 av_buffer_unref(s-sps_list[i]);
 for (i = 0; i  FF_ARRAY_ELEMS(s-pps_list); i++)
@@ -2999,6 +2999,15 @@ static int hevc_update_thread_context(AVCodecContext 
*dst,
 }
 }
 
+for (i = 0; i  FF_ARRAY_ELEMS(s-vps_list); i++) {
+av_buffer_unref(s-vps_list[i]);
+if (s0-vps_list[i]) {
+s-vps_list[i] = av_buffer_ref(s0-vps_list[i]);
+if (!s-vps_list[i])
+return AVERROR(ENOMEM);
+}
+}
+
 for (i = 0; i  FF_ARRAY_ELEMS(s-sps_list); i++) {
 av_buffer_unref(s-sps_list[i]);
 if (s0-sps_list[i]) {
diff --git a/libavcodec/hevc.h b/libavcodec/hevc.h
index d19f312..bd6f50f 100644
--- a/libavcodec/hevc.h
+++ b/libavcodec/hevc.h
@@ -843,7 +843,7 @@ typedef struct HEVCContext {
 const HEVCVPS *vps;
 const HEVCSPS *sps;
 const HEVCPPS *pps;
-HEVCVPS *vps_list[MAX_VPS_COUNT];
+AVBufferRef *vps_list[MAX_VPS_COUNT];
 AVBufferRef *sps_list[MAX_SPS_COUNT];
 AVBufferRef *pps_list[MAX_PPS_COUNT];
 
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 402c16f..d981125 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -328,12 +328,13 @@ int ff_hevc_decode_nal_vps(HEVCContext *s)
 GetBitContext *gb = s-HEVClc.gb;
 int vps_id = 0;
 HEVCVPS *vps;
+AVBufferRef *vps_buf = av_buffer_allocz(sizeof(*vps));
 
-av_log(s-avctx, AV_LOG_DEBUG, Decoding VPS\n);
+if (!vps_buf)
+  return AVERROR(ENOMEM);
+vps = (HEVCVPS*)vps_buf-data;
 
-vps = av_mallocz(sizeof(*vps));
-if (!vps)
-return AVERROR(ENOMEM);
+av_log(s-avctx, AV_LOG_DEBUG, Decoding VPS\n);
 
 vps_id = get_bits(gb, 4);
 if (vps_id = MAX_VPS_COUNT) {
@@ -410,12 +411,12 @@ int ff_hevc_decode_nal_vps(HEVCContext *s)
 }
 get_bits1(gb); /* vps_extension_flag */
 
-av_free(s-vps_list[vps_id]);
-s-vps_list[vps_id] = vps;
+av_buffer_unref(s-vps_list[vps_id]);
+s-vps_list[vps_id] = vps_buf;
 return 0;
 
 err:
-av_free(vps);
+av_buffer_unref(vps_buf);
 return AVERROR_INVALIDDATA;
 }
 

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits