diff --git a/libavcodec/dvdata.c b/libavcodec/dvdata.c
index b29f5ce53f448272833659d592da663abc14336e..f292d4bf197e7a3503c02d00a56cda618a48c7e0 100644
--- a/libavcodec/dvdata.c
+++ b/libavcodec/dvdata.c
@@ -287,9 +287,9 @@ const DVprofile* avpriv_dv_codec_profile(AVCodecContext* codec)
     int i;
 
     for (i=0; i<FF_ARRAY_ELEMS(dv_profiles); i++)
-       if (codec->height  == dv_profiles[i].height  &&
-           codec->pix_fmt == dv_profiles[i].pix_fmt &&
-           codec->width   == dv_profiles[i].width)
+       if (codec->coded_height == dv_profiles[i].height  &&
+           codec->pix_fmt      == dv_profiles[i].pix_fmt &&
+           codec->coded_width  == dv_profiles[i].width)
                return &dv_profiles[i];
 
     return NULL;
diff --git a/libavformat/dv.c b/libavformat/dv.c
index 69c0de95c3122299a934ce77ead043f2ba5eb5df..d99dee37824be6ea7cad387cdbf7f7b2323b3573 100644
--- a/libavformat/dv.c
+++ b/libavformat/dv.c
@@ -251,10 +251,8 @@ static int dv_extract_video_info(DVDemuxContext *c, uint8_t* frame)
         avpriv_set_pts_info(c->vst, 64, c->sys->time_base.num,
                         c->sys->time_base.den);
         avctx->time_base= c->sys->time_base;
-        if (!avctx->width){
-            avctx->width = c->sys->width;
-            avctx->height = c->sys->height;
-        }
+        if (!avctx->width)
+            avcodec_set_dimensions(avctx, c->sys->width, c->sys->height);
         avctx->pix_fmt = c->sys->pix_fmt;
 
         /* finding out SAR is a little bit messy */