]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/dxv.c
Merge commit 'bbf71d46db3417b43bcbd745cbf235e8e2ff69ae'
[ffmpeg] / libavcodec / dxv.c
index e20e940fedc794bef7ed88355ce6d03b9c1f1f67..76b3054fef62f5c21b1241bb9410a0ff93a8706a 100644 (file)
@@ -321,8 +321,10 @@ static int dxv_decode(AVCodecContext *avctx, void *data,
     ThreadFrame tframe;
     GetByteContext *gbc = &ctx->gbc;
     int (*decompress_tex)(AVCodecContext *avctx);
+    const char *msgcomp, *msgtext;
     uint32_t tag;
-    int channels, size = 0, old_type = 0;
+    int version_major, version_minor = 0;
+    int size = 0, old_type = 0;
     int ret;
 
     bytestream2_init(gbc, avpkt->data, avpkt->size);
@@ -334,14 +336,16 @@ static int dxv_decode(AVCodecContext *avctx, void *data,
         ctx->tex_funct = ctx->texdsp.dxt1_block;
         ctx->tex_rat   = 8;
         ctx->tex_step  = 8;
-        av_log(avctx, AV_LOG_DEBUG, "DXTR1 compression and DXT1 texture ");
+        msgcomp = "DXTR1";
+        msgtext = "DXT1";
         break;
     case MKBETAG('D', 'X', 'T', '5'):
         decompress_tex = dxv_decompress_dxt5;
         ctx->tex_funct = ctx->texdsp.dxt5_block;
         ctx->tex_rat   = 4;
         ctx->tex_step  = 16;
-        av_log(avctx, AV_LOG_DEBUG, "DXTR5 compression and DXT5 texture ");
+        msgcomp = "DXTR5";
+        msgtext = "DXT5";
         break;
     case MKBETAG('Y', 'C', 'G', '6'):
     case MKBETAG('Y', 'G', '1', '0'):
@@ -351,13 +355,17 @@ static int dxv_decode(AVCodecContext *avctx, void *data,
         /* Old version does not have a real header, just size and type. */
         size = tag & 0x00FFFFFF;
         old_type = tag >> 24;
-        channels = old_type & 0x0F;
+        version_major = (old_type & 0x0F) - 1;
+        msgcomp = "LZF";
+
         if (old_type & 0x40) {
-            av_log(avctx, AV_LOG_DEBUG, "LZF compression and DXT5 texture ");
+            msgtext = "DXT5";
+
             ctx->tex_funct = ctx->texdsp.dxt5_block;
             ctx->tex_step  = 16;
-        } else if (old_type & 0x20 || old_type & 0x2) {
-            av_log(avctx, AV_LOG_DEBUG, "LZF compression and DXT1 texture ");
+        } else if (old_type & 0x20 || version_major == 1) {
+            msgtext = "DXT1";
+
             ctx->tex_funct = ctx->texdsp.dxt1_block;
             ctx->tex_step  = 8;
         } else {
@@ -371,11 +379,15 @@ static int dxv_decode(AVCodecContext *avctx, void *data,
 
     /* New header is 12 bytes long. */
     if (!old_type) {
-        channels = bytestream2_get_byte(gbc);
-        bytestream2_skip(gbc, 3); // unknown
+        version_major = bytestream2_get_byte(gbc) - 1;
+        version_minor = bytestream2_get_byte(gbc);
+
+        bytestream2_skip(gbc, 2); // unknown
         size = bytestream2_get_le32(gbc);
     }
-    av_log(avctx, AV_LOG_DEBUG, "(%d channels)\n", channels);
+    av_log(avctx, AV_LOG_DEBUG,
+           "%s compression with %s texture (version %d.%d)\n",
+           msgcomp, msgtext, version_major, version_minor);
 
     if (size != bytestream2_get_bytes_left(gbc)) {
         av_log(avctx, AV_LOG_ERROR, "Incomplete or invalid file (%u > %u)\n.",
@@ -397,8 +409,6 @@ static int dxv_decode(AVCodecContext *avctx, void *data,
     ret = ff_thread_get_buffer(avctx, &tframe, 0);
     if (ret < 0)
         return ret;
-    if (avctx->codec->update_thread_context)
-        ff_thread_finish_setup(avctx);
 
     /* Now decompress the texture with the standard functions. */
     avctx->execute2(avctx, decompress_texture_thread,