Set bitrate for encoder 77/262977/1 accepted/tizen/6.5/unified/20211028.101251 accepted/tizen/unified/20210826.024543 submit/tizen/20210825.051606 submit/tizen_6.5/20211028.161801 tizen_6.5.m2_release
authorJeongmo Yang <jm80.yang@samsung.com>
Mon, 2 Aug 2021 09:16:39 +0000 (18:16 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Tue, 24 Aug 2021 07:38:04 +0000 (16:38 +0900)
[Version] 0.6.21
[Issue Type] Bug fix

Change-Id: I441c5dfc9fab3736f2c6ad662bd24c2bb9a0a4a4
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/capi-media-codec.spec
src/media_codec_port.c
src/media_codec_port_gst.c
test/media_codec_test.c

index cf5fbf3..4a500a5 100644 (file)
@@ -4,7 +4,7 @@
 
 Name:       capi-media-codec
 Summary:    A Media Codec library in Tizen Native API
-Version:    0.6.20
+Version:    0.6.21
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 70b5cc3..cadd8e6 100644 (file)
@@ -171,8 +171,10 @@ int mc_set_vdec_info(MMHandleType mediacodec, int width, int height)
                return MC_INVALID_ARG;
        }
 
-       if (!_check_support_video_info(mc_handle->codec_id, width, height))
+       if (!_check_support_video_info(mc_handle->codec_id, width, height)) {
+               LOGE("invaild param[res %dx%d]", width, height);
                return MC_PARAM_ERROR;
+       }
 
        MEDIACODEC_CHECK_CONDITION(mc_handle->codec_id && mc_handle->is_video && !mc_handle->is_encoder,
                        MC_INVALID_ARG, "MEDIACODEC_ERROR_INVALID_PARAMETER");
@@ -195,8 +197,10 @@ int mc_set_venc_info(MMHandleType mediacodec, int width, int height, int fps, in
                return MC_INVALID_ARG;
        }
 
-       if (!_check_support_video_info(mc_handle->codec_id, width, height) || fps < 0 || target_bits < 0)
+       if (!_check_support_video_info(mc_handle->codec_id, width, height) || fps < 0 || target_bits < 0) {
+               LOGE("invaild param[res %dx%d, fps %d, target_bits %d]", width, height, fps, target_bits);
                return MC_PARAM_ERROR;
+       }
 
        MEDIACODEC_CHECK_CONDITION(mc_handle->codec_id && mc_handle->is_video && mc_handle->is_encoder,
                        MC_INVALID_ARG, "MEDIACODEC_ERROR_INVALID_PARAMETER");
@@ -220,8 +224,10 @@ int mc_set_adec_info(MMHandleType mediacodec, int samplerate, int channel, int b
                return MC_INVALID_ARG;
        }
 
-       if (!_check_support_audio_info(mc_handle->codec_id, samplerate, channel, bit))
+       if (!_check_support_audio_info(mc_handle->codec_id, samplerate, channel, bit)) {
+               LOGE("invaild param[samplerate %d, channel %d, bit %d]", samplerate, channel, bit);
                return MC_PARAM_ERROR;
+       }
 
        MEDIACODEC_CHECK_CONDITION(mc_handle->codec_id && !mc_handle->is_video && !mc_handle->is_encoder,
                        MC_INVALID_ARG, "MEDIACODEC_ERROR_INVALID_PARAMETER");
@@ -244,8 +250,10 @@ int mc_set_aenc_info(MMHandleType mediacodec, int samplerate, int channel, int b
                return MC_INVALID_ARG;
        }
 
-       if (!_check_support_audio_info(mc_handle->codec_id, samplerate, channel, bit))
+       if (!_check_support_audio_info(mc_handle->codec_id, samplerate, channel, bit) || bitrate < 0) {
+               LOGE("invaild param[samplerate %d, channel %d, bit %d, bitrate %d]", samplerate, channel, bit, bitrate);
                return MC_PARAM_ERROR;
+       }
 
        MEDIACODEC_CHECK_CONDITION(mc_handle->codec_id && !mc_handle->is_video && mc_handle->is_encoder,
                        MC_INVALID_ARG, "MEDIACODEC_ERROR_INVALID_PARAMETER");
index 110003f..2746bec 100644 (file)
@@ -1696,24 +1696,24 @@ media_packet_h _mc_get_input_buffer(mc_gst_core_t *core)
 
 mc_ret_e mc_gst_prepare(mc_handle_t *mc_handle)
 {
-       MEDIACODEC_FENTER();
-
        int ret = MC_ERROR_NONE;
-       media_format_mimetype_e out_mime;
        int num_supported_codec = 0;
        int i = 0;
-       GstCaps *caps = NULL;
-
-       if (!mc_handle)
-               return MC_PARAM_ERROR;
-
-       mediacodec_codec_type_e id;
+       int bitrate = 0;
        bool video;
        bool encoder;
        bool hardware;
        gchar *factory_name = NULL;
+       GstCaps *caps = NULL;
+       media_format_mimetype_e out_mime;
+       mediacodec_codec_type_e id;
        mc_codec_map_t *codec_map;
 
+       MEDIACODEC_FENTER();
+
+       if (!mc_handle)
+               return MC_PARAM_ERROR;
+
        id = mc_handle->codec_id;
        video = mc_handle->is_video;
        encoder = mc_handle->is_encoder;
@@ -1801,6 +1801,17 @@ mc_ret_e mc_gst_prepare(mc_handle_t *mc_handle)
        g_object_set(new_core->capsfilter, "caps", caps, NULL);
        gst_caps_unref(caps);
 
+       if (new_core->encoder) {
+               if (new_core->video)
+                       bitrate = mc_handle->info.video.bitrate;
+               else
+                       bitrate = mc_handle->info.audio.bitrate;
+
+               LOGI("set encoder bitrate[v:%d] %d", new_core->video, bitrate);
+
+               g_object_set(new_core->codec, "bitrate", bitrate, NULL);
+       }
+
        mc_handle->core = new_core;
        LOGD("initialized... %d", ret);
        MEDIACODEC_FLEAVE();
index b02cd3e..9c77527 100644 (file)
@@ -2246,7 +2246,7 @@ void interpret(char *cmd)
                int len;
                if (cnt == 0) {
                        len = strlen(cmd);
-                       strncpy(app->filepath, cmd, len + 1);
+                       strncpy(app->filepath, cmd, sizeof(app->filepath) - 1);
                        g_print("%s, %d\n", app->filepath, len);
                        cnt++;
                } else if (cnt == 1) {