]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/ptx.c
Port libmpcodec fixes from MPlayer.
[ffmpeg] / libavcodec / ptx.c
index 2ab45b08a7c4b0eeae6ed7903b31714b332aca3c..3273fd2f8e4679ff076bcda4496d28c828ac3f50 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include "libavutil/intreadwrite.h"
+#include "libavutil/imgutils.h"
 #include "avcodec.h"
 
 typedef struct PTXContext {
@@ -36,7 +37,8 @@ static av_cold int ptx_init(AVCodecContext *avctx) {
 }
 
 static int ptx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
-                            const uint8_t *buf, int buf_size) {
+                            AVPacket *avpkt) {
+    const uint8_t *buf = avpkt->data;
     PTXContext * const s = avctx->priv_data;
     AVFrame *picture = data;
     AVFrame * const p = &s->picture;
@@ -49,21 +51,21 @@ static int ptx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
     bytes_per_pixel = AV_RL16(buf+12) >> 3;
 
     if (bytes_per_pixel != 2) {
-        av_log(avctx, AV_LOG_ERROR, "image format is not rgb15, please report on ffmpeg-users mailing list\n");
+        av_log_ask_for_sample(avctx, "Image format is not RGB15.\n");
         return -1;
     }
 
     avctx->pix_fmt = PIX_FMT_RGB555;
 
     if (offset != 0x2c)
-        av_log(avctx, AV_LOG_WARNING, "offset != 0x2c, untested due to lack of sample files\n");
+        av_log_ask_for_sample(avctx, "offset != 0x2c\n");
 
     buf += offset;
 
     if (p->data[0])
         avctx->release_buffer(avctx, p);
 
-    if (avcodec_check_dimensions(avctx, w, h))
+    if (av_image_check_size(w, h, 0, avctx))
         return -1;
     if (w != avctx->width || h != avctx->height)
         avcodec_set_dimensions(avctx, w, h);
@@ -72,13 +74,13 @@ static int ptx_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
         return -1;
     }
 
-    p->pict_type = FF_I_TYPE;
+    p->pict_type = AV_PICTURE_TYPE_I;
 
     ptr    = p->data[0];
     stride = p->linesize[0];
 
     for (y=0; y<h; y++) {
-#ifdef WORDS_BIGENDIAN
+#if HAVE_BIGENDIAN
         unsigned int x;
         for (x=0; x<w*bytes_per_pixel; x+=bytes_per_pixel)
             AV_WN16(ptr+x, AV_RL16(buf+x));
@@ -104,16 +106,16 @@ static av_cold int ptx_end(AVCodecContext *avctx) {
     return 0;
 }
 
-AVCodec ptx_decoder = {
+AVCodec ff_ptx_decoder = {
     "ptx",
-    CODEC_TYPE_VIDEO,
+    AVMEDIA_TYPE_VIDEO,
     CODEC_ID_PTX,
     sizeof(PTXContext),
     ptx_init,
     NULL,
     ptx_end,
     ptx_decode_frame,
-    0,
+    CODEC_CAP_DR1,
     NULL,
     .long_name = NULL_IF_CONFIG_SMALL("V.Flash PTX image"),
 };