Message ID | 20190922154356.2369-1-lance.lmwang@gmail.com |
---|---|
State | New |
Headers | show |
On 9/22/2019 12:43 PM, lance.lmwang@gmail.com wrote: > From: Limin Wang <lance.lmwang@gmail.com> > > Signed-off-by: Limin Wang <lance.lmwang@gmail.com> > --- > libavcodec/dnxhdenc.c | 47 ++++++++++------------------------------------- > libavcodec/dnxhdenc.h | 2 -- > 2 files changed, 10 insertions(+), 39 deletions(-) Err, what? I think you misunderstood what i called unnecessary in my last email...
On Sun, Sep 22, 2019 at 12:45:48PM -0300, James Almer wrote: > On 9/22/2019 12:43 PM, lance.lmwang@gmail.com wrote: > > From: Limin Wang <lance.lmwang@gmail.com> > > > > Signed-off-by: Limin Wang <lance.lmwang@gmail.com> > > --- > > libavcodec/dnxhdenc.c | 47 ++++++++++------------------------------------- > > libavcodec/dnxhdenc.h | 2 -- > > 2 files changed, 10 insertions(+), 39 deletions(-) > > Err, what? I think you misunderstood what i called unnecessary in my > last email... No, I'm not familar with dnxhdenc too much, so I have pass "make fate" to testing the function(with THREAD=0 and THREAD=2) For the performance, by my quick testing, the results are same as before. I hope it's my misunderstanding, but the results are OK. Thanks, Limin > _______________________________________________ > 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".
On 9/22/2019 1:01 PM, Limin Wang wrote: > On Sun, Sep 22, 2019 at 12:45:48PM -0300, James Almer wrote: >> On 9/22/2019 12:43 PM, lance.lmwang@gmail.com wrote: >>> From: Limin Wang <lance.lmwang@gmail.com> >>> >>> Signed-off-by: Limin Wang <lance.lmwang@gmail.com> >>> --- >>> libavcodec/dnxhdenc.c | 47 ++++++++++------------------------------------- >>> libavcodec/dnxhdenc.h | 2 -- >>> 2 files changed, 10 insertions(+), 39 deletions(-) >> >> Err, what? I think you misunderstood what i called unnecessary in my >> last email... > No, I'm not familar with dnxhdenc too much, so I have pass "make fate" to testing > the function(with THREAD=0 and THREAD=2) > > For the performance, by my quick testing, the results are same as before. > > I hope it's my misunderstanding, but the results are OK. Try with THREAD_TYPE=slice, otherwise you'll be testing frame threading. > > > Thanks, > Limin > > >> _______________________________________________ >> 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". > _______________________________________________ > 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". >
On Sun, Sep 22, 2019 at 01:04:01PM -0300, James Almer wrote: > On 9/22/2019 1:01 PM, Limin Wang wrote: > > On Sun, Sep 22, 2019 at 12:45:48PM -0300, James Almer wrote: > >> On 9/22/2019 12:43 PM, lance.lmwang@gmail.com wrote: > >>> From: Limin Wang <lance.lmwang@gmail.com> > >>> > >>> Signed-off-by: Limin Wang <lance.lmwang@gmail.com> > >>> --- > >>> libavcodec/dnxhdenc.c | 47 ++++++++++------------------------------------- > >>> libavcodec/dnxhdenc.h | 2 -- > >>> 2 files changed, 10 insertions(+), 39 deletions(-) > >> > >> Err, what? I think you misunderstood what i called unnecessary in my > >> last email... > > No, I'm not familar with dnxhdenc too much, so I have pass "make fate" to testing > > the function(with THREAD=0 and THREAD=2) > > > > For the performance, by my quick testing, the results are same as before. > > > > I hope it's my misunderstanding, but the results are OK. > > Try with THREAD_TYPE=slice, otherwise you'll be testing frame threading. OK, got it. I believe I haven't tested the code without it. > > > > > > > Thanks, > > Limin > > > > > >> _______________________________________________ > >> 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". > > _______________________________________________ > > 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". > > > > _______________________________________________ > 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".
diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index 41b8079..6be3c43 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -365,7 +365,7 @@ fail: static av_cold int dnxhd_encode_init(AVCodecContext *avctx) { DNXHDEncContext *ctx = avctx->priv_data; - int i, index, ret; + int index, ret; switch (avctx->pix_fmt) { case AV_PIX_FMT_YUV422P: @@ -526,26 +526,11 @@ FF_DISABLE_DEPRECATION_WARNINGS FF_ENABLE_DEPRECATION_WARNINGS #endif - if (avctx->active_thread_type == FF_THREAD_SLICE) { - if (avctx->thread_count > MAX_THREADS) { - av_log(avctx, AV_LOG_ERROR, "too many threads\n"); - return AVERROR(EINVAL); - } - } - if (avctx->qmax <= 1) { av_log(avctx, AV_LOG_ERROR, "qmax must be at least 2\n"); return AVERROR(EINVAL); } - ctx->thread[0] = ctx; - if (avctx->active_thread_type == FF_THREAD_SLICE) { - for (i = 1; i < avctx->thread_count; i++) { - ctx->thread[i] = av_malloc(sizeof(DNXHDEncContext)); - memcpy(ctx->thread[i], ctx, sizeof(DNXHDEncContext)); - } - } - return 0; fail: // for FF_ALLOCZ_OR_GOTO return AVERROR(ENOMEM); @@ -713,11 +698,11 @@ void dnxhd_get_blocks(DNXHDEncContext *ctx, int mb_x, int mb_y) int dct_uv_offset = ctx->dct_uv_offset; int linesize = ctx->m.linesize; int uvlinesize = ctx->m.uvlinesize; - const uint8_t *ptr_y = ctx->thread[0]->src[0] + + const uint8_t *ptr_y = ctx->src[0] + ((mb_y << 4) * ctx->m.linesize) + (mb_x << bs + 1); - const uint8_t *ptr_u = ctx->thread[0]->src[1] + + const uint8_t *ptr_u = ctx->src[1] + ((mb_y << 4) * ctx->m.uvlinesize) + (mb_x << bs + ctx->is_444); - const uint8_t *ptr_v = ctx->thread[0]->src[2] + + const uint8_t *ptr_v = ctx->src[2] + ((mb_y << 4) * ctx->m.uvlinesize) + (mb_x << bs + ctx->is_444); PixblockDSPContext *pdsp = &ctx->m.pdsp; VideoDSPContext *vdsp = &ctx->m.vdsp; @@ -853,7 +838,6 @@ static int dnxhd_calc_bits_thread(AVCodecContext *avctx, void *arg, int mb_y = jobnr, mb_x; int qscale = ctx->qscale; LOCAL_ALIGNED_16(int16_t, block, [64]); - ctx = ctx->thread[threadnr]; ctx->m.last_dc[0] = ctx->m.last_dc[1] = @@ -908,7 +892,6 @@ static int dnxhd_encode_thread(AVCodecContext *avctx, void *arg, { DNXHDEncContext *ctx = avctx->priv_data; int mb_y = jobnr, mb_x; - ctx = ctx->thread[threadnr]; init_put_bits(&ctx->m.pb, (uint8_t *)arg + ctx->data_offset + ctx->slice_offs[jobnr], ctx->slice_size[jobnr]); @@ -969,9 +952,8 @@ static int dnxhd_mb_var_thread(AVCodecContext *avctx, void *arg, int partial_last_row = (mb_y == ctx->m.mb_height - 1) && ((avctx->height >> ctx->interlaced) & 0xF); - ctx = ctx->thread[threadnr]; if (ctx->bit_depth == 8) { - uint8_t *pix = ctx->thread[0]->src[0] + ((mb_y << 4) * ctx->m.linesize); + uint8_t *pix = ctx->src[0] + ((mb_y << 4) * ctx->m.linesize); for (mb_x = 0; mb_x < ctx->m.mb_width; ++mb_x, pix += 16) { unsigned mb = mb_y * ctx->m.mb_width + mb_x; int sum; @@ -1000,7 +982,7 @@ static int dnxhd_mb_var_thread(AVCodecContext *avctx, void *arg, } else { // 10-bit const int linesize = ctx->m.linesize >> 1; for (mb_x = 0; mb_x < ctx->m.mb_width; ++mb_x) { - uint16_t *pix = (uint16_t *)ctx->thread[0]->src[0] + + uint16_t *pix = (uint16_t *)ctx->src[0] + ((mb_y << 4) * linesize) + (mb_x << 4); unsigned mb = mb_y * ctx->m.mb_width + mb_x; int sum = 0; @@ -1264,14 +1246,11 @@ static int dnxhd_encode_fast(AVCodecContext *avctx, DNXHDEncContext *ctx) static void dnxhd_load_picture(DNXHDEncContext *ctx, const AVFrame *frame) { - int i; - for (i = 0; i < ctx->m.avctx->thread_count; i++) { - ctx->thread[i]->m.linesize = frame->linesize[0] << ctx->interlaced; - ctx->thread[i]->m.uvlinesize = frame->linesize[1] << ctx->interlaced; - ctx->thread[i]->dct_y_offset = ctx->m.linesize *8; - ctx->thread[i]->dct_uv_offset = ctx->m.uvlinesize*8; - } + ctx->m.linesize = frame->linesize[0] << ctx->interlaced; + ctx->m.uvlinesize = frame->linesize[1] << ctx->interlaced; + ctx->dct_y_offset = ctx->m.linesize *8; + ctx->dct_uv_offset = ctx->m.uvlinesize*8; #if FF_API_CODED_FRAME FF_DISABLE_DEPRECATION_WARNINGS @@ -1354,7 +1333,6 @@ FF_ENABLE_DEPRECATION_WARNINGS static av_cold int dnxhd_encode_end(AVCodecContext *avctx) { DNXHDEncContext *ctx = avctx->priv_data; - int i; av_freep(&ctx->orig_vlc_codes); av_freep(&ctx->orig_vlc_bits); @@ -1374,11 +1352,6 @@ static av_cold int dnxhd_encode_end(AVCodecContext *avctx) av_freep(&ctx->qmatrix_c16); av_freep(&ctx->qmatrix_l16); - if (avctx->active_thread_type == FF_THREAD_SLICE) { - for (i = 1; i < avctx->thread_count; i++) - av_freep(&ctx->thread[i]); - } - return 0; } diff --git a/libavcodec/dnxhdenc.h b/libavcodec/dnxhdenc.h index 7b0d862..972f2e2 100644 --- a/libavcodec/dnxhdenc.h +++ b/libavcodec/dnxhdenc.h @@ -55,8 +55,6 @@ typedef struct DNXHDEncContext { uint32_t *slice_size; uint32_t *slice_offs; - struct DNXHDEncContext *thread[MAX_THREADS]; - // Because our samples are either 8 or 16 bits for 8-bit and 10-bit // encoding respectively, these refer either to bytes or to two-byte words. unsigned dct_y_offset;