svc_context.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * Copyright (c) 2013 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. /**
  11. * SvcContext - input parameters and state to encode a multi-layered
  12. * spatial SVC frame
  13. */
  14. #ifndef VPX_SVC_CONTEXT_H_
  15. #define VPX_SVC_CONTEXT_H_
  16. #include "vpx/vp8cx.h"
  17. #include "vpx/vpx_encoder.h"
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. typedef enum SVC_ENCODING_MODE {
  22. INTER_LAYER_PREDICTION_I,
  23. ALT_INTER_LAYER_PREDICTION_IP,
  24. INTER_LAYER_PREDICTION_IP,
  25. USE_GOLDEN_FRAME
  26. }
  27. SVC_ENCODING_MODE;
  28. typedef enum SVC_LOG_LEVEL {
  29. SVC_LOG_ERROR,
  30. SVC_LOG_INFO,
  31. SVC_LOG_DEBUG
  32. } SVC_LOG_LEVEL;
  33. typedef struct {
  34. // public interface to svc_command options
  35. int spatial_layers; // number of layers
  36. int first_frame_full_size; // set to one to force first frame full size
  37. SVC_ENCODING_MODE encoding_mode; // svc encoding strategy
  38. SVC_LOG_LEVEL log_level; // amount of information to display
  39. int log_print; // when set, printf log messages instead of returning the
  40. // message with svc_get_message
  41. // private storage for vpx_svc_encode
  42. void *internal;
  43. } SvcContext;
  44. /**
  45. * Set SVC options
  46. * options are supplied as a single string separated by spaces
  47. * Format: encoding-mode=<i|ip|alt-ip|gf>
  48. * layers=<layer_count>
  49. * scaling-factors=<n1>/<d1>,<n2>/<d2>,...
  50. * quantizers=<q1>,<q2>,...
  51. */
  52. vpx_codec_err_t vpx_svc_set_options(SvcContext *svc_ctx, const char *options);
  53. /**
  54. * Set SVC quantizer values
  55. * values comma separated, ordered from lowest resolution to highest
  56. * e.g., "60,53,39,33,27"
  57. */
  58. vpx_codec_err_t vpx_svc_set_quantizers(SvcContext *svc_ctx,
  59. const char *quantizer_values);
  60. /**
  61. * Set SVC scale factors
  62. * values comma separated, ordered from lowest resolution to highest
  63. * e.g., "4/16,5/16,7/16,11/16,16/16"
  64. */
  65. vpx_codec_err_t vpx_svc_set_scale_factors(SvcContext *svc_ctx,
  66. const char *scale_factors);
  67. /**
  68. * initialize SVC encoding
  69. */
  70. vpx_codec_err_t vpx_svc_init(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx,
  71. vpx_codec_iface_t *iface,
  72. vpx_codec_enc_cfg_t *cfg);
  73. /**
  74. * encode a frame of video with multiple layers
  75. */
  76. vpx_codec_err_t vpx_svc_encode(SvcContext *svc_ctx, vpx_codec_ctx_t *codec_ctx,
  77. struct vpx_image *rawimg, vpx_codec_pts_t pts,
  78. int64_t duration, int deadline);
  79. /**
  80. * finished with svc encoding, release allocated resources
  81. */
  82. void vpx_svc_release(SvcContext *svc_ctx);
  83. /**
  84. * dump accumulated statistics and reset accumulated values
  85. */
  86. const char *vpx_svc_dump_statistics(SvcContext *svc_ctx);
  87. /**
  88. * get status message from previous encode
  89. */
  90. const char *vpx_svc_get_message(const SvcContext *svc_ctx);
  91. /**
  92. * return size of encoded data to be returned by vpx_svc_get_buffer
  93. */
  94. size_t vpx_svc_get_frame_size(const SvcContext *svc_ctx);
  95. /**
  96. * return buffer with encoded data
  97. */
  98. void *vpx_svc_get_buffer(const SvcContext *svc_ctx);
  99. /**
  100. * return spatial resolution of the specified layer
  101. */
  102. vpx_codec_err_t vpx_svc_get_layer_resolution(const SvcContext *svc_ctx,
  103. int layer,
  104. unsigned int *width,
  105. unsigned int *height);
  106. /**
  107. * return number of frames that have been encoded
  108. */
  109. int vpx_svc_get_encode_frame_count(const SvcContext *svc_ctx);
  110. /**
  111. * return 1 if last encoded frame was a keyframe
  112. */
  113. int vpx_svc_is_keyframe(const SvcContext *svc_ctx);
  114. /**
  115. * force the next frame to be a keyframe
  116. */
  117. void vpx_svc_set_keyframe(SvcContext *svc_ctx);
  118. #ifdef __cplusplus
  119. } // extern "C"
  120. #endif
  121. #endif /* VPX_SVC_CONTEXT_H_ */