#include "libavutil/avstring.h"
#include "libavutil/integer.h"
#include "libavutil/crc.h"
+#include "libavutil/pixdesc.h"
#include "avcodec.h"
#include "dsputil.h"
#include "opt.h"
#include "imgconvert.h"
#include "audioconvert.h"
+#include "libxvid_internal.h"
#include "internal.h"
#include <stdlib.h>
#include <stdarg.h>
}
#endif
+unsigned avcodec_get_edge_width(void)
+{
+ return EDGE_WIDTH;
+}
+
void avcodec_set_dimensions(AVCodecContext *s, int width, int height){
s->coded_width = width;
s->coded_height= height;
#define INTERNAL_BUFFER_SIZE 32
-void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){
+void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int linesize_align[4]){
int w_align= 1;
int h_align= 1;
*height= FFALIGN(*height, h_align);
if(s->codec_id == CODEC_ID_H264)
*height+=2; // some of the optimized chroma MC reads one line too much
+
+ linesize_align[0] =
+ linesize_align[1] =
+ linesize_align[2] =
+ linesize_align[3] = STRIDE_ALIGN;
+//STRIDE_ALIGN is 8 for SSE* but this does not work for SVQ1 chroma planes
+//we could change STRIDE_ALIGN to 16 for x86/sse but it would increase the
+//picture size unneccessarily in some cases. The solution here is not
+//pretty and better ideas are welcome!
+#if HAVE_MMX
+ if(s->codec_id == CODEC_ID_SVQ1 || s->codec_id == CODEC_ID_VP5 ||
+ s->codec_id == CODEC_ID_VP6 || s->codec_id == CODEC_ID_VP6F ||
+ s->codec_id == CODEC_ID_VP6A) {
+ linesize_align[0] =
+ linesize_align[1] =
+ linesize_align[2] = 16;
+ }
+#endif
+}
+
+void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height){
+ int chroma_shift = av_pix_fmt_descriptors[s->pix_fmt].log2_chroma_w;
+ int linesize_align[4];
+ int align;
+ avcodec_align_dimensions2(s, width, height, linesize_align);
+ align = FFMAX(linesize_align[0], linesize_align[3]);
+ linesize_align[1] <<= chroma_shift;
+ linesize_align[2] <<= chroma_shift;
+ align = FFMAX3(align, linesize_align[1], linesize_align[2]);
+ *width=FFALIGN(*width, align);
}
int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h){
avcodec_get_chroma_sub_sample(s->pix_fmt, &h_chroma_shift, &v_chroma_shift);
- avcodec_align_dimensions(s, &w, &h);
+ avcodec_align_dimensions2(s, &w, &h, stride_align);
if(!(s->flags&CODEC_FLAG_EMU_EDGE)){
w+= EDGE_WIDTH*2;
unaligned = 0;
for (i=0; i<4; i++){
-//STRIDE_ALIGN is 8 for SSE* but this does not work for SVQ1 chroma planes
-//we could change STRIDE_ALIGN to 16 for x86/sse but it would increase the
-//picture size unneccessarily in some cases. The solution here is not
-//pretty and better ideas are welcome!
-#if HAVE_MMX
- if(s->codec_id == CODEC_ID_SVQ1)
- stride_align[i]= 16;
- else
-#endif
- stride_align[i] = STRIDE_ALIGN;
unaligned |= picture.linesize[i] % stride_align[i];
}
} while (unaligned);
}
avctx->codec = codec;
- if ((avctx->codec_type == CODEC_TYPE_UNKNOWN || avctx->codec_type == codec->type) &&
+ if ((avctx->codec_type == AVMEDIA_TYPE_UNKNOWN || avctx->codec_type == codec->type) &&
avctx->codec_id == CODEC_ID_NONE) {
avctx->codec_type = codec->type;
avctx->codec_id = codec->id;
return ret;
}
-int avcodec_close(AVCodecContext *avctx)
+av_cold int avcodec_close(AVCodecContext *avctx)
{
/* If there is a user-supplied mutex locking routine, call it. */
if (ff_lockmgr_cb) {
avctx->codec->close(avctx);
avcodec_default_free_buffers(avctx);
av_freep(&avctx->priv_data);
+ if(avctx->codec->encode)
+ av_freep(&avctx->extradata);
avctx->codec = NULL;
entangled_thread_counter--;
return NULL;
}
-int av_get_bit_rate(AVCodecContext *ctx)
+static int get_bit_rate(AVCodecContext *ctx)
{
int bit_rate;
int bits_per_sample;
switch(ctx->codec_type) {
- case CODEC_TYPE_VIDEO:
+ case AVMEDIA_TYPE_VIDEO:
bit_rate = ctx->bit_rate;
break;
- case CODEC_TYPE_AUDIO:
+ case AVMEDIA_TYPE_AUDIO:
bits_per_sample = av_get_bits_per_sample(ctx->codec_id);
bit_rate = bits_per_sample ? ctx->sample_rate * ctx->channels * bits_per_sample : ctx->bit_rate;
break;
- case CODEC_TYPE_DATA:
+ case AVMEDIA_TYPE_DATA:
bit_rate = ctx->bit_rate;
break;
- case CODEC_TYPE_SUBTITLE:
+ case AVMEDIA_TYPE_SUBTITLE:
bit_rate = ctx->bit_rate;
break;
- case CODEC_TYPE_ATTACHMENT:
+ case AVMEDIA_TYPE_ATTACHMENT:
bit_rate = ctx->bit_rate;
break;
default:
}
switch(enc->codec_type) {
- case CODEC_TYPE_VIDEO:
+ case AVMEDIA_TYPE_VIDEO:
snprintf(buf, buf_size,
"Video: %s%s",
codec_name, enc->mb_decision ? " (hq)" : "");
", q=%d-%d", enc->qmin, enc->qmax);
}
break;
- case CODEC_TYPE_AUDIO:
+ case AVMEDIA_TYPE_AUDIO:
snprintf(buf, buf_size,
"Audio: %s",
codec_name);
", %s", avcodec_get_sample_fmt_name(enc->sample_fmt));
}
break;
- case CODEC_TYPE_DATA:
+ case AVMEDIA_TYPE_DATA:
snprintf(buf, buf_size, "Data: %s", codec_name);
break;
- case CODEC_TYPE_SUBTITLE:
+ case AVMEDIA_TYPE_SUBTITLE:
snprintf(buf, buf_size, "Subtitle: %s", codec_name);
break;
- case CODEC_TYPE_ATTACHMENT:
+ case AVMEDIA_TYPE_ATTACHMENT:
snprintf(buf, buf_size, "Attachment: %s", codec_name);
break;
default:
snprintf(buf + strlen(buf), buf_size - strlen(buf),
", pass 2");
}
- bitrate = av_get_bit_rate(enc);
+ bitrate = get_bit_rate(enc);
if (bitrate != 0) {
snprintf(buf + strlen(buf), buf_size - strlen(buf),
", %d kb/s", bitrate / 1000);
return 0;
}
+int ff_match_2uint16(const uint16_t (*tab)[2], int size, int a, int b){
+ int i;
+ for(i=0; i<size && !(tab[i][0]==a && tab[i][1]==b); i++);
+ return i;
+}
+
void av_log_missing_feature(void *avc, const char *feature, int want_sample)
{
av_log(avc, AV_LOG_WARNING, "%s not implemented. Update your FFmpeg "