comparison libtheoraenc.c @ 10568:aacf5f712ba7 libavcodec

Support compiling against libtheora older than 1.1
author conrad
date Wed, 25 Nov 2009 16:00:14 +0000
parents 54e322044750
children c1328f04458a
comparison
equal deleted inserted replaced
10567:d4ca61e293a3 10568:aacf5f712ba7
84 return 0; 84 return 0;
85 } 85 }
86 86
87 static int get_stats(AVCodecContext *avctx, int eos) 87 static int get_stats(AVCodecContext *avctx, int eos)
88 { 88 {
89 #ifdef TH_ENCCTL_2PASS_OUT
89 TheoraContext *h = avctx->priv_data; 90 TheoraContext *h = avctx->priv_data;
90 uint8_t *buf; 91 uint8_t *buf;
91 int bytes; 92 int bytes;
92 93
93 bytes = th_encode_ctl(h->t_state, TH_ENCCTL_2PASS_OUT, &buf, sizeof(buf)); 94 bytes = th_encode_ctl(h->t_state, TH_ENCCTL_2PASS_OUT, &buf, sizeof(buf));
106 memcpy(h->stats, buf, bytes); 107 memcpy(h->stats, buf, bytes);
107 avctx->stats_out = av_malloc(b64_size); 108 avctx->stats_out = av_malloc(b64_size);
108 av_base64_encode(avctx->stats_out, b64_size, h->stats, h->stats_offset); 109 av_base64_encode(avctx->stats_out, b64_size, h->stats, h->stats_offset);
109 } 110 }
110 return 0; 111 return 0;
112 #else
113 av_log(avctx, AV_LOG_ERROR, "libtheora too old to support 2pass\n");
114 return -1;
115 #endif
111 } 116 }
112 117
113 // libtheora won't read the entire buffer we give it at once, so we have to 118 // libtheora won't read the entire buffer we give it at once, so we have to
114 // repeatedly submit it... 119 // repeatedly submit it...
115 static int submit_stats(AVCodecContext *avctx) 120 static int submit_stats(AVCodecContext *avctx)
116 { 121 {
122 #ifdef TH_ENCCTL_2PASS_IN
117 TheoraContext *h = avctx->priv_data; 123 TheoraContext *h = avctx->priv_data;
118 int bytes; 124 int bytes;
119 if (!h->stats) { 125 if (!h->stats) {
120 if (!avctx->stats_in) { 126 if (!avctx->stats_in) {
121 av_log(avctx, AV_LOG_ERROR, "No statsfile for second pass\n"); 127 av_log(avctx, AV_LOG_ERROR, "No statsfile for second pass\n");
136 if (!bytes) 142 if (!bytes)
137 return 0; 143 return 0;
138 h->stats_offset += bytes; 144 h->stats_offset += bytes;
139 } 145 }
140 return 0; 146 return 0;
147 #else
148 av_log(avctx, AV_LOG_ERROR, "libtheora too old to support 2pass\n");
149 return -1;
150 #endif
141 } 151 }
142 152
143 static av_cold int encode_init(AVCodecContext* avc_context) 153 static av_cold int encode_init(AVCodecContext* avc_context)
144 { 154 {
145 th_info t_info; 155 th_info t_info;