* [FFmpeg-devel] [PATCH 01/14] avcodec/ylc: Remove inclusion of huffyuvdsp.h
@ 2022-10-02 0:04 Andreas Rheinhardt
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 02/14] avcodec/huffyuvenc: Remove redundant casts Andreas Rheinhardt
` (14 more replies)
0 siblings, 15 replies; 16+ messages in thread
From: Andreas Rheinhardt @ 2022-10-02 0:04 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Also improve the other headers a bit.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/ylc.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/libavcodec/ylc.c b/libavcodec/ylc.c
index 3ea6749ffe..29c10f05da 100644
--- a/libavcodec/ylc.c
+++ b/libavcodec/ylc.c
@@ -18,21 +18,17 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
#define YLC_VLC_BITS 10
-#include "libavutil/imgutils.h"
-#include "libavutil/internal.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mem.h"
+#include "libavutil/pixfmt.h"
#include "avcodec.h"
#include "bswapdsp.h"
#include "codec_internal.h"
#include "get_bits.h"
-#include "huffyuvdsp.h"
#include "thread.h"
#include "unary.h"
--
2.34.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH 02/14] avcodec/huffyuvenc: Remove redundant casts
2022-10-02 0:04 [FFmpeg-devel] [PATCH 01/14] avcodec/ylc: Remove inclusion of huffyuvdsp.h Andreas Rheinhardt
@ 2022-10-02 0:06 ` Andreas Rheinhardt
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 03/14] avcodec/huffyuvenc: Avoid pointless indirections Andreas Rheinhardt
` (13 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Andreas Rheinhardt @ 2022-10-02 0:06 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/huffyuvenc.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
index 2d63b12abc..d159d5d309 100644
--- a/libavcodec/huffyuvenc.c
+++ b/libavcodec/huffyuvenc.c
@@ -333,20 +333,20 @@ static av_cold int encode_init(AVCodecContext *avctx)
return AVERROR(EINVAL);
}
- ((uint8_t*)avctx->extradata)[0] = s->predictor | (s->decorrelate << 6);
- ((uint8_t*)avctx->extradata)[2] = s->interlaced ? 0x10 : 0x20;
+ avctx->extradata[0] = s->predictor | (s->decorrelate << 6);
+ avctx->extradata[2] = s->interlaced ? 0x10 : 0x20;
if (s->context)
- ((uint8_t*)avctx->extradata)[2] |= 0x40;
+ avctx->extradata[2] |= 0x40;
if (s->version < 3) {
- ((uint8_t*)avctx->extradata)[1] = s->bitstream_bpp;
- ((uint8_t*)avctx->extradata)[3] = 0;
+ avctx->extradata[1] = s->bitstream_bpp;
+ avctx->extradata[3] = 0;
} else {
- ((uint8_t*)avctx->extradata)[1] = ((s->bps-1)<<4) | s->chroma_h_shift | (s->chroma_v_shift<<2);
+ avctx->extradata[1] = ((s->bps-1)<<4) | s->chroma_h_shift | (s->chroma_v_shift<<2);
if (s->chroma)
- ((uint8_t*)avctx->extradata)[2] |= s->yuv ? 1 : 2;
+ avctx->extradata[2] |= s->yuv ? 1 : 2;
if (s->alpha)
- ((uint8_t*)avctx->extradata)[2] |= 4;
- ((uint8_t*)avctx->extradata)[3] = 1;
+ avctx->extradata[2] |= 4;
+ avctx->extradata[3] = 1;
}
s->avctx->extradata_size = 4;
--
2.34.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH 03/14] avcodec/huffyuvenc: Avoid pointless indirections
2022-10-02 0:04 [FFmpeg-devel] [PATCH 01/14] avcodec/ylc: Remove inclusion of huffyuvdsp.h Andreas Rheinhardt
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 02/14] avcodec/huffyuvenc: Remove redundant casts Andreas Rheinhardt
@ 2022-10-02 0:06 ` Andreas Rheinhardt
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 04/14] avcodec/huffyuvenc: Remove always-false check Andreas Rheinhardt
` (12 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Andreas Rheinhardt @ 2022-10-02 0:06 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/huffyuvenc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
index d159d5d309..fa4923962f 100644
--- a/libavcodec/huffyuvenc.c
+++ b/libavcodec/huffyuvenc.c
@@ -348,7 +348,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
avctx->extradata[2] |= 4;
avctx->extradata[3] = 1;
}
- s->avctx->extradata_size = 4;
+ avctx->extradata_size = 4;
if (avctx->stats_in) {
char *p = avctx->stats_in;
@@ -378,10 +378,10 @@ static av_cold int encode_init(AVCodecContext *avctx)
}
}
- ret = store_huffman_tables(s, s->avctx->extradata + s->avctx->extradata_size);
+ ret = store_huffman_tables(s, avctx->extradata + avctx->extradata_size);
if (ret < 0)
return ret;
- s->avctx->extradata_size += ret;
+ avctx->extradata_size += ret;
if (s->context) {
for (i = 0; i < 4; i++) {
--
2.34.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH 04/14] avcodec/huffyuvenc: Remove always-false check
2022-10-02 0:04 [FFmpeg-devel] [PATCH 01/14] avcodec/ylc: Remove inclusion of huffyuvdsp.h Andreas Rheinhardt
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 02/14] avcodec/huffyuvenc: Remove redundant casts Andreas Rheinhardt
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 03/14] avcodec/huffyuvenc: Avoid pointless indirections Andreas Rheinhardt
@ 2022-10-02 0:06 ` Andreas Rheinhardt
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 05/14] avcodec/huffyuvenc: Remove redundant call Andreas Rheinhardt
` (11 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Andreas Rheinhardt @ 2022-10-02 0:06 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
The ffvhuff encoder has AVCodec.pix_fmts set and therefore
encode_preinit_video() checks that the used pixel format
is permissible.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/huffyuvenc.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
index fa4923962f..80dcdbaa93 100644
--- a/libavcodec/huffyuvenc.c
+++ b/libavcodec/huffyuvenc.c
@@ -310,12 +310,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
}
if (avctx->codec->id == AV_CODEC_ID_HUFFYUV) {
- if (avctx->pix_fmt == AV_PIX_FMT_YUV420P) {
- av_log(avctx, AV_LOG_ERROR,
- "Error: YV12 is not supported by huffyuv; use "
- "vcodec=ffvhuff or format=422p\n");
- return AVERROR(EINVAL);
- }
if (s->interlaced != ( s->height > 288 ))
av_log(avctx, AV_LOG_INFO,
"using huffyuv 2.2.0 or newer interlacing flag\n");
--
2.34.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH 05/14] avcodec/huffyuvenc: Remove redundant call
2022-10-02 0:04 [FFmpeg-devel] [PATCH 01/14] avcodec/ylc: Remove inclusion of huffyuvdsp.h Andreas Rheinhardt
` (2 preceding siblings ...)
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 04/14] avcodec/huffyuvenc: Remove always-false check Andreas Rheinhardt
@ 2022-10-02 0:06 ` Andreas Rheinhardt
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 06/14] avcodec/huffyuvenc: Don't second-guess error code Andreas Rheinhardt
` (10 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Andreas Rheinhardt @ 2022-10-02 0:06 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
All codecs here have the FF_CODEC_CAP_INIT_CLEANUP set,
so ff_huffyuv_common_end() will be called automatically
in encode_end() on error.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/huffyuvenc.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
index 80dcdbaa93..8867de0d44 100644
--- a/libavcodec/huffyuvenc.c
+++ b/libavcodec/huffyuvenc.c
@@ -392,7 +392,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
}
if (ff_huffyuv_alloc_temp(s)) {
- ff_huffyuv_common_end(s);
return AVERROR(ENOMEM);
}
--
2.34.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH 06/14] avcodec/huffyuvenc: Don't second-guess error code
2022-10-02 0:04 [FFmpeg-devel] [PATCH 01/14] avcodec/ylc: Remove inclusion of huffyuvdsp.h Andreas Rheinhardt
` (3 preceding siblings ...)
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 05/14] avcodec/huffyuvenc: Remove redundant call Andreas Rheinhardt
@ 2022-10-02 0:06 ` Andreas Rheinhardt
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 07/14] avcodec/huffyuvencdsp: Pass pix_fmt directly when initing dsp Andreas Rheinhardt
` (9 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Andreas Rheinhardt @ 2022-10-02 0:06 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/huffyuvenc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
index 8867de0d44..84ab7f423a 100644
--- a/libavcodec/huffyuvenc.c
+++ b/libavcodec/huffyuvenc.c
@@ -391,9 +391,9 @@ static av_cold int encode_init(AVCodecContext *avctx)
s->stats[i][j]= 0;
}
- if (ff_huffyuv_alloc_temp(s)) {
- return AVERROR(ENOMEM);
- }
+ ret = ff_huffyuv_alloc_temp(s);
+ if (ret < 0)
+ return ret;
s->picture_number=0;
--
2.34.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH 07/14] avcodec/huffyuvencdsp: Pass pix_fmt directly when initing dsp
2022-10-02 0:04 [FFmpeg-devel] [PATCH 01/14] avcodec/ylc: Remove inclusion of huffyuvdsp.h Andreas Rheinhardt
` (4 preceding siblings ...)
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 06/14] avcodec/huffyuvenc: Don't second-guess error code Andreas Rheinhardt
@ 2022-10-02 0:06 ` Andreas Rheinhardt
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 08/14] avocdec/huffyuvdec: Don't use HYuvContext.avctx Andreas Rheinhardt
` (8 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Andreas Rheinhardt @ 2022-10-02 0:06 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
It is the only thing that is actually used.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/huffyuvenc.c | 2 +-
libavcodec/huffyuvencdsp.c | 4 ++--
libavcodec/huffyuvencdsp.h | 6 +++---
libavcodec/x86/huffyuvencdsp_init.c | 4 ++--
4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
index 84ab7f423a..2137a16714 100644
--- a/libavcodec/huffyuvenc.c
+++ b/libavcodec/huffyuvenc.c
@@ -210,7 +210,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
ff_huffyuv_common_init(avctx);
- ff_huffyuvencdsp_init(&s->hencdsp, avctx);
+ ff_huffyuvencdsp_init(&s->hencdsp, avctx->pix_fmt);
ff_llvidencdsp_init(&s->llvidencdsp);
avctx->extradata = av_mallocz(3*MAX_N + 4);
diff --git a/libavcodec/huffyuvencdsp.c b/libavcodec/huffyuvencdsp.c
index ea1ef911b0..36e8f6130b 100644
--- a/libavcodec/huffyuvencdsp.c
+++ b/libavcodec/huffyuvencdsp.c
@@ -68,12 +68,12 @@ static void sub_hfyu_median_pred_int16_c(uint16_t *dst, const uint16_t *src1, co
*left_top = lt;
}
-av_cold void ff_huffyuvencdsp_init(HuffYUVEncDSPContext *c, AVCodecContext *avctx)
+av_cold void ff_huffyuvencdsp_init(HuffYUVEncDSPContext *c, enum AVPixelFormat pix_fmt)
{
c->diff_int16 = diff_int16_c;
c->sub_hfyu_median_pred_int16 = sub_hfyu_median_pred_int16_c;
#if ARCH_X86
- ff_huffyuvencdsp_init_x86(c, avctx);
+ ff_huffyuvencdsp_init_x86(c, pix_fmt);
#endif
}
diff --git a/libavcodec/huffyuvencdsp.h b/libavcodec/huffyuvencdsp.h
index 603f9c8c2c..779a51ac79 100644
--- a/libavcodec/huffyuvencdsp.h
+++ b/libavcodec/huffyuvencdsp.h
@@ -21,7 +21,7 @@
#include <stdint.h>
-#include "avcodec.h"
+#include "libavutil/pixfmt.h"
typedef struct HuffYUVEncDSPContext {
void (*diff_int16)(uint16_t *dst /* align 16 */,
@@ -34,7 +34,7 @@ typedef struct HuffYUVEncDSPContext {
int w, int *left, int *left_top);
} HuffYUVEncDSPContext;
-void ff_huffyuvencdsp_init(HuffYUVEncDSPContext *c, AVCodecContext *avctx);
-void ff_huffyuvencdsp_init_x86(HuffYUVEncDSPContext *c, AVCodecContext *avctx);
+void ff_huffyuvencdsp_init(HuffYUVEncDSPContext *c, enum AVPixelFormat pix_fmt);
+void ff_huffyuvencdsp_init_x86(HuffYUVEncDSPContext *c, enum AVPixelFormat pix_fmt);
#endif /* AVCODEC_HUFFYUVENCDSP_H */
diff --git a/libavcodec/x86/huffyuvencdsp_init.c b/libavcodec/x86/huffyuvencdsp_init.c
index cc6dc5a560..c9c33b75b4 100644
--- a/libavcodec/x86/huffyuvencdsp_init.c
+++ b/libavcodec/x86/huffyuvencdsp_init.c
@@ -35,10 +35,10 @@ void ff_diff_int16_avx2(uint16_t *dst, const uint16_t *src1, const uint16_t *src
void ff_sub_hfyu_median_pred_int16_mmxext(uint16_t *dst, const uint16_t *src1, const uint16_t *src2,
unsigned mask, int w, int *left, int *left_top);
-av_cold void ff_huffyuvencdsp_init_x86(HuffYUVEncDSPContext *c, AVCodecContext *avctx)
+av_cold void ff_huffyuvencdsp_init_x86(HuffYUVEncDSPContext *c, enum AVPixelFormat pix_fmt)
{
av_unused int cpu_flags = av_get_cpu_flags();
- const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(avctx->pix_fmt);
+ const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(pix_fmt);
if (EXTERNAL_MMXEXT(cpu_flags) && pix_desc && pix_desc->comp[0].depth<16) {
c->sub_hfyu_median_pred_int16 = ff_sub_hfyu_median_pred_int16_mmxext;
--
2.34.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH 08/14] avocdec/huffyuvdec: Don't use HYuvContext.avctx
2022-10-02 0:04 [FFmpeg-devel] [PATCH 01/14] avcodec/ylc: Remove inclusion of huffyuvdsp.h Andreas Rheinhardt
` (5 preceding siblings ...)
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 07/14] avcodec/huffyuvencdsp: Pass pix_fmt directly when initing dsp Andreas Rheinhardt
@ 2022-10-02 0:06 ` Andreas Rheinhardt
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 09/14] avcodec/huffyuvenc: Improve code locality Andreas Rheinhardt
` (7 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Andreas Rheinhardt @ 2022-10-02 0:06 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
It is nearly unused anyway, so stop use the field altogether.
This is in preparation for splitting HYuvContext into
decoder and encoder contexts.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/huffyuv.c | 1 -
libavcodec/huffyuvdec.c | 18 +++++++++---------
libavcodec/huffyuvenc.c | 1 +
3 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c
index e582060cc3..471bfa1bb9 100644
--- a/libavcodec/huffyuv.c
+++ b/libavcodec/huffyuv.c
@@ -72,7 +72,6 @@ av_cold void ff_huffyuv_common_init(AVCodecContext *avctx)
{
HYuvContext *s = avctx->priv_data;
- s->avctx = avctx;
s->flags = avctx->flags;
ff_bswapdsp_init(&s->bdsp);
diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c
index fce7497386..edfc8c0038 100644
--- a/libavcodec/huffyuvdec.c
+++ b/libavcodec/huffyuvdec.c
@@ -813,12 +813,12 @@ static void decode_bgr_bitstream(HYuvContext *s, int count)
}
}
-static void draw_slice(HYuvContext *s, AVFrame *frame, int y)
+static void draw_slice(HYuvContext *s, AVCodecContext *avctx, AVFrame *frame, int y)
{
int h, cy, i;
int offset[AV_NUM_DATA_POINTERS];
- if (!s->avctx->draw_horiz_band)
+ if (!avctx->draw_horiz_band)
return;
h = y - s->last_slice_end;
@@ -836,7 +836,7 @@ static void draw_slice(HYuvContext *s, AVFrame *frame, int y)
offset[i] = 0;
emms_c();
- s->avctx->draw_horiz_band(s->avctx, frame, offset, y, 3, h);
+ avctx->draw_horiz_band(avctx, frame, offset, y, 3, h);
s->last_slice_end = y + h;
}
@@ -952,7 +952,7 @@ static int decode_slice(AVCodecContext *avctx, AVFrame *p, int height,
break;
}
}
- draw_slice(s, p, height);
+ draw_slice(s, avctx, p, height);
} else if (s->bitstream_bpp < 24) {
int y, cy;
int lefty, leftu, leftv;
@@ -1006,7 +1006,7 @@ static int decode_slice(AVCodecContext *avctx, AVFrame *p, int height,
break;
}
- draw_slice(s, p, y);
+ draw_slice(s, avctx, p, y);
ydst = p->data[0] + p->linesize[0] * (y + y_offset);
udst = p->data[1] + p->linesize[1] * (cy + y_offset);
@@ -1029,7 +1029,7 @@ static int decode_slice(AVCodecContext *avctx, AVFrame *p, int height,
}
}
}
- draw_slice(s, p, height);
+ draw_slice(s, avctx, p, height);
break;
case MEDIAN:
@@ -1100,7 +1100,7 @@ static int decode_slice(AVCodecContext *avctx, AVFrame *p, int height,
if (y >= height)
break;
}
- draw_slice(s, p, y);
+ draw_slice(s, avctx, p, y);
decode_422_bitstream(s, width);
@@ -1117,7 +1117,7 @@ static int decode_slice(AVCodecContext *avctx, AVFrame *p, int height,
}
}
- draw_slice(s, p, height);
+ draw_slice(s, avctx, p, height);
break;
}
}
@@ -1163,7 +1163,7 @@ static int decode_slice(AVCodecContext *avctx, AVFrame *p, int height,
}
}
// just 1 large slice as this is not possible in reverse order
- draw_slice(s, p, height);
+ draw_slice(s, avctx, p, height);
break;
default:
av_log(avctx, AV_LOG_ERROR,
diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
index 2137a16714..020159a20e 100644
--- a/libavcodec/huffyuvenc.c
+++ b/libavcodec/huffyuvenc.c
@@ -209,6 +209,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
int ret;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
+ s->avctx = avctx;
ff_huffyuv_common_init(avctx);
ff_huffyuvencdsp_init(&s->hencdsp, avctx->pix_fmt);
ff_llvidencdsp_init(&s->llvidencdsp);
--
2.34.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH 09/14] avcodec/huffyuvenc: Improve code locality
2022-10-02 0:04 [FFmpeg-devel] [PATCH 01/14] avcodec/ylc: Remove inclusion of huffyuvdsp.h Andreas Rheinhardt
` (6 preceding siblings ...)
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 08/14] avocdec/huffyuvdec: Don't use HYuvContext.avctx Andreas Rheinhardt
@ 2022-10-02 0:06 ` Andreas Rheinhardt
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 10/14] avcodec/huffyuvenc: Avoid unnecessary function call Andreas Rheinhardt
` (6 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Andreas Rheinhardt @ 2022-10-02 0:06 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/huffyuvenc.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
index 020159a20e..f903b1924a 100644
--- a/libavcodec/huffyuvenc.c
+++ b/libavcodec/huffyuvenc.c
@@ -207,7 +207,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
HYuvContext *s = avctx->priv_data;
int i, j;
int ret;
- const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
+ const AVPixFmtDescriptor *desc;
s->avctx = avctx;
ff_huffyuv_common_init(avctx);
@@ -215,6 +215,8 @@ static av_cold int encode_init(AVCodecContext *avctx)
ff_llvidencdsp_init(&s->llvidencdsp);
avctx->extradata = av_mallocz(3*MAX_N + 4);
+ if (!avctx->extradata)
+ return AVERROR(ENOMEM);
if (s->flags&AV_CODEC_FLAG_PASS1) {
#define STATS_OUT_SIZE 21*MAX_N*3 + 4
avctx->stats_out = av_mallocz(STATS_OUT_SIZE); // 21*256*3(%llu ) + 3(\n) + 1(0) = 16132
@@ -223,9 +225,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
}
s->version = 2;
- if (!avctx->extradata)
- return AVERROR(ENOMEM);
-
+ desc = av_pix_fmt_desc_get(avctx->pix_fmt);
s->bps = desc->comp[0].depth;
s->yuv = !(desc->flags & AV_PIX_FMT_FLAG_RGB) && desc->nb_components >= 2;
s->chroma = desc->nb_components > 2;
--
2.34.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH 10/14] avcodec/huffyuvenc: Avoid unnecessary function call
2022-10-02 0:04 [FFmpeg-devel] [PATCH 01/14] avcodec/ylc: Remove inclusion of huffyuvdsp.h Andreas Rheinhardt
` (7 preceding siblings ...)
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 09/14] avcodec/huffyuvenc: Improve code locality Andreas Rheinhardt
@ 2022-10-02 0:06 ` Andreas Rheinhardt
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 11/14] avcodec/huffyuv: Use AVCodecContext.(width|height) directly Andreas Rheinhardt
` (5 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Andreas Rheinhardt @ 2022-10-02 0:06 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
av_pix_fmt_get_chroma_sub_sample() is superfluous if one
already has an AVPixFmtDescriptor.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/huffyuvenc.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
index f903b1924a..9da344a666 100644
--- a/libavcodec/huffyuvenc.c
+++ b/libavcodec/huffyuvenc.c
@@ -230,9 +230,8 @@ static av_cold int encode_init(AVCodecContext *avctx)
s->yuv = !(desc->flags & AV_PIX_FMT_FLAG_RGB) && desc->nb_components >= 2;
s->chroma = desc->nb_components > 2;
s->alpha = !!(desc->flags & AV_PIX_FMT_FLAG_ALPHA);
- av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt,
- &s->chroma_h_shift,
- &s->chroma_v_shift);
+ s->chroma_h_shift = desc->log2_chroma_w;
+ s->chroma_v_shift = desc->log2_chroma_h;
switch (avctx->pix_fmt) {
case AV_PIX_FMT_YUV420P:
--
2.34.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH 11/14] avcodec/huffyuv: Use AVCodecContext.(width|height) directly
2022-10-02 0:04 [FFmpeg-devel] [PATCH 01/14] avcodec/ylc: Remove inclusion of huffyuvdsp.h Andreas Rheinhardt
` (8 preceding siblings ...)
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 10/14] avcodec/huffyuvenc: Avoid unnecessary function call Andreas Rheinhardt
@ 2022-10-02 0:06 ` Andreas Rheinhardt
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 12/14] avcodec/huffyuv: Inline ff_huffyuv_common_init() in its callers Andreas Rheinhardt
` (4 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Andreas Rheinhardt @ 2022-10-02 0:06 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
These parameters are easily accessible whereever they
are accessed, so using copies from HYuvContext is
unnecessary.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/huffyuv.c | 9 ++-------
libavcodec/huffyuv.h | 3 +--
libavcodec/huffyuvdec.c | 10 +++++-----
libavcodec/huffyuvenc.c | 20 +++++++++-----------
4 files changed, 17 insertions(+), 25 deletions(-)
diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c
index 471bfa1bb9..4a5bd53998 100644
--- a/libavcodec/huffyuv.c
+++ b/libavcodec/huffyuv.c
@@ -55,12 +55,12 @@ int ff_huffyuv_generate_bits_table(uint32_t *dst, const uint8_t *len_table, int
return 0;
}
-av_cold int ff_huffyuv_alloc_temp(HYuvContext *s)
+av_cold int ff_huffyuv_alloc_temp(HYuvContext *s, int width)
{
int i;
for (i=0; i<3; i++) {
- s->temp[i]= av_malloc(4*s->width + 16);
+ s->temp[i] = av_malloc(4 * width + 16);
if (!s->temp[i])
return AVERROR(ENOMEM);
s->temp16[i] = (uint16_t*)s->temp[i];
@@ -75,11 +75,6 @@ av_cold void ff_huffyuv_common_init(AVCodecContext *avctx)
s->flags = avctx->flags;
ff_bswapdsp_init(&s->bdsp);
-
- s->width = avctx->width;
- s->height = avctx->height;
-
- av_assert1(s->width > 0 && s->height > 0);
}
av_cold void ff_huffyuv_common_end(HYuvContext *s)
diff --git a/libavcodec/huffyuv.h b/libavcodec/huffyuv.h
index 83309d4b11..92e390ad78 100644
--- a/libavcodec/huffyuv.h
+++ b/libavcodec/huffyuv.h
@@ -72,7 +72,6 @@ typedef struct HYuvContext {
int yuv;
int chroma_h_shift;
int chroma_v_shift;
- int width, height;
int flags;
int context;
int picture_number;
@@ -96,7 +95,7 @@ typedef struct HYuvContext {
void ff_huffyuv_common_init(AVCodecContext *s);
void ff_huffyuv_common_end(HYuvContext *s);
-int ff_huffyuv_alloc_temp(HYuvContext *s);
+int ff_huffyuv_alloc_temp(HYuvContext *s, int width);
int ff_huffyuv_generate_bits_table(uint32_t *dst, const uint8_t *len_table, int n);
#endif /* AVCODEC_HUFFYUV_H */
diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c
index edfc8c0038..89db3db65a 100644
--- a/libavcodec/huffyuvdec.c
+++ b/libavcodec/huffyuvdec.c
@@ -558,7 +558,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
return AVERROR_INVALIDDATA;
}
- if ((ret = ff_huffyuv_alloc_temp(s)) < 0)
+ if ((ret = ff_huffyuv_alloc_temp(s, avctx->width)) < 0)
return ret;
return 0;
@@ -873,8 +873,8 @@ static int decode_slice(AVCodecContext *avctx, AVFrame *p, int height,
{
HYuvContext *s = avctx->priv_data;
int fake_ystride, fake_ustride, fake_vstride;
- const int width = s->width;
- const int width2 = s->width >> 1;
+ const int width = avctx->width;
+ const int width2 = avctx->width >> 1;
int ret;
if ((ret = init_get_bits8(&s->gb, s->bitstream_buffer + table_size, buf_size - table_size)) < 0)
@@ -1185,8 +1185,8 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p,
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
HYuvContext *s = avctx->priv_data;
- const int width = s->width;
- const int height = s->height;
+ const int width = avctx->width;
+ const int height = avctx->height;
int slice, table_size = 0, ret, nb_slices;
unsigned slices_info_offset;
int slice_height;
diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
index 9da344a666..0e9b24c8db 100644
--- a/libavcodec/huffyuvenc.c
+++ b/libavcodec/huffyuvenc.c
@@ -236,7 +236,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
switch (avctx->pix_fmt) {
case AV_PIX_FMT_YUV420P:
case AV_PIX_FMT_YUV422P:
- if (s->width & 1) {
+ if (avctx->width & 1) {
av_log(avctx, AV_LOG_ERROR, "Width must be even for this colorspace.\n");
return AVERROR(EINVAL);
}
@@ -310,7 +310,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
}
if (avctx->codec->id == AV_CODEC_ID_HUFFYUV) {
- if (s->interlaced != ( s->height > 288 ))
+ if (s->interlaced != ( avctx->height > 288 ))
av_log(avctx, AV_LOG_INFO,
"using huffyuv 2.2.0 or newer interlacing flag\n");
}
@@ -379,7 +379,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
if (s->context) {
for (i = 0; i < 4; i++) {
- int pels = s->width * s->height / (i ? 40 : 10);
+ int pels = avctx->width * avctx->height / (i ? 40 : 10);
for (j = 0; j < s->vlc_n; j++) {
int d = FFMIN(j, s->vlc_n - j);
s->stats[i][j] = pels/(d*d + 1);
@@ -391,7 +391,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
s->stats[i][j]= 0;
}
- ret = ff_huffyuv_alloc_temp(s);
+ ret = ff_huffyuv_alloc_temp(s, avctx->width);
if (ret < 0)
return ret;
@@ -715,9 +715,9 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet)
{
HYuvContext *s = avctx->priv_data;
- const int width = s->width;
- const int width2 = s->width>>1;
- const int height = s->height;
+ const int width = avctx->width;
+ const int width2 = avctx->width >> 1;
+ const int height = avctx->height;
const int fake_ystride = s->interlaced ? pict->linesize[0]*2 : pict->linesize[0];
const int fake_ustride = s->interlaced ? pict->linesize[1]*2 : pict->linesize[1];
const int fake_vstride = s->interlaced ? pict->linesize[2]*2 : pict->linesize[2];
@@ -848,7 +848,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const uint8_t *data = p->data[0] + (height - 1) * p->linesize[0];
const int stride = -p->linesize[0];
const int fake_stride = -fake_ystride;
- int y;
int leftr, leftg, leftb, lefta;
put_bits(&s->pb, 8, lefta = data[A]);
@@ -860,7 +859,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
&leftr, &leftg, &leftb, &lefta);
encode_bgra_bitstream(s, width - 1, 4);
- for (y = 1; y < s->height; y++) {
+ for (int y = 1; y < height; y++) {
const uint8_t *dst = data + y*stride;
if (s->predictor == PLANE && s->interlaced < y) {
s->llvidencdsp.diff_bytes(s->temp[1], dst, dst - fake_stride, width * 4);
@@ -876,7 +875,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const uint8_t *data = p->data[0] + (height - 1) * p->linesize[0];
const int stride = -p->linesize[0];
const int fake_stride = -fake_ystride;
- int y;
int leftr, leftg, leftb;
put_bits(&s->pb, 8, leftr = data[0]);
@@ -888,7 +886,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
&leftr, &leftg, &leftb);
encode_bgra_bitstream(s, width-1, 3);
- for (y = 1; y < s->height; y++) {
+ for (int y = 1; y < height; y++) {
const uint8_t *dst = data + y * stride;
if (s->predictor == PLANE && s->interlaced < y) {
s->llvidencdsp.diff_bytes(s->temp[1], dst, dst - fake_stride,
--
2.34.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH 12/14] avcodec/huffyuv: Inline ff_huffyuv_common_init() in its callers
2022-10-02 0:04 [FFmpeg-devel] [PATCH 01/14] avcodec/ylc: Remove inclusion of huffyuvdsp.h Andreas Rheinhardt
` (9 preceding siblings ...)
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 11/14] avcodec/huffyuv: Use AVCodecContext.(width|height) directly Andreas Rheinhardt
@ 2022-10-02 0:06 ` Andreas Rheinhardt
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 13/14] avcodec/huffyuv: Split HYuvContext into decoder and encoder context Andreas Rheinhardt
` (3 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Andreas Rheinhardt @ 2022-10-02 0:06 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
This is in preparation for splitting HYuvContext.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/huffyuv.c | 9 ---------
libavcodec/huffyuv.h | 1 -
libavcodec/huffyuvdec.c | 5 +++--
libavcodec/huffyuvenc.c | 4 +++-
4 files changed, 6 insertions(+), 13 deletions(-)
diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c
index 4a5bd53998..23a2bb2537 100644
--- a/libavcodec/huffyuv.c
+++ b/libavcodec/huffyuv.c
@@ -68,15 +68,6 @@ av_cold int ff_huffyuv_alloc_temp(HYuvContext *s, int width)
return 0;
}
-av_cold void ff_huffyuv_common_init(AVCodecContext *avctx)
-{
- HYuvContext *s = avctx->priv_data;
-
- s->flags = avctx->flags;
-
- ff_bswapdsp_init(&s->bdsp);
-}
-
av_cold void ff_huffyuv_common_end(HYuvContext *s)
{
int i;
diff --git a/libavcodec/huffyuv.h b/libavcodec/huffyuv.h
index 92e390ad78..823a091809 100644
--- a/libavcodec/huffyuv.h
+++ b/libavcodec/huffyuv.h
@@ -93,7 +93,6 @@ typedef struct HYuvContext {
int non_determ; // non-deterministic, multi-threaded encoder allowed
} HYuvContext;
-void ff_huffyuv_common_init(AVCodecContext *s);
void ff_huffyuv_common_end(HYuvContext *s);
int ff_huffyuv_alloc_temp(HYuvContext *s, int width);
int ff_huffyuv_generate_bits_table(uint32_t *dst, const uint8_t *len_table, int n);
diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c
index 89db3db65a..093070e348 100644
--- a/libavcodec/huffyuvdec.c
+++ b/libavcodec/huffyuvdec.c
@@ -300,6 +300,9 @@ static av_cold int decode_init(AVCodecContext *avctx)
if (ret < 0)
return ret;
+ s->flags = avctx->flags;
+
+ ff_bswapdsp_init(&s->bdsp);
ff_huffyuvdsp_init(&s->hdsp, avctx->pix_fmt);
ff_llviddsp_init(&s->llviddsp);
memset(s->vlc, 0, 4 * sizeof(VLC));
@@ -545,8 +548,6 @@ static av_cold int decode_init(AVCodecContext *avctx)
}
}
- ff_huffyuv_common_init(avctx);
-
if ((avctx->pix_fmt == AV_PIX_FMT_YUV422P || avctx->pix_fmt == AV_PIX_FMT_YUV420P) && avctx->width & 1) {
av_log(avctx, AV_LOG_ERROR, "width must be even for this colorspace\n");
return AVERROR_INVALIDDATA;
diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
index 0e9b24c8db..5293d32d2b 100644
--- a/libavcodec/huffyuvenc.c
+++ b/libavcodec/huffyuvenc.c
@@ -210,7 +210,9 @@ static av_cold int encode_init(AVCodecContext *avctx)
const AVPixFmtDescriptor *desc;
s->avctx = avctx;
- ff_huffyuv_common_init(avctx);
+ s->flags = avctx->flags;
+
+ ff_bswapdsp_init(&s->bdsp);
ff_huffyuvencdsp_init(&s->hencdsp, avctx->pix_fmt);
ff_llvidencdsp_init(&s->llvidencdsp);
--
2.34.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH 13/14] avcodec/huffyuv: Split HYuvContext into decoder and encoder context
2022-10-02 0:04 [FFmpeg-devel] [PATCH 01/14] avcodec/ylc: Remove inclusion of huffyuvdsp.h Andreas Rheinhardt
` (10 preceding siblings ...)
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 12/14] avcodec/huffyuv: Inline ff_huffyuv_common_init() in its callers Andreas Rheinhardt
@ 2022-10-02 0:06 ` Andreas Rheinhardt
2022-10-02 0:10 ` [FFmpeg-devel] [PATCH 14/14] avcodec/huffyuv: Speed up generating Huffman codes Andreas Rheinhardt
` (2 subsequent siblings)
14 siblings, 0 replies; 16+ messages in thread
From: Andreas Rheinhardt @ 2022-10-02 0:06 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
While the share of elements used by both is quite big, the amount
of code shared between the decoders and encoders is negligible.
Therefore one can easily split the context if one wants to.
The reasons for doing so are that the non-shared elements
are non-negligible: The stats array which is only used by
the encoder takes 524288B of 868904B (on x64); similarly,
pix_bgr_map which is only used by the decoder takes 16KiB.
Furthermore, using a shared context also entails inclusions
of unneeded headers like put_bits.h for the decoder and get_bits.h
for the encoder (and all of these and much more for huffyuv.c).
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/huffyuv.c | 19 +++++-----
libavcodec/huffyuv.h | 68 ++++++++---------------------------
libavcodec/huffyuvdec.c | 80 ++++++++++++++++++++++++++++++-----------
libavcodec/huffyuvdsp.c | 1 +
libavcodec/huffyuvdsp.h | 13 -------
libavcodec/huffyuvenc.c | 73 +++++++++++++++++++++++++++----------
6 files changed, 139 insertions(+), 115 deletions(-)
diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c
index 23a2bb2537..bbe4b952b0 100644
--- a/libavcodec/huffyuv.c
+++ b/libavcodec/huffyuv.c
@@ -30,10 +30,11 @@
#include <stdint.h>
+#include "libavutil/attributes.h"
+#include "libavutil/error.h"
+#include "libavutil/log.h"
#include "libavutil/mem.h"
-#include "avcodec.h"
-#include "bswapdsp.h"
#include "huffyuv.h"
int ff_huffyuv_generate_bits_table(uint32_t *dst, const uint8_t *len_table, int n)
@@ -55,25 +56,25 @@ int ff_huffyuv_generate_bits_table(uint32_t *dst, const uint8_t *len_table, int
return 0;
}
-av_cold int ff_huffyuv_alloc_temp(HYuvContext *s, int width)
+av_cold int ff_huffyuv_alloc_temp(uint8_t *temp[3], uint16_t *temp16[3], int width)
{
int i;
for (i=0; i<3; i++) {
- s->temp[i] = av_malloc(4 * width + 16);
- if (!s->temp[i])
+ temp[i] = av_malloc(4 * width + 16);
+ if (!temp[i])
return AVERROR(ENOMEM);
- s->temp16[i] = (uint16_t*)s->temp[i];
+ temp16[i] = (uint16_t*)temp[i];
}
return 0;
}
-av_cold void ff_huffyuv_common_end(HYuvContext *s)
+av_cold void ff_huffyuv_common_end(uint8_t *temp[3], uint16_t *temp16[3])
{
int i;
for(i = 0; i < 3; i++) {
- av_freep(&s->temp[i]);
- s->temp16[i] = NULL;
+ av_freep(&temp[i]);
+ temp16[i] = NULL;
}
}
diff --git a/libavcodec/huffyuv.h b/libavcodec/huffyuv.h
index 823a091809..6cc48bf57d 100644
--- a/libavcodec/huffyuv.h
+++ b/libavcodec/huffyuv.h
@@ -31,16 +31,19 @@
#include <stdint.h>
-#include "avcodec.h"
-#include "bswapdsp.h"
-#include "get_bits.h"
-#include "huffyuvdsp.h"
-#include "huffyuvencdsp.h"
-#include "put_bits.h"
-#include "lossless_videodsp.h"
-#include "lossless_videoencdsp.h"
-
-#define VLC_BITS 12
+#include "config.h"
+
+#if HAVE_BIGENDIAN
+#define B 3
+#define G 2
+#define R 1
+#define A 0
+#else
+#define B 0
+#define G 1
+#define R 2
+#define A 3
+#endif
#define MAX_BITS 16
#define MAX_N (1<<MAX_BITS)
@@ -52,49 +55,8 @@ typedef enum Predictor {
MEDIAN,
} Predictor;
-typedef struct HYuvContext {
- AVClass *class;
- AVCodecContext *avctx;
- Predictor predictor;
- GetBitContext gb;
- PutBitContext pb;
- int interlaced;
- int decorrelate;
- int bitstream_bpp;
- int version;
- int yuy2; //use yuy2 instead of 422P
- int bgr32; //use bgr32 instead of bgr24
- int bps;
- int n; // 1<<bps
- int vlc_n; // number of vlc codes (FFMIN(1<<bps, MAX_VLC_N))
- int alpha;
- int chroma;
- int yuv;
- int chroma_h_shift;
- int chroma_v_shift;
- int flags;
- int context;
- int picture_number;
- int last_slice_end;
- uint8_t *temp[3];
- uint16_t *temp16[3]; ///< identical to temp but 16bit type
- uint64_t stats[4][MAX_VLC_N];
- uint8_t len[4][MAX_VLC_N];
- uint32_t bits[4][MAX_VLC_N];
- uint32_t pix_bgr_map[1<<VLC_BITS];
- VLC vlc[8]; //Y,U,V,A,YY,YU,YV,AA
- uint8_t *bitstream_buffer;
- unsigned int bitstream_buffer_size;
- BswapDSPContext bdsp;
- HuffYUVDSPContext hdsp;
- HuffYUVEncDSPContext hencdsp;
- LLVidDSPContext llviddsp;
- LLVidEncDSPContext llvidencdsp;
- int non_determ; // non-deterministic, multi-threaded encoder allowed
-} HYuvContext;
-
-void ff_huffyuv_common_end(HYuvContext *s);
-int ff_huffyuv_alloc_temp(HYuvContext *s, int width);
+void ff_huffyuv_common_end(uint8_t *temp[3], uint16_t *temp16[3]);
+int ff_huffyuv_alloc_temp(uint8_t *temp[3], uint16_t *temp16[3], int width);
int ff_huffyuv_generate_bits_table(uint32_t *dst, const uint8_t *len_table, int n);
#endif /* AVCODEC_HUFFYUV_H */
diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c
index 093070e348..a065185986 100644
--- a/libavcodec/huffyuvdec.c
+++ b/libavcodec/huffyuvdec.c
@@ -35,6 +35,7 @@
#include "config_components.h"
#include "avcodec.h"
+#include "bswapdsp.h"
#include "codec_internal.h"
#include "get_bits.h"
#include "huffyuv.h"
@@ -44,6 +45,43 @@
#include "libavutil/imgutils.h"
#include "libavutil/pixdesc.h"
+#define VLC_BITS 12
+
+typedef struct HYuvDecContext {
+ GetBitContext gb;
+ Predictor predictor;
+ int interlaced;
+ int decorrelate;
+ int bitstream_bpp;
+ int version;
+ int yuy2; //use yuy2 instead of 422P
+ int bgr32; //use bgr32 instead of bgr24
+ int bps;
+ int n; // 1<<bps
+ int vlc_n; // number of vlc codes (FFMIN(1<<bps, MAX_VLC_N))
+ int alpha;
+ int chroma;
+ int yuv;
+ int chroma_h_shift;
+ int chroma_v_shift;
+ int flags;
+ int context;
+ int last_slice_end;
+
+ uint8_t *temp[3];
+ uint16_t *temp16[3]; ///< identical to temp but 16bit type
+ uint8_t len[4][MAX_VLC_N];
+ uint32_t bits[4][MAX_VLC_N];
+ uint32_t pix_bgr_map[1<<VLC_BITS];
+ VLC vlc[8]; //Y,U,V,A,YY,YU,YV,AA
+ uint8_t *bitstream_buffer;
+ unsigned int bitstream_buffer_size;
+ BswapDSPContext bdsp;
+ HuffYUVDSPContext hdsp;
+ LLVidDSPContext llviddsp;
+} HYuvDecContext;
+
+
#define classic_shift_luma_table_size 42
static const unsigned char classic_shift_luma[classic_shift_luma_table_size + AV_INPUT_BUFFER_PADDING_SIZE] = {
34, 36, 35, 69, 135, 232, 9, 16, 10, 24, 11, 23, 12, 16, 13, 10,
@@ -118,7 +156,7 @@ static int read_len_table(uint8_t *dst, GetBitContext *gb, int n)
return 0;
}
-static int generate_joint_tables(HYuvContext *s)
+static int generate_joint_tables(HYuvDecContext *s)
{
int ret;
uint16_t *symbols = av_mallocz(5 << VLC_BITS);
@@ -208,7 +246,7 @@ out:
return ret;
}
-static int read_huffman_tables(HYuvContext *s, const uint8_t *src, int length)
+static int read_huffman_tables(HYuvDecContext *s, const uint8_t *src, int length)
{
GetBitContext gb;
int i, ret;
@@ -237,7 +275,7 @@ static int read_huffman_tables(HYuvContext *s, const uint8_t *src, int length)
return (get_bits_count(&gb) + 7) / 8;
}
-static int read_old_huffman_tables(HYuvContext *s)
+static int read_old_huffman_tables(HYuvDecContext *s)
{
GetBitContext gb;
int i, ret;
@@ -279,10 +317,10 @@ static int read_old_huffman_tables(HYuvContext *s)
static av_cold int decode_end(AVCodecContext *avctx)
{
- HYuvContext *s = avctx->priv_data;
+ HYuvDecContext *s = avctx->priv_data;
int i;
- ff_huffyuv_common_end(s);
+ ff_huffyuv_common_end(s->temp, s->temp16);
av_freep(&s->bitstream_buffer);
for (i = 0; i < 8; i++)
@@ -293,7 +331,7 @@ static av_cold int decode_end(AVCodecContext *avctx)
static av_cold int decode_init(AVCodecContext *avctx)
{
- HYuvContext *s = avctx->priv_data;
+ HYuvDecContext *s = avctx->priv_data;
int ret;
ret = av_image_check_size(avctx->width, avctx->height, 0, avctx);
@@ -559,7 +597,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
return AVERROR_INVALIDDATA;
}
- if ((ret = ff_huffyuv_alloc_temp(s, avctx->width)) < 0)
+ if ((ret = ff_huffyuv_alloc_temp(s->temp, s->temp16, avctx->width)) < 0)
return ret;
return 0;
@@ -618,7 +656,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
GET_VLC_DUAL(dst0, dst1, re, &s->gb, s->vlc[4+plane1].table, \
s->vlc[0].table, s->vlc[plane1].table, VLC_BITS, 3, OP8bits)
-static void decode_422_bitstream(HYuvContext *s, int count)
+static void decode_422_bitstream(HYuvDecContext *s, int count)
{
int i, icount;
OPEN_READER(re, &s->gb);
@@ -662,7 +700,7 @@ static void decode_422_bitstream(HYuvContext *s, int count)
dst1 = get_vlc2(&s->gb, s->vlc[plane].table, VLC_BITS, 3)<<2;\
dst1 += get_bits(&s->gb, 2);\
}
-static void decode_plane_bitstream(HYuvContext *s, int width, int plane)
+static void decode_plane_bitstream(HYuvDecContext *s, int width, int plane)
{
int i, count = width/2;
@@ -723,7 +761,7 @@ static void decode_plane_bitstream(HYuvContext *s, int width, int plane)
}
}
-static void decode_gray_bitstream(HYuvContext *s, int count)
+static void decode_gray_bitstream(HYuvDecContext *s, int count)
{
int i;
OPEN_READER(re, &s->gb);
@@ -741,7 +779,7 @@ static void decode_gray_bitstream(HYuvContext *s, int count)
CLOSE_READER(re, &s->gb);
}
-static av_always_inline void decode_bgr_1(HYuvContext *s, int count,
+static av_always_inline void decode_bgr_1(HYuvDecContext *s, int count,
int decorrelate, int alpha)
{
int i;
@@ -799,7 +837,7 @@ static av_always_inline void decode_bgr_1(HYuvContext *s, int count,
CLOSE_READER(re, &s->gb);
}
-static void decode_bgr_bitstream(HYuvContext *s, int count)
+static void decode_bgr_bitstream(HYuvDecContext *s, int count)
{
if (s->decorrelate) {
if (s->bitstream_bpp == 24)
@@ -814,7 +852,7 @@ static void decode_bgr_bitstream(HYuvContext *s, int count)
}
}
-static void draw_slice(HYuvContext *s, AVCodecContext *avctx, AVFrame *frame, int y)
+static void draw_slice(HYuvDecContext *s, AVCodecContext *avctx, AVFrame *frame, int y)
{
int h, cy, i;
int offset[AV_NUM_DATA_POINTERS];
@@ -842,7 +880,7 @@ static void draw_slice(HYuvContext *s, AVCodecContext *avctx, AVFrame *frame, in
s->last_slice_end = y + h;
}
-static int left_prediction(HYuvContext *s, uint8_t *dst, const uint8_t *src, int w, int acc)
+static int left_prediction(HYuvDecContext *s, uint8_t *dst, const uint8_t *src, int w, int acc)
{
if (s->bps <= 8) {
return s->llviddsp.add_left_pred(dst, src, w, acc);
@@ -851,7 +889,7 @@ static int left_prediction(HYuvContext *s, uint8_t *dst, const uint8_t *src, int
}
}
-static void add_bytes(HYuvContext *s, uint8_t *dst, uint8_t *src, int w)
+static void add_bytes(HYuvDecContext *s, uint8_t *dst, uint8_t *src, int w)
{
if (s->bps <= 8) {
s->llviddsp.add_bytes(dst, src, w);
@@ -860,7 +898,7 @@ static void add_bytes(HYuvContext *s, uint8_t *dst, uint8_t *src, int w)
}
}
-static void add_median_prediction(HYuvContext *s, uint8_t *dst, const uint8_t *src, const uint8_t *diff, int w, int *left, int *left_top)
+static void add_median_prediction(HYuvDecContext *s, uint8_t *dst, const uint8_t *src, const uint8_t *diff, int w, int *left, int *left_top)
{
if (s->bps <= 8) {
s->llviddsp.add_median_pred(dst, src, diff, w, left, left_top);
@@ -872,7 +910,7 @@ static void add_median_prediction(HYuvContext *s, uint8_t *dst, const uint8_t *s
static int decode_slice(AVCodecContext *avctx, AVFrame *p, int height,
int buf_size, int y_offset, int table_size)
{
- HYuvContext *s = avctx->priv_data;
+ HYuvDecContext *s = avctx->priv_data;
int fake_ystride, fake_ustride, fake_vstride;
const int width = avctx->width;
const int width2 = avctx->width >> 1;
@@ -1185,7 +1223,7 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *p,
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
- HYuvContext *s = avctx->priv_data;
+ HYuvDecContext *s = avctx->priv_data;
const int width = avctx->width;
const int height = avctx->height;
int slice, table_size = 0, ret, nb_slices;
@@ -1268,7 +1306,7 @@ const FFCodec ff_huffyuv_decoder = {
CODEC_LONG_NAME("Huffyuv / HuffYUV"),
.p.type = AVMEDIA_TYPE_VIDEO,
.p.id = AV_CODEC_ID_HUFFYUV,
- .priv_data_size = sizeof(HYuvContext),
+ .priv_data_size = sizeof(HYuvDecContext),
.init = decode_init,
.close = decode_end,
FF_CODEC_DECODE_CB(decode_frame),
@@ -1283,7 +1321,7 @@ const FFCodec ff_ffvhuff_decoder = {
CODEC_LONG_NAME("Huffyuv FFmpeg variant"),
.p.type = AVMEDIA_TYPE_VIDEO,
.p.id = AV_CODEC_ID_FFVHUFF,
- .priv_data_size = sizeof(HYuvContext),
+ .priv_data_size = sizeof(HYuvDecContext),
.init = decode_init,
.close = decode_end,
FF_CODEC_DECODE_CB(decode_frame),
@@ -1299,7 +1337,7 @@ const FFCodec ff_hymt_decoder = {
CODEC_LONG_NAME("HuffYUV MT"),
.p.type = AVMEDIA_TYPE_VIDEO,
.p.id = AV_CODEC_ID_HYMT,
- .priv_data_size = sizeof(HYuvContext),
+ .priv_data_size = sizeof(HYuvDecContext),
.init = decode_init,
.close = decode_end,
FF_CODEC_DECODE_CB(decode_frame),
diff --git a/libavcodec/huffyuvdsp.c b/libavcodec/huffyuvdsp.c
index 10723b2fca..fb98836cc4 100644
--- a/libavcodec/huffyuvdsp.c
+++ b/libavcodec/huffyuvdsp.c
@@ -21,6 +21,7 @@
#include "config.h"
#include "libavutil/attributes.h"
#include "mathops.h"
+#include "huffyuv.h"
#include "huffyuvdsp.h"
// 0x00010001 or 0x0001000100010001 or whatever, depending on the cpu's native arithmetic size
diff --git a/libavcodec/huffyuvdsp.h b/libavcodec/huffyuvdsp.h
index e5f5b05466..90e50b5429 100644
--- a/libavcodec/huffyuvdsp.h
+++ b/libavcodec/huffyuvdsp.h
@@ -21,19 +21,6 @@
#include <stdint.h>
#include "libavutil/pixfmt.h"
-#include "config.h"
-
-#if HAVE_BIGENDIAN
-#define B 3
-#define G 2
-#define R 1
-#define A 0
-#else
-#define B 0
-#define G 1
-#define R 2
-#define A 3
-#endif
typedef struct HuffYUVDSPContext {
void (*add_int16)(uint16_t *dst/*align 16*/, const uint16_t *src/*align 16*/,
diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
index 5293d32d2b..17d2490dc3 100644
--- a/libavcodec/huffyuvenc.c
+++ b/libavcodec/huffyuvenc.c
@@ -31,6 +31,7 @@
#include "config_components.h"
#include "avcodec.h"
+#include "bswapdsp.h"
#include "codec_internal.h"
#include "encode.h"
#include "huffyuv.h"
@@ -41,7 +42,39 @@
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
-static inline void diff_bytes(HYuvContext *s, uint8_t *dst,
+typedef struct HYuvEncContext {
+ AVClass *class;
+ AVCodecContext *avctx;
+ PutBitContext pb;
+ Predictor predictor;
+ int interlaced;
+ int decorrelate;
+ int bitstream_bpp;
+ int version;
+ int bps;
+ int n; // 1<<bps
+ int vlc_n; // number of vlc codes (FFMIN(1<<bps, MAX_VLC_N))
+ int alpha;
+ int chroma;
+ int yuv;
+ int chroma_h_shift;
+ int chroma_v_shift;
+ int flags;
+ int context;
+ int picture_number;
+
+ uint8_t *temp[3];
+ uint16_t *temp16[3]; ///< identical to temp but 16bit type
+ uint64_t stats[4][MAX_VLC_N];
+ uint8_t len[4][MAX_VLC_N];
+ uint32_t bits[4][MAX_VLC_N];
+ BswapDSPContext bdsp;
+ HuffYUVEncDSPContext hencdsp;
+ LLVidEncDSPContext llvidencdsp;
+ int non_determ; // non-deterministic, multi-threaded encoder allowed
+} HYuvEncContext;
+
+static inline void diff_bytes(HYuvEncContext *s, uint8_t *dst,
const uint8_t *src0, const uint8_t *src1, int w)
{
if (s->bps <= 8) {
@@ -51,7 +84,7 @@ static inline void diff_bytes(HYuvContext *s, uint8_t *dst,
}
}
-static inline int sub_left_prediction(HYuvContext *s, uint8_t *dst,
+static inline int sub_left_prediction(HYuvEncContext *s, uint8_t *dst,
const uint8_t *src, int w, int left)
{
int i;
@@ -82,7 +115,7 @@ static inline int sub_left_prediction(HYuvContext *s, uint8_t *dst,
}
}
-static inline void sub_left_prediction_bgr32(HYuvContext *s, uint8_t *dst,
+static inline void sub_left_prediction_bgr32(HYuvEncContext *s, uint8_t *dst,
const uint8_t *src, int w,
int *red, int *green, int *blue,
int *alpha)
@@ -118,7 +151,7 @@ static inline void sub_left_prediction_bgr32(HYuvContext *s, uint8_t *dst,
*alpha = src[(w - 1) * 4 + A];
}
-static inline void sub_left_prediction_rgb24(HYuvContext *s, uint8_t *dst,
+static inline void sub_left_prediction_rgb24(HYuvEncContext *s, uint8_t *dst,
const uint8_t *src, int w,
int *red, int *green, int *blue)
{
@@ -146,7 +179,9 @@ static inline void sub_left_prediction_rgb24(HYuvContext *s, uint8_t *dst,
*blue = src[(w - 1) * 3 + 2];
}
-static void sub_median_prediction(HYuvContext *s, uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int w, int *left, int *left_top)
+static void sub_median_prediction(HYuvEncContext *s, uint8_t *dst,
+ const uint8_t *src1, const uint8_t *src2,
+ int w, int *left, int *left_top)
{
if (s->bps <= 8) {
s->llvidencdsp.sub_median_pred(dst, src1, src2, w , left, left_top);
@@ -155,7 +190,7 @@ static void sub_median_prediction(HYuvContext *s, uint8_t *dst, const uint8_t *s
}
}
-static int store_table(HYuvContext *s, const uint8_t *len, uint8_t *buf)
+static int store_table(HYuvEncContext *s, const uint8_t *len, uint8_t *buf)
{
int i;
int index = 0;
@@ -180,7 +215,7 @@ static int store_table(HYuvContext *s, const uint8_t *len, uint8_t *buf)
return index;
}
-static int store_huffman_tables(HYuvContext *s, uint8_t *buf)
+static int store_huffman_tables(HYuvEncContext *s, uint8_t *buf)
{
int i, ret;
int size = 0;
@@ -204,7 +239,7 @@ static int store_huffman_tables(HYuvContext *s, uint8_t *buf)
static av_cold int encode_init(AVCodecContext *avctx)
{
- HYuvContext *s = avctx->priv_data;
+ HYuvEncContext *s = avctx->priv_data;
int i, j;
int ret;
const AVPixFmtDescriptor *desc;
@@ -393,7 +428,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
s->stats[i][j]= 0;
}
- ret = ff_huffyuv_alloc_temp(s, avctx->width);
+ ret = ff_huffyuv_alloc_temp(s->temp, s->temp16, avctx->width);
if (ret < 0)
return ret;
@@ -401,7 +436,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
return 0;
}
-static int encode_422_bitstream(HYuvContext *s, int offset, int count)
+static int encode_422_bitstream(HYuvEncContext *s, int offset, int count)
{
int i;
const uint8_t *y = s->temp[0] + offset;
@@ -456,7 +491,7 @@ static int encode_422_bitstream(HYuvContext *s, int offset, int count)
return 0;
}
-static int encode_plane_bitstream(HYuvContext *s, int width, int plane)
+static int encode_plane_bitstream(HYuvEncContext *s, int width, int plane)
{
int i, count = width/2;
@@ -618,7 +653,7 @@ static int encode_plane_bitstream(HYuvContext *s, int width, int plane)
return 0;
}
-static int encode_gray_bitstream(HYuvContext *s, int count)
+static int encode_gray_bitstream(HYuvEncContext *s, int count)
{
int i;
@@ -663,7 +698,7 @@ static int encode_gray_bitstream(HYuvContext *s, int count)
return 0;
}
-static inline int encode_bgra_bitstream(HYuvContext *s, int count, int planes)
+static inline int encode_bgra_bitstream(HYuvEncContext *s, int count, int planes)
{
int i;
@@ -716,7 +751,7 @@ static inline int encode_bgra_bitstream(HYuvContext *s, int count, int planes)
static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet)
{
- HYuvContext *s = avctx->priv_data;
+ HYuvEncContext *s = avctx->priv_data;
const int width = avctx->width;
const int width2 = avctx->width >> 1;
const int height = avctx->height;
@@ -996,16 +1031,16 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
static av_cold int encode_end(AVCodecContext *avctx)
{
- HYuvContext *s = avctx->priv_data;
+ HYuvEncContext *s = avctx->priv_data;
- ff_huffyuv_common_end(s);
+ ff_huffyuv_common_end(s->temp, s->temp16);
av_freep(&avctx->stats_out);
return 0;
}
-#define OFFSET(x) offsetof(HYuvContext, x)
+#define OFFSET(x) offsetof(HYuvEncContext, x)
#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
#define COMMON_OPTIONS \
@@ -1048,7 +1083,7 @@ const FFCodec ff_huffyuv_encoder = {
.p.type = AVMEDIA_TYPE_VIDEO,
.p.id = AV_CODEC_ID_HUFFYUV,
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
- .priv_data_size = sizeof(HYuvContext),
+ .priv_data_size = sizeof(HYuvEncContext),
.init = encode_init,
FF_CODEC_ENCODE_CB(encode_frame),
.close = encode_end,
@@ -1067,7 +1102,7 @@ const FFCodec ff_ffvhuff_encoder = {
.p.type = AVMEDIA_TYPE_VIDEO,
.p.id = AV_CODEC_ID_FFVHUFF,
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS,
- .priv_data_size = sizeof(HYuvContext),
+ .priv_data_size = sizeof(HYuvEncContext),
.init = encode_init,
FF_CODEC_ENCODE_CB(encode_frame),
.close = encode_end,
--
2.34.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH 14/14] avcodec/huffyuv: Speed up generating Huffman codes
2022-10-02 0:04 [FFmpeg-devel] [PATCH 01/14] avcodec/ylc: Remove inclusion of huffyuvdsp.h Andreas Rheinhardt
` (11 preceding siblings ...)
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 13/14] avcodec/huffyuv: Split HYuvContext into decoder and encoder context Andreas Rheinhardt
@ 2022-10-02 0:10 ` Andreas Rheinhardt
2022-10-02 14:46 ` [FFmpeg-devel] [PATCH 15/15] avcodec/huffyuv: Update outdated link Andreas Rheinhardt
2022-10-07 11:58 ` [FFmpeg-devel] [PATCH 01/14] avcodec/ylc: Remove inclusion of huffyuvdsp.h Andreas Rheinhardt
14 siblings, 0 replies; 16+ messages in thread
From: Andreas Rheinhardt @ 2022-10-02 0:10 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
The codes here have the property that the long codes
are to the left of the tree (each zero bit child node
is by definition to the left of its one bit sibling);
they also have the property that among codes of the same length,
the symbol is ascending from left to right.
These properties can be used to create the codes from
the lengths in only two passes over the array of lengths
(the current code uses one pass for each length, i.e. 32):
First one counts how many nodes of each length there are.
Then one calculates the range of codes of each length
(possible because the codes are ordered by length in the tree).
This enables one to calculate the actual codes with only
one further traversal of the length array.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
Given that the long codes are to the left of the tree,
one can actually use uint16_t here despite the codes
being up to 32 bits long (so many leading digits have to be zero
that the codes fit into uint16_t).
libavcodec/huffyuv.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c
index bbe4b952b0..6bcaacfc37 100644
--- a/libavcodec/huffyuv.c
+++ b/libavcodec/huffyuv.c
@@ -39,19 +39,23 @@
int ff_huffyuv_generate_bits_table(uint32_t *dst, const uint8_t *len_table, int n)
{
- int len, index;
- uint32_t bits = 0;
+ int lens[33] = { 0 };
+ uint32_t codes[33];
- for (len = 32; len > 0; len--) {
- for (index = 0; index < n; index++) {
- if (len_table[index] == len)
- dst[index] = bits++;
- }
- if (bits & 1) {
+ for (int i = 0; i < n; i++)
+ lens[len_table[i]]++;
+
+ codes[32] = 0;
+ for (int i = FF_ARRAY_ELEMS(lens) - 1; i > 0; i--) {
+ if ((lens[i] + codes[i]) & 1) {
av_log(NULL, AV_LOG_ERROR, "Error generating huffman table\n");
return -1;
}
- bits >>= 1;
+ codes[i - 1] = (lens[i] + codes[i]) >> 1;
+ }
+ for (int i = 0; i < n; i++) {
+ if (len_table[i])
+ dst[i] = codes[len_table[i]]++;
}
return 0;
}
--
2.34.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 16+ messages in thread
* [FFmpeg-devel] [PATCH 15/15] avcodec/huffyuv: Update outdated link
2022-10-02 0:04 [FFmpeg-devel] [PATCH 01/14] avcodec/ylc: Remove inclusion of huffyuvdsp.h Andreas Rheinhardt
` (12 preceding siblings ...)
2022-10-02 0:10 ` [FFmpeg-devel] [PATCH 14/14] avcodec/huffyuv: Speed up generating Huffman codes Andreas Rheinhardt
@ 2022-10-02 14:46 ` Andreas Rheinhardt
2022-10-07 11:58 ` [FFmpeg-devel] [PATCH 01/14] avcodec/ylc: Remove inclusion of huffyuvdsp.h Andreas Rheinhardt
14 siblings, 0 replies; 16+ messages in thread
From: Andreas Rheinhardt @ 2022-10-02 14:46 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/huffyuv.c | 2 +-
libavcodec/huffyuv.h | 2 +-
libavcodec/huffyuvdec.c | 2 +-
libavcodec/huffyuvenc.c | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c
index 6bcaacfc37..aaba313bf1 100644
--- a/libavcodec/huffyuv.c
+++ b/libavcodec/huffyuv.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2002-2014 Michael Niedermayer <michaelni@gmx.at>
*
- * see http://www.pcisys.net/~melanson/codecs/huffyuv.txt for a description of
+ * see https://multimedia.cx/huffyuv.txt for a description of
* the algorithm used
*
* This file is part of FFmpeg.
diff --git a/libavcodec/huffyuv.h b/libavcodec/huffyuv.h
index 6cc48bf57d..22a766611e 100644
--- a/libavcodec/huffyuv.h
+++ b/libavcodec/huffyuv.h
@@ -1,7 +1,7 @@
/*
* Copyright (c) 2002-2014 Michael Niedermayer <michaelni@gmx.at>
*
- * see http://www.pcisys.net/~melanson/codecs/huffyuv.txt for a description of
+ * see https://multimedia.cx/huffyuv.txt for a description of
* the algorithm used
*
* This file is part of FFmpeg.
diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c
index a065185986..7d3515cc88 100644
--- a/libavcodec/huffyuvdec.c
+++ b/libavcodec/huffyuvdec.c
@@ -3,7 +3,7 @@
*
* Copyright (c) 2002-2014 Michael Niedermayer <michaelni@gmx.at>
*
- * see http://www.pcisys.net/~melanson/codecs/huffyuv.txt for a description of
+ * see https://multimedia.cx/huffyuv.txt for a description of
* the algorithm used
*
* This file is part of FFmpeg.
diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c
index 17d2490dc3..db274e37ad 100644
--- a/libavcodec/huffyuvenc.c
+++ b/libavcodec/huffyuvenc.c
@@ -1,7 +1,7 @@
/*
* Copyright (c) 2002-2014 Michael Niedermayer <michaelni@gmx.at>
*
- * see http://www.pcisys.net/~melanson/codecs/huffyuv.txt for a description of
+ * see https://multimedia.cx/huffyuv.txt for a description of
* the algorithm used
*
* This file is part of FFmpeg.
--
2.34.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [FFmpeg-devel] [PATCH 01/14] avcodec/ylc: Remove inclusion of huffyuvdsp.h
2022-10-02 0:04 [FFmpeg-devel] [PATCH 01/14] avcodec/ylc: Remove inclusion of huffyuvdsp.h Andreas Rheinhardt
` (13 preceding siblings ...)
2022-10-02 14:46 ` [FFmpeg-devel] [PATCH 15/15] avcodec/huffyuv: Update outdated link Andreas Rheinhardt
@ 2022-10-07 11:58 ` Andreas Rheinhardt
14 siblings, 0 replies; 16+ messages in thread
From: Andreas Rheinhardt @ 2022-10-07 11:58 UTC (permalink / raw)
To: ffmpeg-devel
Andreas Rheinhardt:
> Also improve the other headers a bit.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> libavcodec/ylc.c | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/libavcodec/ylc.c b/libavcodec/ylc.c
> index 3ea6749ffe..29c10f05da 100644
> --- a/libavcodec/ylc.c
> +++ b/libavcodec/ylc.c
> @@ -18,21 +18,17 @@
> * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> */
>
> -#include <stdio.h>
> -#include <stdlib.h>
> #include <string.h>
>
> #define YLC_VLC_BITS 10
>
> -#include "libavutil/imgutils.h"
> -#include "libavutil/internal.h"
> #include "libavutil/intreadwrite.h"
> #include "libavutil/mem.h"
> +#include "libavutil/pixfmt.h"
> #include "avcodec.h"
> #include "bswapdsp.h"
> #include "codec_internal.h"
> #include "get_bits.h"
> -#include "huffyuvdsp.h"
> #include "thread.h"
> #include "unary.h"
>
Will apply this patchset tomorrow unless there are objections.
- Andreas
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2022-10-07 11:59 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-02 0:04 [FFmpeg-devel] [PATCH 01/14] avcodec/ylc: Remove inclusion of huffyuvdsp.h Andreas Rheinhardt
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 02/14] avcodec/huffyuvenc: Remove redundant casts Andreas Rheinhardt
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 03/14] avcodec/huffyuvenc: Avoid pointless indirections Andreas Rheinhardt
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 04/14] avcodec/huffyuvenc: Remove always-false check Andreas Rheinhardt
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 05/14] avcodec/huffyuvenc: Remove redundant call Andreas Rheinhardt
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 06/14] avcodec/huffyuvenc: Don't second-guess error code Andreas Rheinhardt
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 07/14] avcodec/huffyuvencdsp: Pass pix_fmt directly when initing dsp Andreas Rheinhardt
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 08/14] avocdec/huffyuvdec: Don't use HYuvContext.avctx Andreas Rheinhardt
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 09/14] avcodec/huffyuvenc: Improve code locality Andreas Rheinhardt
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 10/14] avcodec/huffyuvenc: Avoid unnecessary function call Andreas Rheinhardt
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 11/14] avcodec/huffyuv: Use AVCodecContext.(width|height) directly Andreas Rheinhardt
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 12/14] avcodec/huffyuv: Inline ff_huffyuv_common_init() in its callers Andreas Rheinhardt
2022-10-02 0:06 ` [FFmpeg-devel] [PATCH 13/14] avcodec/huffyuv: Split HYuvContext into decoder and encoder context Andreas Rheinhardt
2022-10-02 0:10 ` [FFmpeg-devel] [PATCH 14/14] avcodec/huffyuv: Speed up generating Huffman codes Andreas Rheinhardt
2022-10-02 14:46 ` [FFmpeg-devel] [PATCH 15/15] avcodec/huffyuv: Update outdated link Andreas Rheinhardt
2022-10-07 11:58 ` [FFmpeg-devel] [PATCH 01/14] avcodec/ylc: Remove inclusion of huffyuvdsp.h Andreas Rheinhardt
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git