diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 2b36aeb8c140479b7b24a6d7296841928e430e13..72d6d32efb5c0df16ab1a9879d48df4e95ce5c1b 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 8206df470ee3a959b97a2c9e7b3ec603e0b6a675..c6681212461c0d3b4a0f04af33e597f29a548de7 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 e6909817aa7d29c6bf057f0e8cb9bcee60fa344d..147b36a3b5281a7d16d7f4d0bcadd5eb8211e015 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 1b532fc94cdacc547eaa6e225f8dc937500d47e1..ba47785ffca251684e73a35a07cbebc7db82b926 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;
 }