FFmpegPlayer icon indicating copy to clipboard operation
FFmpegPlayer copied to clipboard

Disable Volume Decode Issues

Open w136111526 opened this issue 5 years ago • 7 comments

I want to disable audio decoding and restore it. Why not rewrite it at ParseThread? How do I rewrite your code to synchronize audio and video? The part I rewrote was:

auto guard = MakeGuard(&packet, av_packet_unref);
auto seekLambda = [this]
{
    return m_seekDuration != AV_NOPTS_VALUE || m_videoResetDuration != AV_NOPTS_VALUE;
};

if (seekLambda())
{
    return; // guard frees packet
}

if (packet.stream_index == m_videoStreamNumber)
{ 
    if (!m_videoPacketsQueue.push(packet, seekLambda))
    {
        return; // guard frees packet
    }
}
else if (packet.stream_index == m_audioStreamNumber)
{
	if (m_bNeedVolume)
	{
		if (!m_audioPacketsQueue.push(packet, seekLambda))
		{
		    return; // guard frees packet
		}
	}
	else
		av_packet_unref(&packet);
}
else
{
    return; // guard frees packet
}

w136111526 avatar Apr 29 '19 03:04 w136111526

I see one small issue with it: avcodec_close() and setupAudioCodec() calls would be needed after missing data to reset audio decoder context. Most probably it should be done accordingly by the audio parser runnable thread.

aliakseis avatar Apr 29 '19 11:04 aliakseis

I 'll try it out later. I have another question. Can you make this video hard decoded? Can you get it to support DPI adaptation? Does it match a high resolution monitor, like 3000 X 2000. Is not supporting the current code.

w136111526 avatar Apr 29 '19 11:04 w136111526

Could you please elaborate on this? As far as I see, both setup and display code invoke DPI scaling in the same way, so that there is no overflow.

aliakseis avatar Apr 29 '19 15:04 aliakseis

My computer is Win10 device hard decoded as dxva2, I would like to ask if you can create IDrect3D9_Creative Design when specifying different adapterID to support different resolutions. At present, I think your code is using adapter = 0. Here is the relevant code:

ctx->d3d9 = createD3D(D3D_SDK_VERSION); if (!ctx->d3d9) { av_log(NULL, loglevel, "Failed to create IDirect3D object\n"); goto fail; }

    if (ist->hwaccel_device) {
        adapter = atoi(ist->hwaccel_device);
        av_log(NULL, AV_LOG_INFO, "Using HWAccel device %d\n", adapter);
    }

    IDirect3D9_GetAdapterDisplayMode(ctx->d3d9, adapter, &d3ddm);
    d3dpp.Windowed = TRUE;
    d3dpp.BackBufferWidth = GetSystemMetrics(SM_CXSCREEN);
    d3dpp.BackBufferHeight = GetSystemMetrics(SM_CYSCREEN);
    d3dpp.BackBufferCount = 1;
    d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;// d3ddm.Format;
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    d3dpp.Flags = D3DPRESENTFLAG_VIDEO;

    d3dpp.Windowed = TRUE;
    d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
    d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;

    hr = IDirect3D9_CreateDevice(ctx->d3d9, adapter, D3DDEVTYPE_HAL, GetDesktopWindow(),
        D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED | D3DCREATE_FPU_PRESERVE,
        &d3dpp, &ctx->d3d9device);
    if (FAILED(hr)) {
        av_log(NULL, loglevel, "Failed to create Direct3D device\n");
        goto fail;
    }

w136111526 avatar Apr 30 '19 01:04 w136111526

I've done some basic adapter selection implementation. Sorry, not sure how to do it optimally since I don't have any problems with default adapter in my environments.

aliakseis avatar May 02 '19 06:05 aliakseis

Hello, please ask why the CPlayerView class does not use thread lock CSingleLock lock(&m_csSurface, TRUE); What are the consequences of m_csSurface, TRUE)?

w136111526 avatar May 03 '19 07:05 w136111526

CSingleLock lock(&m_csSurface, TRUE) (with TRUE flag) works similarly to the lock_guard: https://en.cppreference.com/w/cpp/thread/lock_guard It protects parts that are critical from the mltithreaded access point of view. Let me know if you have any questions.

aliakseis avatar May 03 '19 15:05 aliakseis