[Title] Add api index for checking sdk version between host and guest.
authorKitae Kim <kt920.kim@samsung.com>
Tue, 8 May 2012 11:11:31 +0000 (20:11 +0900)
committerKitae Kim <kt920.kim@samsung.com>
Tue, 8 May 2012 11:11:31 +0000 (20:11 +0900)
[Type] enhancement
[Module] emulator / codec
[Priority] major
[CQ#]
[Redmine#]
[Problem]
[Cause]
[Solution]
[TestCase]

tizen/distrib/libav/include/libavcodec/version.h [new file with mode: 0644]
tizen/distrib/libav/libavcodec/version.h [new file with mode: 0644]
tizen/src/hw/maru_codec.c
tizen/src/hw/maru_codec.h

diff --git a/tizen/distrib/libav/include/libavcodec/version.h b/tizen/distrib/libav/include/libavcodec/version.h
new file mode 100644 (file)
index 0000000..aded68e
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_VERSION_H
+#define AVCODEC_VERSION_H
+
+#define LIBAVCODEC_VERSION_MAJOR 53
+#define LIBAVCODEC_VERSION_MINOR  5
+#define LIBAVCODEC_VERSION_MICRO  0
+
+#define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
+                                               LIBAVCODEC_VERSION_MINOR, \
+                                               LIBAVCODEC_VERSION_MICRO)
+#define LIBAVCODEC_VERSION      AV_VERSION(LIBAVCODEC_VERSION_MAJOR,    \
+                                           LIBAVCODEC_VERSION_MINOR,    \
+                                           LIBAVCODEC_VERSION_MICRO)
+#define LIBAVCODEC_BUILD        LIBAVCODEC_VERSION_INT
+
+#define LIBAVCODEC_IDENT        "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION)
+
+/**
+ * Those FF_API_* defines are not part of public API.
+ * They may change, break or disappear at any time.
+ */
+#ifndef FF_API_PALETTE_CONTROL
+#define FF_API_PALETTE_CONTROL  (LIBAVCODEC_VERSION_MAJOR < 54)
+#endif
+#ifndef FF_API_OLD_SAMPLE_FMT
+#define FF_API_OLD_SAMPLE_FMT   (LIBAVCODEC_VERSION_MAJOR < 54)
+#endif
+#ifndef FF_API_OLD_AUDIOCONVERT
+#define FF_API_OLD_AUDIOCONVERT (LIBAVCODEC_VERSION_MAJOR < 54)
+#endif
+#ifndef FF_API_ANTIALIAS_ALGO
+#define FF_API_ANTIALIAS_ALGO   (LIBAVCODEC_VERSION_MAJOR < 54)
+#endif
+#ifndef FF_API_REQUEST_CHANNELS
+#define FF_API_REQUEST_CHANNELS (LIBAVCODEC_VERSION_MAJOR < 54)
+#endif
+#ifndef FF_API_OPT_H
+#define FF_API_OPT_H            (LIBAVCODEC_VERSION_MAJOR < 54)
+#endif
+#ifndef FF_API_THREAD_INIT
+#define FF_API_THREAD_INIT      (LIBAVCODEC_VERSION_MAJOR < 54)
+#endif
+#ifndef FF_API_OLD_FF_PICT_TYPES
+#define FF_API_OLD_FF_PICT_TYPES (LIBAVCODEC_VERSION_MAJOR < 54)
+#endif
+#ifndef FF_API_FLAC_GLOBAL_OPTS
+#define FF_API_FLAC_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54)
+#endif
+#ifndef FF_API_GET_PIX_FMT_NAME
+#define FF_API_GET_PIX_FMT_NAME (LIBAVCODEC_VERSION_MAJOR < 54)
+#endif
+
+#endif /* AVCODEC_VERSION_H */
diff --git a/tizen/distrib/libav/libavcodec/version.h b/tizen/distrib/libav/libavcodec/version.h
new file mode 100644 (file)
index 0000000..aded68e
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_VERSION_H
+#define AVCODEC_VERSION_H
+
+#define LIBAVCODEC_VERSION_MAJOR 53
+#define LIBAVCODEC_VERSION_MINOR  5
+#define LIBAVCODEC_VERSION_MICRO  0
+
+#define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
+                                               LIBAVCODEC_VERSION_MINOR, \
+                                               LIBAVCODEC_VERSION_MICRO)
+#define LIBAVCODEC_VERSION      AV_VERSION(LIBAVCODEC_VERSION_MAJOR,    \
+                                           LIBAVCODEC_VERSION_MINOR,    \
+                                           LIBAVCODEC_VERSION_MICRO)
+#define LIBAVCODEC_BUILD        LIBAVCODEC_VERSION_INT
+
+#define LIBAVCODEC_IDENT        "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION)
+
+/**
+ * Those FF_API_* defines are not part of public API.
+ * They may change, break or disappear at any time.
+ */
+#ifndef FF_API_PALETTE_CONTROL
+#define FF_API_PALETTE_CONTROL  (LIBAVCODEC_VERSION_MAJOR < 54)
+#endif
+#ifndef FF_API_OLD_SAMPLE_FMT
+#define FF_API_OLD_SAMPLE_FMT   (LIBAVCODEC_VERSION_MAJOR < 54)
+#endif
+#ifndef FF_API_OLD_AUDIOCONVERT
+#define FF_API_OLD_AUDIOCONVERT (LIBAVCODEC_VERSION_MAJOR < 54)
+#endif
+#ifndef FF_API_ANTIALIAS_ALGO
+#define FF_API_ANTIALIAS_ALGO   (LIBAVCODEC_VERSION_MAJOR < 54)
+#endif
+#ifndef FF_API_REQUEST_CHANNELS
+#define FF_API_REQUEST_CHANNELS (LIBAVCODEC_VERSION_MAJOR < 54)
+#endif
+#ifndef FF_API_OPT_H
+#define FF_API_OPT_H            (LIBAVCODEC_VERSION_MAJOR < 54)
+#endif
+#ifndef FF_API_THREAD_INIT
+#define FF_API_THREAD_INIT      (LIBAVCODEC_VERSION_MAJOR < 54)
+#endif
+#ifndef FF_API_OLD_FF_PICT_TYPES
+#define FF_API_OLD_FF_PICT_TYPES (LIBAVCODEC_VERSION_MAJOR < 54)
+#endif
+#ifndef FF_API_FLAC_GLOBAL_OPTS
+#define FF_API_FLAC_GLOBAL_OPTS (LIBAVCODEC_VERSION_MAJOR < 54)
+#endif
+#ifndef FF_API_GET_PIX_FMT_NAME
+#define FF_API_GET_PIX_FMT_NAME (LIBAVCODEC_VERSION_MAJOR < 54)
+#endif
+
+#endif /* AVCODEC_VERSION_H */
index 76f3af6..ce5d2da 100644 (file)
  */
 
 #include "maru_codec.h"
-#include <pthread.h>
 
-#define QEMU_DEV_NAME   "codec"
-#define MARU_CODEC_VERSION "1.0"
+#define MARU_CODEC_DEV_NAME     "codec"
+#define MARU_CODEC_VERSION      "1.0"
 
 /*  Needs 16M to support 1920x1080 video resolution.
  *  Output size for encoding has to be greater than (width * height * 6)
@@ -44,8 +43,6 @@
 
 #define MARU_ROUND_UP_16(num)   (((num) + 15) & ~15)
 
-#define CODEC_DUMMY
-
 /* define debug channel */
 MULTI_DEBUG_CHANNEL(qemu, marucodec);
 
@@ -69,7 +66,6 @@ static void qemu_codec_close (SVCodecState *s, uint32_t value)
     int ctxIndex = 0;
 
     TRACE("[%s] Enter\n", __func__);
-
     pthread_mutex_lock(&s->codec_mutex);
 
     for (i = 0; i < CODEC_MAX_CONTEXT; i++) {
@@ -78,18 +74,17 @@ static void qemu_codec_close (SVCodecState *s, uint32_t value)
             break;
         }
     }
-
     TRACE("[%s] Close %d context\n", __func__, ctxIndex);
 
     s->ctxArr[ctxIndex].bUsed = false;
     qemu_parser_init(s, ctxIndex);
 
     pthread_mutex_unlock(&s->codec_mutex);
-
     TRACE("[%s] Leave\n", __func__);
 }
 
-static void qemu_restore_context (AVCodecContext *dst, AVCodecContext *src) {
+static void qemu_restore_context (AVCodecContext *dst, AVCodecContext *src)
+{
     TRACE("[%s] Enter\n", __func__);
 
     dst->av_class = src->av_class;
@@ -123,6 +118,19 @@ static void qemu_restore_context (AVCodecContext *dst, AVCodecContext *src) {
     TRACE("[%s] Leave\n", __func__);
 }
 
+void qemu_get_codec_ver (SVCodecState *s, int ctxIndex)
+{
+    char codec_ver[32];
+    off_t offset;
+
+    offset = s->codecParam.mmapOffset;
+
+    memset(codec_ver, 0x00, 32);
+    strncpy(codec_ver, MARU_CODEC_VERSION, strlen(MARU_CODEC_VERSION));
+    printf("codec_version:%s\n", codec_ver);
+    memcpy((uint8_t*)s->vaddr + offset, codec_ver, 32);
+}
+
 /* void av_register_all() */
 static void qemu_av_register_all (void)
 {
@@ -216,7 +224,9 @@ static int qemu_avcodec_open (SVCodecState *s, int ctxIndex)
 static int qemu_avcodec_open (SVCodecState *s, int ctxIndex)
 {
     AVCodecContext *avctx;
+#ifndef CODEC_COPY_DATA
     AVCodecContext tempCtx;
+#endif
     AVCodec *codec;
     enum CodecID codec_id;
     off_t offset;
@@ -236,7 +246,7 @@ static int qemu_avcodec_open (SVCodecState *s, int ctxIndex)
 
     TRACE("[%s] Context Index:%d, offset:%d\n", __func__, ctxIndex, offset);
 
-#ifndef CODEC_DUMMY
+#ifndef CODEC_COPY_DATA
     size = sizeof(AVCodecContext);
     memcpy(&tempCtx, avctx, size);
     memcpy(avctx, (uint8_t*)s->vaddr + offset, size);
@@ -327,7 +337,7 @@ static int qemu_avcodec_open (SVCodecState *s, int ctxIndex)
               avctx->sample_rate, avctx->channels);
     }
 
-#ifndef CODEC_DUMMY
+#ifndef CODEC_COPY_DATA
     memcpy((uint8_t*)s->vaddr + offset, avctx, sizeof(AVCodecContext));
     memcpy((uint8_t*)s->vaddr + offset + sizeof(AVCodecContext), &ret, sizeof(int));
 #else
@@ -674,7 +684,7 @@ static int qemu_avcodec_decode_video (SVCodecState* s, int ctxIndex)
         TRACE("[%s] There is no frame\n", __func__);
     }
 
-#ifndef CODEC_DUMMY
+#ifndef CODEC_COPY_DATA
     size = sizeof(AVCodecContext);
     memcpy((uint8_t*)s->vaddr + offset, avctx, size);
 #else
@@ -932,7 +942,7 @@ static int qemu_avcodec_decode_audio (SVCodecState *s, int ctxIndex)
     ret = avcodec_decode_audio3(avctx, samples, &frame_size_ptr, &avpkt);
     TRACE("After decoding audio!, ret:%d\n", ret);
 
-#ifndef CODEC_DUMMY
+#ifndef CODEC_COPY_DATA
     size = sizeof(AVCodecContext);
     memcpy((uint8_t*)s->vaddr + offset, avctx, size);
 #else
@@ -1209,7 +1219,7 @@ static int qemu_av_parser_parse (SVCodecState *s, int ctxIndex)
     }
 
     TRACE("[%s] inbuf : %p, outbuf : %p\n", __func__, inbuf, poutbuf);
-#ifndef CODEC_DUMMY
+#ifndef CODEC_COPY_DATA
 //    memcpy((uint8_t*)s->vaddr + offset, parserctx, sizeof(AVCodecParserContext));
 //    size = sizeof(AVCodecParserContext);
     memcpy((uint8_t*)s->vaddr + offset, &parserctx->pts, sizeof(int64_t));
@@ -1258,7 +1268,6 @@ static void qemu_av_parser_close (SVCodecState *s, int ctxIndex)
     }
     av_parser_close(parserctx);
     pthread_mutex_unlock(&s->codec_mutex);
-
 }
 
 static int codec_operate (uint32_t apiIndex, uint32_t ctxIndex, SVCodecState *state)
@@ -1323,6 +1332,9 @@ static int codec_operate (uint32_t apiIndex, uint32_t ctxIndex, SVCodecState *st
         case EMUL_AV_PARSER_CLOSE:
             qemu_av_parser_close(state, ctxIndex);
             break;
+        case EMUL_GET_CODEC_VER:
+            qemu_get_codec_ver(state, ctxIndex);
+            break;
         default:
             WARN("The api index does not exsit!. api index:%d\n", apiIndex);
     }
@@ -1336,7 +1348,7 @@ uint64_t codec_read (void *opaque, target_phys_addr_t addr, unsigned size)
 {
     switch (addr) {
         default:
-            ERR("There is no avaiable command for %s\n", QEMU_DEV_NAME);
+            ERR("There is no avaiable command for %s\n", MARU_CODEC_DEV_NAME);
     }
     return 0;
 }
@@ -1379,7 +1391,7 @@ void codec_write (void *opaque, target_phys_addr_t addr, uint64_t value, unsigne
             qemu_codec_close(state, value);
             break;
         default:
-            ERR("There is no avaiable command for %s\n", QEMU_DEV_NAME);
+            ERR("There is no avaiable command for %s\n", MARU_CODEC_DEV_NAME);
     }
 }
 
@@ -1425,12 +1437,12 @@ static int codec_exitfn (PCIDevice *dev)
 int codec_init (PCIBus *bus)
 {
     INFO("[%s] device create\n", __func__);
-    pci_create_simple (bus, -1, QEMU_DEV_NAME);
+    pci_create_simple (bus, -1, MARU_CODEC_DEV_NAME);
     return 0;
 }
 
 static PCIDeviceInfo codec_info = {
-    .qdev.name      = QEMU_DEV_NAME,
+    .qdev.name      = MARU_CODEC_DEV_NAME,
     .qdev.desc      = "Virtual Codec device for Tizen emulator",
     .qdev.size      = sizeof (SVCodecState),
     .init           = codec_initfn,
index 203659a..8d55cd7 100644 (file)
@@ -41,6 +41,7 @@
 #include <libavformat/avformat.h>
 
 #define CODEC_MAX_CONTEXT   10
+#define CODEC_COPY_DATA
 
 /*
  *  Codec Device Structures
@@ -109,6 +110,7 @@ enum {
     EMUL_AV_PARSER_INIT,
     EMUL_AV_PARSER_PARSE,
     EMUL_AV_PARSER_CLOSE,
+    EMUL_GET_CODEC_VER = 50,
 };