vp9_dthread.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 "vpx_util/vpx_thread.h"
  14. #include "vpx/internal/vpx_codec_internal.h"
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. struct VP9Common;
  19. struct VP9Decoder;
  20. // WorkerData for the FrameWorker thread. It contains all the information of
  21. // the worker and decode structures for decoding a frame.
  22. typedef struct FrameWorkerData {
  23. struct VP9Decoder *pbi;
  24. const uint8_t *data;
  25. const uint8_t *data_end;
  26. size_t data_size;
  27. void *user_priv;
  28. int result;
  29. int worker_id;
  30. int received_frame;
  31. // scratch_buffer is used in frame parallel mode only.
  32. // It is used to make a copy of the compressed data.
  33. uint8_t *scratch_buffer;
  34. size_t scratch_buffer_size;
  35. #if CONFIG_MULTITHREAD
  36. pthread_mutex_t stats_mutex;
  37. pthread_cond_t stats_cond;
  38. #endif
  39. int frame_context_ready; // Current frame's context is ready to read.
  40. int frame_decoded; // Finished decoding current frame.
  41. } FrameWorkerData;
  42. void vp9_frameworker_lock_stats(VPxWorker *const worker);
  43. void vp9_frameworker_unlock_stats(VPxWorker *const worker);
  44. void vp9_frameworker_signal_stats(VPxWorker *const worker);
  45. // Wait until ref_buf has been decoded to row in real pixel unit.
  46. // Note: worker may already finish decoding ref_buf and release it in order to
  47. // start decoding next frame. So need to check whether worker is still decoding
  48. // ref_buf.
  49. void vp9_frameworker_wait(VPxWorker *const worker, RefCntBuffer *const ref_buf,
  50. int row);
  51. // FrameWorker broadcasts its decoding progress so other workers that are
  52. // waiting on it can resume decoding.
  53. void vp9_frameworker_broadcast(RefCntBuffer *const buf, int row);
  54. // Copy necessary decoding context from src worker to dst worker.
  55. void vp9_frameworker_copy_context(VPxWorker *const dst_worker,
  56. VPxWorker *const src_worker);
  57. #ifdef __cplusplus
  58. } // extern "C"
  59. #endif
  60. #endif // VP9_DECODER_VP9_DTHREAD_H_