2011-02-08 02:15:44 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2008 Alexander Strange <astrange@ithinksw.com>
|
|
|
|
*
|
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* Multithreading support functions
|
|
|
|
* @author Alexander Strange <astrange@ithinksw.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef AVCODEC_THREAD_H
|
|
|
|
#define AVCODEC_THREAD_H
|
|
|
|
|
2012-11-21 20:34:46 +00:00
|
|
|
#include "libavutil/buffer.h"
|
|
|
|
|
2011-02-08 02:15:44 +00:00
|
|
|
#include "avcodec.h"
|
|
|
|
|
|
|
|
/**
|
2011-12-07 12:03:53 +00:00
|
|
|
* Wait for decoding threads to finish and reset internal state.
|
|
|
|
* Called by avcodec_flush_buffers().
|
2011-02-08 02:15:44 +00:00
|
|
|
*
|
|
|
|
* @param avctx The context.
|
|
|
|
*/
|
|
|
|
void ff_thread_flush(AVCodecContext *avctx);
|
|
|
|
|
|
|
|
/**
|
2011-12-07 12:03:53 +00:00
|
|
|
* Submit a new frame to a decoding thread.
|
2011-02-08 02:15:44 +00:00
|
|
|
* Returns the next available frame in picture. *got_picture_ptr
|
|
|
|
* will be 0 if none is available.
|
2011-11-24 00:50:05 +00:00
|
|
|
* The return value on success is the size of the consumed packet for
|
2024-04-25 09:18:18 +00:00
|
|
|
* compatibility with FFCodec.decode. This means the decoder
|
2011-11-24 00:50:05 +00:00
|
|
|
* has to consume the full packet.
|
2011-02-08 02:15:44 +00:00
|
|
|
*
|
2024-04-25 09:18:18 +00:00
|
|
|
* Parameters are the same as FFCodec.decode.
|
2011-02-08 02:15:44 +00:00
|
|
|
*/
|
|
|
|
int ff_thread_decode_frame(AVCodecContext *avctx, AVFrame *picture,
|
|
|
|
int *got_picture_ptr, AVPacket *avpkt);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If the codec defines update_thread_context(), call this
|
|
|
|
* when they are ready for the next thread to start decoding
|
|
|
|
* the next frame. After calling it, do not change any variables
|
|
|
|
* read by the update_thread_context() method, or call ff_thread_get_buffer().
|
|
|
|
*
|
|
|
|
* @param avctx The context.
|
|
|
|
*/
|
|
|
|
void ff_thread_finish_setup(AVCodecContext *avctx);
|
|
|
|
|
2022-05-23 03:23:35 +00:00
|
|
|
#if FF_API_THREAD_SAFE_CALLBACKS
|
2013-04-07 08:17:09 +00:00
|
|
|
/**
|
|
|
|
* Wrapper around get_format() for frame-multithreaded codecs.
|
|
|
|
* Call this function instead of avctx->get_format().
|
|
|
|
* Cannot be called after the codec has called ff_thread_finish_setup().
|
|
|
|
*
|
|
|
|
* @param avctx The current context.
|
|
|
|
* @param fmt The list of available formats.
|
|
|
|
*/
|
|
|
|
enum AVPixelFormat ff_thread_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt);
|
2022-05-23 03:23:35 +00:00
|
|
|
#else
|
|
|
|
#define ff_thread_get_format ff_get_format
|
|
|
|
#endif
|
2011-02-08 02:15:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Wrapper around get_buffer() for frame-multithreaded codecs.
|
2012-11-10 12:22:56 +00:00
|
|
|
* Call this function instead of ff_get_buffer(f).
|
2011-02-08 02:15:44 +00:00
|
|
|
* Cannot be called after the codec has called ff_thread_finish_setup().
|
|
|
|
*
|
|
|
|
* @param avctx The current context.
|
|
|
|
* @param f The frame to write into.
|
|
|
|
*/
|
2024-04-25 09:18:18 +00:00
|
|
|
int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f, int flags);
|
2011-02-08 02:15:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Wrapper around release_buffer() frame-for multithreaded codecs.
|
|
|
|
* Call this function instead of avctx->release_buffer(f).
|
|
|
|
* The AVFrame will be copied and the actual release_buffer() call
|
|
|
|
* will be performed later. The contents of data pointed to by the
|
|
|
|
* AVFrame should not be changed until ff_thread_get_buffer() is called
|
|
|
|
* on it.
|
|
|
|
*
|
|
|
|
* @param avctx The current context.
|
|
|
|
* @param f The picture being released.
|
|
|
|
*/
|
2024-04-25 09:18:18 +00:00
|
|
|
void ff_thread_release_buffer(AVCodecContext *avctx, AVFrame *f);
|
2011-02-08 02:15:44 +00:00
|
|
|
|
2011-03-26 12:55:30 +00:00
|
|
|
int ff_thread_init(AVCodecContext *s);
|
2017-09-07 20:48:17 +00:00
|
|
|
int ff_slice_thread_execute_with_mainfunc(AVCodecContext *avctx,
|
|
|
|
int (*action_func2)(AVCodecContext *c, void *arg, int jobnr, int threadnr),
|
|
|
|
int (*main_func)(AVCodecContext *c), void *arg, int *ret, int job_count);
|
2011-02-08 02:15:45 +00:00
|
|
|
void ff_thread_free(AVCodecContext *s);
|
2013-10-20 20:48:03 +00:00
|
|
|
int ff_alloc_entries(AVCodecContext *avctx, int count);
|
|
|
|
void ff_reset_entries(AVCodecContext *avctx);
|
2024-04-25 09:18:18 +00:00
|
|
|
int ff_slice_thread_init_progress(AVCodecContext *avctx);
|
2013-10-20 20:48:03 +00:00
|
|
|
void ff_thread_report_progress2(AVCodecContext *avctx, int field, int thread, int n);
|
|
|
|
void ff_thread_await_progress2(AVCodecContext *avctx, int field, int thread, int shift);
|
|
|
|
|
2011-02-08 02:15:44 +00:00
|
|
|
#endif /* AVCODEC_THREAD_H */
|