Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compat: media: Send CSD data separately to en/decoder #16

Open
wants to merge 1 commit into
base: halium-9.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions compat/media/media_codec_layer.cpp
Original file line number Diff line number Diff line change
@@ -352,17 +352,19 @@ int media_codec_configure(MediaCodecDelegate delegate, MediaFormat format, Surfa
if (format_priv->max_input_size > 0)
aformat->setInt32("max-input-size", format_priv->max_input_size);

if (format_priv->csd.get() != NULL) {
const size_t csd_size = format_priv->csd->size();
for (auto it = format_priv->csd.begin(); it != format_priv->csd.end(); it++) {
const AString key = it->first;
const sp<ABuffer> csd = it->second;
const size_t csd_size = csd->size();

ALOGD("Adding csd (%zu bytes)", csd_size);

sp<ABuffer> buffer = new ABuffer(csd_size);
memcpy(buffer->data(), format_priv->csd->data(), csd_size);
memcpy(buffer->data(), csd->data(), csd_size);

buffer->meta()->setInt32("csd", true);
buffer->meta()->setInt64("timeUs", 0);
aformat->setBuffer("csd-0", buffer);
aformat->setBuffer(key.c_str(), buffer);
}

ALOGD("Format: %s", aformat->debugString().c_str());
@@ -433,7 +435,6 @@ int media_codec_queue_csd(MediaCodecDelegate delegate, MediaFormat format)

_MediaCodecDelegate *d = get_internal_delegate(delegate);
_MediaFormat *format_priv = static_cast<_MediaFormat*>(format);
assert(format_priv->csd != NULL);

status_t err = OK;

@@ -445,9 +446,9 @@ int media_codec_queue_csd(MediaCodecDelegate delegate, MediaFormat format)
err = d->media_codec->getInputBuffers(&input_bufs[0]);
CHECK_EQ(err, static_cast<status_t>(OK));

for (size_t i=0; i<2; ++i)
for (auto it = format_priv->csd.begin(); it != format_priv->csd.end(); it++)
{
const sp<ABuffer> &srcBuffer = format_priv->csd;
const sp<ABuffer> &srcBuffer = it->second;

size_t index = 0;
err = d->media_codec->dequeueInputBuffer(&index, -1ll);
3 changes: 1 addition & 2 deletions compat/media/media_format_layer.cpp
Original file line number Diff line number Diff line change
@@ -108,8 +108,7 @@ void media_format_set_byte_buffer(MediaFormat format, const char *key, uint8_t *
if (key == NULL || data == NULL || size == 0)
return;

mf->csd_key_name = AString(key);
mf->csd = sp<ABuffer>(new ABuffer(data, size));
mf->csd[AString(key)] = sp<ABuffer>(new ABuffer(data, size));
}

const char* media_format_get_mime(MediaFormat format)
6 changes: 3 additions & 3 deletions compat/media/media_format_layer_priv.h
Original file line number Diff line number Diff line change
@@ -22,6 +22,8 @@
#include <stddef.h>
#include <unistd.h>

#include <map>

#include <media/stagefright/foundation/AString.h>
#include <media/stagefright/foundation/ABuffer.h>

@@ -34,7 +36,6 @@ struct _MediaFormat : public android::RefBase
width(0),
height(0),
max_input_size(0),
csd(NULL),
stride(0),
slice_height(0),
color_format(0),
@@ -51,8 +52,7 @@ struct _MediaFormat : public android::RefBase
int32_t width;
int32_t height;
int32_t max_input_size;
android::AString csd_key_name;
android::sp<android::ABuffer> csd;
std::map<android::AString, android::sp<android::ABuffer>> csd;

int32_t stride;
int32_t slice_height;