vp9_dthread.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (c) 2014 The WebM project authors. All Rights Reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef VP9_DECODER_VP9_DTHREAD_H_
  11. #define VP9_DECODER_VP9_DTHREAD_H_
  12. #include "./vpx_config.h"
  13. #include "vp9/common/vp9_thread.h"
  14. #include "vpx/internal/vpx_codec_internal.h"
  15. struct VP9Common;
  16. struct VP9Decoder;
  17. // WorkerData for the FrameWorker thread. It contains all the information of
  18. // the worker and decode structures for decoding a frame.
  19. typedef struct FrameWorkerData {
  20. struct VP9Decoder *pbi;
  21. const uint8_t *data;
  22. const uint8_t *data_end;
  23. size_t data_size;
  24. void *user_priv;
  25. int result;
  26. int worker_id;
  27. int received_frame;
  28. // scratch_buffer is used in frame parallel mode only.
  29. // It is used to make a copy of the compressed data.
  30. uint8_t *scratch_buffer;
  31. size_t scratch_buffer_size;
  32. #if CONFIG_MULTITHREAD
  33. pthread_mutex_t stats_mutex;
  34. pthread_cond_t stats_cond;
  35. #endif
  36. int frame_context_ready; // Current frame's context is ready to read.
  37. int frame_decoded; // Finished decoding current frame.
  38. } FrameWorkerData;
  39. void vp9_frameworker_lock_stats(VP9Worker *const worker);
  40. void vp9_frameworker_unlock_stats(VP9Worker *const worker);
  41. void vp9_frameworker_signal_stats(VP9Worker *const worker);
  42. // Wait until ref_buf has been decoded to row in real pixel unit.
  43. // Note: worker may already finish decoding ref_buf and release it in order to
  44. // start decoding next frame. So need to check whether worker is still decoding
  45. // ref_buf.
  46. void vp9_frameworker_wait(VP9Worker *const worker, RefCntBuffer *const ref_buf,
  47. int row);
  48. // FrameWorker broadcasts its decoding progress so other workers that are
  49. // waiting on it can resume decoding.
  50. void vp9_frameworker_broadcast(RefCntBuffer *const buf, int row);
  51. // Copy necessary decoding context from src worker to dst worker.
  52. void vp9_frameworker_copy_context(VP9Worker *const dst_worker,
  53. VP9Worker *const src_worker);
  54. #endif // VP9_DECODER_VP9_DTHREAD_H_