You've already forked FFmpeg
							
							
				mirror of
				https://github.com/FFmpeg/FFmpeg.git
				synced 2025-10-30 23:18:11 +02:00 
			
		
		
		
	avcodec/dsd: Make initializing DSD tables thread-safe
This automatically makes the DSD formats as well as DST and WavPack init-threadsafe. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
		| @@ -21,6 +21,7 @@ | ||||
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||||
|  */ | ||||
|  | ||||
| #include "libavutil/thread.h" | ||||
| #include "libavcodec/internal.h" | ||||
| #include "libavcodec/mathops.h" | ||||
| #include "avcodec.h" | ||||
| @@ -45,11 +46,8 @@ static av_cold void dsd_ctables_tableinit(void) | ||||
|  | ||||
| av_cold void ff_init_dsd_data(void) | ||||
| { | ||||
|     static int done = 0; | ||||
|     if (done) | ||||
|         return; | ||||
|     dsd_ctables_tableinit(); | ||||
|     done = 1; | ||||
|     static AVOnce init_static_once = AV_ONCE_INIT; | ||||
|     ff_thread_once(&init_static_once, dsd_ctables_tableinit); | ||||
| } | ||||
|  | ||||
| void ff_dsd2pcm_translate(DSDContext* s, size_t samples, int lsbf, | ||||
|   | ||||
| @@ -125,6 +125,7 @@ AVCodec ff_##name_##_decoder = { \ | ||||
|     .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS, \ | ||||
|     .sample_fmts  = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLTP, \ | ||||
|                                                    AV_SAMPLE_FMT_NONE }, \ | ||||
|     .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, \ | ||||
| }; | ||||
|  | ||||
| DSD_DECODER(DSD_LSBF, dsd_lsbf, "DSD (Direct Stream Digital), least significant bit first") | ||||
|   | ||||
| @@ -389,4 +389,5 @@ AVCodec ff_dst_decoder = { | ||||
|     .capabilities   = AV_CODEC_CAP_DR1, | ||||
|     .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLT, | ||||
|                                                       AV_SAMPLE_FMT_NONE }, | ||||
|     .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE, | ||||
| }; | ||||
|   | ||||
| @@ -1712,5 +1712,6 @@ AVCodec ff_wavpack_decoder = { | ||||
|     .update_thread_context = ONLY_IF_THREADS_ENABLED(update_thread_context), | ||||
|     .capabilities   = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | | ||||
|                       AV_CODEC_CAP_SLICE_THREADS, | ||||
|     .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_ALLOCATE_PROGRESS, | ||||
|     .caps_internal  = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP | | ||||
|                       FF_CODEC_CAP_ALLOCATE_PROGRESS, | ||||
| }; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user