Loading media/ndk/NdkMediaCodec.cpp +16 −5 Original line number Diff line number Diff line Loading @@ -715,7 +715,13 @@ uint8_t* AMediaCodec_getInputBuffer(AMediaCodec *mData, size_t idx, size_t *out_ if (out_size != NULL) { *out_size = abuf->capacity(); } return abuf->data(); // When an input buffer is provided to the application, it is essentially // empty. Ignore its offset as we will set it upon queueInputBuffer. // This actually works as expected as we do not provide visibility of // a potential internal offset to the client, so it is equivalent to // setting the offset to 0 prior to returning the buffer to the client. return abuf->base(); } android::Vector<android::sp<android::MediaCodecBuffer> > abufs; Loading @@ -732,7 +738,7 @@ uint8_t* AMediaCodec_getInputBuffer(AMediaCodec *mData, size_t idx, size_t *out_ if (out_size != NULL) { *out_size = abufs[idx]->capacity(); } return abufs[idx]->data(); return abufs[idx]->base(); } ALOGE("couldn't get input buffers"); return NULL; Loading @@ -747,8 +753,12 @@ uint8_t* AMediaCodec_getOutputBuffer(AMediaCodec *mData, size_t idx, size_t *out return NULL; } // Note that we do not provide visibility of the internal offset to the // client, but it also does not make sense to provide visibility of the // buffer capacity vs the actual size. if (out_size != NULL) { *out_size = abuf->capacity(); *out_size = abuf->size(); } return abuf->data(); } Loading @@ -761,7 +771,7 @@ uint8_t* AMediaCodec_getOutputBuffer(AMediaCodec *mData, size_t idx, size_t *out return NULL; } if (out_size != NULL) { *out_size = abufs[idx]->capacity(); *out_size = abufs[idx]->size(); } return abufs[idx]->data(); } Loading Loading @@ -791,7 +801,8 @@ ssize_t AMediaCodec_dequeueOutputBuffer(AMediaCodec *mData, requestActivityNotification(mData); switch (ret) { case OK: info->offset = offset; // the output buffer address is already offset in AMediaCodec_getOutputBuffer() info->offset = 0; info->size = size; info->flags = flags; info->presentationTimeUs = presentationTimeUs; Loading media/ndk/include/media/NdkMediaCodec.h +13 −2 Original line number Diff line number Diff line Loading @@ -251,6 +251,11 @@ uint8_t* AMediaCodec_getInputBuffer(AMediaCodec*, size_t idx, size_t *out_size) * dequeueOutputBuffer, and not yet queued. * * Available since API level 21. * <p> * At or before API level 35, the out_size returned was invalid, and instead the * size returned in the AMediaCodecBufferInfo struct from * AMediaCodec_dequeueOutputBuffer() should be used. After API * level 35, this API returns the correct output buffer size as well. */ uint8_t* AMediaCodec_getOutputBuffer(AMediaCodec*, size_t idx, size_t *out_size) __INTRODUCED_IN(21); Loading Loading @@ -309,9 +314,16 @@ media_status_t AMediaCodec_queueSecureInputBuffer(AMediaCodec*, size_t idx, #undef _off_t_compat /** * Get the index of the next available buffer of processed data. * Get the index of the next available buffer of processed data along with the * metadata associated with it. * * Available since API level 21. * <p> * At or before API level 35, the offset in the AMediaCodecBufferInfo struct * was invalid and should be ignored; however, at the same time * the buffer size could only be obtained from this struct. After API * level 35, the offset returned in the struct is always set to 0, and the * buffer size can also be obtained from the AMediaCodec_getOutputBuffer() call. */ ssize_t AMediaCodec_dequeueOutputBuffer(AMediaCodec*, AMediaCodecBufferInfo *info, int64_t timeoutUs) __INTRODUCED_IN(21); Loading Loading @@ -468,7 +480,6 @@ void AMediaCodec_releaseName(AMediaCodec*, char* name) __INTRODUCED_IN(28); /** * Set an asynchronous callback for actionable AMediaCodec events. * When asynchronous callback is enabled, it is an error for the client to call * AMediaCodec_getInputBuffers(), AMediaCodec_getOutputBuffers(), * AMediaCodec_dequeueInputBuffer() or AMediaCodec_dequeueOutputBuffer(). * * AMediaCodec_flush() behaves differently in asynchronous mode. Loading Loading
media/ndk/NdkMediaCodec.cpp +16 −5 Original line number Diff line number Diff line Loading @@ -715,7 +715,13 @@ uint8_t* AMediaCodec_getInputBuffer(AMediaCodec *mData, size_t idx, size_t *out_ if (out_size != NULL) { *out_size = abuf->capacity(); } return abuf->data(); // When an input buffer is provided to the application, it is essentially // empty. Ignore its offset as we will set it upon queueInputBuffer. // This actually works as expected as we do not provide visibility of // a potential internal offset to the client, so it is equivalent to // setting the offset to 0 prior to returning the buffer to the client. return abuf->base(); } android::Vector<android::sp<android::MediaCodecBuffer> > abufs; Loading @@ -732,7 +738,7 @@ uint8_t* AMediaCodec_getInputBuffer(AMediaCodec *mData, size_t idx, size_t *out_ if (out_size != NULL) { *out_size = abufs[idx]->capacity(); } return abufs[idx]->data(); return abufs[idx]->base(); } ALOGE("couldn't get input buffers"); return NULL; Loading @@ -747,8 +753,12 @@ uint8_t* AMediaCodec_getOutputBuffer(AMediaCodec *mData, size_t idx, size_t *out return NULL; } // Note that we do not provide visibility of the internal offset to the // client, but it also does not make sense to provide visibility of the // buffer capacity vs the actual size. if (out_size != NULL) { *out_size = abuf->capacity(); *out_size = abuf->size(); } return abuf->data(); } Loading @@ -761,7 +771,7 @@ uint8_t* AMediaCodec_getOutputBuffer(AMediaCodec *mData, size_t idx, size_t *out return NULL; } if (out_size != NULL) { *out_size = abufs[idx]->capacity(); *out_size = abufs[idx]->size(); } return abufs[idx]->data(); } Loading Loading @@ -791,7 +801,8 @@ ssize_t AMediaCodec_dequeueOutputBuffer(AMediaCodec *mData, requestActivityNotification(mData); switch (ret) { case OK: info->offset = offset; // the output buffer address is already offset in AMediaCodec_getOutputBuffer() info->offset = 0; info->size = size; info->flags = flags; info->presentationTimeUs = presentationTimeUs; Loading
media/ndk/include/media/NdkMediaCodec.h +13 −2 Original line number Diff line number Diff line Loading @@ -251,6 +251,11 @@ uint8_t* AMediaCodec_getInputBuffer(AMediaCodec*, size_t idx, size_t *out_size) * dequeueOutputBuffer, and not yet queued. * * Available since API level 21. * <p> * At or before API level 35, the out_size returned was invalid, and instead the * size returned in the AMediaCodecBufferInfo struct from * AMediaCodec_dequeueOutputBuffer() should be used. After API * level 35, this API returns the correct output buffer size as well. */ uint8_t* AMediaCodec_getOutputBuffer(AMediaCodec*, size_t idx, size_t *out_size) __INTRODUCED_IN(21); Loading Loading @@ -309,9 +314,16 @@ media_status_t AMediaCodec_queueSecureInputBuffer(AMediaCodec*, size_t idx, #undef _off_t_compat /** * Get the index of the next available buffer of processed data. * Get the index of the next available buffer of processed data along with the * metadata associated with it. * * Available since API level 21. * <p> * At or before API level 35, the offset in the AMediaCodecBufferInfo struct * was invalid and should be ignored; however, at the same time * the buffer size could only be obtained from this struct. After API * level 35, the offset returned in the struct is always set to 0, and the * buffer size can also be obtained from the AMediaCodec_getOutputBuffer() call. */ ssize_t AMediaCodec_dequeueOutputBuffer(AMediaCodec*, AMediaCodecBufferInfo *info, int64_t timeoutUs) __INTRODUCED_IN(21); Loading Loading @@ -468,7 +480,6 @@ void AMediaCodec_releaseName(AMediaCodec*, char* name) __INTRODUCED_IN(28); /** * Set an asynchronous callback for actionable AMediaCodec events. * When asynchronous callback is enabled, it is an error for the client to call * AMediaCodec_getInputBuffers(), AMediaCodec_getOutputBuffers(), * AMediaCodec_dequeueInputBuffer() or AMediaCodec_dequeueOutputBuffer(). * * AMediaCodec_flush() behaves differently in asynchronous mode. Loading