Re: [libav-devel] [PATCH 3/3] hevc_ps: make sure failing to decode an SPS always returns an error
On Mon, Jul 13, 2015 at 6:54 AM, Anton Khirnov an...@khirnov.net wrote: Some of the goto err clauses do not set the error code. It seems better to fall back on INVALIDDATA instead of adding it everywhere explicitly. --- 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 6102905..a1eaf6e 100644 --- a/libavcodec/hevc_ps.c +++ b/libavcodec/hevc_ps.c @@ -965,7 +965,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, return 0; err: -return ret; +return ret 0 ? ret : AVERROR_INVALIDDATA; } int ff_hevc_decode_nal_sps(GetBitContext *gb, AVCodecContext *avctx, should we return the error type immediately instead of using goto? nothing seems to need extra handling there -- Vittorio ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 1/6] asfdec: prevent the infinite loop when size of unknown object is 0
--- libavformat/asfdec.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index eaa69fd..b53a13f 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -1636,9 +1636,11 @@ static int asf_read_header(AVFormatContext *s) while (1) { // for the cases when object size is invalid if (avio_tell(pb) == asf-offset) { -if (asf-data_reached) +if (asf-data_reached) { avio_seek(pb, asf-first_packet_offset, SEEK_SET); -break; +break; +} else +return AVERROR_INVALIDDATA; } asf-offset = avio_tell(pb); if ((ret = ff_get_guid(pb, guid)) 0) { -- 2.0.1 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 2/6] asfdec: prevent memory leaks found with Coverity Scan
--- libavformat/asfdec.c | 12 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index b53a13f..3342c11 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -281,8 +281,10 @@ static int asf_read_value(AVFormatContext *s, uint8_t *name, uint16_t name_len, av_log(s, AV_LOG_WARNING, av_dict_set failed.\n); } else { char buf[256]; -if (val_len sizeof(buf)) -return AVERROR_INVALIDDATA; +if (val_len sizeof(buf)) { +ret = AVERROR_INVALIDDATA; +goto failed; +} if ((ret = avio_read(pb, value, val_len)) 0) goto failed; if (ret 2 * val_len) @@ -404,8 +406,10 @@ static int asf_read_picture(AVFormatContext *s, int len) } asf-asf_st[asf-nb_streams] = av_mallocz(sizeof(*asf_st)); asf_st = asf-asf_st[asf-nb_streams]; -if (!asf_st) -return AVERROR(ENOMEM); +if (!asf_st) { +ret = AVERROR(ENOMEM); +goto fail; +} st-disposition |= AV_DISPOSITION_ATTACHED_PIC; st-codec-codec_type = asf_st-type = AVMEDIA_TYPE_VIDEO; -- 2.0.1 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 3/3] hevc_ps: make sure failing to decode an SPS always returns an error
On 13/07/15 07:54, Anton Khirnov wrote: Some of the goto err clauses do not set the error code. It seems better to fall back on INVALIDDATA instead of adding it everywhere explicitly. --- 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 6102905..a1eaf6e 100644 --- a/libavcodec/hevc_ps.c +++ b/libavcodec/hevc_ps.c @@ -965,7 +965,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, return 0; err: -return ret; +return ret 0 ? ret : AVERROR_INVALIDDATA; } int ff_hevc_decode_nal_sps(GetBitContext *gb, AVCodecContext *avctx, I'm reworking that part already, not sure if somebody treats enomem differently from invaliddata. Apply if you feel like, shouldn't hurt particularly. lu ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 2/3] hevc: handle a NULL sps in set_sps() properly
On 13/07/15 07:54, Anton Khirnov wrote: This can happen in update_thread_context(), when the previous frame was corrupted. --- libavcodec/hevc.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) Shouldn't hurt. lu ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 4/6] asfdec: hadle invalid Object size properly
--- libavformat/asfdec.c | 12 ++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index 31e9bd4..7450bb1 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -903,7 +903,7 @@ static int asf_read_data(AVFormatContext *s, const GUIDParseTable *g) uint64_t size = asf-data_size = avio_rl64(pb); int i; -if (!asf-data_reached pb-seekable) { +if (!asf-data_reached) { asf-data_reached = 1; asf-data_offset= asf-offset; } @@ -1662,7 +1662,15 @@ static int asf_read_header(AVFormatContext *s) return ret; } else { size = avio_rl64(pb); -align_position(pb, asf-offset, size); +if (size INT64_MAX) +align_position(pb, asf-offset, size); +else { +if (asf-data_reached) { +avio_seek(pb, asf-first_packet_offset, SEEK_SET); +break; +} else +return AVERROR_INVALIDDATA; +} } if (asf-data_reached !pb-seekable) break; -- 2.0.1 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 6/6] asfdec: close the demuxer properly when read_header is failing
--- libavformat/asfdec.c | 26 ++ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index 1086427..ecc3f5c 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -1629,8 +1629,10 @@ static int asf_read_header(AVFormatContext *s) asf-preroll = 0; asf-is_simple_index = 0; ff_get_guid(pb, guid); -if (ff_guidcmp(guid, ff_asf_header)) -return AVERROR_INVALIDDATA; +if (ff_guidcmp(guid, ff_asf_header)) { +ret = AVERROR_INVALIDDATA; +goto failed; +} avio_skip(pb, 8); // skip header object size avio_skip(pb, 6); // skip number of header objects and 2 reserved bytes asf-data_reached = 0; @@ -1645,8 +1647,10 @@ static int asf_read_header(AVFormatContext *s) if (asf-data_reached) { avio_seek(pb, asf-first_packet_offset, SEEK_SET); break; -} else -return AVERROR_INVALIDDATA; +} else { +ret = AVERROR_INVALIDDATA; +goto failed; +} } asf-offset = avio_tell(pb); if ((ret = ff_get_guid(pb, guid)) 0) { @@ -1654,14 +1658,14 @@ static int asf_read_header(AVFormatContext *s) avio_seek(pb, asf-first_packet_offset, SEEK_SET); break; } else -return ret; +goto failed; } g = find_guid(guid); if (g) { asf-unknown_offset = asf-offset; asf-is_header = 1; if ((ret = g-read_object(s, g)) 0) -return ret; +goto failed; } else { size = avio_rl64(pb); if (size INT64_MAX) @@ -1670,8 +1674,10 @@ static int asf_read_header(AVFormatContext *s) if (asf-data_reached) { avio_seek(pb, asf-first_packet_offset, SEEK_SET); break; -} else -return AVERROR_INVALIDDATA; +} else { +ret = AVERROR_INVALIDDATA; +goto failed; +} } } if (asf-data_reached !pb-seekable) @@ -1698,6 +1704,10 @@ static int asf_read_header(AVFormatContext *s) } return 0; + +failed: +asf_read_close(s); +return ret; } AVInputFormat ff_asf_demuxer = { -- 2.0.1 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 5/6] asfdec: avoid crash in the case when chunk_len is 0
--- libavformat/asfdec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index 7450bb1..1086427 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -776,6 +776,8 @@ static int asf_read_stream_properties(AVFormatContext *s, const GUIDParseTable * asf_st-span = span; asf_st-virtual_pkt_len = avio_rl16(pb); asf_st-virtual_chunk_len = avio_rl16(pb); +if (!asf_st-virtual_chunk_len) +return AVERROR_INVALIDDATA; avio_skip(pb, err_data_len - 5); } else avio_skip(pb, err_data_len - 1); -- 2.0.1 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH 3/6] asfdec: prevent integer overflow in asf_read_subpayload
found with Coverity Scan --- libavformat/asfdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index 3342c11..31e9bd4 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -134,7 +134,7 @@ typedef struct ASFContext { // packet state uint64_t sub_left; // subpayloads left or not -int nb_sub; // number of subpayloads read so far from the current ASF packet +unsigned int nb_sub; // number of subpayloads read so far from the current ASF packet uint16_t mult_sub_len; // total length of subpayloads array inside multiple payload uint64_t nb_mult_left; // multiple payloads left int return_subpayload; -- 2.0.1 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] hevc_parser: fix standalone build with the hevc decoder disabled
On 13/07/15 08:57, Anton Khirnov wrote: The parser depends on hevc_ps, which in turn needs some data tables. --- libavcodec/Makefile| 4 +-- libavcodec/hevc.c | 52 -- libavcodec/hevc_data.c | 75 ++ 3 files changed, 77 insertions(+), 54 deletions(-) create mode 100644 libavcodec/hevc_data.c Ok. ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] dxva2_hevc: unbreak compilation after recent sps/pps changes
On 13/07/15 09:01, Anton Khirnov wrote: From: James Almer jamr...@gmail.com Signed-off-by: James Almer jamr...@gmail.com Signed-off-by: Anton Khirnov an...@khirnov.net --- libavcodec/dxva2_hevc.c | 142 1 file changed, 72 insertions(+), 70 deletions(-) Probably Ok. ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 1/3] hevc: do not pass an entire HEVCContext into export_stream_params()
On 13/07/15 07:54, Anton Khirnov wrote: It only needs the parameter sets. --- libavcodec/hevc.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) Ok. ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 6/6] asfdec: close the demuxer properly when read_header is failing
Quoting Alexandra Hájková (2015-07-13 12:02:07) --- libavformat/asfdec.c | 26 ++ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index 1086427..ecc3f5c 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -1629,8 +1629,10 @@ static int asf_read_header(AVFormatContext *s) asf-preroll = 0; asf-is_simple_index = 0; ff_get_guid(pb, guid); -if (ff_guidcmp(guid, ff_asf_header)) -return AVERROR_INVALIDDATA; +if (ff_guidcmp(guid, ff_asf_header)) { +ret = AVERROR_INVALIDDATA; +goto failed; +} This does not seem to be necessary, there should be no objects to free at this point. -- Anton Khirnov ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] APIchanges: Mention lavfi and lavd identification symbol addtion
Quoting Vittorio Giovara (2015-07-10 16:23:18) --- doc/APIchanges | 4 1 file changed, 4 insertions(+) diff --git a/doc/APIchanges b/doc/APIchanges index c803f71..2803763 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -19,6 +19,10 @@ API changes, most recent first: 2015-xx-xx - xxx - lavu 56.15.0 Add av_version_info(). +2015-xx-xx - xxx - lavfi 5.1.0 - version.h + xxx - lavd 55.2.0 - version.h + Add library identification symbols. + 2015-xx-xx - xxx - lavf 56.20.0 - avio.h Add avio_put_str16be. -- 1.9.5 (Apple Git-50.3) It's better to mention the added stuff by name explicitly, so people can grep for it. That is the main use case for this file, I think nobody really reads it all sequentially. -- Anton Khirnov ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 5/6] asfdec: avoid crash in the case when chunk_len is 0
Quoting Alexandra Hájková (2015-07-13 12:02:06) --- libavformat/asfdec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index 7450bb1..1086427 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -776,6 +776,8 @@ static int asf_read_stream_properties(AVFormatContext *s, const GUIDParseTable * asf_st-span = span; asf_st-virtual_pkt_len = avio_rl16(pb); asf_st-virtual_chunk_len = avio_rl16(pb); +if (!asf_st-virtual_chunk_len) +return AVERROR_INVALIDDATA; What about virtual_pkt_len? -- Anton Khirnov ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 2/2] hevc: Print the non-supported chroma_format_idc
Quoting Luca Barbato (2015-07-13 00:48:49) And drop the spurious newline. --- libavcodec/hevc_ps.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c index 67bd189..75c4a78 100644 --- a/libavcodec/hevc_ps.c +++ b/libavcodec/hevc_ps.c @@ -719,7 +719,8 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, sps-chroma_format_idc = get_ue_golomb_long(gb); if (sps-chroma_format_idc != 1) { -avpriv_report_missing_feature(avctx, chroma_format_idc != 1\n); +avpriv_report_missing_feature(avctx, chroma_format_idc %d, + sps-chroma_format_idc); ret = AVERROR_PATCHWELCOME; goto err; } -- 2.3.2 Both patches LGTM -- Anton Khirnov ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 3/6] asfdec: prevent integer overflow in asf_read_subpayload
On Mon, Jul 13, 2015 at 8:29 PM, Anton Khirnov an...@khirnov.net wrote: Quoting Alexandra Hájková (2015-07-13 12:02:04) found with Coverity Scan --- libavformat/asfdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index 3342c11..31e9bd4 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -134,7 +134,7 @@ typedef struct ASFContext { // packet state uint64_t sub_left; // subpayloads left or not -int nb_sub; // number of subpayloads read so far from the current ASF packet +unsigned int nb_sub; // number of subpayloads read so far from the current ASF packet The commit message is not correct, this change cannot prevent any integer overflow. Well, if the number of sub payloads is coded as an unsigned int, and we store it as a signed int, it could overflow, while if we store it as an unsigned, it cannot? Seems sensible to me. - Hendrik ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 3/6] asfdec: prevent integer overflow in asf_read_subpayload
Quoting Hendrik Leppkes (2015-07-13 20:49:51) On Mon, Jul 13, 2015 at 8:29 PM, Anton Khirnov an...@khirnov.net wrote: Quoting Alexandra Hájková (2015-07-13 12:02:04) found with Coverity Scan --- libavformat/asfdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index 3342c11..31e9bd4 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -134,7 +134,7 @@ typedef struct ASFContext { // packet state uint64_t sub_left; // subpayloads left or not -int nb_sub; // number of subpayloads read so far from the current ASF packet +unsigned int nb_sub; // number of subpayloads read so far from the current ASF packet The commit message is not correct, this change cannot prevent any integer overflow. Well, if the number of sub payloads is coded as an unsigned int, and we store it as a signed int, it could overflow, while if we store it as an unsigned, it cannot? Seems sensible to me. The number is not read from the file, this is a counter incremented when subpayloads are read. -- Anton Khirnov ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] mp3: Forward seeking errors
Quoting Luca Barbato (2015-07-12 15:48:00) --- libavformat/mp3dec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) Thanks to Anton for spotting it. diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c index 72fa60b..a875b82 100644 --- a/libavformat/mp3dec.c +++ b/libavformat/mp3dec.c @@ -422,7 +422,9 @@ static int reposition(AVFormatContext *s, int64_t pos) if (best_valid = 0) return AVERROR(ENOSYS); -avio_seek(s-pb, best_pos, SEEK_SET); +p = avio_seek(s-pb, best_pos, SEEK_SET); +if (p 0) +return p; return 0; } -- 2.3.2 Ok -- Anton Khirnov ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 06/15] libxvid: Do not entangle coded_frame
Quoting Vittorio Giovara (2015-07-10 16:32:53) On Fri, Jul 10, 2015 at 2:54 PM, Anton Khirnov an...@khirnov.net wrote: Quoting Vittorio Giovara (2015-06-30 15:50:19) --- libavcodec/libxvid.c | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c index 97ff95b..0012876 100644 --- a/libavcodec/libxvid.c +++ b/libavcodec/libxvid.c @@ -663,7 +663,6 @@ static int xvid_encode_frame(AVCodecContext *avctx, AVPacket *pkt, { int xerr, i, ret, user_packet = !!pkt-data; struct xvid_context *x = avctx-priv_data; -AVFrame *p = avctx-coded_frame; int mb_width = (avctx-width + 15) / 16; int mb_height = (avctx-height + 15) / 16; char *tmp; @@ -749,23 +748,24 @@ static int xvid_encode_frame(AVCodecContext *avctx, AVPacket *pkt, if (xerr 0) { *got_packet = 1; -p-quality = xvid_enc_stats.quant * FF_QP2LAMBDA; +avctx-coded_frame-quality = xvid_enc_stats.quant * FF_QP2LAMBDA; if (xvid_enc_stats.type == XVID_TYPE_PVOP) -p-pict_type = AV_PICTURE_TYPE_P; +avctx-coded_frame-pict_type = AV_PICTURE_TYPE_P; else if (xvid_enc_stats.type == XVID_TYPE_BVOP) -p-pict_type = AV_PICTURE_TYPE_B; +avctx-coded_frame-pict_type = AV_PICTURE_TYPE_B; else if (xvid_enc_stats.type == XVID_TYPE_SVOP) -p-pict_type = AV_PICTURE_TYPE_S; +avctx-coded_frame-pict_type = AV_PICTURE_TYPE_S; else -p-pict_type = AV_PICTURE_TYPE_I; +avctx-coded_frame-pict_type = AV_PICTURE_TYPE_I; if (xvid_enc_frame.out_flags XVID_KEYFRAME) { -p-key_frame = 1; +avctx-coded_frame-key_frame = 1; pkt-flags |= AV_PKT_FLAG_KEY; if (x-quicktime_format) return xvid_strip_vol_header(avctx, pkt, xvid_enc_stats.hlength, xerr); -} else -p-key_frame = 0; +} else { +avctx-coded_frame-key_frame = 0; +} pkt-size = xerr; -- 1.9.5 (Apple Git-50.3) If I'm reading right, this patch is a no-op that just replaces a local variable with a longer name for the same. Yes, it is mainly to simplify wrapping this section with an #if block later on. Is it ok if I mention this in the commit? I'd very much appreciate it, if this was explained fully in the first patch that does this. You abuse poor 'entangle' as a weasel word which does not really say anything about what is actually being done or why. -- Anton Khirnov ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 4/6] asfdec: hadle invalid Object size properly
Quoting Alexandra Hájková (2015-07-13 12:02:05) --- libavformat/asfdec.c | 12 ++-- 1 file changed, 10 insertions(+), 2 deletions(-) The commit message sucks. 'handle X properly' is pretty much the same as 'fix bug' and carries close to no information. A good commit message should explain in detail what exactly is being changed and why. diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index 31e9bd4..7450bb1 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -903,7 +903,7 @@ static int asf_read_data(AVFormatContext *s, const GUIDParseTable *g) uint64_t size = asf-data_size = avio_rl64(pb); int i; -if (!asf-data_reached pb-seekable) { +if (!asf-data_reached) { How is this change related to the other chunk? asf-data_reached = 1; asf-data_offset= asf-offset; } @@ -1662,7 +1662,15 @@ static int asf_read_header(AVFormatContext *s) return ret; } else { size = avio_rl64(pb); -align_position(pb, asf-offset, size); +if (size INT64_MAX) +align_position(pb, asf-offset, size); +else { +if (asf-data_reached) { +avio_seek(pb, asf-first_packet_offset, SEEK_SET); +break; +} else +return AVERROR_INVALIDDATA; +} } if (asf-data_reached !pb-seekable) break; -- 2.0.1 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel -- Anton Khirnov ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH] checkasm: Add unit tests for h264qpel
--- tests/checkasm/Makefile | 1 + tests/checkasm/checkasm.c | 3 ++ tests/checkasm/checkasm.h | 1 + tests/checkasm/h264qpel.c | 80 +++ 4 files changed, 85 insertions(+) create mode 100644 tests/checkasm/h264qpel.c diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile index 33e2c09..0758746 100644 --- a/tests/checkasm/Makefile +++ b/tests/checkasm/Makefile @@ -1,5 +1,6 @@ # libavcodec tests AVCODECOBJS-$(CONFIG_H264PRED) += h264pred.o +AVCODECOBJS-$(CONFIG_H264QPEL) += h264qpel.o CHECKASMOBJS-$(CONFIG_AVCODEC) += $(AVCODECOBJS-yes) diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 59383b8..7b1ea8f 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -57,6 +57,9 @@ static void (* const tests[])(void) = { #if CONFIG_H264PRED checkasm_check_h264pred, #endif +#if CONFIG_H264QPEL +checkasm_check_h264qpel, +#endif NULL }; diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index 90844e2..1a46e9b 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -30,6 +30,7 @@ #include libavutil/timer.h void checkasm_check_h264pred(void); +void checkasm_check_h264qpel(void); intptr_t (*checkasm_check_func(intptr_t (*func)(), const char *name, ...))() av_printf_format(2, 3); int checkasm_bench_func(void); diff --git a/tests/checkasm/h264qpel.c b/tests/checkasm/h264qpel.c new file mode 100644 index 000..06bc6ad --- /dev/null +++ b/tests/checkasm/h264qpel.c @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2015 Henrik Gramner + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with Libav; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include string.h +#include checkasm.h +#include libavcodec/h264qpel.h +#include libavutil/common.h +#include libavutil/intreadwrite.h + +static const uint32_t pixel_mask[3] = { 0x, 0x01ff01ff, 0x03ff03ff }; + +#define SIZEOF_PIXEL ((bit_depth + 7) / 8) +#define BUF_SIZE (2*16*(16+3+4)) + +#define randomize_buffers()\ +do {\ +uint32_t mask = pixel_mask[bit_depth-8];\ +int k;\ +for (k = 0; k BUF_SIZE; k += 4) {\ +uint32_t r = rnd() mask;\ +AV_WN32A(buf0+k, r);\ +AV_WN32A(buf1+k, r);\ +r = rnd();\ +AV_WN32A(dst0+k, r);\ +AV_WN32A(dst1+k, r);\ +}\ +} while (0) + +#define src0 (buf0 + 3*2*16) /* h264qpel functions read data from negative src pointer offsets */ +#define src1 (buf1 + 3*2*16) + +void checkasm_check_h264qpel(void) +{ +DECLARE_ALIGNED(16, uint8_t, buf0)[BUF_SIZE]; +DECLARE_ALIGNED(16, uint8_t, buf1)[BUF_SIZE]; +DECLARE_ALIGNED(16, uint8_t, dst0)[BUF_SIZE]; +DECLARE_ALIGNED(16, uint8_t, dst1)[BUF_SIZE]; +H264QpelContext h; +int op, bit_depth, i, j; + +for (op = 0; op 2; op++) { +qpel_mc_func (*tab)[16] = op ? h.avg_h264_qpel_pixels_tab : h.put_h264_qpel_pixels_tab; +const char *op_name = op ? avg : put; + +for (bit_depth = 8; bit_depth = 10; bit_depth++) { +ff_h264qpel_init(h, bit_depth); +for (i = 0; i (op ? 3 : 4); i++) { +int size = 16 i; +for (j = 0; j 16; j++) { +if (check_func(tab[i][j], %s_h264_qpel_%d_mc%d%d_%d, op_name, size, j3, j2, bit_depth)) { +randomize_buffers(); +call_ref(dst0, src0, (ptrdiff_t)size*SIZEOF_PIXEL); +call_new(dst1, src1, (ptrdiff_t)size*SIZEOF_PIXEL); +if (memcmp(dst0, dst1, BUF_SIZE)) +fail(); +bench_new(dst1, src1, (ptrdiff_t)size*SIZEOF_PIXEL); +} +} +} +} +report(%s_h264_qpel, op_name); +} +} -- 1.8.3.2 ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 3/3] hevc_ps: make sure failing to decode an SPS always returns an error
Quoting Vittorio Giovara (2015-07-13 14:46:17) On Mon, Jul 13, 2015 at 6:54 AM, Anton Khirnov an...@khirnov.net wrote: Some of the goto err clauses do not set the error code. It seems better to fall back on INVALIDDATA instead of adding it everywhere explicitly. --- 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 6102905..a1eaf6e 100644 --- a/libavcodec/hevc_ps.c +++ b/libavcodec/hevc_ps.c @@ -965,7 +965,7 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id, return 0; err: -return ret; +return ret 0 ? ret : AVERROR_INVALIDDATA; } int ff_hevc_decode_nal_sps(GetBitContext *gb, AVCodecContext *avctx, should we return the error type immediately instead of using goto? nothing seems to need extra handling there Not worth the effort of changing it IMO -- Anton Khirnov ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 3/6] asfdec: prevent integer overflow in asf_read_subpayload
Quoting Alexandra Hájková (2015-07-13 12:02:04) found with Coverity Scan --- libavformat/asfdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c index 3342c11..31e9bd4 100644 --- a/libavformat/asfdec.c +++ b/libavformat/asfdec.c @@ -134,7 +134,7 @@ typedef struct ASFContext { // packet state uint64_t sub_left; // subpayloads left or not -int nb_sub; // number of subpayloads read so far from the current ASF packet +unsigned int nb_sub; // number of subpayloads read so far from the current ASF packet The commit message is not correct, this change cannot prevent any integer overflow. -- Anton Khirnov ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 12/15] flashsvenc: Keep coded_frame.key_frame a write-only variable
Quoting Vittorio Giovara (2015-06-30 15:50:25) --- libavcodec/flashsvenc.c | 2 +- libavcodec/qtrleenc.c | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/libavcodec/flashsvenc.c b/libavcodec/flashsvenc.c index 971ce1b..1c87ae3 100644 --- a/libavcodec/flashsvenc.c +++ b/libavcodec/flashsvenc.c @@ -275,7 +275,7 @@ static int flashsv_encode_frame(AVCodecContext *avctx, AVPacket *pkt, avctx-coded_frame-key_frame = 0; } -if (avctx-coded_frame-key_frame) +if (I_frame) pkt-flags |= AV_PKT_FLAG_KEY; *got_packet = 1; diff --git a/libavcodec/qtrleenc.c b/libavcodec/qtrleenc.c index 91dbb8b..90c2c50 100644 --- a/libavcodec/qtrleenc.c +++ b/libavcodec/qtrleenc.c @@ -304,7 +304,6 @@ static int qtrle_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet) { QtrleEncContext * const s = avctx-priv_data; -AVFrame * const p = avctx-coded_frame; int ret; if ((ret = ff_alloc_packet(pkt, s-max_buf_size)) 0) { @@ -315,11 +314,11 @@ static int qtrle_encode_frame(AVCodecContext *avctx, AVPacket *pkt, if (avctx-gop_size == 0 || (s-avctx-frame_number % avctx-gop_size) == 0) { /* I-Frame */ -p-pict_type = AV_PICTURE_TYPE_I; +avctx-coded_frame-pict_type = AV_PICTURE_TYPE_I; s-key_frame = 1; } else { /* P-Frame */ -p-pict_type = AV_PICTURE_TYPE_P; +avctx-coded_frame-pict_type = AV_PICTURE_TYPE_P; s-key_frame = 0; } Wrong patch. -- Anton Khirnov ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 11/15] qtrleenc: Keep coded_frame.key_frame a write-only variable
Quoting Vittorio Giovara (2015-06-30 15:50:24) --- libavcodec/qtrleenc.c | 13 - 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libavcodec/qtrleenc.c b/libavcodec/qtrleenc.c index 7c98bea..91dbb8b 100644 --- a/libavcodec/qtrleenc.c +++ b/libavcodec/qtrleenc.c @@ -57,6 +57,9 @@ typedef struct QtrleEncContext { * Will contain at ith position the number of consecutive pixels equal to the previous * frame starting from pixel i */ uint8_t* skip_table; + +/** Encoded frame is a key frame */ +int key_frame; } QtrleEncContext; static av_cold int qtrle_encode_end(AVCodecContext *avctx) @@ -159,7 +162,7 @@ static void qtrle_encode_line(QtrleEncContext *s, const AVFrame *p, int line, ui for (i = width - 1; i = 0; i--) { -if (!s-avctx-coded_frame-key_frame !memcmp(this_line, prev_line, s-pixel_size)) +if (!s-key_frame !memcmp(this_line, prev_line, s-pixel_size)) skipcount = FFMIN(skipcount + 1, MAX_RLE_SKIP); else skipcount = 0; @@ -263,7 +266,7 @@ static int encode_frame(QtrleEncContext *s, const AVFrame *p, uint8_t *buf) int end_line = s-avctx-height; uint8_t *orig_buf = buf; -if (!s-avctx-coded_frame-key_frame) { +if (!s-key_frame) { unsigned line_size = s-avctx-width * s-pixel_size; for (start_line = 0; start_line s-avctx-height; start_line++) if (memcmp(p-data[0] + start_line*p-linesize[0], @@ -313,11 +316,11 @@ static int qtrle_encode_frame(AVCodecContext *avctx, AVPacket *pkt, if (avctx-gop_size == 0 || (s-avctx-frame_number % avctx-gop_size) == 0) { /* I-Frame */ p-pict_type = AV_PICTURE_TYPE_I; -p-key_frame = 1; +s-key_frame = 1; } else { /* P-Frame */ p-pict_type = AV_PICTURE_TYPE_P; -p-key_frame = 0; +s-key_frame = 0; Now you're not exporting key_frame anymore, right? -- Anton Khirnov ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] checkasm: Add unit tests for h264qpel
Attaching a modified version that also verifies that the src buffers are identical after the calls. Probably overkill, but might as well check while we're at it. /Henrik From 259c3acc59581f13bb0a4b8debe62ea1c65d66f4 Mon Sep 17 00:00:00 2001 From: Henrik Gramner hen...@gramner.com Date: Mon, 13 Jul 2015 23:11:25 +0200 Subject: [PATCH] checkasm: Add unit tests for h264qpel --- tests/checkasm/Makefile | 1 + tests/checkasm/checkasm.c | 3 ++ tests/checkasm/checkasm.h | 1 + tests/checkasm/h264qpel.c | 80 +++ 4 files changed, 85 insertions(+) create mode 100644 tests/checkasm/h264qpel.c diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile index 33e2c09..0758746 100644 --- a/tests/checkasm/Makefile +++ b/tests/checkasm/Makefile @@ -1,5 +1,6 @@ # libavcodec tests AVCODECOBJS-$(CONFIG_H264PRED) += h264pred.o +AVCODECOBJS-$(CONFIG_H264QPEL) += h264qpel.o CHECKASMOBJS-$(CONFIG_AVCODEC) += $(AVCODECOBJS-yes) diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 59383b8..7b1ea8f 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -57,6 +57,9 @@ static void (* const tests[])(void) = { #if CONFIG_H264PRED checkasm_check_h264pred, #endif +#if CONFIG_H264QPEL +checkasm_check_h264qpel, +#endif NULL }; diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index 90844e2..1a46e9b 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -30,6 +30,7 @@ #include libavutil/timer.h void checkasm_check_h264pred(void); +void checkasm_check_h264qpel(void); intptr_t (*checkasm_check_func(intptr_t (*func)(), const char *name, ...))() av_printf_format(2, 3); int checkasm_bench_func(void); diff --git a/tests/checkasm/h264qpel.c b/tests/checkasm/h264qpel.c new file mode 100644 index 000..3ec5f1c --- /dev/null +++ b/tests/checkasm/h264qpel.c @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2015 Henrik Gramner + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with Libav; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include string.h +#include checkasm.h +#include libavcodec/h264qpel.h +#include libavutil/common.h +#include libavutil/intreadwrite.h + +static const uint32_t pixel_mask[3] = { 0x, 0x01ff01ff, 0x03ff03ff }; + +#define SIZEOF_PIXEL ((bit_depth + 7) / 8) +#define BUF_SIZE (2*16*(16+3+4)) + +#define randomize_buffers()\ +do {\ +uint32_t mask = pixel_mask[bit_depth-8];\ +int k;\ +for (k = 0; k BUF_SIZE; k += 4) {\ +uint32_t r = rnd() mask;\ +AV_WN32A(buf0+k, r);\ +AV_WN32A(buf1+k, r);\ +r = rnd();\ +AV_WN32A(dst0+k, r);\ +AV_WN32A(dst1+k, r);\ +}\ +} while (0) + +#define src0 (buf0 + 3*2*16) /* h264qpel functions read data from negative src pointer offsets */ +#define src1 (buf1 + 3*2*16) + +void checkasm_check_h264qpel(void) +{ +DECLARE_ALIGNED(16, uint8_t, buf0)[BUF_SIZE]; +DECLARE_ALIGNED(16, uint8_t, buf1)[BUF_SIZE]; +DECLARE_ALIGNED(16, uint8_t, dst0)[BUF_SIZE]; +DECLARE_ALIGNED(16, uint8_t, dst1)[BUF_SIZE]; +H264QpelContext h; +int op, bit_depth, i, j; + +for (op = 0; op 2; op++) { +qpel_mc_func (*tab)[16] = op ? h.avg_h264_qpel_pixels_tab : h.put_h264_qpel_pixels_tab; +const char *op_name = op ? avg : put; + +for (bit_depth = 8; bit_depth = 10; bit_depth++) { +ff_h264qpel_init(h, bit_depth); +for (i = 0; i (op ? 3 : 4); i++) { +int size = 16 i; +for (j = 0; j 16; j++) { +if (check_func(tab[i][j], %s_h264_qpel_%d_mc%d%d_%d, op_name, size, j3, j2, bit_depth)) { +randomize_buffers(); +call_ref(dst0, src0, (ptrdiff_t)size*SIZEOF_PIXEL); +call_new(dst1, src1, (ptrdiff_t)size*SIZEOF_PIXEL); +if (memcmp(buf0, buf1, BUF_SIZE) || memcmp(dst0, dst1, BUF_SIZE)) +fail(); +bench_new(dst1, src1, (ptrdiff_t)size*SIZEOF_PIXEL); +} +} +} +} +report(%s_h264_qpel, op_name); +} +} -- 1.8.3.2 ___ libav-devel mailing list
Re: [libav-devel] [PATCH 06/15] libxvid: Do not entangle coded_frame
On Mon, Jul 13, 2015 at 8:22 PM, Anton Khirnov an...@khirnov.net wrote: Quoting Vittorio Giovara (2015-07-10 16:32:53) On Fri, Jul 10, 2015 at 2:54 PM, Anton Khirnov an...@khirnov.net wrote: Quoting Vittorio Giovara (2015-06-30 15:50:19) --- libavcodec/libxvid.c | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c index 97ff95b..0012876 100644 --- a/libavcodec/libxvid.c +++ b/libavcodec/libxvid.c @@ -663,7 +663,6 @@ static int xvid_encode_frame(AVCodecContext *avctx, AVPacket *pkt, { int xerr, i, ret, user_packet = !!pkt-data; struct xvid_context *x = avctx-priv_data; -AVFrame *p = avctx-coded_frame; int mb_width = (avctx-width + 15) / 16; int mb_height = (avctx-height + 15) / 16; char *tmp; @@ -749,23 +748,24 @@ static int xvid_encode_frame(AVCodecContext *avctx, AVPacket *pkt, if (xerr 0) { *got_packet = 1; -p-quality = xvid_enc_stats.quant * FF_QP2LAMBDA; +avctx-coded_frame-quality = xvid_enc_stats.quant * FF_QP2LAMBDA; if (xvid_enc_stats.type == XVID_TYPE_PVOP) -p-pict_type = AV_PICTURE_TYPE_P; +avctx-coded_frame-pict_type = AV_PICTURE_TYPE_P; else if (xvid_enc_stats.type == XVID_TYPE_BVOP) -p-pict_type = AV_PICTURE_TYPE_B; +avctx-coded_frame-pict_type = AV_PICTURE_TYPE_B; else if (xvid_enc_stats.type == XVID_TYPE_SVOP) -p-pict_type = AV_PICTURE_TYPE_S; +avctx-coded_frame-pict_type = AV_PICTURE_TYPE_S; else -p-pict_type = AV_PICTURE_TYPE_I; +avctx-coded_frame-pict_type = AV_PICTURE_TYPE_I; if (xvid_enc_frame.out_flags XVID_KEYFRAME) { -p-key_frame = 1; +avctx-coded_frame-key_frame = 1; pkt-flags |= AV_PKT_FLAG_KEY; if (x-quicktime_format) return xvid_strip_vol_header(avctx, pkt, xvid_enc_stats.hlength, xerr); -} else -p-key_frame = 0; +} else { +avctx-coded_frame-key_frame = 0; +} pkt-size = xerr; -- 1.9.5 (Apple Git-50.3) If I'm reading right, this patch is a no-op that just replaces a local variable with a longer name for the same. Yes, it is mainly to simplify wrapping this section with an #if block later on. Is it ok if I mention this in the commit? I'd very much appreciate it, if this was explained fully in the first patch that does this. You abuse poor 'entangle' as a weasel word which does not really say anything about what is actually being done or why. Noted. -- Vittorio ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 12/15] flashsvenc: Keep coded_frame.key_frame a write-only variable
On Tue, Jul 14, 2015 at 12:11 AM, Luca Barbato lu_z...@gentoo.org wrote: On 30/06/15 15:50, Vittorio Giovara wrote: diff --git a/libavcodec/qtrleenc.c b/libavcodec/qtrleenc.c index 91dbb8b..90c2c50 100644 --- a/libavcodec/qtrleenc.c +++ b/libavcodec/qtrleenc.c @@ -304,7 +304,6 @@ static int qtrle_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet) { QtrleEncContext * const s = avctx-priv_data; -AVFrame * const p = avctx-coded_frame; int ret; if ((ret = ff_alloc_packet(pkt, s-max_buf_size)) 0) { @@ -315,11 +314,11 @@ static int qtrle_encode_frame(AVCodecContext *avctx, AVPacket *pkt, if (avctx-gop_size == 0 || (s-avctx-frame_number % avctx-gop_size) == 0) { /* I-Frame */ -p-pict_type = AV_PICTURE_TYPE_I; +avctx-coded_frame-pict_type = AV_PICTURE_TYPE_I; s-key_frame = 1; } else { /* P-Frame */ -p-pict_type = AV_PICTURE_TYPE_P; +avctx-coded_frame-pict_type = AV_PICTURE_TYPE_P; s-key_frame = 0; } This part is necessary? I guess only the first hunk is enough, isn't it? yes consider it dropped -- Vittorio ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH] hq_hqa: Fix decoding when INFO section is absent
On Sat, Jul 11, 2015 at 5:50 AM, Kostya Shishkov kostya.shish...@gmail.com wrote: On Fri, Jul 10, 2015 at 09:09:44PM +0200, Luca Barbato wrote: On 10/07/15 16:52, Vittorio Giovara wrote: --- libavcodec/hq_hqa.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/hq_hqa.c b/libavcodec/hq_hqa.c index ae378e6..4871c59 100644 --- a/libavcodec/hq_hqa.c +++ b/libavcodec/hq_hqa.c @@ -310,9 +310,11 @@ static int hq_hqa_decode_frame(AVCodecContext *avctx, void *data, return AVERROR_INVALIDDATA; } -info_tag = bytestream2_get_le32(ctx-gbc); +info_tag = bytestream2_peek_le32(ctx-gbc); if (info_tag == MKTAG('I', 'N', 'F', 'O')) { -int info_size = bytestream2_get_le32(ctx-gbc); +int info_size; +bytestream2_skip(ctx-gbc, 4); +info_size = bytestream2_get_le32(ctx-gbc); if (bytestream2_get_bytes_left(ctx-gbc) info_size) { av_log(avctx, AV_LOG_ERROR, Invalid INFO size (%d).\n, info_size); return AVERROR_INVALIDDATA; Ok. Doesn't that apply to HQX and CLLC as well? No because these two do not use GetBytestream functions, but rather AV_RL32, so offset is moved only when the INFO tag matches. -- Vittorio ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH] APIchanges: Mention lavfi and lavd identification symbol addition
--- doc/APIchanges | 4 1 file changed, 4 insertions(+) diff --git a/doc/APIchanges b/doc/APIchanges index a2c5eb05..8d22556 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -16,6 +16,10 @@ API changes, most recent first: 2015-xx-xx - xxx - lavu 56.15.0 Add av_version_info(). +2015-xx-xx - xxx - lavfi 5.1.0 - version.h + xxx - lavd 55.2.0 - version.h + Add library identification symbols, LIBAVFILTER_IDENT and LIBAVDEVICE_IDENT. + 2015-xx-xx - xxx - lavf 56.20.0 - avio.h Add avio_put_str16be. -- 1.9.5 (Apple Git-50.3) ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 12/15] flashsvenc: Keep coded_frame.key_frame a write-only variable
On 30/06/15 15:50, Vittorio Giovara wrote: diff --git a/libavcodec/qtrleenc.c b/libavcodec/qtrleenc.c index 91dbb8b..90c2c50 100644 --- a/libavcodec/qtrleenc.c +++ b/libavcodec/qtrleenc.c @@ -304,7 +304,6 @@ static int qtrle_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet) { QtrleEncContext * const s = avctx-priv_data; -AVFrame * const p = avctx-coded_frame; int ret; if ((ret = ff_alloc_packet(pkt, s-max_buf_size)) 0) { @@ -315,11 +314,11 @@ static int qtrle_encode_frame(AVCodecContext *avctx, AVPacket *pkt, if (avctx-gop_size == 0 || (s-avctx-frame_number % avctx-gop_size) == 0) { /* I-Frame */ -p-pict_type = AV_PICTURE_TYPE_I; +avctx-coded_frame-pict_type = AV_PICTURE_TYPE_I; s-key_frame = 1; } else { /* P-Frame */ -p-pict_type = AV_PICTURE_TYPE_P; +avctx-coded_frame-pict_type = AV_PICTURE_TYPE_P; s-key_frame = 0; } This part is necessary? I guess only the first hunk is enough, isn't it? lu ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH] fixup! libtheoraenc: Keep coded_frame.key_frame a write-only variable
--- libavcodec/qtrleenc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/qtrleenc.c b/libavcodec/qtrleenc.c index 91dbb8b..7ed09de 100644 --- a/libavcodec/qtrleenc.c +++ b/libavcodec/qtrleenc.c @@ -329,6 +329,8 @@ static int qtrle_encode_frame(AVCodecContext *avctx, AVPacket *pkt, av_picture_copy(s-previous_frame, (const AVPicture *)pict, avctx-pix_fmt, avctx-width, avctx-height); +avctx-coded_frame-key_frame = s-key_frame; + if (s-key_frame) pkt-flags |= AV_PKT_FLAG_KEY; *got_packet = 1; -- 1.9.5 (Apple Git-50.3) ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH] qtrleenc: Keep coded_frame.key_frame a write-only variable
--- This superseeds all the previous parts which were mistakenly split across multiple patches. I'll send a full set with all the amendments later on. Vittorio libavcodec/qtrleenc.c | 22 ++ 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/libavcodec/qtrleenc.c b/libavcodec/qtrleenc.c index 7c98bea..fe1fafc 100644 --- a/libavcodec/qtrleenc.c +++ b/libavcodec/qtrleenc.c @@ -57,6 +57,9 @@ typedef struct QtrleEncContext { * Will contain at ith position the number of consecutive pixels equal to the previous * frame starting from pixel i */ uint8_t* skip_table; + +/** Encoded frame is a key frame */ +int key_frame; } QtrleEncContext; static av_cold int qtrle_encode_end(AVCodecContext *avctx) @@ -159,7 +162,7 @@ static void qtrle_encode_line(QtrleEncContext *s, const AVFrame *p, int line, ui for (i = width - 1; i = 0; i--) { -if (!s-avctx-coded_frame-key_frame !memcmp(this_line, prev_line, s-pixel_size)) +if (!s-key_frame !memcmp(this_line, prev_line, s-pixel_size)) skipcount = FFMIN(skipcount + 1, MAX_RLE_SKIP); else skipcount = 0; @@ -263,7 +266,7 @@ static int encode_frame(QtrleEncContext *s, const AVFrame *p, uint8_t *buf) int end_line = s-avctx-height; uint8_t *orig_buf = buf; -if (!s-avctx-coded_frame-key_frame) { +if (!s-key_frame) { unsigned line_size = s-avctx-width * s-pixel_size; for (start_line = 0; start_line s-avctx-height; start_line++) if (memcmp(p-data[0] + start_line*p-linesize[0], @@ -301,7 +304,7 @@ static int qtrle_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet) { QtrleEncContext * const s = avctx-priv_data; -AVFrame * const p = avctx-coded_frame; +enum AVPictureType pict_type; int ret; if ((ret = ff_alloc_packet(pkt, s-max_buf_size)) 0) { @@ -312,12 +315,12 @@ static int qtrle_encode_frame(AVCodecContext *avctx, AVPacket *pkt, if (avctx-gop_size == 0 || (s-avctx-frame_number % avctx-gop_size) == 0) { /* I-Frame */ -p-pict_type = AV_PICTURE_TYPE_I; -p-key_frame = 1; +pict_type = AV_PICTURE_TYPE_I; +s-key_frame = 1; } else { /* P-Frame */ -p-pict_type = AV_PICTURE_TYPE_P; -p-key_frame = 0; +pict_type = AV_PICTURE_TYPE_P; +s-key_frame = 0; } pkt-size = encode_frame(s, pict, pkt-data); @@ -326,7 +329,10 @@ static int qtrle_encode_frame(AVCodecContext *avctx, AVPacket *pkt, av_picture_copy(s-previous_frame, (const AVPicture *)pict, avctx-pix_fmt, avctx-width, avctx-height); -if (p-key_frame) +avctx-coded_frame-key_frame = s-key_frame; +avctx-coded_frame-pict_type = s-pict_type; + +if (s-key_frame) pkt-flags |= AV_PKT_FLAG_KEY; *got_packet = 1; -- 1.9.5 (Apple Git-50.3) ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH] dxva2_hevc: unbreak compilation after recent sps/pps changes
From: James Almer jamr...@gmail.com Signed-off-by: James Almer jamr...@gmail.com Signed-off-by: Anton Khirnov an...@khirnov.net --- libavcodec/dxva2_hevc.c | 142 1 file changed, 72 insertions(+), 70 deletions(-) diff --git a/libavcodec/dxva2_hevc.c b/libavcodec/dxva2_hevc.c index 5112bd2..88d4782 100644 --- a/libavcodec/dxva2_hevc.c +++ b/libavcodec/dxva2_hevc.c @@ -57,102 +57,104 @@ static void fill_picture_parameters(const AVCodecContext *avctx, AVDXVAContext * DXVA_PicParams_HEVC *pp) { const HEVCFrame *current_picture = h-ref; +const HEVCSPS *sps = h-ps.sps; +const HEVCPPS *pps = h-ps.pps; int i, j; memset(pp, 0, sizeof(*pp)); -pp-PicWidthInMinCbsY = h-sps-min_cb_width; -pp-PicHeightInMinCbsY = h-sps-min_cb_height; +pp-PicWidthInMinCbsY = sps-min_cb_width; +pp-PicHeightInMinCbsY = sps-min_cb_height; -pp-wFormatAndSequenceInfoFlags = (h-sps-chroma_format_idc 0) | - (h-sps-separate_colour_plane_flag 2) | - ((h-sps-bit_depth - 8) 3) | - ((h-sps-bit_depth - 8) 6) | - ((h-sps-log2_max_poc_lsb - 4) 9) | +pp-wFormatAndSequenceInfoFlags = (sps-chroma_format_idc 0) | + (sps-separate_colour_plane_flag 2) | + ((sps-bit_depth - 8) 3) | + ((sps-bit_depth - 8) 6) | + ((sps-log2_max_poc_lsb - 4) 9) | (0 13) | (0 14) | (0 15); fill_picture_entry(pp-CurrPic, ff_dxva2_get_surface_index(avctx, ctx, current_picture-frame), 0); -pp-sps_max_dec_pic_buffering_minus1 = h-sps-temporal_layer[h-sps-max_sub_layers - 1].max_dec_pic_buffering - 1; -pp-log2_min_luma_coding_block_size_minus3 = h-sps-log2_min_cb_size - 3; -pp-log2_diff_max_min_luma_coding_block_size = h-sps-log2_diff_max_min_coding_block_size; -pp-log2_min_transform_block_size_minus2 = h-sps-log2_min_tb_size - 2; -pp-log2_diff_max_min_transform_block_size = h-sps-log2_max_trafo_size - h-sps-log2_min_tb_size; -pp-max_transform_hierarchy_depth_inter = h-sps-max_transform_hierarchy_depth_inter; -pp-max_transform_hierarchy_depth_intra = h-sps-max_transform_hierarchy_depth_intra; -pp-num_short_term_ref_pic_sets = h-sps-nb_st_rps; -pp-num_long_term_ref_pics_sps = h-sps-num_long_term_ref_pics_sps; +pp-sps_max_dec_pic_buffering_minus1 = sps-temporal_layer[sps-max_sub_layers - 1].max_dec_pic_buffering - 1; +pp-log2_min_luma_coding_block_size_minus3 = sps-log2_min_cb_size - 3; +pp-log2_diff_max_min_luma_coding_block_size = sps-log2_diff_max_min_coding_block_size; +pp-log2_min_transform_block_size_minus2 = sps-log2_min_tb_size - 2; +pp-log2_diff_max_min_transform_block_size = sps-log2_max_trafo_size - sps-log2_min_tb_size; +pp-max_transform_hierarchy_depth_inter = sps-max_transform_hierarchy_depth_inter; +pp-max_transform_hierarchy_depth_intra = sps-max_transform_hierarchy_depth_intra; +pp-num_short_term_ref_pic_sets = sps-nb_st_rps; +pp-num_long_term_ref_pics_sps = sps-num_long_term_ref_pics_sps; -pp-num_ref_idx_l0_default_active_minus1 = h-pps-num_ref_idx_l0_default_active - 1; -pp-num_ref_idx_l1_default_active_minus1 = h-pps-num_ref_idx_l1_default_active - 1; -pp-init_qp_minus26 = h-pps-pic_init_qp_minus26; +pp-num_ref_idx_l0_default_active_minus1 = pps-num_ref_idx_l0_default_active - 1; +pp-num_ref_idx_l1_default_active_minus1 = pps-num_ref_idx_l1_default_active - 1; +pp-init_qp_minus26 = pps-pic_init_qp_minus26; if (h-sh.short_term_ref_pic_set_sps_flag == 0 h-sh.short_term_rps) { pp-ucNumDeltaPocsOfRefRpsIdx= h-sh.short_term_rps-num_delta_pocs; pp-wNumBitsForShortTermRPSInSlice = h-sh.short_term_ref_pic_set_size; } -pp-dwCodingParamToolFlags = (h-sps-scaling_list_enable_flag 0) | - (h-sps-amp_enabled_flag 1) | - (h-sps-sao_enabled 2) | - (h-sps-pcm_enabled_flag 3) | - ((h-sps-pcm_enabled_flag ? (h-sps-pcm.bit_depth - 1) : 0)
Re: [libav-devel] [PATCH 09/11] hevc_parser: parse and export some stream parameters
On 09/07/15 3:23 PM, Anton Khirnov wrote: Particularly those that will be needed by the QSV decoder. More can be added later as necessary. --- configure| 1 + libavcodec/Makefile | 2 +- libavcodec/hevc_parser.c | 128 +-- 3 files changed, 125 insertions(+), 6 deletions(-) diff --git a/configure b/configure index 45d1cf9..7154187 100755 --- a/configure +++ b/configure @@ -2059,6 +2059,7 @@ wmv3_vdpau_hwaccel_select=vc1_vdpau_hwaccel # parsers h264_parser_select=h264_decoder +hevc_parser_select=golomb ./configure --enable-gpl --disable-everything --disable-programs --enable-avconv --enable-parser=hevc LD avconv libavcodec/libavcodec.a(hevc_parser.o): In function `parse_nal_units': /home/jamrial/libav/libavcodec/hevc_parser.c:95: undefined reference to `ff_hevc_decode_nal_pps' /home/jamrial/libav/libavcodec/hevc_parser.c:94: undefined reference to `ff_hevc_decode_nal_sps' /home/jamrial/libav/libavcodec/hevc_parser.c:93: undefined reference to `ff_hevc_decode_nal_vps' collect2: error: ld returned 1 exit status ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
Re: [libav-devel] [PATCH 09/11] hevc_parser: parse and export some stream parameters
Quoting James Almer (2015-07-13 08:39:06) On 09/07/15 3:23 PM, Anton Khirnov wrote: Particularly those that will be needed by the QSV decoder. More can be added later as necessary. --- configure| 1 + libavcodec/Makefile | 2 +- libavcodec/hevc_parser.c | 128 +-- 3 files changed, 125 insertions(+), 6 deletions(-) diff --git a/configure b/configure index 45d1cf9..7154187 100755 --- a/configure +++ b/configure @@ -2059,6 +2059,7 @@ wmv3_vdpau_hwaccel_select=vc1_vdpau_hwaccel # parsers h264_parser_select=h264_decoder +hevc_parser_select=golomb ./configure --enable-gpl --disable-everything --disable-programs --enable-avconv --enable-parser=hevc LD avconv libavcodec/libavcodec.a(hevc_parser.o): In function `parse_nal_units': /home/jamrial/libav/libavcodec/hevc_parser.c:95: undefined reference to `ff_hevc_decode_nal_pps' /home/jamrial/libav/libavcodec/hevc_parser.c:94: undefined reference to `ff_hevc_decode_nal_sps' /home/jamrial/libav/libavcodec/hevc_parser.c:93: undefined reference to `ff_hevc_decode_nal_vps' collect2: error: ld returned 1 exit status Thanks, fix sent. -- Anton Khirnov ___ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel
[libav-devel] [PATCH] hevc_parser: fix standalone build with the hevc decoder disabled
The parser depends on hevc_ps, which in turn needs some data tables. --- libavcodec/Makefile| 4 +-- libavcodec/hevc.c | 52 -- libavcodec/hevc_data.c | 75 ++ 3 files changed, 77 insertions(+), 54 deletions(-) create mode 100644 libavcodec/hevc_data.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 2cb5368..d933ffd 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -240,7 +240,7 @@ OBJS-$(CONFIG_HAP_DECODER) += hapdec.o OBJS-$(CONFIG_HAP_ENCODER) += hapenc.o OBJS-$(CONFIG_HEVC_DECODER)+= hevc.o hevc_mvs.o hevc_ps.o hevc_sei.o \ hevc_cabac.o hevc_refs.o hevcpred.o \ - hevcdsp.o hevc_filter.o hevc_parse.o + hevcdsp.o hevc_filter.o hevc_parse.o hevc_data.o OBJS-$(CONFIG_HEVC_NVENC_ENCODER) += nvenc_hevc.o OBJS-$(CONFIG_HEVC_QSV_ENCODER)+= qsvenc_hevc.o hevc_ps_enc.o hevc_parse.o OBJS-$(CONFIG_HNM4_VIDEO_DECODER) += hnm4video.o @@ -697,7 +697,7 @@ OBJS-$(CONFIG_GSM_PARSER) += gsm_parser.o OBJS-$(CONFIG_H261_PARSER) += h261_parser.o OBJS-$(CONFIG_H263_PARSER) += h263_parser.o OBJS-$(CONFIG_H264_PARSER) += h264_parser.o -OBJS-$(CONFIG_HEVC_PARSER) += hevc_parser.o hevc_parse.o +OBJS-$(CONFIG_HEVC_PARSER) += hevc_parser.o hevc_parse.o hevc_ps.o hevc_data.o OBJS-$(CONFIG_MJPEG_PARSER)+= mjpeg_parser.o OBJS-$(CONFIG_MLP_PARSER) += mlp_parser.o mlp.o OBJS-$(CONFIG_MPEG4VIDEO_PARSER) += mpeg4video_parser.o h263.o \ diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c index dd56d58..25e706f 100644 --- a/libavcodec/hevc.c +++ b/libavcodec/hevc.c @@ -82,20 +82,6 @@ static const uint8_t diag_scan2x2_inv[2][2] = { { 1, 3, }, }; -const uint8_t ff_hevc_diag_scan4x4_x[16] = { -0, 0, 1, 0, -1, 2, 0, 1, -2, 3, 1, 2, -3, 2, 3, 3, -}; - -const uint8_t ff_hevc_diag_scan4x4_y[16] = { -0, 1, 0, 2, -1, 0, 3, 2, -1, 0, 3, 2, -1, 3, 2, 3, -}; - static const uint8_t diag_scan4x4_inv[4][4] = { { 0, 2, 5, 9, }, { 1, 4, 8, 12, }, @@ -103,44 +89,6 @@ static const uint8_t diag_scan4x4_inv[4][4] = { { 6, 10, 13, 15, }, }; -const uint8_t ff_hevc_diag_scan8x8_x[64] = { -0, 0, 1, 0, -1, 2, 0, 1, -2, 3, 0, 1, -2, 3, 4, 0, -1, 2, 3, 4, -5, 0, 1, 2, -3, 4, 5, 6, -0, 1, 2, 3, -4, 5, 6, 7, -1, 2, 3, 4, -5, 6, 7, 2, -3, 4, 5, 6, -7, 3, 4, 5, -6, 7, 4, 5, -6, 7, 5, 6, -7, 6, 7, 7, -}; - -const uint8_t ff_hevc_diag_scan8x8_y[64] = { -0, 1, 0, 2, -1, 0, 3, 2, -1, 0, 4, 3, -2, 1, 0, 5, -4, 3, 2, 1, -0, 6, 5, 4, -3, 2, 1, 0, -7, 6, 5, 4, -3, 2, 1, 0, -7, 6, 5, 4, -3, 2, 1, 7, -6, 5, 4, 3, -2, 7, 6, 5, -4, 3, 7, 6, -5, 4, 7, 6, -5, 7, 6, 7, -}; - static const uint8_t diag_scan8x8_inv[8][8] = { { 0, 2, 5, 9, 14, 20, 27, 35, }, { 1, 4, 8, 13, 19, 26, 34, 42, }, diff --git a/libavcodec/hevc_data.c b/libavcodec/hevc_data.c new file mode 100644 index 000..f4b6096 --- /dev/null +++ b/libavcodec/hevc_data.c @@ -0,0 +1,75 @@ +/* + * HEVC shared tables + * + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include stdint.h + +#include hevc.h + +const uint8_t ff_hevc_diag_scan4x4_x[16] = { +0, 0, 1, 0, +1, 2, 0, 1, +2, 3, 1, 2, +3, 2, 3, 3, +}; + +const uint8_t ff_hevc_diag_scan4x4_y[16] = { +0, 1, 0, 2, +1, 0, 3, 2, +1, 0, 3, 2, +1, 3, 2, 3, +}; + +const uint8_t ff_hevc_diag_scan8x8_x[64] = { +0, 0, 1, 0, +1, 2, 0, 1, +2, 3, 0, 1, +2, 3, 4, 0, +1, 2, 3, 4, +5, 0, 1, 2, +3, 4, 5, 6, +0, 1, 2, 3, +4, 5, 6, 7, +1, 2, 3, 4, +5, 6, 7, 2, +3, 4, 5, 6, +7, 3, 4, 5, +6, 7, 4, 5, +6, 7, 5, 6, +7, 6, 7, 7, +}; + +const uint8_t ff_hevc_diag_scan8x8_y[64] = { +0, 1, 0, 2, +1, 0, 3, 2, +1, 0, 4, 3, +2, 1, 0, 5, +4, 3, 2, 1, +0, 6, 5, 4, +3, 2, 1, 0, +7, 6, 5, 4, +3, 2, 1, 0, +7, 6, 5, 4, +3, 2, 1, 7, +6,