From a33c7159e1630ecef81c71e3f2624f09e7d2a413 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sun, 12 Jan 2003 00:48:29 +0000 Subject: [PATCH] get_format() Originally committed as revision 1451 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/avcodec.h | 10 ++++++++++ libavcodec/mpegvideo.c | 2 ++ libavcodec/mpegvideo.h | 1 + libavcodec/utils.c | 5 +++++ 4 files changed, 18 insertions(+) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 2b36aeb8c1..72d6d32efb 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -923,6 +923,16 @@ typedef struct AVCodecContext { */ int me_subpel_quality; + /** + * callback to negotiate the pixelFormat + * @param fmt is the list of formats which are supported by the codec, + * its terminated by -1 as 0 is a valid format, the formats are ordered by quality + * the first is allways the native one + * @return the choosen format + * encoding: unused + * decoding: set by user, if not set then the native format will always be choosen + */ + enum PixelFormat (*get_format)(struct AVCodecContext *s, enum PixelFormat * fmt); } AVCodecContext; typedef struct AVCodec { diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 8206df470e..c668121246 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -86,6 +86,8 @@ static const uint8_t h263_chroma_roundtab[16] = { static UINT16 (*default_mv_penalty)[MAX_MV*2+1]=NULL; static UINT8 default_fcode_tab[MAX_MV*2+1]; +enum PixelFormat ff_yuv420p_list[2]= {PIX_FMT_YUV420P, -1}; + static void convert_matrix(MpegEncContext *s, int (*qmat)[64], uint16_t (*qmat16)[64], uint16_t (*qmat16_bias)[64], const UINT16 *quant_matrix, int bias, int qmin, int qmax) { diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index e6909817aa..147b36a3b5 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -597,6 +597,7 @@ void ff_emulated_edge_mc(MpegEncContext *s, UINT8 *src, int linesize, int block_ int src_x, int src_y, int w, int h); char ff_get_pict_type_char(int pict_type); +extern enum PixelFormat ff_yuv420p_list[2]; extern int ff_bit_exact; diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 1b532fc94c..ba47785ffc 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -185,6 +185,10 @@ void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic){ //printf("R%X\n", pic->opaque); } +enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, enum PixelFormat * fmt){ + return fmt[0]; +} + void avcodec_get_context_defaults(AVCodecContext *s){ s->bit_rate= 800*1000; s->bit_rate_tolerance= s->bit_rate*10; @@ -207,6 +211,7 @@ void avcodec_get_context_defaults(AVCodecContext *s){ s->me_method= ME_EPZS; s->get_buffer= avcodec_default_get_buffer; s->release_buffer= avcodec_default_release_buffer; + s->get_format= avcodec_default_get_format; s->me_subpel_quality=8; }