123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- #ifdef HAVE_CONFIG_H
- # include <config.h>
- #endif
- #include <stdio.h>
- #include <stdlib.h>
- #include "theora/theoraenc.h"
- int print_version(void)
- {
- unsigned version = th_version_number();
- fprintf(stdout, "Bitstream: %d.%d.%d (0x%06X)\n",
- (version >> 16) & 0xff, (version >> 8) & 0xff, (version) & 0xff,
- version);
- return 0;
- }
- int print_version_string(void)
- {
- const char *version = th_version_string();
- if (version == NULL) {
- fprintf(stderr, "Error querying libtheora version string.\n");
- return -1;
- }
- fprintf(stdout, "Version: %s\n", version);
- return 0;
- }
- th_enc_ctx *dummy_encode_ctx(void)
- {
- th_enc_ctx *ctx;
- th_info info;
-
- th_info_init(&info);
- info.frame_width=320;
- info.frame_height=240;
- info.fps_numerator=1;
- info.fps_denominator=1;
-
- ctx = th_encode_alloc(&info);
- if (ctx == NULL) {
- fprintf(stderr, "Error allocating encoder context.\n");
- }
-
- th_info_clear(&info);
- return ctx;
- }
- int check_speed_level(th_enc_ctx *ctx, int *current, int *max)
- {
- int ret;
-
- ret = th_encode_ctl(ctx, TH_ENCCTL_GET_SPLEVEL, current, sizeof(int));
- if (ret) {
- fprintf(stderr, "Error %d getting current speed level.\n", ret);
- return ret;
- }
-
- ret = th_encode_ctl(ctx, TH_ENCCTL_GET_SPLEVEL_MAX, max, sizeof(int));
- if (ret) {
- fprintf(stderr, "Error %d getting max speed level.\n", ret);
- return ret;
- }
- return 0;
- }
- int print_speed_level(th_enc_ctx *ctx)
- {
- int current = -1;
- int max = -1;
- int ret;
- ret = check_speed_level(ctx, ¤t, &max);
- if (ret == 0) {
- fprintf(stdout, "Default speed level: %d\n", current);
- fprintf(stdout, "Maximum speed level: %d\n", max);
- }
- return ret;
- }
- int main(int argc, char **argv) {
- th_enc_ctx *ctx;
-
- print_version_string();
- print_version();
-
- ctx = dummy_encode_ctx();
- if (ctx != NULL) {
-
- print_speed_level(ctx);
-
- th_encode_free(ctx);
- }
- return 0;
- }
|