[FFmpeg-cvslog] lavc/pthread_frame: avoid leaving stale hwaccel state in worker threads

2022-09-06 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Fri Sep  2 
22:21:27 2022 +0200| [cc867f2c09d2b69cee8a0eccd62aff002cbbfe11] | committer: 
Anton Khirnov

lavc/pthread_frame: avoid leaving stale hwaccel state in worker threads

This state is not refcounted, so make sure it always has a well-defined
owner.

Remove the block added in 091341f2ab5bd35ca1a2aae90503adc74f8d3523, as
this commit also solves that issue in a more general way.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cc867f2c09d2b69cee8a0eccd62aff002cbbfe11
---

 libavcodec/pthread_frame.c | 47 ++
 1 file changed, 35 insertions(+), 12 deletions(-)

diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 08a6f98898..066269621d 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -148,6 +148,12 @@ typedef struct FrameThreadContext {
 * Set for the first N packets, where N is 
the number of threads.
 * While it is set, 
ff_thread_en/decode_frame won't return any results.
 */
+
+/* hwaccel state is temporarily stored here in order to transfer its 
ownership
+ * to the next decoding thread without the need for extra synchronization 
*/
+const AVHWAccel *stash_hwaccel;
+void*stash_hwaccel_context;
+void*stash_hwaccel_priv;
 } FrameThreadContext;
 
 #if FF_API_THREAD_SAFE_CALLBACKS
@@ -228,9 +234,17 @@ FF_ENABLE_DEPRECATION_WARNINGS
 ff_thread_finish_setup(avctx);
 
 if (p->hwaccel_serializing) {
+/* wipe hwaccel state to avoid stale pointers lying around;
+ * the state was transferred to FrameThreadContext in
+ * ff_thread_finish_setup(), so nothing is leaked */
+avctx->hwaccel = NULL;
+avctx->hwaccel_context = NULL;
+avctx->internal->hwaccel_priv_data = NULL;
+
 p->hwaccel_serializing = 0;
 pthread_mutex_unlock(&p->parent->hwaccel_mutex);
 }
+av_assert0(!avctx->hwaccel);
 
 if (p->async_serializing) {
 p->async_serializing = 0;
@@ -294,9 +308,6 @@ static int update_context_from_thread(AVCodecContext *dst, 
AVCodecContext *src,
 dst->color_range = src->color_range;
 dst->chroma_sample_location = src->chroma_sample_location;
 
-dst->hwaccel = src->hwaccel;
-dst->hwaccel_context = src->hwaccel_context;
-
 dst->sample_rate= src->sample_rate;
 dst->sample_fmt = src->sample_fmt;
 #if FF_API_OLD_CHANNEL_LAYOUT
@@ -309,8 +320,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
 if (err < 0)
 return err;
 
-dst->internal->hwaccel_priv_data = src->internal->hwaccel_priv_data;
-
 if (!!dst->hw_frames_ctx != !!src->hw_frames_ctx ||
 (dst->hw_frames_ctx && dst->hw_frames_ctx->data != 
src->hw_frames_ctx->data)) {
 av_buffer_unref(&dst->hw_frames_ctx);
@@ -450,6 +459,12 @@ static int submit_packet(PerThreadContext *p, 
AVCodecContext *user_avctx,
 pthread_mutex_unlock(&p->mutex);
 return err;
 }
+
+/* transfer hwaccel state stashed from previous thread, if any */
+av_assert0(!p->avctx->hwaccel);
+FFSWAP(const AVHWAccel*, p->avctx->hwaccel, 
fctx->stash_hwaccel);
+FFSWAP(void*,p->avctx->hwaccel_context, 
fctx->stash_hwaccel_context);
+FFSWAP(void*,p->avctx->internal->hwaccel_priv_data, 
fctx->stash_hwaccel_priv);
 }
 
 av_packet_unref(p->avpkt);
@@ -655,6 +670,14 @@ void ff_thread_finish_setup(AVCodecContext *avctx) {
 async_lock(p->parent);
 }
 
+/* save hwaccel state for passing to the next thread;
+ * this is done here so that this worker thread can wipe its own hwaccel
+ * state after decoding, without requiring synchronization */
+av_assert0(!p->parent->stash_hwaccel);
+p->parent->stash_hwaccel = avctx->hwaccel;
+p->parent->stash_hwaccel_context = avctx->hwaccel_context;
+p->parent->stash_hwaccel_priv= avctx->internal->hwaccel_priv_data;
+
 pthread_mutex_lock(&p->progress_mutex);
 if(atomic_load(&p->state) == STATE_SETUP_FINISHED){
 av_log(avctx, AV_LOG_WARNING, "Multiple ff_thread_finish_setup() 
calls\n");
@@ -708,13 +731,6 @@ void ff_frame_thread_free(AVCodecContext *avctx, int 
thread_count)
 
 park_frame_worker_threads(fctx, thread_count);
 
-if (fctx->prev_thread && avctx->internal->hwaccel_priv_data !=
- 
fctx->prev_thread->avctx->internal->hwaccel_priv_data) {
-if (update_context_from_thread(avctx, fctx->prev_thread->avctx, 1) < 
0) {
-av_log(avctx, AV_LOG_ERROR, "Failed to update user thread.\n");
-}
-}
-
 for (i = 0; i < thread_count; i++) {
 PerThread

[FFmpeg-cvslog] lavc: fix and extend AVCodecContext.hwaccel_context doxy

2022-09-06 Thread Anton Khirnov
ffmpeg | branch: master | Anton Khirnov  | Fri Sep  2 
19:14:55 2022 +0200| [0a811f8f944ae051a5e50c1435eae5eb272ef0b4] | committer: 
Anton Khirnov

lavc: fix and extend AVCodecContext.hwaccel_context doxy

Mention:
- that it is legacy and optional (every hwaccel that uses it can also
  work with hwcontext, though some optional information can only be
  signalled throught hwaccel_context)
- that it can be used for encoders (only qsvenc currently)
- ownership and lifetime

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0a811f8f944ae051a5e50c1435eae5eb272ef0b4
---

 libavcodec/avcodec.h | 27 ---
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 65c8535359..7db5d1b1c5 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1388,13 +1388,26 @@ typedef struct AVCodecContext {
 const struct AVHWAccel *hwaccel;
 
 /**
- * Hardware accelerator context.
- * For some hardware accelerators, a global context needs to be
- * provided by the user. In that case, this holds display-dependent
- * data FFmpeg cannot instantiate itself. Please refer to the
- * FFmpeg HW accelerator documentation to know how to fill this.
- * - encoding: unused
- * - decoding: Set by user
+ * Legacy hardware accelerator context.
+ *
+ * For some hardware acceleration methods, the caller may use this field to
+ * signal hwaccel-specific data to the codec. The struct pointed to by this
+ * pointer is hwaccel-dependent and defined in the respective header. 
Please
+ * refer to the FFmpeg HW accelerator documentation to know how to fill
+ * this.
+ *
+ * In most cases this field is optional - the necessary information may 
also
+ * be provided to libavcodec through @ref hw_frames_ctx or @ref
+ * hw_device_ctx (see avcodec_get_hw_config()). However, in some cases it
+ * may be the only method of signalling some (optional) information.
+ *
+ * The struct and its contents are owned by the caller.
+ *
+ * - encoding: May be set by the caller before avcodec_open2(). Must remain
+ * valid until avcodec_free_context().
+ * - decoding: May be set by the caller in the get_format() callback.
+ * Must remain valid until the next get_format() call,
+ * or avcodec_free_context() (whichever comes first).
  */
 void *hwaccel_context;
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] lavc/pthread_frame: avoid leaving stale hwaccel state in worker threads

2022-09-06 Thread Anton Khirnov
ffmpeg | branch: release/5.1 | Anton Khirnov  | Fri Sep  2 
22:21:27 2022 +0200| [35aa7e70e7ec350319e7634a30d8d8aa1e6ecdda] | committer: 
Anton Khirnov

lavc/pthread_frame: avoid leaving stale hwaccel state in worker threads

This state is not refcounted, so make sure it always has a well-defined
owner.

Remove the block added in 091341f2ab5bd35ca1a2aae90503adc74f8d3523, as
this commit also solves that issue in a more general way.

(cherry picked from commit cc867f2c09d2b69cee8a0eccd62aff002cbbfe11)
Signed-off-by: Anton Khirnov 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=35aa7e70e7ec350319e7634a30d8d8aa1e6ecdda
---

 libavcodec/pthread_frame.c | 47 ++
 1 file changed, 35 insertions(+), 12 deletions(-)

diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 8faea75a49..80c15b35be 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -147,6 +147,12 @@ typedef struct FrameThreadContext {
 * Set for the first N packets, where N is 
the number of threads.
 * While it is set, 
ff_thread_en/decode_frame won't return any results.
 */
+
+/* hwaccel state is temporarily stored here in order to transfer its 
ownership
+ * to the next decoding thread without the need for extra synchronization 
*/
+const AVHWAccel *stash_hwaccel;
+void*stash_hwaccel_context;
+void*stash_hwaccel_priv;
 } FrameThreadContext;
 
 #if FF_API_THREAD_SAFE_CALLBACKS
@@ -227,9 +233,17 @@ FF_ENABLE_DEPRECATION_WARNINGS
 ff_thread_finish_setup(avctx);
 
 if (p->hwaccel_serializing) {
+/* wipe hwaccel state to avoid stale pointers lying around;
+ * the state was transferred to FrameThreadContext in
+ * ff_thread_finish_setup(), so nothing is leaked */
+avctx->hwaccel = NULL;
+avctx->hwaccel_context = NULL;
+avctx->internal->hwaccel_priv_data = NULL;
+
 p->hwaccel_serializing = 0;
 pthread_mutex_unlock(&p->parent->hwaccel_mutex);
 }
+av_assert0(!avctx->hwaccel);
 
 if (p->async_serializing) {
 p->async_serializing = 0;
@@ -293,9 +307,6 @@ static int update_context_from_thread(AVCodecContext *dst, 
AVCodecContext *src,
 dst->color_range = src->color_range;
 dst->chroma_sample_location = src->chroma_sample_location;
 
-dst->hwaccel = src->hwaccel;
-dst->hwaccel_context = src->hwaccel_context;
-
 dst->sample_rate= src->sample_rate;
 dst->sample_fmt = src->sample_fmt;
 #if FF_API_OLD_CHANNEL_LAYOUT
@@ -308,8 +319,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
 if (err < 0)
 return err;
 
-dst->internal->hwaccel_priv_data = src->internal->hwaccel_priv_data;
-
 if (!!dst->hw_frames_ctx != !!src->hw_frames_ctx ||
 (dst->hw_frames_ctx && dst->hw_frames_ctx->data != 
src->hw_frames_ctx->data)) {
 av_buffer_unref(&dst->hw_frames_ctx);
@@ -449,6 +458,12 @@ static int submit_packet(PerThreadContext *p, 
AVCodecContext *user_avctx,
 pthread_mutex_unlock(&p->mutex);
 return err;
 }
+
+/* transfer hwaccel state stashed from previous thread, if any */
+av_assert0(!p->avctx->hwaccel);
+FFSWAP(const AVHWAccel*, p->avctx->hwaccel, 
fctx->stash_hwaccel);
+FFSWAP(void*,p->avctx->hwaccel_context, 
fctx->stash_hwaccel_context);
+FFSWAP(void*,p->avctx->internal->hwaccel_priv_data, 
fctx->stash_hwaccel_priv);
 }
 
 av_packet_unref(p->avpkt);
@@ -654,6 +669,14 @@ void ff_thread_finish_setup(AVCodecContext *avctx) {
 async_lock(p->parent);
 }
 
+/* save hwaccel state for passing to the next thread;
+ * this is done here so that this worker thread can wipe its own hwaccel
+ * state after decoding, without requiring synchronization */
+av_assert0(!p->parent->stash_hwaccel);
+p->parent->stash_hwaccel = avctx->hwaccel;
+p->parent->stash_hwaccel_context = avctx->hwaccel_context;
+p->parent->stash_hwaccel_priv= avctx->internal->hwaccel_priv_data;
+
 pthread_mutex_lock(&p->progress_mutex);
 if(atomic_load(&p->state) == STATE_SETUP_FINISHED){
 av_log(avctx, AV_LOG_WARNING, "Multiple ff_thread_finish_setup() 
calls\n");
@@ -707,13 +730,6 @@ void ff_frame_thread_free(AVCodecContext *avctx, int 
thread_count)
 
 park_frame_worker_threads(fctx, thread_count);
 
-if (fctx->prev_thread && avctx->internal->hwaccel_priv_data !=
- 
fctx->prev_thread->avctx->internal->hwaccel_priv_data) {
-if (update_context_from_thread(avctx, fctx->prev_thread->avctx, 1) < 
0) {
-av_log(avctx, AV_LOG_ERROR, "Failed to 

[FFmpeg-cvslog] lavc/pthread_frame: avoid leaving stale hwaccel state in worker threads

2022-09-06 Thread Anton Khirnov
ffmpeg | branch: release/5.0 | Anton Khirnov  | Fri Sep  2 
22:21:27 2022 +0200| [3bc28e9d1ab33627cea3c632dd6b0c33e22e93ba] | committer: 
Anton Khirnov

lavc/pthread_frame: avoid leaving stale hwaccel state in worker threads

This state is not refcounted, so make sure it always has a well-defined
owner.

Remove the block added in 091341f2ab5bd35ca1a2aae90503adc74f8d3523, as
this commit also solves that issue in a more general way.

(cherry picked from commit cc867f2c09d2b69cee8a0eccd62aff002cbbfe11)
Signed-off-by: Anton Khirnov 
(cherry picked from commit 35aa7e70e7ec350319e7634a30d8d8aa1e6ecdda)
Signed-off-by: Anton Khirnov 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3bc28e9d1ab33627cea3c632dd6b0c33e22e93ba
---

 libavcodec/pthread_frame.c | 46 +++---
 1 file changed, 35 insertions(+), 11 deletions(-)

diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 85a6bc98c1..e40dcedfdd 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -145,6 +145,12 @@ typedef struct FrameThreadContext {
 * Set for the first N packets, where N is 
the number of threads.
 * While it is set, 
ff_thread_en/decode_frame won't return any results.
 */
+
+/* hwaccel state is temporarily stored here in order to transfer its 
ownership
+ * to the next decoding thread without the need for extra synchronization 
*/
+const AVHWAccel *stash_hwaccel;
+void*stash_hwaccel_context;
+void*stash_hwaccel_priv;
 } FrameThreadContext;
 
 #if FF_API_THREAD_SAFE_CALLBACKS
@@ -229,9 +235,17 @@ FF_ENABLE_DEPRECATION_WARNINGS
 ff_thread_finish_setup(avctx);
 
 if (p->hwaccel_serializing) {
+/* wipe hwaccel state to avoid stale pointers lying around;
+ * the state was transferred to FrameThreadContext in
+ * ff_thread_finish_setup(), so nothing is leaked */
+avctx->hwaccel = NULL;
+avctx->hwaccel_context = NULL;
+avctx->internal->hwaccel_priv_data = NULL;
+
 p->hwaccel_serializing = 0;
 pthread_mutex_unlock(&p->parent->hwaccel_mutex);
 }
+av_assert0(!avctx->hwaccel);
 
 if (p->async_serializing) {
 p->async_serializing = 0;
@@ -294,14 +308,10 @@ static int update_context_from_thread(AVCodecContext 
*dst, AVCodecContext *src,
 dst->color_range = src->color_range;
 dst->chroma_sample_location = src->chroma_sample_location;
 
-dst->hwaccel = src->hwaccel;
-dst->hwaccel_context = src->hwaccel_context;
-
 dst->channels   = src->channels;
 dst->sample_rate= src->sample_rate;
 dst->sample_fmt = src->sample_fmt;
 dst->channel_layout = src->channel_layout;
-dst->internal->hwaccel_priv_data = src->internal->hwaccel_priv_data;
 
 if (!!dst->hw_frames_ctx != !!src->hw_frames_ctx ||
 (dst->hw_frames_ctx && dst->hw_frames_ctx->data != 
src->hw_frames_ctx->data)) {
@@ -442,6 +452,12 @@ static int submit_packet(PerThreadContext *p, 
AVCodecContext *user_avctx,
 pthread_mutex_unlock(&p->mutex);
 return err;
 }
+
+/* transfer hwaccel state stashed from previous thread, if any */
+av_assert0(!p->avctx->hwaccel);
+FFSWAP(const AVHWAccel*, p->avctx->hwaccel, 
fctx->stash_hwaccel);
+FFSWAP(void*,p->avctx->hwaccel_context, 
fctx->stash_hwaccel_context);
+FFSWAP(void*,p->avctx->internal->hwaccel_priv_data, 
fctx->stash_hwaccel_priv);
 }
 
 av_packet_unref(p->avpkt);
@@ -647,6 +663,14 @@ void ff_thread_finish_setup(AVCodecContext *avctx) {
 async_lock(p->parent);
 }
 
+/* save hwaccel state for passing to the next thread;
+ * this is done here so that this worker thread can wipe its own hwaccel
+ * state after decoding, without requiring synchronization */
+av_assert0(!p->parent->stash_hwaccel);
+p->parent->stash_hwaccel = avctx->hwaccel;
+p->parent->stash_hwaccel_context = avctx->hwaccel_context;
+p->parent->stash_hwaccel_priv= avctx->internal->hwaccel_priv_data;
+
 pthread_mutex_lock(&p->progress_mutex);
 if(atomic_load(&p->state) == STATE_SETUP_FINISHED){
 av_log(avctx, AV_LOG_WARNING, "Multiple ff_thread_finish_setup() 
calls\n");
@@ -700,13 +724,6 @@ void ff_frame_thread_free(AVCodecContext *avctx, int 
thread_count)
 
 park_frame_worker_threads(fctx, thread_count);
 
-if (fctx->prev_thread && avctx->internal->hwaccel_priv_data !=
- 
fctx->prev_thread->avctx->internal->hwaccel_priv_data) {
-if (update_context_from_thread(avctx, fctx->prev_thread->avctx, 1) < 
0) {
-av_log(avctx, AV_LOG_E

[FFmpeg-cvslog] lavc/pthread_frame: avoid leaving stale hwaccel state in worker threads

2022-09-06 Thread Anton Khirnov
ffmpeg | branch: release/4.4 | Anton Khirnov  | Fri Sep  2 
22:21:27 2022 +0200| [d4b7b3c03ee2baf0166ce49dff17ec9beff684db] | committer: 
Anton Khirnov

lavc/pthread_frame: avoid leaving stale hwaccel state in worker threads

This state is not refcounted, so make sure it always has a well-defined
owner.

Remove the block added in 091341f2ab5bd35ca1a2aae90503adc74f8d3523, as
this commit also solves that issue in a more general way.

(cherry picked from commit cc867f2c09d2b69cee8a0eccd62aff002cbbfe11)
Signed-off-by: Anton Khirnov 
(cherry picked from commit 35aa7e70e7ec350319e7634a30d8d8aa1e6ecdda)
Signed-off-by: Anton Khirnov 
(cherry picked from commit 3bc28e9d1ab33627cea3c632dd6b0c33e22e93ba)
Signed-off-by: Anton Khirnov 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d4b7b3c03ee2baf0166ce49dff17ec9beff684db
---

 libavcodec/pthread_frame.c | 46 +++---
 1 file changed, 35 insertions(+), 11 deletions(-)

diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 9176027f15..6da5cae55c 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -145,6 +145,12 @@ typedef struct FrameThreadContext {
 * Set for the first N packets, where N is 
the number of threads.
 * While it is set, 
ff_thread_en/decode_frame won't return any results.
 */
+
+/* hwaccel state is temporarily stored here in order to transfer its 
ownership
+ * to the next decoding thread without the need for extra synchronization 
*/
+const AVHWAccel *stash_hwaccel;
+void*stash_hwaccel_context;
+void*stash_hwaccel_priv;
 } FrameThreadContext;
 
 #if FF_API_THREAD_SAFE_CALLBACKS
@@ -229,9 +235,17 @@ FF_ENABLE_DEPRECATION_WARNINGS
 ff_thread_finish_setup(avctx);
 
 if (p->hwaccel_serializing) {
+/* wipe hwaccel state to avoid stale pointers lying around;
+ * the state was transferred to FrameThreadContext in
+ * ff_thread_finish_setup(), so nothing is leaked */
+avctx->hwaccel = NULL;
+avctx->hwaccel_context = NULL;
+avctx->internal->hwaccel_priv_data = NULL;
+
 p->hwaccel_serializing = 0;
 pthread_mutex_unlock(&p->parent->hwaccel_mutex);
 }
+av_assert0(!avctx->hwaccel);
 
 if (p->async_serializing) {
 p->async_serializing = 0;
@@ -293,14 +307,10 @@ static int update_context_from_thread(AVCodecContext 
*dst, AVCodecContext *src,
 dst->color_range = src->color_range;
 dst->chroma_sample_location = src->chroma_sample_location;
 
-dst->hwaccel = src->hwaccel;
-dst->hwaccel_context = src->hwaccel_context;
-
 dst->channels   = src->channels;
 dst->sample_rate= src->sample_rate;
 dst->sample_fmt = src->sample_fmt;
 dst->channel_layout = src->channel_layout;
-dst->internal->hwaccel_priv_data = src->internal->hwaccel_priv_data;
 
 if (!!dst->hw_frames_ctx != !!src->hw_frames_ctx ||
 (dst->hw_frames_ctx && dst->hw_frames_ctx->data != 
src->hw_frames_ctx->data)) {
@@ -444,6 +454,12 @@ static int submit_packet(PerThreadContext *p, 
AVCodecContext *user_avctx,
 pthread_mutex_unlock(&p->mutex);
 return err;
 }
+
+/* transfer hwaccel state stashed from previous thread, if any */
+av_assert0(!p->avctx->hwaccel);
+FFSWAP(const AVHWAccel*, p->avctx->hwaccel, 
fctx->stash_hwaccel);
+FFSWAP(void*,p->avctx->hwaccel_context, 
fctx->stash_hwaccel_context);
+FFSWAP(void*,p->avctx->internal->hwaccel_priv_data, 
fctx->stash_hwaccel_priv);
 }
 
 av_packet_unref(p->avpkt);
@@ -649,6 +665,14 @@ void ff_thread_finish_setup(AVCodecContext *avctx) {
 async_lock(p->parent);
 }
 
+/* save hwaccel state for passing to the next thread;
+ * this is done here so that this worker thread can wipe its own hwaccel
+ * state after decoding, without requiring synchronization */
+av_assert0(!p->parent->stash_hwaccel);
+p->parent->stash_hwaccel = avctx->hwaccel;
+p->parent->stash_hwaccel_context = avctx->hwaccel_context;
+p->parent->stash_hwaccel_priv= avctx->internal->hwaccel_priv_data;
+
 pthread_mutex_lock(&p->progress_mutex);
 if(atomic_load(&p->state) == STATE_SETUP_FINISHED){
 av_log(avctx, AV_LOG_WARNING, "Multiple ff_thread_finish_setup() 
calls\n");
@@ -743,13 +767,6 @@ void ff_frame_thread_free(AVCodecContext *avctx, int 
thread_count)
 
 park_frame_worker_threads(fctx, thread_count);
 
-if (fctx->prev_thread && avctx->internal->hwaccel_priv_data !=
- 
fctx->prev_thread->avctx->internal->hwaccel_priv_data) {
-if (update_

[FFmpeg-cvslog] avcodec/decode: remove superfluous initial channels fields

2022-09-06 Thread James Almer
ffmpeg | branch: master | James Almer  | Tue Sep  6 10:07:02 
2022 -0300| [5a78421746e9406c388407d5625c1c416775ba54] | committer: James Almer

avcodec/decode: remove superfluous initial channels fields

They are internal, so there's no need to keep them around as they are
just duplicate functionality.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5a78421746e9406c388407d5625c1c416775ba54
---

 libavcodec/decode.c   | 12 
 libavcodec/internal.h |  4 
 2 files changed, 16 deletions(-)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 75373989c6..2961705c9d 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -735,12 +735,6 @@ int ff_decode_receive_frame(AVCodecContext *avctx, AVFrame 
*frame)
 case AVMEDIA_TYPE_AUDIO:
 avci->initial_sample_rate = frame->sample_rate ? 
frame->sample_rate :
  
avctx->sample_rate;
-#if FF_API_OLD_CHANNEL_LAYOUT
-FF_DISABLE_DEPRECATION_WARNINGS
-avci->initial_channels   = frame->ch_layout.nb_channels;
-avci->initial_channel_layout = frame->channel_layout;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
 ret = av_channel_layout_copy(&avci->initial_ch_layout, 
&frame->ch_layout);
 if (ret < 0) {
 av_frame_unref(frame);
@@ -759,15 +753,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
avci->initial_height != frame->height;
 break;
 case AVMEDIA_TYPE_AUDIO:
-FF_DISABLE_DEPRECATION_WARNINGS
 changed |= avci->initial_sample_rate!= frame->sample_rate 
||
avci->initial_sample_rate!= avctx->sample_rate 
||
-#if FF_API_OLD_CHANNEL_LAYOUT
-   avci->initial_channels   != frame->channels ||
-   avci->initial_channel_layout != 
frame->channel_layout ||
-#endif
av_channel_layout_compare(&avci->initial_ch_layout, 
&frame->ch_layout);
-FF_ENABLE_DEPRECATION_WARNINGS
 break;
 }
 
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index e2a914c271..35e3dd303a 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -153,10 +153,6 @@ typedef struct AVCodecInternal {
 int initial_format;
 int initial_width, initial_height;
 int initial_sample_rate;
-#if FF_API_OLD_CHANNEL_LAYOUT
-int initial_channels;
-uint64_t initial_channel_layout;
-#endif
 AVChannelLayout initial_ch_layout;
 
 #if CONFIG_LCMS2

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avfilter/vf_scale: overwrite the width and height expressions with the original values

2022-09-06 Thread James Almer
ffmpeg | branch: master | James Almer  | Sun Sep  4 23:43:04 
2022 -0300| [d9e3cb7e73c77ccddc4d29ed5c1be3920f72c226] | committer: James Almer

avfilter/vf_scale: overwrite the width and height expressions with the original 
values

Instead of the potentially adjusted ones. Otherwise, if config_props() is
called again and if using force_original_aspect_ratio, the already adjusted
values could be altered again.

Example command line
scale=size=1920x1000:force_original_aspect_ratio=decrease:force_divisible_by=2

user value 1920x1000 -> 1920x798 on init_dict() -> 1918x798 on frame
change when eval_mode == EVAL_MODE_INIT, which after e645a1ddb9 could be at the
very first frame.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d9e3cb7e73c77ccddc4d29ed5c1be3920f72c226
---

 libavfilter/vf_scale.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 996f7aaa5b..2b12cf283c 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -491,19 +491,19 @@ static int config_props(AVFilterLink *outlink)
 if ((ret = scale_eval_dimensions(ctx)) < 0)
 goto fail;
 
-ff_scale_adjust_dimensions(inlink, &scale->w, &scale->h,
+outlink->w = scale->w;
+outlink->h = scale->h;
+
+ff_scale_adjust_dimensions(inlink, &outlink->w, &outlink->h,
scale->force_original_aspect_ratio,
scale->force_divisible_by);
 
-if (scale->w > INT_MAX ||
-scale->h > INT_MAX ||
-(scale->h * inlink->w) > INT_MAX ||
-(scale->w * inlink->h) > INT_MAX)
+if (outlink->w > INT_MAX ||
+outlink->h > INT_MAX ||
+(outlink->h * inlink->w) > INT_MAX ||
+(outlink->w * inlink->h) > INT_MAX)
 av_log(ctx, AV_LOG_ERROR, "Rescaled value for width or height is too 
big.\n");
 
-outlink->w = scale->w;
-outlink->h = scale->h;
-
 /* TODO: make algorithm configurable */
 
 scale->input_is_pal = desc->flags & AV_PIX_FMT_FLAG_PAL;
@@ -718,9 +718,9 @@ static int scale_frame(AVFilterLink *link, AVFrame *in, 
AVFrame **frame_out)
 goto scale;
 
 if (scale->eval_mode == EVAL_MODE_INIT) {
-snprintf(buf, sizeof(buf)-1, "%d", outlink->w);
+snprintf(buf, sizeof(buf) - 1, "%d", scale->w);
 av_opt_set(scale, "w", buf, 0);
-snprintf(buf, sizeof(buf)-1, "%d", outlink->h);
+snprintf(buf, sizeof(buf) - 1, "%d", scale->h);
 av_opt_set(scale, "h", buf, 0);
 
 ret = scale_parse_expr(ctx, NULL, &scale->w_pexpr, "width", 
scale->w_expr);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] x86/tx_float: Fix building for platforms with a symbol prefix

2022-09-06 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö  | Tue Sep  6 
12:24:28 2022 +0300| [e4759fa951311d7b02a26756af63f7e5b499c7fc] | committer: 
Martin Storsjö

x86/tx_float: Fix building for platforms with a symbol prefix

This fixes building for x86 macOS (both i386 and x86_64) and
i386 windows.

Signed-off-by: Martin Storsjö 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e4759fa951311d7b02a26756af63f7e5b499c7fc
---

 libavutil/x86/tx_float.asm | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavutil/x86/tx_float.asm b/libavutil/x86/tx_float.asm
index 1b9131e7fa..69f67720c1 100644
--- a/libavutil/x86/tx_float.asm
+++ b/libavutil/x86/tx_float.asm
@@ -744,7 +744,7 @@ cglobal fft8_float, 4, 4, 6, ctx, out, in, tmp
 
 %if %1
 cglobal fft8_ns_float, 4, 4, 6, ctx, out, in, tmp
-call ff_tx_fft8_asm_float_sse3
+call mangle(ff_tx_fft8_asm_float_sse3)
 RET
 %endif
 %endmacro
@@ -784,7 +784,7 @@ cglobal fft8_float, 4, 4, 4, ctx, out, in, tmp
 
 %if %1
 cglobal fft8_ns_float, 4, 4, 4, ctx, out, in, tmp
-call ff_tx_fft8_asm_float_avx
+call mangle(ff_tx_fft8_asm_float_avx)
 RET
 %endif
 %endmacro
@@ -833,7 +833,7 @@ cglobal fft16_float, 4, 4, 8, ctx, out, in, tmp
 
 %if %2
 cglobal fft16_ns_float, 4, 4, 8, ctx, out, in, tmp
-call ff_tx_fft16_asm_float_ %+ %1
+call mangle(ff_tx_fft16_asm_float_ %+ %1)
 RET
 %endif
 %endmacro
@@ -917,7 +917,7 @@ cglobal fft32_float, 4, 4, 16, ctx, out, in, tmp
 
 %if %2
 cglobal fft32_ns_float, 4, 4, 16, ctx, out, in, tmp
-call ff_tx_fft32_asm_float_ %+ %1
+call mangle(ff_tx_fft32_asm_float_ %+ %1)
 RET
 %endif
 %endmacro
@@ -1342,7 +1342,7 @@ cglobal fft_sr_ns_float, 4, 9, 16, 272, ctx, out, in, 
tmp, len, lut, itab, rtab,
 mov lutq, [ctxq + AVTXContext.map]
 mov tgtq, lenq
 
-call ff_tx_fft_sr_asm_float_ %+ %1
+call mangle(ff_tx_fft_sr_asm_float_ %+ %1)
 RET
 %endif
 %endmacro

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] slicethread: Limit the automatic number of threads to 16

2022-09-06 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö  | Mon Sep  5 
15:17:56 2022 +0300| [da5f7799a03aa53d0ffd25572aa9c65ba8279e57] | committer: 
Martin Storsjö

slicethread: Limit the automatic number of threads to 16

This matches a similar cap on the number of automatic threads
in libavcodec/pthread_slice.c.

On systems with lots of cores, this fixes a couple fate failures
in 32 bit mode on such machines (where spawning a huge number of
threads runs out of address space).

Signed-off-by: Martin Storsjö 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=da5f7799a03aa53d0ffd25572aa9c65ba8279e57
---

 libavutil/slicethread.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavutil/slicethread.c b/libavutil/slicethread.c
index ea1c9c8311..115b099736 100644
--- a/libavutil/slicethread.c
+++ b/libavutil/slicethread.c
@@ -24,6 +24,8 @@
 #include "thread.h"
 #include "avassert.h"
 
+#define MAX_AUTO_THREADS 16
+
 #if HAVE_PTHREADS || HAVE_W32THREADS || HAVE_OS2THREADS
 
 typedef struct WorkerContext {
@@ -105,7 +107,7 @@ int avpriv_slicethread_create(AVSliceThread **pctx, void 
*priv,
 if (!nb_threads) {
 int nb_cpus = av_cpu_count();
 if (nb_cpus > 1)
-nb_threads = nb_cpus + 1;
+nb_threads = FFMIN(nb_cpus + 1, MAX_AUTO_THREADS);
 else
 nb_threads = 1;
 }

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] x86/tx_float: add missing check for AVX2

2022-09-06 Thread James Almer
ffmpeg | branch: master | James Almer  | Tue Sep  6 14:06:33 
2022 -0300| [f4097e4c1f1bb244cae78c363a69d5e84495b616] | committer: James Almer

x86/tx_float: add missing check for AVX2

Fixes compilation with old yasm.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f4097e4c1f1bb244cae78c363a69d5e84495b616
---

 libavutil/x86/tx_float.asm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/x86/tx_float.asm b/libavutil/x86/tx_float.asm
index 6d33ee7f30..dbb04e8b4d 100644
--- a/libavutil/x86/tx_float.asm
+++ b/libavutil/x86/tx_float.asm
@@ -1537,6 +1537,6 @@ cglobal mdct_sr_inv_float, 4, 12, 16, 288, ctx, out, in, 
stride, len, lut, exp,
 RET
 %endmacro
 
-%if ARCH_X86_64
+%if ARCH_X86_64 && HAVE_AVX2_EXTERNAL
 IMDCT_FN avx2
 %endif

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] x86/tx_float: set all operands for shufps

2022-09-06 Thread James Almer
ffmpeg | branch: master | James Almer  | Tue Sep  6 14:06:03 
2022 -0300| [74f5fb6db899dbc4fde9ccf77f37256ddcb9] | committer: James Almer

x86/tx_float: set all operands for shufps

Fixes compilation with AVX2 enabled yasm.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=74f5fb6db899dbc4fde9ccf77f37256ddcb9
---

 libavutil/x86/tx_float.asm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavutil/x86/tx_float.asm b/libavutil/x86/tx_float.asm
index 69f67720c1..6d33ee7f30 100644
--- a/libavutil/x86/tx_float.asm
+++ b/libavutil/x86/tx_float.asm
@@ -1408,8 +1408,8 @@ cglobal mdct_sr_inv_float, 4, 12, 16, 288, ctx, out, in, 
stride, len, lut, exp,
 mulps m10, m2; 1 reim * imim
 mulps m11, m3; 2 reim * imim
 
-shufps m10, m10, q2301
-shufps m11, m11, q2301
+shufps m10, m10, m10, q2301
+shufps m11, m11, m11, q2301
 
 fmaddsubps m10, m12, m2, m10
 fmaddsubps m11, m13, m3, m11

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avfilter/vf_scale: overwrite the width and height expressions with the original values

2022-09-06 Thread James Almer
ffmpeg | branch: release/5.1 | James Almer  | Sun Sep  4 
23:43:04 2022 -0300| [fcbd9ec24895b53bfa6a206aed29b5b04b68c41b] | committer: 
James Almer

avfilter/vf_scale: overwrite the width and height expressions with the original 
values

Instead of the potentially adjusted ones. Otherwise, if config_props() is
called again and if using force_original_aspect_ratio, the already adjusted
values could be altered again.

Example command line
scale=size=1920x1000:force_original_aspect_ratio=decrease:force_divisible_by=2

user value 1920x1000 -> 1920x798 on init_dict() -> 1918x798 on frame
change when eval_mode == EVAL_MODE_INIT, which after e645a1ddb9 could be at the
very first frame.

Signed-off-by: James Almer 
(cherry picked from commit d9e3cb7e73c77ccddc4d29ed5c1be3920f72c226)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fcbd9ec24895b53bfa6a206aed29b5b04b68c41b
---

 libavfilter/vf_scale.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 996f7aaa5b..2b12cf283c 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -491,19 +491,19 @@ static int config_props(AVFilterLink *outlink)
 if ((ret = scale_eval_dimensions(ctx)) < 0)
 goto fail;
 
-ff_scale_adjust_dimensions(inlink, &scale->w, &scale->h,
+outlink->w = scale->w;
+outlink->h = scale->h;
+
+ff_scale_adjust_dimensions(inlink, &outlink->w, &outlink->h,
scale->force_original_aspect_ratio,
scale->force_divisible_by);
 
-if (scale->w > INT_MAX ||
-scale->h > INT_MAX ||
-(scale->h * inlink->w) > INT_MAX ||
-(scale->w * inlink->h) > INT_MAX)
+if (outlink->w > INT_MAX ||
+outlink->h > INT_MAX ||
+(outlink->h * inlink->w) > INT_MAX ||
+(outlink->w * inlink->h) > INT_MAX)
 av_log(ctx, AV_LOG_ERROR, "Rescaled value for width or height is too 
big.\n");
 
-outlink->w = scale->w;
-outlink->h = scale->h;
-
 /* TODO: make algorithm configurable */
 
 scale->input_is_pal = desc->flags & AV_PIX_FMT_FLAG_PAL;
@@ -718,9 +718,9 @@ static int scale_frame(AVFilterLink *link, AVFrame *in, 
AVFrame **frame_out)
 goto scale;
 
 if (scale->eval_mode == EVAL_MODE_INIT) {
-snprintf(buf, sizeof(buf)-1, "%d", outlink->w);
+snprintf(buf, sizeof(buf) - 1, "%d", scale->w);
 av_opt_set(scale, "w", buf, 0);
-snprintf(buf, sizeof(buf)-1, "%d", outlink->h);
+snprintf(buf, sizeof(buf) - 1, "%d", scale->h);
 av_opt_set(scale, "h", buf, 0);
 
 ret = scale_parse_expr(ctx, NULL, &scale->w_pexpr, "width", 
scale->w_expr);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] swscale/input: add support for XV36LE

2022-09-06 Thread Philip Langdale
ffmpeg | branch: master | Philip Langdale  | Sat Sep  3 
15:58:47 2022 -0700| [8d9462844a85b0546c827a5f2c4cc7a1ba49dc9d] | committer: 
Philip Langdale

swscale/input: add support for XV36LE

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8d9462844a85b0546c827a5f2c4cc7a1ba49dc9d
---

 libswscale/input.c   | 25 +
 libswscale/utils.c   |  1 +
 libswscale/version.h |  2 +-
 3 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/libswscale/input.c b/libswscale/input.c
index 92681c9c53..8032360907 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -685,6 +685,25 @@ static void read_vuya_A_c(uint8_t *dst, const uint8_t 
*src, const uint8_t *unuse
 dst[i] = src[i * 4 + 3];
 }
 
+static void read_xv36le_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t 
*unused0, const uint8_t *unused1, int width,
+   uint32_t *unused2, void *opq)
+{
+int i;
+for (i = 0; i < width; i++)
+AV_WN16(dst + i * 2, AV_RL16(src + i * 8 + 2) >> 4);
+}
+
+
+static void read_xv36le_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t 
*unused0, const uint8_t *src,
+   const uint8_t *unused1, int width, uint32_t 
*unused2, void *opq)
+{
+int i;
+for (i = 0; i < width; i++) {
+AV_WN16(dstU + i * 2, AV_RL16(src + i * 8 + 0) >> 4);
+AV_WN16(dstV + i * 2, AV_RL16(src + i * 8 + 4) >> 4);
+}
+}
+
 /* This is almost identical to the previous, end exists only because
  * yuy2ToY/UV)(dst, src + 1, ...) would have 100% unaligned accesses. */
 static void uyvyToY_c(uint8_t *dst, const uint8_t *src, const uint8_t 
*unused1, const uint8_t *unused2,  int width,
@@ -1381,6 +1400,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
 case AV_PIX_FMT_AYUV64LE:
 c->chrToYV12 = read_ayuv64le_UV_c;
 break;
+case AV_PIX_FMT_XV36LE:
+c->chrToYV12 = read_xv36le_UV_c;
+break;
 case AV_PIX_FMT_P010LE:
 case AV_PIX_FMT_P210LE:
 case AV_PIX_FMT_P410LE:
@@ -1759,6 +1781,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
 case AV_PIX_FMT_AYUV64LE:
 c->lumToYV12 = read_ayuv64le_Y_c;
 break;
+case AV_PIX_FMT_XV36LE:
+c->lumToYV12 = read_xv36le_Y_c;
+break;
 case AV_PIX_FMT_YUYV422:
 case AV_PIX_FMT_YVYU422:
 case AV_PIX_FMT_YA8:
diff --git a/libswscale/utils.c b/libswscale/utils.c
index a621a35862..a67e07b612 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -262,6 +262,7 @@ static const FormatEntry format_entries[] = {
 [AV_PIX_FMT_VUYX]= { 1, 1 },
 [AV_PIX_FMT_RGBAF16BE]   = { 1, 0 },
 [AV_PIX_FMT_RGBAF16LE]   = { 1, 0 },
+[AV_PIX_FMT_XV36LE]  = { 1, 0 },
 };
 
 int ff_shuffle_filter_coefficients(SwsContext *c, int *filterPos,
diff --git a/libswscale/version.h b/libswscale/version.h
index 17264b45da..403fc8f9e7 100644
--- a/libswscale/version.h
+++ b/libswscale/version.h
@@ -29,7 +29,7 @@
 #include "version_major.h"
 
 #define LIBSWSCALE_VERSION_MINOR   8
-#define LIBSWSCALE_VERSION_MICRO 104
+#define LIBSWSCALE_VERSION_MICRO 105
 
 #define LIBSWSCALE_VERSION_INT  AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \
LIBSWSCALE_VERSION_MINOR, \

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] swscale/input: add support for P012

2022-09-06 Thread Philip Langdale
ffmpeg | branch: master | Philip Langdale  | Sun Sep  4 
15:43:23 2022 -0700| [5bdd7261150db5d254d588f6cf8f038c149e63b5] | committer: 
Philip Langdale

swscale/input: add support for P012

As we now have three of these formats, I added macros to generate the
conversion functions.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5bdd7261150db5d254d588f6cf8f038c149e63b5
---

 libswscale/input.c   | 123 +++
 libswscale/utils.c   |   2 +
 libswscale/version.h |   2 +-
 3 files changed, 67 insertions(+), 60 deletions(-)

diff --git a/libswscale/input.c b/libswscale/input.c
index 8032360907..babedfd541 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -749,67 +749,60 @@ static void nv21ToUV_c(uint8_t *dstU, uint8_t *dstV,
 nvXXtoUV_c(dstV, dstU, src1, width);
 }
 
-static void p010LEToY_c(uint8_t *dst, const uint8_t *src, const uint8_t 
*unused1,
-const uint8_t *unused2, int width, uint32_t *unused, 
void *opq)
-{
-int i;
-for (i = 0; i < width; i++) {
-AV_WN16(dst + i * 2, AV_RL16(src + i * 2) >> 6);
-}
-}
-
-static void p010BEToY_c(uint8_t *dst, const uint8_t *src, const uint8_t 
*unused1,
-const uint8_t *unused2, int width, uint32_t *unused, 
void *opq)
-{
-int i;
-for (i = 0; i < width; i++) {
-AV_WN16(dst + i * 2, AV_RB16(src + i * 2) >> 6);
+#define p01x_uv_wrapper(bits, shift) \
+static void p0 ## bits ## LEToUV_c(uint8_t *dstU, uint8_t *dstV, \
+   const uint8_t *unused0,   \
+   const uint8_t *src1,  \
+   const uint8_t *src2, int width,   \
+   uint32_t *unused, void *opq)  \
+{\
+int i;   \
+for (i = 0; i < width; i++) {\
+AV_WN16(dstU + i * 2, AV_RL16(src1 + i * 4 + 0) >> shift);   \
+AV_WN16(dstV + i * 2, AV_RL16(src1 + i * 4 + 2) >> shift);   \
+}\
+}\
+ \
+static void p0 ## bits ## BEToUV_c(uint8_t *dstU, uint8_t *dstV, \
+   const uint8_t *unused0,   \
+   const uint8_t *src1,  \
+   const uint8_t *src2, int width,   \
+   uint32_t *unused, void *opq)  \
+{\
+int i;   \
+for (i = 0; i < width; i++) {\
+AV_WN16(dstU + i * 2, AV_RB16(src1 + i * 4 + 0) >> shift);   \
+AV_WN16(dstV + i * 2, AV_RB16(src1 + i * 4 + 2) >> shift);   \
+}\
 }
-}
 
-static void p010LEToUV_c(uint8_t *dstU, uint8_t *dstV,
-   const uint8_t *unused0, const uint8_t *src1, const 
uint8_t *src2,
-   int width, uint32_t *unused, void *opq)
-{
-int i;
-for (i = 0; i < width; i++) {
-AV_WN16(dstU + i * 2, AV_RL16(src1 + i * 4 + 0) >> 6);
-AV_WN16(dstV + i * 2, AV_RL16(src1 + i * 4 + 2) >> 6);
-}
-}
-
-static void p010BEToUV_c(uint8_t *dstU, uint8_t *dstV,
- const uint8_t *unused0, const uint8_t *src1, const 
uint8_t *src2,
- int width, uint32_t *unused, void *opq)
-{
-int i;
-for (i = 0; i < width; i++) {
-AV_WN16(dstU + i * 2, AV_RB16(src1 + i * 4 + 0) >> 6);
-AV_WN16(dstV + i * 2, AV_RB16(src1 + i * 4 + 2) >> 6);
-}
-}
-
-static void p016LEToUV_c(uint8_t *dstU, uint8_t *dstV,
- const uint8_t *unused0, const uint8_t *src1, const 
uint8_t *src2,
- int width, uint32_t *unused, void *opq)
-{
-int i;
-for (i = 0; i < width; i++) {
-AV_WN16(dstU + i * 2, AV_RL16(src1 + i * 4 + 0));
-AV_WN16(dstV + i * 2, AV_RL16(src1 + i * 4 + 2));
-}
-}
-
-static void p016BEToUV_c(uint8_t *dstU, uint8_t *dstV,
- const uint8_t *unused0, const uint8_t *src1, const 
uint8_t *src2,
- int width, uint32_t *unused, void *opq)
-{
-int i;
-for (i = 0; i < width; i++) {
-AV_WN16(dstU + i * 2, AV_RB16(src1 + i * 4 + 0));
-AV_WN16(dstV + i * 2, AV_RB16(src1 + i * 4 + 2));
-}
-}
+#define p01x_wrapper(bits, shift) \
+static void p0 ## bits ## LEToY_c(uint8_t *dst, const uint8_t *src, 

[FFmpeg-cvslog] swscale/input: add support for XV30LE

2022-09-06 Thread Philip Langdale
ffmpeg | branch: master | Philip Langdale  | Sun Sep  4 
16:32:06 2022 -0700| [198b5b90d5ab1c48aa54e0c6f2b6acd28487b0b3] | committer: 
Philip Langdale

swscale/input: add support for XV30LE

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=198b5b90d5ab1c48aa54e0c6f2b6acd28487b0b3
---

 libswscale/input.c   | 25 +
 libswscale/utils.c   |  1 +
 libswscale/version.h |  2 +-
 3 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/libswscale/input.c b/libswscale/input.c
index babedfd541..f4f08c8f72 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -685,6 +685,25 @@ static void read_vuya_A_c(uint8_t *dst, const uint8_t 
*src, const uint8_t *unuse
 dst[i] = src[i * 4 + 3];
 }
 
+static void read_xv30le_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t 
*unused0, const uint8_t *unused1, int width,
+   uint32_t *unused2, void *opq)
+{
+int i;
+for (i = 0; i < width; i++)
+AV_WN16(dst + i * 2, (AV_RL32(src + i * 4) >> 10) & 0x3FFu);
+}
+
+
+static void read_xv30le_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t 
*unused0, const uint8_t *src,
+   const uint8_t *unused1, int width, uint32_t 
*unused2, void *opq)
+{
+int i;
+for (i = 0; i < width; i++) {
+AV_WN16(dstU + i * 2, AV_RL32(src + i * 4) & 0x3FFu);
+AV_WN16(dstV + i * 2, (AV_RL32(src + i * 4) >> 20) & 0x3FFu);
+}
+}
+
 static void read_xv36le_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t 
*unused0, const uint8_t *unused1, int width,
uint32_t *unused2, void *opq)
 {
@@ -1390,6 +1409,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
 case AV_PIX_FMT_VUYX:
 c->chrToYV12 = read_vuyx_UV_c;
 break;
+case AV_PIX_FMT_XV30LE:
+c->chrToYV12 = read_xv30le_UV_c;
+break;
 case AV_PIX_FMT_AYUV64LE:
 c->chrToYV12 = read_ayuv64le_UV_c;
 break;
@@ -1777,6 +1799,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
 case AV_PIX_FMT_VUYX:
 c->lumToYV12 = read_vuyx_Y_c;
 break;
+case AV_PIX_FMT_XV30LE:
+c->lumToYV12 = read_xv30le_Y_c;
+break;
 case AV_PIX_FMT_AYUV64LE:
 c->lumToYV12 = read_ayuv64le_Y_c;
 break;
diff --git a/libswscale/utils.c b/libswscale/utils.c
index a7f77cd39d..ab86037cd4 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -264,6 +264,7 @@ static const FormatEntry format_entries[] = {
 [AV_PIX_FMT_VUYX]= { 1, 1 },
 [AV_PIX_FMT_RGBAF16BE]   = { 1, 0 },
 [AV_PIX_FMT_RGBAF16LE]   = { 1, 0 },
+[AV_PIX_FMT_XV30LE]  = { 1, 0 },
 [AV_PIX_FMT_XV36LE]  = { 1, 0 },
 };
 
diff --git a/libswscale/version.h b/libswscale/version.h
index dd517a1fc6..d2880590a6 100644
--- a/libswscale/version.h
+++ b/libswscale/version.h
@@ -29,7 +29,7 @@
 #include "version_major.h"
 
 #define LIBSWSCALE_VERSION_MINOR   8
-#define LIBSWSCALE_VERSION_MICRO 106
+#define LIBSWSCALE_VERSION_MICRO 107
 
 #define LIBSWSCALE_VERSION_INT  AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \
LIBSWSCALE_VERSION_MINOR, \

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] swscale/input: add support for Y212LE

2022-09-06 Thread Philip Langdale
ffmpeg | branch: master | Philip Langdale  | Sun Sep  4 
16:42:32 2022 -0700| [4a59eba227135f90a59a412a0175c783dc0be6d5] | committer: 
Philip Langdale

swscale/input: add support for Y212LE

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4a59eba227135f90a59a412a0175c783dc0be6d5
---

 libswscale/input.c   | 45 ++---
 libswscale/utils.c   |  1 +
 libswscale/version.h |  2 +-
 3 files changed, 32 insertions(+), 16 deletions(-)

diff --git a/libswscale/input.c b/libswscale/input.c
index f4f08c8f72..be8f3940e1 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -559,23 +559,32 @@ static void yvy2ToUV_c(uint8_t *dstU, uint8_t *dstV, 
const uint8_t *unused0, con
 av_assert1(src1 == src2);
 }
 
-static void y210le_UV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *unused0, 
const uint8_t *src,
-const uint8_t *unused1, int width, uint32_t *unused2, 
void *opq)
-{
-int i;
-for (i = 0; i < width; i++) {
-AV_WN16(dstU + i * 2, AV_RL16(src + i * 8 + 2) >> 6);
-AV_WN16(dstV + i * 2, AV_RL16(src + i * 8 + 6) >> 6);
+#define y21xle_wrapper(bits, shift) \
+static void y2 ## bits ## le_UV_c(uint8_t *dstU, uint8_t *dstV,  \
+  const uint8_t *unused0,\
+  const uint8_t *src,\
+  const uint8_t *unused1, int width, \
+  uint32_t *unused2, void *opq)  \
+{\
+int i;   \
+for (i = 0; i < width; i++) {\
+AV_WN16(dstU + i * 2, AV_RL16(src + i * 8 + 2) >> shift);\
+AV_WN16(dstV + i * 2, AV_RL16(src + i * 8 + 6) >> shift);\
+}\
+}\
+ \
+static void y2 ## bits ## le_Y_c(uint8_t *dst, const uint8_t *src,   \
+ const uint8_t *unused0, \
+ const uint8_t *unused1, int width,  \
+ uint32_t *unused2, void *opq)   \
+{\
+int i;   \
+for (i = 0; i < width; i++)  \
+AV_WN16(dst + i * 2, AV_RL16(src + i * 4) >> shift); \
 }
-}
 
-static void y210le_Y_c(uint8_t *dst, const uint8_t *src, const uint8_t 
*unused0,
-   const uint8_t *unused1, int width, uint32_t *unused2, 
void *opq)
-{
-int i;
-for (i = 0; i < width; i++)
-AV_WN16(dst + i * 2, AV_RL16(src + i * 4) >> 6);
-}
+y21xle_wrapper(10, 6);
+y21xle_wrapper(12, 4);
 
 static void bswap16Y_c(uint8_t *_dst, const uint8_t *_src, const uint8_t 
*unused1, const uint8_t *unused2, int width,
uint32_t *unused, void *opq)
@@ -1447,6 +1456,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
 case AV_PIX_FMT_Y210LE:
 c->chrToYV12 = y210le_UV_c;
 break;
+case AV_PIX_FMT_Y212LE:
+c->chrToYV12 = y212le_UV_c;
+break;
 }
 if (c->chrSrcHSubSample) {
 switch (srcFormat) {
@@ -1932,6 +1944,9 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
 case AV_PIX_FMT_Y210LE:
 c->lumToYV12 = y210le_Y_c;
 break;
+case AV_PIX_FMT_Y212LE:
+c->lumToYV12 = y212le_Y_c;
+break;
 case AV_PIX_FMT_X2RGB10LE:
 c->lumToYV12 = rgb30leToY_c;
 break;
diff --git a/libswscale/utils.c b/libswscale/utils.c
index ab86037cd4..a5a9bc589a 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -249,6 +249,7 @@ static const FormatEntry format_entries[] = {
 [AV_PIX_FMT_NV24]= { 1, 1 },
 [AV_PIX_FMT_NV42]= { 1, 1 },
 [AV_PIX_FMT_Y210LE]  = { 1, 0 },
+[AV_PIX_FMT_Y212LE]  = { 1, 0 },
 [AV_PIX_FMT_X2RGB10LE]   = { 1, 1 },
 [AV_PIX_FMT_X2BGR10LE]   = { 1, 1 },
 [AV_PIX_FMT_P210BE]  = { 1, 1 },
diff --git a/libswscale/version.h b/libswscale/version.h
index d2880590a6..908995b7b0 100644
--- a/libswscale/version.h
+++ b/libswscale/version.h
@@ -29,7 +29,7 @@
 #include "version_major.h"
 
 #define LIBSWSCALE_VERSION_MINOR   8
-#define LIBSWSCALE_VERSION_MICRO 107
+#define LIBSWSCALE_VERSION_MICRO 108
 
 #define LIBSWSCALE_VERSION_INT  AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \
LIBSWSCALE_VERSION_MINOR, \

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/

[FFmpeg-cvslog] avcodec/dvdata: Order code table by codes

2022-09-06 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Sep  4 01:23:00 2022 +0200| [8c7583b7528b11e4e86bc66b27a8a65c80cf0a93] | 
committer: Andreas Rheinhardt

avcodec/dvdata: Order code table by codes

Right now, it is nearly ordered by "left codes in the tree first";
the only exception is the escape value which has been put at the
end. This commit moves it to the place it should have according
to the above order. This is in preparation for further commits.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8c7583b7528b11e4e86bc66b27a8a65c80cf0a93
---

 libavcodec/dv_tablegen.h |  2 +-
 libavcodec/dvdata.c  | 12 
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/libavcodec/dv_tablegen.h b/libavcodec/dv_tablegen.h
index 941b5572be..0dcfffc140 100644
--- a/libavcodec/dv_tablegen.h
+++ b/libavcodec/dv_tablegen.h
@@ -51,7 +51,7 @@ static struct dv_vlc_pair 
dv_vlc_map[DV_VLC_MAP_RUN_SIZE][DV_VLC_MAP_LEV_SIZE];
 static av_cold void dv_vlc_map_tableinit(void)
 {
 int i, j;
-for (i = 0; i < NB_DV_VLC - 1; i++) {
+for (int i = 0; i < NB_DV_VLC; i++) {
 if (ff_dv_vlc_run[i] >= DV_VLC_MAP_RUN_SIZE)
 continue;
 #if CONFIG_SMALL
diff --git a/libavcodec/dvdata.c b/libavcodec/dvdata.c
index 231569a328..1e48db591d 100644
--- a/libavcodec/dvdata.c
+++ b/libavcodec/dvdata.c
@@ -75,7 +75,7 @@ const uint8_t ff_dv_quant_offset[4] = { 6, 3, 0, 1 };
  * when building misc. tables. E.g. (1, 0) can be either 0x7cf or 0x1f82.
  */
 const uint16_t ff_dv_vlc_bits[NB_DV_VLC] = {
-0x, 0x0002, 0x0007, 0x0008, 0x0009, 0x0014, 0x0015, 0x0016,
+0x, 0x0002, 0x0006, 0x0007, 0x0008, 0x0009, 0x0014, 0x0015, 0x0016,
 0x0017, 0x0030, 0x0031, 0x0032, 0x0033, 0x0068, 0x0069, 0x006a,
 0x006b, 0x006c, 0x006d, 0x006e, 0x006f, 0x00e0, 0x00e1, 0x00e2,
 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, 0x00e8, 0x00e9, 0x00ea,
@@ -126,11 +126,10 @@ const uint16_t ff_dv_vlc_bits[NB_DV_VLC] = {
 0x7fe8, 0x7fe9, 0x7fea, 0x7feb, 0x7fec, 0x7fed, 0x7fee, 0x7fef,
 0x7ff0, 0x7ff1, 0x7ff2, 0x7ff3, 0x7ff4, 0x7ff5, 0x7ff6, 0x7ff7,
 0x7ff8, 0x7ff9, 0x7ffa, 0x7ffb, 0x7ffc, 0x7ffd, 0x7ffe, 0x7fff,
-0x0006,
 };
 
 const uint8_t ff_dv_vlc_len[NB_DV_VLC] = {
- 2,  3,  4,  4,  4,  5,  5,  5,
+ 2,  3,  4,  4,  4,  4,  5,  5,  5,
  5,  6,  6,  6,  6,  7,  7,  7,
  7,  7,  7,  7,  7,  8,  8,  8,
  8,  8,  8,  8,  8,  8,  8,  8,
@@ -181,11 +180,10 @@ const uint8_t ff_dv_vlc_len[NB_DV_VLC] = {
 15, 15, 15, 15, 15, 15, 15, 15,
 15, 15, 15, 15, 15, 15, 15, 15,
 15, 15, 15, 15, 15, 15, 15, 15,
- 4,
 };
 
 const uint8_t ff_dv_vlc_run[NB_DV_VLC] = {
- 0,  0,  1,  0,  0,  2,  1,  0,
+ 0,  0, 127, 1,  0,  0,  2,  1,  0,
  0,  3,  4,  0,  0,  5,  6,  2,
  1,  1,  0,  0,  0,  7,  8,  9,
 10,  3,  4,  2,  1,  1,  1,  0,
@@ -236,11 +234,10 @@ const uint8_t ff_dv_vlc_run[NB_DV_VLC] = {
  0,  0,  0,  0,  0,  0,  0,  0,
  0,  0,  0,  0,  0,  0,  0,  0,
  0,  0,  0,  0,  0,  0,  0,  0,
-   127,
 };
 
 const uint8_t ff_dv_vlc_level[NB_DV_VLC] = {
- 1,   2,   1,   3,   4,   1,   2,   5,
+ 1,   2,   0,   1,   3,   4,   1,   2,   5,
  6,   1,   1,   7,   8,   1,   1,   2,
  3,   4,   9,  10,  11,   1,   1,   1,
  1,   2,   2,   3,   5,   6,   7,  12,
@@ -291,5 +288,4 @@ const uint8_t ff_dv_vlc_level[NB_DV_VLC] = {
232, 233, 234, 235, 236, 237, 238, 239,
240, 241, 242, 243, 244, 245, 246, 247,
248, 249, 250, 251, 252, 253, 254, 255,
- 0,
 };

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/dv_tablegen, dvdata: Remove ff_dv_vlc_bits

2022-09-06 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Sep  4 02:03:08 2022 +0200| [116e2a9ee2c9eb7eaa99af9a066bcc37825721c7] | 
committer: Andreas Rheinhardt

avcodec/dv_tablegen, dvdata: Remove ff_dv_vlc_bits

The codes can be easily calculated, so the table is unnecessary.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=116e2a9ee2c9eb7eaa99af9a066bcc37825721c7
---

 libavcodec/dv_tablegen.h |  5 -
 libavcodec/dvdata.c  | 54 
 libavcodec/dvdata.h  |  1 -
 3 files changed, 4 insertions(+), 56 deletions(-)

diff --git a/libavcodec/dv_tablegen.h b/libavcodec/dv_tablegen.h
index 0dcfffc140..7f0ab53fa7 100644
--- a/libavcodec/dv_tablegen.h
+++ b/libavcodec/dv_tablegen.h
@@ -50,8 +50,11 @@ static struct dv_vlc_pair 
dv_vlc_map[DV_VLC_MAP_RUN_SIZE][DV_VLC_MAP_LEV_SIZE];
 
 static av_cold void dv_vlc_map_tableinit(void)
 {
+uint32_t code = 0;
 int i, j;
 for (int i = 0; i < NB_DV_VLC; i++) {
+uint32_t cur_code = code >> (32 - ff_dv_vlc_len[i]);
+code += 1U << (32 - ff_dv_vlc_len[i]);
 if (ff_dv_vlc_run[i] >= DV_VLC_MAP_RUN_SIZE)
 continue;
 #if CONFIG_SMALL
@@ -63,7 +66,7 @@ static av_cold void dv_vlc_map_tableinit(void)
 continue;
 
 dv_vlc_map[ff_dv_vlc_run[i]][ff_dv_vlc_level[i]].vlc  =
-ff_dv_vlc_bits[i] << (!!ff_dv_vlc_level[i]);
+cur_code << (!!ff_dv_vlc_level[i]);
 dv_vlc_map[ff_dv_vlc_run[i]][ff_dv_vlc_level[i]].size =
 ff_dv_vlc_len[i]   + (!!ff_dv_vlc_level[i]);
 }
diff --git a/libavcodec/dvdata.c b/libavcodec/dvdata.c
index 1e48db591d..0cd10aed10 100644
--- a/libavcodec/dvdata.c
+++ b/libavcodec/dvdata.c
@@ -74,60 +74,6 @@ const uint8_t ff_dv_quant_offset[4] = { 6, 3, 0, 1 };
  * between (run, level) and vlc is not 1-1. So you have to watch out for that
  * when building misc. tables. E.g. (1, 0) can be either 0x7cf or 0x1f82.
  */
-const uint16_t ff_dv_vlc_bits[NB_DV_VLC] = {
-0x, 0x0002, 0x0006, 0x0007, 0x0008, 0x0009, 0x0014, 0x0015, 0x0016,
-0x0017, 0x0030, 0x0031, 0x0032, 0x0033, 0x0068, 0x0069, 0x006a,
-0x006b, 0x006c, 0x006d, 0x006e, 0x006f, 0x00e0, 0x00e1, 0x00e2,
-0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, 0x00e8, 0x00e9, 0x00ea,
-0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef, 0x01e0, 0x01e1, 0x01e2,
-0x01e3, 0x01e4, 0x01e5, 0x01e6, 0x01e7, 0x01e8, 0x01e9, 0x01ea,
-0x01eb, 0x01ec, 0x01ed, 0x01ee, 0x01ef, 0x03e0, 0x03e1, 0x03e2,
-0x03e3, 0x03e4, 0x03e5, 0x03e6, 0x07ce, 0x07cf, 0x07d0, 0x07d1,
-0x07d2, 0x07d3, 0x07d4, 0x07d5, 0x0fac, 0x0fad, 0x0fae, 0x0faf,
-0x0fb0, 0x0fb1, 0x0fb2, 0x0fb3, 0x0fb4, 0x0fb5, 0x0fb6, 0x0fb7,
-0x0fb8, 0x0fb9, 0x0fba, 0x0fbb, 0x0fbc, 0x0fbd, 0x0fbe, 0x0fbf,
-0x1f80, 0x1f81, 0x1f82, 0x1f83, 0x1f84, 0x1f85, 0x1f86, 0x1f87,
-0x1f88, 0x1f89, 0x1f8a, 0x1f8b, 0x1f8c, 0x1f8d, 0x1f8e, 0x1f8f,
-0x1f90, 0x1f91, 0x1f92, 0x1f93, 0x1f94, 0x1f95, 0x1f96, 0x1f97,
-0x1f98, 0x1f99, 0x1f9a, 0x1f9b, 0x1f9c, 0x1f9d, 0x1f9e, 0x1f9f,
-0x1fa0, 0x1fa1, 0x1fa2, 0x1fa3, 0x1fa4, 0x1fa5, 0x1fa6, 0x1fa7,
-0x1fa8, 0x1fa9, 0x1faa, 0x1fab, 0x1fac, 0x1fad, 0x1fae, 0x1faf,
-0x1fb0, 0x1fb1, 0x1fb2, 0x1fb3, 0x1fb4, 0x1fb5, 0x1fb6, 0x1fb7,
-0x1fb8, 0x1fb9, 0x1fba, 0x1fbb, 0x1fbc, 0x1fbd, 0x1fbe, 0x1fbf,
-0x7f00, 0x7f01, 0x7f02, 0x7f03, 0x7f04, 0x7f05, 0x7f06, 0x7f07,
-0x7f08, 0x7f09, 0x7f0a, 0x7f0b, 0x7f0c, 0x7f0d, 0x7f0e, 0x7f0f,
-0x7f10, 0x7f11, 0x7f12, 0x7f13, 0x7f14, 0x7f15, 0x7f16, 0x7f17,
-0x7f18, 0x7f19, 0x7f1a, 0x7f1b, 0x7f1c, 0x7f1d, 0x7f1e, 0x7f1f,
-0x7f20, 0x7f21, 0x7f22, 0x7f23, 0x7f24, 0x7f25, 0x7f26, 0x7f27,
-0x7f28, 0x7f29, 0x7f2a, 0x7f2b, 0x7f2c, 0x7f2d, 0x7f2e, 0x7f2f,
-0x7f30, 0x7f31, 0x7f32, 0x7f33, 0x7f34, 0x7f35, 0x7f36, 0x7f37,
-0x7f38, 0x7f39, 0x7f3a, 0x7f3b, 0x7f3c, 0x7f3d, 0x7f3e, 0x7f3f,
-0x7f40, 0x7f41, 0x7f42, 0x7f43, 0x7f44, 0x7f45, 0x7f46, 0x7f47,
-0x7f48, 0x7f49, 0x7f4a, 0x7f4b, 0x7f4c, 0x7f4d, 0x7f4e, 0x7f4f,
-0x7f50, 0x7f51, 0x7f52, 0x7f53, 0x7f54, 0x7f55, 0x7f56, 0x7f57,
-0x7f58, 0x7f59, 0x7f5a, 0x7f5b, 0x7f5c, 0x7f5d, 0x7f5e, 0x7f5f,
-0x7f60, 0x7f61, 0x7f62, 0x7f63, 0x7f64, 0x7f65, 0x7f66, 0x7f67,
-0x7f68, 0x7f69, 0x7f6a, 0x7f6b, 0x7f6c, 0x7f6d, 0x7f6e, 0x7f6f,
-0x7f70, 0x7f71, 0x7f72, 0x7f73, 0x7f74, 0x7f75, 0x7f76, 0x7f77,
-0x7f78, 0x7f79, 0x7f7a, 0x7f7b, 0x7f7c, 0x7f7d, 0x7f7e, 0x7f7f,
-0x7f80, 0x7f81, 0x7f82, 0x7f83, 0x7f84, 0x7f85, 0x7f86, 0x7f87,
-0x7f88, 0x7f89, 0x7f8a, 0x7f8b, 0x7f8c, 0x7f8d, 0x7f8e, 0x7f8f,
-0x7f90, 0x7f91, 0x7f92, 0x7f93, 0x7f94, 0x7f95, 0x7f96, 0x7f97,
-0x7f98, 0x7f99, 0x7f9a, 0x7f9b, 0x7f9c, 0x7f9d, 0x7f9e, 0x7f9f,
-0x7fa0, 0x7fa1, 0x7fa2, 0x7fa3, 0x7fa4, 0x7fa5, 0x7fa6, 0x7fa7,
-0x7fa8, 0x7fa9, 0x7faa, 0x7fab, 0x7fac, 0x7fad, 0x7fae, 0x7faf,
-0x7fb0, 0x7fb1, 0x7fb2, 0x7fb3, 0x7fb4, 0x7fb5, 0x7fb6, 0x7fb7,
-0x7fb8, 0x7fb9, 0x7fba, 0x7fbb, 0x7fbc, 0x7fbd, 0x7f

[FFmpeg-cvslog] avcodec/dvdec: Use ff_init_vlc_from_lengths()

2022-09-06 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Sep  4 01:40:38 2022 +0200| [297e91ed2b3b51ec3bfa63a4c955941ba68a2419] | 
committer: Andreas Rheinhardt

avcodec/dvdec: Use ff_init_vlc_from_lengths()

This is possible because the codes are already ordered
from left to right in the tree. It avoids having to create
the codes ourselves and will enable the codes table
to be removed altogether once the encoder stops using it.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=297e91ed2b3b51ec3bfa63a4c955941ba68a2419
---

 libavcodec/dvdec.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c
index 28dbe8c11a..9d521525a3 100644
--- a/libavcodec/dvdec.c
+++ b/libavcodec/dvdec.c
@@ -152,7 +152,6 @@ static void dv_init_static(void)
 {
 VLCElem vlc_buf[FF_ARRAY_ELEMS(dv_rl_vlc)] = { 0 };
 VLC dv_vlc = { .table = vlc_buf, .table_allocated = 
FF_ARRAY_ELEMS(vlc_buf) };
-uint16_t  new_dv_vlc_bits[NB_DV_VLC * 2];
 uint8_tnew_dv_vlc_len[NB_DV_VLC * 2];
 uint8_tnew_dv_vlc_run[NB_DV_VLC * 2];
 int16_t  new_dv_vlc_level[NB_DV_VLC * 2];
@@ -160,17 +159,14 @@ static void dv_init_static(void)
 
 /* it's faster to include sign bit in a generic VLC parsing scheme */
 for (i = 0, j = 0; i < NB_DV_VLC; i++, j++) {
-new_dv_vlc_bits[j]  = ff_dv_vlc_bits[i];
 new_dv_vlc_len[j]   = ff_dv_vlc_len[i];
 new_dv_vlc_run[j]   = ff_dv_vlc_run[i];
 new_dv_vlc_level[j] = ff_dv_vlc_level[i];
 
 if (ff_dv_vlc_level[i]) {
-new_dv_vlc_bits[j] <<= 1;
 new_dv_vlc_len[j]++;
 
 j++;
-new_dv_vlc_bits[j]  = (ff_dv_vlc_bits[i] << 1) | 1;
 new_dv_vlc_len[j]   =  ff_dv_vlc_len[i] + 1;
 new_dv_vlc_run[j]   =  ff_dv_vlc_run[i];
 new_dv_vlc_level[j] = -ff_dv_vlc_level[i];
@@ -179,8 +175,9 @@ static void dv_init_static(void)
 
 /* NOTE: as a trick, we use the fact the no codes are unused
  * to accelerate the parsing of partial codes */
-init_vlc(&dv_vlc, TEX_VLC_BITS, j, new_dv_vlc_len,
- 1, 1, new_dv_vlc_bits, 2, 2, INIT_VLC_USE_NEW_STATIC);
+ff_init_vlc_from_lengths(&dv_vlc, TEX_VLC_BITS, j,
+ new_dv_vlc_len, 1,
+ NULL, 0, 0, 0, INIT_VLC_USE_NEW_STATIC, NULL);
 av_assert1(dv_vlc.table_size == 1664);
 
 for (int i = 0; i < dv_vlc.table_size; i++) {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/dvdec: Mark dv_init_static() as av_cold

2022-09-06 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Sep  4 02:09:35 2022 +0200| [1fa535e8f3cb1a4fcec71c39e55b6ba997c0b83e] | 
committer: Andreas Rheinhardt

avcodec/dvdec: Mark dv_init_static() as av_cold

Forgotten in 6d484671ecb612c32cbda0fab65f961743aff5f8.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1fa535e8f3cb1a4fcec71c39e55b6ba997c0b83e
---

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

diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c
index 9d521525a3..7692300bdd 100644
--- a/libavcodec/dvdec.c
+++ b/libavcodec/dvdec.c
@@ -148,7 +148,7 @@ static const uint16_t dv_iweight_720_c[64] = {
 /* XXX: also include quantization */
 static RL_VLC_ELEM dv_rl_vlc[1664];
 
-static void dv_init_static(void)
+static av_cold void dv_init_static(void)
 {
 VLCElem vlc_buf[FF_ARRAY_ELEMS(dv_rl_vlc)] = { 0 };
 VLC dv_vlc = { .table = vlc_buf, .table_allocated = 
FF_ARRAY_ELEMS(vlc_buf) };

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/dvdec: Avoid stack buffers

2022-09-06 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Sep  4 04:16:17 2022 +0200| [51ca74b52593bcb1a74083875b688f889cf9b520] | 
committer: Andreas Rheinhardt

avcodec/dvdec: Avoid stack buffers

Instead reuse the destination RL VLC as scratch space.
This is possible, because the (implicit) codes here are already
ordered from left-to-right in the tree and because the codelengths
are increasing, which implies that mapping from VLC entries to the
corresponding entries used to initialize the VLC is monotonically
increasing. This means that one can reuse the right end of the
destination RL VLC to store the tables used to initialize the VLC
with.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=51ca74b52593bcb1a74083875b688f889cf9b520
---

 libavcodec/dvdata.h |  2 ++
 libavcodec/dvdec.c  | 26 +-
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/libavcodec/dvdata.h b/libavcodec/dvdata.h
index ae104096ad..31191a8475 100644
--- a/libavcodec/dvdata.h
+++ b/libavcodec/dvdata.h
@@ -27,6 +27,8 @@ extern const uint8_t ff_dv_quant_shifts[22][4];
 extern const uint8_t ff_dv_quant_offset[4];
 
 #define NB_DV_VLC 409
+/* The number of entries with value zero in ff_dv_vlc_level. */
+#define NB_DV_ZERO_LEVEL_ENTRIES 72
 
 extern const uint8_t ff_dv_vlc_len[NB_DV_VLC];
 extern const uint8_t ff_dv_vlc_run[NB_DV_VLC];
diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c
index 7692300bdd..afc4bb0bcd 100644
--- a/libavcodec/dvdec.c
+++ b/libavcodec/dvdec.c
@@ -152,31 +152,30 @@ static av_cold void dv_init_static(void)
 {
 VLCElem vlc_buf[FF_ARRAY_ELEMS(dv_rl_vlc)] = { 0 };
 VLC dv_vlc = { .table = vlc_buf, .table_allocated = 
FF_ARRAY_ELEMS(vlc_buf) };
-uint8_tnew_dv_vlc_len[NB_DV_VLC * 2];
-uint8_tnew_dv_vlc_run[NB_DV_VLC * 2];
-int16_t  new_dv_vlc_level[NB_DV_VLC * 2];
+const unsigned offset = FF_ARRAY_ELEMS(dv_rl_vlc) - (2 * NB_DV_VLC - 
NB_DV_ZERO_LEVEL_ENTRIES);
+RL_VLC_ELEM *tmp = dv_rl_vlc + offset;
 int i, j;
 
 /* it's faster to include sign bit in a generic VLC parsing scheme */
 for (i = 0, j = 0; i < NB_DV_VLC; i++, j++) {
-new_dv_vlc_len[j]   = ff_dv_vlc_len[i];
-new_dv_vlc_run[j]   = ff_dv_vlc_run[i];
-new_dv_vlc_level[j] = ff_dv_vlc_level[i];
+tmp[j].len   = ff_dv_vlc_len[i];
+tmp[j].run   = ff_dv_vlc_run[i];
+tmp[j].level = ff_dv_vlc_level[i];
 
 if (ff_dv_vlc_level[i]) {
-new_dv_vlc_len[j]++;
+tmp[j].len++;
 
 j++;
-new_dv_vlc_len[j]   =  ff_dv_vlc_len[i] + 1;
-new_dv_vlc_run[j]   =  ff_dv_vlc_run[i];
-new_dv_vlc_level[j] = -ff_dv_vlc_level[i];
+tmp[j].len   =  ff_dv_vlc_len[i] + 1;
+tmp[j].run   =  ff_dv_vlc_run[i];
+tmp[j].level = -ff_dv_vlc_level[i];
 }
 }
 
 /* NOTE: as a trick, we use the fact the no codes are unused
  * to accelerate the parsing of partial codes */
 ff_init_vlc_from_lengths(&dv_vlc, TEX_VLC_BITS, j,
- new_dv_vlc_len, 1,
+ &tmp[0].len, sizeof(tmp[0]),
  NULL, 0, 0, 0, INIT_VLC_USE_NEW_STATIC, NULL);
 av_assert1(dv_vlc.table_size == 1664);
 
@@ -189,8 +188,9 @@ static av_cold void dv_init_static(void)
 run   = 0;
 level = code;
 } else {
-run   = new_dv_vlc_run[code] + 1;
-level = new_dv_vlc_level[code];
+av_assert1(i <= code + offset);
+run   = tmp[code].run + 1;
+level = tmp[code].level;
 }
 dv_rl_vlc[i].len   = len;
 dv_rl_vlc[i].level = level;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/wmaprodec: Use symbol table more efficiently

2022-09-06 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Sep  4 22:44:04 2022 +0200| [232e88928eee71afa55233d021eeda25eb3ed5b4] | 
committer: Andreas Rheinhardt

avcodec/wmaprodec: Use symbol table more efficiently

By using a symbol table one can already bake in applying
a LUT on the return value of get_vlc2(). So change the
symbol table for the vec2 and vec4 tables to avoid
using the symbol_to_vec2/4 LUTs.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=232e88928eee71afa55233d021eeda25eb3ed5b4
---

 libavcodec/wmaprodata.h | 147 
 libavcodec/wmaprodec.c  |  22 
 2 files changed, 72 insertions(+), 97 deletions(-)

diff --git a/libavcodec/wmaprodata.h b/libavcodec/wmaprodata.h
index 3a30be40b5..057ce1d02d 100644
--- a/libavcodec/wmaprodata.h
+++ b/libavcodec/wmaprodata.h
@@ -325,67 +325,73 @@ static const float coef1_level[HUFF_COEF1_SIZE] = {
  */
 #define HUFF_VEC4_SIZE127
 #define HUFF_VEC4_MAXBITS  14
-static const uint8_t vec4_table[HUFF_VEC4_SIZE][2] = {
-{ 126,  1 }, {  76,  6 }, {  28,  8 }, {  93, 10 }, {  69, 10 },
-{ 117, 10 }, {  98, 10 }, {  31,  8 }, {  84,  8 }, {  38, 10 },
-{   9, 10 }, { 108,  9 }, {  96,  8 }, {  73,  8 }, {  67,  9 },
-{ 121, 12 }, {  90, 12 }, { 110, 11 }, {  35, 12 }, {  54, 12 },
-{  17, 11 }, {  86,  9 }, {  44,  9 }, {  82,  8 }, {  41,  8 },
-{  36,  9 }, { 103,  9 }, {  78,  8 }, {  66,  8 }, {  11,  9 },
-{  97,  9 }, {   4, 12 }, {  19, 12 }, {  70, 12 }, {  55, 14 },
-{  20, 14 }, {   5, 13 }, {  51, 11 }, {  94, 11 }, { 106,  9 },
-{ 101,  8 }, {  83,  9 }, {  42,  9 }, {  45, 11 }, {  46, 11 },
-{ 112, 10 }, {  99,  9 }, {   8,  8 }, {  56,  6 }, {   1,  6 },
-{  75,  6 }, {  27,  6 }, {  72,  6 }, {  62,  6 }, { 113, 11 },
-{ 124, 11 }, { 114, 10 }, {  15, 11 }, { 116, 11 }, {  24, 10 },
-{  59, 10 }, {  39, 11 }, {  10, 11 }, { 118,  9 }, { 105,  7 },
-{  71,  6 }, {  77,  7 }, {  85,  7 }, {  21,  6 }, {   7,  6 },
-{   6,  6 }, {   0,  5 }, {  79,  7 }, { 100, 11 }, {  48, 11 },
-{  87, 10 }, { 107,  9 }, {  92,  8 }, {  57,  6 }, { 119,  9 },
-{  29,  9 }, {  16, 10 }, {  49, 10 }, {  64,  9 }, {  95,  8 },
-{  58,  8 }, {  26,  6 }, {  61,  6 }, {  22,  6 }, {  23,  8 },
-{  81,  8 }, {  13,  9 }, {  53, 12 }, {  52, 12 }, { 123, 11 },
-{  33, 10 }, {  12,  8 }, {  40,  8 }, {  30,  8 }, {  47, 10 },
-{ 111, 10 }, {   3, 10 }, {  68, 10 }, {  74,  9 }, { 115,  9 },
-{  91,  8 }, { 120, 10 }, {  25, 11 }, { 122, 11 }, {  89,  9 },
-{   2,  8 }, {  37,  8 }, {  65,  8 }, {  43,  9 }, {  34,  9 },
-{  14, 10 }, {  60, 11 }, {  18, 12 }, { 125, 12 }, {  50,  9 },
-{  80,  9 }, {  88,  9 }, { 109,  8 }, {  32,  8 }, { 102,  7 },
-{ 104,  7 }, {  63,  7 },
+static const uint8_t vec4_lens[HUFF_VEC4_SIZE] = {
+ 1,  6,  8, 10, 10, 10, 10,  8,  8, 10, 10,  9,  8,  8,  9, 12, 12, 11,
+12, 12, 11,  9,  9,  8,  8,  9,  9,  8,  8,  9,  9, 12, 12, 12, 14, 14,
+13, 11, 11,  9,  8,  9,  9, 11, 11, 10,  9,  8,  6,  6,  6,  6,  6,  6,
+11, 11, 10, 11, 11, 10, 10, 11, 11,  9,  7,  6,  7,  7,  6,  6,  6,  5,
+ 7, 11, 11, 10,  9,  8,  6,  9,  9, 10, 10,  9,  8,  8,  6,  6,  6,  8,
+ 8,  9, 12, 12, 11, 10,  8,  8,  8, 10, 10, 10, 10,  9,  9,  8, 10, 11,
+11,  9,  8,  8,  8,  9,  9, 10, 11, 12, 12,  9,  9,  9,  8,  8,  7,  7,
+ 7,
+};
+
+/* The entry in the following table with symbol zero indicates
+ * that four further entries are coded explicitly; all other
+ * entries encode four numbers in the 0..15 range via
+ * the four nibbles of (symbol - 1). */
+static const uint16_t vec4_syms[HUFF_VEC4_SIZE] = {
+0,  4370,   275,  8195,  4146, 12545,  8225,   290,  4625,   515,
+   20,  8706,  8210,  4355,  4131, 16385,  5121,  8961,   321,  1041,
+   51,  4641,   546,  4610,   530,   513,  8451,  4385,  4130,33,
+ 8211, 5,66,  4161,  1281,81, 6,   801,  8196,  8481,
+ 8449,  4611,   531,   561,   769, 12290,  8226,19,  4097, 2,
+ 4369,   274,  4354,  4114, 12291, 16641, 12305,49, 12321,   260,
+ 4100,   516,21, 12546,  8466,  4353,  4371,  4626,   257,18,
+   17, 1,  4386,  8241,   771,  4865,  8705,  8194,  4098, 12561,
+  276,50,   785,  4116,  8209,  4099,   273,  4113,   258,   259,
+ 4609,35,  1026,  1025, 16401,   305,34,   529,   289,   770,
+12289, 4,  4145,  4356, 12306,  8193, 12801,   261, 16386,  4881,
+3,   514,  4129,   545,   306,36,  4101,65, 20481,   786,
+ 4401,  4866,  8721,   291,  8450,  8465,  4115,
 };
 
 
 #define HUFF_VEC2_SIZE137
 #define HUFF_VEC2_MAXBITS  12
+/* The entry in the following table with symbol zero indicates
+ * that two further entries are coded explicitly; all other
+ * entries encode two numbers in the 0..15 range via
+ * (symbol - 1) & 0xF and (symbol - 1) >> 4. */
 stat

[FFmpeg-cvslog] avcodec/wmaprodec: Use ff_init_vlc_from_lengths() instead of init_vlc

2022-09-06 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Sep  4 21:03:21 2022 +0200| [f050bc0506643cf2a7211634b4ba3310fa290190] | 
committer: Andreas Rheinhardt

avcodec/wmaprodec: Use ff_init_vlc_from_lengths() instead of init_vlc

It allows to replace tables of big codes (uint16_t and uint32_t)
by tables of smaller symbols (mostly uint8_t).

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f050bc0506643cf2a7211634b4ba3310fa290190
---

 libavcodec/wmaprodata.h | 551 +++-
 libavcodec/wmaprodec.c  |  42 ++--
 2 files changed, 236 insertions(+), 357 deletions(-)

diff --git a/libavcodec/wmaprodata.h b/libavcodec/wmaprodata.h
index 53824799d5..3a30be40b5 100644
--- a/libavcodec/wmaprodata.h
+++ b/libavcodec/wmaprodata.h
@@ -48,42 +48,32 @@ static const uint16_t critical_freq[] = {
  */
 #define HUFF_SCALE_SIZE121
 #define HUFF_SCALE_MAXBITS  19
-static const uint16_t scale_huffcodes[HUFF_SCALE_SIZE] = {
-0xE639, 0xE6C2, 0xE6C1, 0xE6C0, 0xE63F, 0xE63E, 0xE63D, 0xE63C,
-0xE63B, 0xE63A, 0xE638, 0xE637, 0xE636, 0xE635, 0xE634, 0xE632,
-0xE633, 0xE620, 0x737B, 0xE610, 0xE611, 0xE612, 0xE613, 0xE614,
-0xE615, 0xE616, 0xE617, 0xE618, 0xE619, 0xE61A, 0xE61B, 0xE61C,
-0xE61D, 0xE61E, 0xE61F, 0xE6C3, 0xE621, 0xE622, 0xE623, 0xE624,
-0xE625, 0xE626, 0xE627, 0xE628, 0xE629, 0xE62A, 0xE62B, 0xE62C,
-0xE62D, 0xE62E, 0xE62F, 0xE630, 0xE631, 0x1CDF, 0x0E60, 0x0399,
-0x00E7, 0x001D, 0x, 0x0001, 0x0001, 0x0001, 0x0002, 0x0006,
-0x0002, 0x0007, 0x0006, 0x000F, 0x0038, 0x0072, 0x039A, 0xE6C4,
-0xE6C5, 0xE6C6, 0xE6C7, 0xE6C8, 0xE6C9, 0xE6CA, 0xE6CB, 0xE6CC,
-0xE6CD, 0xE6CE, 0xE6CF, 0xE6D0, 0xE6D1, 0xE6D2, 0xE6D3, 0xE6D4,
-0xE6D5, 0xE6D6, 0xE6D7, 0xE6D8, 0xE6D9, 0xE6DA, 0xE6DB, 0xE6DC,
-0xE6DD, 0xE6DE, 0xE6DF, 0xE6E0, 0xE6E1, 0xE6E2, 0xE6E3, 0xE6E4,
-0xE6E5, 0xE6E6, 0xE6E7, 0xE6E8, 0xE6E9, 0xE6EA, 0xE6EB, 0xE6EC,
-0xE6ED, 0xE6EE, 0xE6EF, 0xE6F0, 0xE6F1, 0xE6F2, 0xE6F3, 0xE6F4,
-0xE6F5,
-};
-
-static const uint8_t scale_huffbits[HUFF_SCALE_SIZE] = {
-19, 19, 19, 19, 19, 19, 19, 19,
-19, 19, 19, 19, 19, 19, 19, 19,
-19, 19, 18, 19, 19, 19, 19, 19,
-19, 19, 19, 19, 19, 19, 19, 19,
-19, 19, 19, 19, 19, 19, 19, 19,
-19, 19, 19, 19, 19, 19, 19, 19,
-19, 19, 19, 19, 19, 16, 15, 13,
-11,  8,  5,  2,  1,  3,  5,  6,
- 6,  7,  7,  7,  9, 10, 13, 19,
-19, 19, 19, 19, 19, 19, 19, 19,
-19, 19, 19, 19, 19, 19, 19, 19,
-19, 19, 19, 19, 19, 19, 19, 19,
-19, 19, 19, 19, 19, 19, 19, 19,
-19, 19, 19, 19, 19, 19, 19, 19,
-19, 19, 19, 19, 19, 19, 19, 19,
-19,
+static const uint8_t scale_table[HUFF_SCALE_SIZE][2] = {
+{  58,  5 }, {  64,  6 }, {  66,  7 }, {  65,  7 }, {  62,  5 },
+{  63,  6 }, {  68,  9 }, {  69, 10 }, {  54, 15 }, {  19, 19 },
+{  20, 19 }, {  21, 19 }, {  22, 19 }, {  23, 19 }, {  24, 19 },
+{  25, 19 }, {  26, 19 }, {  27, 19 }, {  28, 19 }, {  29, 19 },
+{  30, 19 }, {  31, 19 }, {  32, 19 }, {  33, 19 }, {  34, 19 },
+{  17, 19 }, {  36, 19 }, {  37, 19 }, {  38, 19 }, {  39, 19 },
+{  40, 19 }, {  41, 19 }, {  42, 19 }, {  43, 19 }, {  44, 19 },
+{  45, 19 }, {  46, 19 }, {  47, 19 }, {  48, 19 }, {  49, 19 },
+{  50, 19 }, {  51, 19 }, {  52, 19 }, {  15, 19 }, {  16, 19 },
+{  14, 19 }, {  13, 19 }, {  12, 19 }, {  11, 19 }, {  10, 19 },
+{   0, 19 }, {   9, 19 }, {   8, 19 }, {   7, 19 }, {   6, 19 },
+{   5, 19 }, {   4, 19 }, {  55, 13 }, {  70, 13 }, {   3, 19 },
+{   2, 19 }, {   1, 19 }, {  35, 19 }, {  71, 19 }, {  72, 19 },
+{  73, 19 }, {  74, 19 }, {  75, 19 }, {  76, 19 }, {  77, 19 },
+{  78, 19 }, {  79, 19 }, {  80, 19 }, {  81, 19 }, {  82, 19 },
+{  83, 19 }, {  84, 19 }, {  85, 19 }, {  86, 19 }, {  87, 19 },
+{  88, 19 }, {  89, 19 }, {  90, 19 }, {  91, 19 }, {  92, 19 },
+{  93, 19 }, {  94, 19 }, {  95, 19 }, {  96, 19 }, {  97, 19 },
+{  98, 19 }, {  99, 19 }, { 100, 19 }, { 101, 19 }, { 102, 19 },
+{ 103, 19 }, { 104, 19 }, { 105, 19 }, { 106, 19 }, { 107, 19 },
+{ 108, 19 }, { 109, 19 }, { 110, 19 }, { 111, 19 }, { 112, 19 },
+{ 113, 19 }, { 114, 19 }, { 115, 19 }, { 116, 19 }, { 117, 19 },
+{ 118, 19 }, { 119, 19 }, { 120, 19 }, {  18, 18 }, {  53, 16 },
+{  56, 11 }, {  57,  8 }, {  67,  7 }, {  61,  3 }, {  59,  2 },
+{  60,  1 },
 };
 /** @} */
 
@@ -94,46 +84,31 @@ static const uint8_t scale_huffbits[HUFF_SCALE_SIZE] = {
  */
 #define HUFF_SCALE_RL_SIZE120
 #define HUFF_SCALE_RL_MAXBITS  21
-static const uint32_t scale_rl_huffcodes[HUFF_SCALE_RL_SIZE] = {
-0x00010C, 0x01, 0x10FE2A, 0x03, 0x03, 0x01, 0x13,
-0x20, 0x29, 0x14, 0x16, 0x45, 0x49, 0x2F,
-0x42, 0x8E, 0x8F, 0x000129, 0x09, 0x0D, 0x0004AC,
-0x2C, 0x000561, 0x0002E6, 0x00087C, 0x0002E2, 0x00095C, 0x18,
-0x01, 0x16, 0x

[FFmpeg-cvslog] avcodec/wmavoice: Avoid code table

2022-09-06 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Sep  4 19:38:38 2022 +0200| [af847fe000f9eb78e3aa013ee64ab2274bfd5e68] | 
committer: Andreas Rheinhardt

avcodec/wmavoice: Avoid code table

These codes are already ordered from left-to-right in the tree,
so one can just use ff_init_vlc_static_from_lengths().

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=af847fe000f9eb78e3aa013ee64ab2274bfd5e68
---

 libavcodec/wmavoice.c | 14 +++---
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c
index 8fa9db63ee..4438089e51 100644
--- a/libavcodec/wmavoice.c
+++ b/libavcodec/wmavoice.c
@@ -320,18 +320,10 @@ static av_cold void wmavoice_init_static_data(void)
 10, 10, 10, 12, 12, 12,
 14, 14, 14, 14
 };
-static const uint16_t codes[] = {
-  0x, 0x0001, 0x0002,//  00/01/10
-  0x000c, 0x000d, 0x000e,//   11+00/01/10
-  0x003c, 0x003d, 0x003e,// +00/01/10
-  0x00fc, 0x00fd, 0x00fe,//   11+00/01/10
-  0x03fc, 0x03fd, 0x03fe,// +00/01/10
-  0x0ffc, 0x0ffd, 0x0ffe,//   11+00/01/10
-  0x3ffc, 0x3ffd, 0x3ffe, 0x3fff // +xx
-};
 
-INIT_VLC_STATIC(&frame_type_vlc, VLC_NBITS, sizeof(bits),
-bits, 1, 1, codes, 2, 2, 132);
+INIT_VLC_STATIC_FROM_LENGTHS(&frame_type_vlc, VLC_NBITS,
+ FF_ARRAY_ELEMS(bits), bits,
+ 1, NULL, 0, 0, 0, 0, 132);
 }
 
 static av_cold void wmavoice_flush(AVCodecContext *ctx)

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/wmaprodec: Move applying offset to VLC creation

2022-09-06 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Sep  4 21:09:40 2022 +0200| [cca7f571bac7e5c7fb35f2faef5e4a23eb77516a] | 
committer: Andreas Rheinhardt

avcodec/wmaprodec: Move applying offset to VLC creation

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cca7f571bac7e5c7fb35f2faef5e4a23eb77516a
---

 libavcodec/wmaprodec.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/wmaprodec.c b/libavcodec/wmaprodec.c
index 1909ce2dad..698841dcaf 100644
--- a/libavcodec/wmaprodec.c
+++ b/libavcodec/wmaprodec.c
@@ -320,7 +320,7 @@ static av_cold void decode_init_static(void)
 {
 INIT_VLC_STATIC_FROM_LENGTHS(&sf_vlc, SCALEVLCBITS, HUFF_SCALE_SIZE,
  &scale_table[0][1], 2,
- &scale_table[0][0], 2, 1, 0, 0, 616);
+ &scale_table[0][0], 2, 1, -60, 0, 616);
 INIT_VLC_STATIC_FROM_LENGTHS(&sf_rl_vlc, VLCBITS, HUFF_SCALE_RL_SIZE,
  &scale_rl_table[0][1], 2,
  &scale_rl_table[0][0], 2, 1, 0, 0, 1406);
@@ -1056,7 +1056,7 @@ static int decode_scale_factors(WMAProDecodeCtx* s)
 s->channel[c].scale_factor_step = get_bits(&s->gb, 2) + 1;
 val = 45 / s->channel[c].scale_factor_step;
 for (sf = s->channel[c].scale_factors; sf < sf_end; sf++) {
-val += get_vlc2(&s->gb, sf_vlc.table, SCALEVLCBITS, 
SCALEMAXDEPTH) - 60;
+val += get_vlc2(&s->gb, sf_vlc.table, SCALEVLCBITS, 
SCALEMAXDEPTH);
 *sf = val;
 }
 } else {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/ffv1: Only allocate ThreadFrames for the decoder

2022-09-06 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Fri Sep  2 20:51:24 2022 +0200| [ff6f2c558640bcb6ee9f6b17f259645c4193151b] | 
committer: Andreas Rheinhardt

avcodec/ffv1: Only allocate ThreadFrames for the decoder

The FFV1 decoder only uses the last frame's data to conceal
errors. The encoder does not have this problem and therefore
only uses the current frame and none of the ThreadFrames.
So only allocate them for the decoder.

Signed-off-by: Andreas Rheinhardt 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ff6f2c558640bcb6ee9f6b17f259645c4193151b
---

 libavcodec/ffv1.c| 13 -
 libavcodec/ffv1dec.c | 23 ++-
 2 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c
index c8781cdaaa..b6204740ed 100644
--- a/libavcodec/ffv1.c
+++ b/libavcodec/ffv1.c
@@ -43,11 +43,6 @@ av_cold int ff_ffv1_common_init(AVCodecContext *avctx)
 s->avctx = avctx;
 s->flags = avctx->flags;
 
-s->picture.f = av_frame_alloc();
-s->last_picture.f = av_frame_alloc();
-if (!s->picture.f || !s->last_picture.f)
-return AVERROR(ENOMEM);
-
 s->width  = avctx->width;
 s->height = avctx->height;
 
@@ -198,14 +193,6 @@ av_cold int ff_ffv1_close(AVCodecContext *avctx)
 FFV1Context *s = avctx->priv_data;
 int i, j;
 
-if (s->picture.f)
-ff_thread_release_ext_buffer(avctx, &s->picture);
-av_frame_free(&s->picture.f);
-
-if (s->last_picture.f)
-ff_thread_release_ext_buffer(avctx, &s->last_picture);
-av_frame_free(&s->last_picture.f);
-
 for (j = 0; j < s->max_slice_count; j++) {
 FFV1Context *fs = s->slice_context[j];
 for (i = 0; i < s->plane_count; i++) {
diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c
index 794c58cc40..d4bc60a7da 100644
--- a/libavcodec/ffv1dec.c
+++ b/libavcodec/ffv1dec.c
@@ -823,6 +823,11 @@ static av_cold int decode_init(AVCodecContext *avctx)
 if ((ret = ff_ffv1_common_init(avctx)) < 0)
 return ret;
 
+f->picture.f  = av_frame_alloc();
+f->last_picture.f = av_frame_alloc();
+if (!f->picture.f || !f->last_picture.f)
+return AVERROR(ENOMEM);
+
 if (avctx->extradata_size > 0 && (ret = read_extra_header(f)) < 0)
 return ret;
 
@@ -1068,6 +1073,22 @@ static int update_thread_context(AVCodecContext *dst, 
const AVCodecContext *src)
 }
 #endif
 
+static av_cold int ffv1_decode_close(AVCodecContext *avctx)
+{
+FFV1Context *const s = avctx->priv_data;
+
+if (s->picture.f) {
+ff_thread_release_ext_buffer(avctx, &s->picture);
+av_frame_free(&s->picture.f);
+}
+
+if (s->last_picture.f) {
+ff_thread_release_ext_buffer(avctx, &s->last_picture);
+av_frame_free(&s->last_picture.f);
+}
+return ff_ffv1_close(avctx);
+}
+
 const FFCodec ff_ffv1_decoder = {
 .p.name = "ffv1",
 CODEC_LONG_NAME("FFmpeg video codec #1"),
@@ -1075,7 +1096,7 @@ const FFCodec ff_ffv1_decoder = {
 .p.id   = AV_CODEC_ID_FFV1,
 .priv_data_size = sizeof(FFV1Context),
 .init   = decode_init,
-.close  = ff_ffv1_close,
+.close  = ffv1_decode_close,
 FF_CODEC_DECODE_CB(decode_frame),
 UPDATE_THREAD_CONTEXT(update_thread_context),
 .p.capabilities = AV_CODEC_CAP_DR1 /*| AV_CODEC_CAP_DRAW_HORIZ_BAND*/ |

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] lavc/qsv: Add support for decoding & encoding 8bit 4:4:4 content

2022-09-06 Thread Haihao Xiang
ffmpeg | branch: master | Haihao Xiang  | Tue Sep  6 
12:53:38 2022 +0800| [db85e01fd7976150a522a1881f3479661d8c1a79] | committer: 
Haihao Xiang

lavc/qsv: Add support for decoding & encoding 8bit 4:4:4 content

AV_PIX_FMT_VUYX is used in FFmpeg and MFX_FOURCC_AYUV is used in the SDK

Reviewed-by: Philip Langdale 
Signed-off-by: Haihao Xiang 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=db85e01fd7976150a522a1881f3479661d8c1a79
---

 libavcodec/qsv.c | 14 ++
 libavcodec/qsvdec.c  |  2 ++
 libavcodec/qsvenc_hevc.c |  1 +
 libavcodec/qsvenc_vp9.c  |  1 +
 4 files changed, 18 insertions(+)

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 3449789a2c..51aac16695 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -211,6 +211,7 @@ enum AVPixelFormat ff_qsv_map_fourcc(uint32_t fourcc)
 #if CONFIG_VAAPI
 case MFX_FOURCC_YUY2: return AV_PIX_FMT_YUYV422;
 case MFX_FOURCC_Y210: return AV_PIX_FMT_Y210;
+case MFX_FOURCC_AYUV: return AV_PIX_FMT_VUYX;
 #endif
 }
 return AV_PIX_FMT_NONE;
@@ -243,6 +244,9 @@ int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t 
*fourcc)
 case AV_PIX_FMT_Y210:
 *fourcc = MFX_FOURCC_Y210;
 return AV_PIX_FMT_Y210;
+case AV_PIX_FMT_VUYX:
+*fourcc = MFX_FOURCC_AYUV;
+return AV_PIX_FMT_VUYX;
 #endif
 default:
 return AVERROR(ENOSYS);
@@ -277,6 +281,16 @@ int ff_qsv_map_frame_to_surface(const AVFrame *frame, 
mfxFrameSurface1 *surface)
 surface->Data.U16 = (mfxU16 *)frame->data[0] + 1;
 surface->Data.V16 = (mfxU16 *)frame->data[0] + 3;
 break;
+
+case AV_PIX_FMT_VUYX:
+surface->Data.V = frame->data[0];
+surface->Data.U = frame->data[0] + 1;
+surface->Data.Y = frame->data[0] + 2;
+// Only set Data.A to a valid address, the SDK doesn't
+// use the value from the frame.
+surface->Data.A = frame->data[0] + 3;
+break;
+
 default:
 return AVERROR(ENOSYS);
 }
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 0f0d719e23..0254a394bd 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -141,6 +141,7 @@ static int qsv_get_continuous_buffer(AVCodecContext *avctx, 
AVFrame *frame,
 frame->linesize[0] = 2 * FFALIGN(avctx->width, 128);
 break;
 case AV_PIX_FMT_Y210:
+case AV_PIX_FMT_VUYX:
 frame->linesize[0] = 4 * FFALIGN(avctx->width, 128);
 break;
 default:
@@ -1041,6 +1042,7 @@ const FFCodec ff_##x##_qsv_decoder = { \
 AV_PIX_FMT_P010, \
 AV_PIX_FMT_YUYV422, \
 AV_PIX_FMT_Y210, \
+AV_PIX_FMT_VUYX, \
 AV_PIX_FMT_QSV, \
 AV_PIX_FMT_NONE }, \
 .hw_configs = qsv_hw_configs, \
diff --git a/libavcodec/qsvenc_hevc.c b/libavcodec/qsvenc_hevc.c
index 98e002a305..45b373d643 100644
--- a/libavcodec/qsvenc_hevc.c
+++ b/libavcodec/qsvenc_hevc.c
@@ -315,6 +315,7 @@ const FFCodec ff_hevc_qsv_encoder = {
 AV_PIX_FMT_QSV,
 AV_PIX_FMT_BGRA,
 AV_PIX_FMT_X2RGB10,
+AV_PIX_FMT_VUYX,
 AV_PIX_FMT_NONE },
 .p.priv_class   = &class,
 .defaults   = qsv_enc_defaults,
diff --git a/libavcodec/qsvenc_vp9.c b/libavcodec/qsvenc_vp9.c
index 61d50156d3..044a882d1a 100644
--- a/libavcodec/qsvenc_vp9.c
+++ b/libavcodec/qsvenc_vp9.c
@@ -113,6 +113,7 @@ const FFCodec ff_vp9_qsv_encoder = {
 .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HYBRID,
 .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
 AV_PIX_FMT_P010,
+AV_PIX_FMT_VUYX,
 AV_PIX_FMT_QSV,
 AV_PIX_FMT_NONE },
 .p.priv_class   = &class,

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] lavc/qsvenc: use VBR if maxrate is not specified on Windows

2022-09-06 Thread Haihao Xiang
ffmpeg | branch: master | Haihao Xiang  | Thu Sep  1 
10:12:57 2022 +0800| [a5b6e292271f18d309389e7672e362332dc7dd7c] | committer: 
Haihao Xiang

lavc/qsvenc: use VBR if maxrate is not specified on Windows

Currently AVBR is disabled and VBR is the default method if maxrate is
not specified on Linux, but AVBR is the default one if maxrate is not
specified on Windows. In order to make user experience better accross
Linux and Windows, use VBR by default on Windows if maxrate is not
specified. User need to set both avbr_accuracy and avbr_convergence to
non-zero explicitly and not to specify maxrate if AVBR is expected.

In addition, AVBR works for H264 and HEVC only in the SDK.

$ ffmpeg.exe -v verbose -f lavfi -i yuvtestsrc -vf "format=nv12" -c:v
vp9_qsv -f null -

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a5b6e292271f18d309389e7672e362332dc7dd7c
---

 doc/encoders.texi| 45 +
 libavcodec/qsvenc.c  |  5 -
 libavcodec/qsvenc.h  |  6 --
 libavcodec/qsvenc_h264.c |  1 +
 libavcodec/qsvenc_hevc.c |  1 +
 5 files changed, 39 insertions(+), 19 deletions(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index d36464d629..d2046e437d 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -3244,9 +3244,9 @@ the average bitrate.
 than the average bitrate.
 
 @item
-@var{AVBR} - average VBR mode, when @option{maxrate} is not specified. This 
mode
-is further configured by the @option{avbr_accuracy} and
-@option{avbr_convergence} options.
+@var{AVBR} - average VBR mode, when @option{maxrate} is not specified, both
+@option{avbr_accuracy} and @option{avbr_convergence} are set to non-zero. This
+mode is available for H264 and HEVC on Windows.
 @end itemize
 @end itemize
 
@@ -3300,19 +3300,6 @@ Specifies how many asynchronous operations an 
application performs
 before the application explicitly synchronizes the result. If zero,
 the value is not specified.
 
-@item @var{avbr_accuracy}
-Accuracy of the AVBR ratecontrol (unit of tenth of percent).
-
-@item @var{avbr_convergence}
-Convergence of the AVBR ratecontrol (unit of 100 frames)
-
-The parameters @var{avbr_accuracy} and @var{avbr_convergence} are for the
-average variable bitrate control (AVBR) algorithm.
-The algorithm focuses on overall encoding quality while meeting the specified
-bitrate, @var{target_bitrate}, within the accuracy range @var{avbr_accuracy},
-after a @var{avbr_Convergence} period. This method does not follow HRD and the
-instant bitrate is not capped or padded.
-
 @item @var{preset}
 This option itemizes a range of choices from veryfast (best speed) to veryslow
 (best quality).
@@ -3518,6 +3505,19 @@ Provides a hint to encoder about the scenario for the 
encoding session.
 @item remotegaming
 @end table
 
+@item @var{avbr_accuracy}
+Accuracy of the AVBR ratecontrol (unit of tenth of percent).
+
+@item @var{avbr_convergence}
+Convergence of the AVBR ratecontrol (unit of 100 frames)
+
+The parameters @var{avbr_accuracy} and @var{avbr_convergence} are for the
+average variable bitrate control (AVBR) algorithm.
+The algorithm focuses on overall encoding quality while meeting the specified
+bitrate, @var{target_bitrate}, within the accuracy range @var{avbr_accuracy},
+after a @var{avbr_Convergence} period. This method does not follow HRD and the
+instant bitrate is not capped or padded.
+
 @end table
 
 @subsection HEVC Options
@@ -3681,6 +3681,19 @@ Provides a hint to encoder about the scenario for the 
encoding session.
 @item remotegaming
 @end table
 
+@item @var{avbr_accuracy}
+Accuracy of the AVBR ratecontrol (unit of tenth of percent).
+
+@item @var{avbr_convergence}
+Convergence of the AVBR ratecontrol (unit of 100 frames)
+
+The parameters @var{avbr_accuracy} and @var{avbr_convergence} are for the
+average variable bitrate control (AVBR) algorithm.
+The algorithm focuses on overall encoding quality while meeting the specified
+bitrate, @var{target_bitrate}, within the accuracy range @var{avbr_accuracy},
+after a @var{avbr_Convergence} period. This method does not follow HRD and the
+instant bitrate is not capped or padded.
+
 @end table
 
 @subsection MPEG2 Options
diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 7ac5390f10..31ff3b76ed 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -479,7 +479,10 @@ static int select_rc_mode(AVCodecContext *avctx, 
QSVEncContext *q)
 rc_desc = "constant bitrate (CBR)";
 }
 #if QSV_HAVE_AVBR
-else if (!avctx->rc_max_rate) {
+else if (!avctx->rc_max_rate &&
+ (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == 
AV_CODEC_ID_HEVC) &&
+ q->avbr_accuracy &&
+ q->avbr_convergence) {
 rc_mode = MFX_RATECONTROL_AVBR;
 rc_desc = "average variable bitrate (AVBR)";
 }
diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index a983651dda..ff859f2a7e 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -52,8 +52,6 

[FFmpeg-cvslog] lavu/hwcontext_qsv: add support for AV_PIX_FMT_VUYX on Linux

2022-09-06 Thread Haihao Xiang
ffmpeg | branch: master | Haihao Xiang  | Tue Sep  6 
12:53:37 2022 +0800| [b7dbffe69801d15cd1ba59223f94b449c2ac8dbc] | committer: 
Haihao Xiang

lavu/hwcontext_qsv: add support for AV_PIX_FMT_VUYX on Linux

AV_PIX_FMT_VUYX is used for 8bit 4:4:4 content in FFmpeg VAAPI, so
AV_PIX_FMT_VUYX should be used for 8bit 4:4:4 content in FFmpeg QSV too
because QSV is based on VAAPI on Linux. However the SDK only declares
support for AYUV and does nothing with the alpha, so this commit fudged
a mapping between AV_PIX_FMT_VUYX and MFX_FOURCC_AYUV.

Reviewed-by: Philip Langdale 
Signed-off-by: Haihao Xiang 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b7dbffe69801d15cd1ba59223f94b449c2ac8dbc
---

 libavutil/hwcontext_qsv.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 510f422562..9fa0dfa1c0 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -119,6 +119,10 @@ static const struct {
MFX_FOURCC_YUY2 },
 { AV_PIX_FMT_Y210,
MFX_FOURCC_Y210 },
+// VUYX is used for VAAPI child device,
+// the SDK only delares support for AYUV
+{ AV_PIX_FMT_VUYX,
+   MFX_FOURCC_AYUV },
 #endif
 };
 
@@ -1502,6 +1506,14 @@ static int map_frame_to_surface(const AVFrame *frame, 
mfxFrameSurface1 *surface)
 surface->Data.U16 = (mfxU16 *)frame->data[0] + 1;
 surface->Data.V16 = (mfxU16 *)frame->data[0] + 3;
 break;
+case AV_PIX_FMT_VUYX:
+surface->Data.V = frame->data[0];
+surface->Data.U = frame->data[0] + 1;
+surface->Data.Y = frame->data[0] + 2;
+// Only set Data.A to a valid address, the SDK doesn't
+// use the value from the frame.
+surface->Data.A = frame->data[0] + 3;
+break;
 #endif
 default:
 return MFX_ERR_UNSUPPORTED;

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".