slicethread.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * This file is part of FFmpeg.
  3. *
  4. * FFmpeg is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * FFmpeg is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with FFmpeg; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef AVUTIL_SLICETHREAD_H
  19. #define AVUTIL_SLICETHREAD_H
  20. typedef struct AVSliceThread AVSliceThread;
  21. /**
  22. * Create slice threading context.
  23. * @param pctx slice threading context returned here
  24. * @param priv private pointer to be passed to callback function
  25. * @param worker_func callback function to be executed
  26. * @param main_func special callback function, called from main thread, may be NULL
  27. * @param nb_threads number of threads, 0 for automatic, must be >= 0
  28. * @return return number of threads or negative AVERROR on failure
  29. */
  30. int avpriv_slicethread_create(AVSliceThread **pctx, void *priv,
  31. void (*worker_func)(void *priv, int jobnr, int threadnr, int nb_jobs, int nb_threads),
  32. void (*main_func)(void *priv),
  33. int nb_threads);
  34. /**
  35. * Execute slice threading.
  36. * @param ctx slice threading context
  37. * @param nb_jobs number of jobs, must be > 0
  38. * @param execute_main also execute main_func
  39. */
  40. void avpriv_slicethread_execute(AVSliceThread *ctx, int nb_jobs, int execute_main);
  41. /**
  42. * Destroy slice threading context.
  43. * @param pctx pointer to context
  44. */
  45. void avpriv_slicethread_free(AVSliceThread **pctx);
  46. #endif